text:
Q: How to count occurrence of Polish characters in .txt file I have to prepare a .txt file and count how many times each character of alphabet occurs in the file. I've found a very nice piece of code, but unfortunately, it doesn't work with Polish characters like ą,ę,ć,ó,ż,ź. Even though I put them in the array, for some reason they are not found in the .txt file so the output is 0.
Does anyone know why? Maybe I should count them differently, with "Switch" or something similar.
Before anyone asks - yes, the .txt file is saved with UTF-8 :)
public static void main(String[] args) throws FileNotFoundException {
        int ch;
        BufferedReader reader;
        try {
            int counter = 0;

            for (char a : "AĄĆĘÓBCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray()) {
                reader = new BufferedReader(new FileReader("C:\\Users\\User\\Desktop\\pan.txt"));
                char toSearch = a;
                counter = 0;

                try {
                    while ((ch = reader.read()) != -1) {
                        if (a == Character.toUpperCase((char) ch)) {
                            counter++;
                            }
                    }

                } catch (IOException e) {
                    System.out.println("Error");
                    e.printStackTrace();
                }
                System.out.println(toSearch + " occurs " + counter);

            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

A: Looks like your problem related to encoding and default system charset
try to change reader variable to this
InputStreamReader reader = new InputStreamReader(new FileInputStream("C:\\Users\\User\\Desktop\\pan.txt"), "UTF-8");

A: try this:
I suggest that you use NIO and this code I have written for you using NIO, RandomAccessFile and MappedByteBuffer that is faster:
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.util.HashMap;
import java.util.Map;

public class FileReadNio
{
public static void main(String[] args) throws IOException
{
    Map<Character, Integer> charCountMap = new HashMap<>();

    RandomAccessFile rndFile = new RandomAccessFile
            ("c:\\test123.txt", "r");
    FileChannel inChannel = rndFile.getChannel();
    MappedByteBuffer buffer = inChannel.map(FileChannel.MapMode.READ_ONLY, 0, inChannel.size());
    buffer.load();
    for (int i = 0; i < buffer.limit(); i++)
    {

        char c = (char) buffer.get();

        if (charCountMap.get(c) != null) {
        int cnt = charCountMap.get(c);
            charCountMap.put(c, ++cnt);

        }
        else
        {
            charCountMap.put(c, 1);
        }
    }

    for (Map.Entry<Character,Integer> characterIntegerEntry : charCountMap.entrySet()) {

        System.out.printf("char: %s :: count=%d", characterIntegerEntry.getKey(), characterIntegerEntry.getValue());
        System.out.println();
    }

    buffer.clear();
    inChannel.close();
    rndFile.close();
}
}


text:
Q: Android: Dropbox api, downloaded photos are rotated? I'm using the Dropbox Core API to download and display photos. Downloading them and writing to a FileOutputStream is easy enough with:
DropboxAPI.getFile(filePath, null, fos, null);

But the downloaded image is always rotated. If I view the image in my web browser, it displays as upright. But the image written to the FileOutputStream is rotated. Any suggestions as to why this occurs? I can't find anything provided by the metadata that describes how an image should be orientated, but possibly I'm missing something there?
It seems like it would be a mistake to simply check if the image's width is greater than it's height, and to rotate it to portrait orientation based on that?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Initializing fields of a structure I'm working on a hash table assignment and I'm getting an unexpected error when trying to initialize my structure variables with a macro value. Here is my code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "symTable.h"
#define DEFAULT_TABLE_SIZE 61
#define HASH_MULTIPLIER 65599

typedef struct Node
{
    char *key;
    int *value;
    struct Node *next;
} Node_T;

typedef struct SymTable
{
    Node_T **Table;
    int tablesize = DEFAULT_TABLE_SIZE; //where I am getting my error
    int counter = 1;
} *SymTable_T;

and the error I am getting is
error: expected ':', ',', ';', '}' or '__attribute__' before '=' token

Can someone explain to me why it isn't accepting my macro value?

A: You try to initialize a member in a struct definition, which is a type1. That's no variable definition and doesn't take up any memory at runtime, mind you. You don't define any variable at all, so there's nothing to initialize.
When actually defining a variable you can do something similar by using a designated initializer list:
struct SymTable table = { .tablesize = DEFAULT_TABLE_SIZE, .counter = 1 };

This feature is only available since C99, however (GCC implements it as a non-conformant extension since C90!). Another, < C99 way, would be the somewhat bulkier
struct SymTable table = { NULL, DEFAULT_TABLE_SIZE, 1 };

where you need to know the order of members and the default values of each member.

1 Thanks to @M.M for that neat wording!

A: You are trying to use an assignment in the definition of struct SymTable. This is a structure, i.e. a kind of type. You can't assign a value to a type, or to a part of a type: a type isn't a piece of storage, it's a classification of storage.
You can use an assignment when defining an object of type struct SymTable. You can assign all the fields; if you omit some fields, the fields you omit will be initialized to "zero" (meaning 0 for integer fields, 0.0 for floating point fields, NULL for pointer fields).
struct SymTable syms1 = {NULL, DEFAULT_TABLE_SIZE, 1};
struct SymTable syms2 = {.counter = 1, .tablesize = DEFAULT_TABLE_SIZE};

The syntax I used for syms2 was introduced in C99, which is supported by most but not all common compilers). The syntax I used for syms1 has existed since the dawn of time; it has the downside that you need to provide values for the fields in order.
If you were trying to provide default values for any new object of type struct symTable, this is not a feature that C provides natively. A struct symTable declared by just writing struct symTable somename; in a function has uninitialized content, and there's nothing you can do about it. You can do it via a macro, but you'll need to call the macro explicitly when you create an object.
#define STRUCT_SYMTABLE_DEFAULT {NULL, DEFAULT_TABLE_SIZE, 1}
…
struct symTable syms3 = STRUCT_SYMTABLE_DEFAULT;

This approach has some downsides: you can only use this to initialize a struct, you can't use this syntax to assign a value later. Also, there's no type checking. A way to fix these defects is to return a value from a function. Good compilers will optimize it to the same code.
struct symTable inline symTable_default(void) {
    struct symTable default = {NULL, DEFAULT_TABLE_SIZE, 1};
    return default;
}
…
struct symTable syms4 = symTable_default();
…
/* Reset the table to its default value */
syms4 = symTable_default();


text:
Q: Reset Map ( remove and reset on next put ) Value on Key Expiration My requirement is to run the timer on inserting key in Map (and increment the value) and on expiration remove the key but as soon as same key comes again start the timer again and reset the value to 1 and then increment it.
So Timer would be not on Map, it should be on keys. This means if K1 put into map at time T1 then timer get starts for K1 and if K2 put into map at time T2 then timer get starts for K2.
I have write sample code of it but i think there would be issue if run in multi threaded environment.
if(nMap.get(tf) != null){    //after this if timer gets expired and key removed then next line gives issue
nMap.get(tf).incrementAndGet();
}

Full Sample Code :
public class TestDemo {

    ConcurrentHashMap<Integer, ConcurrentHashMap<String, AtomicInteger>> nwMap = null;

    Timer timer = new Timer();
    long timeout = 2000; // milliseconds

    public void initilize(){
        nwMap = new ConcurrentHashMap<Integer, ConcurrentHashMap<String, AtomicInteger>>();

        nwMap.put(1, new ConcurrentHashMap<String, AtomicInteger>());
        nwMap.put(2, new ConcurrentHashMap<String, AtomicInteger>());
        nwMap.put(3, new ConcurrentHashMap<String, AtomicInteger>());

    }

    void actionAfterTimeout(String tf, int nw ) {

            System.out.println("Before :  "+nwMap);
            nwMap.get(nw).remove(tf);
            System.out.println("After:   "+nwMap);

    }

    public void addTf(String tf, int nw){

        if(nwMap.get(nw).get(tf) == null){
            ConcurrentHashMap<String, AtomicInteger> nMap = nwMap.get(nw);
            nMap.put(tf, new AtomicInteger(1));

            timer.schedule(new TimerTask() {

                @Override
                public void run() {

                    actionAfterTimeout(tf, nw);

                }
            }, timeout);
        }else{
            ConcurrentHashMap<String, AtomicInteger> nMap = nwMap.get(nw);
            if(nMap.get(tf) != null){   **<--- after this if timer gets expired and key removed then next line gives issue**
            nMap.get(tf).incrementAndGet();
            }

        }
    }

    public static void main(String[] args) throws InterruptedException {

        TestDemo demo = new TestDemo();
        demo.initilize();

        for(int i = 0;i<1000000;i++){
            demo.addTf("+811111111", 1);

        }

        Thread.sleep(50000);
    }

}


text:
Q: Find $y = P(x) $ for $x=4,18$ Let $P(x)= ax^2+bx+c$ whose coefficients are approximate numbers: $a= 2,51$, $b=-0,89$, $c=2,84$
Find $y= p(x) for x=4,1800000000$ and find $\delta_y$ the absolute error of the answer.
My attempt:

*

*To find $y$ all I have to do is plug in the value. I get: $y= 42,9748$

*Now to find the absolute value I plugged in for $a,b, c$ and $x$ the values that would give me the biggest result:
$P(x)_{max} = 2,515 \times 4,1800000005^2 -0,885 \times 4,1799999995 + 2,845 = 43.088786011$ Now $\delta_y = |P(x)_{max} - y| = 43.088786011-42,9748 =0.113986011$

Is that the right way to approach the problem?


text:
Q: Determine bindings from IIS hosting environment I would like to retrieve the bindings of a running IIS application directly from the context of the applications running code.
I've explored System.Web.Hosting.HostingEnvironment, but from there I can only access properties like SiteName etc.
What I need is the host string part of the binding. Like "app.mydomain.com".
Is that possible? A simple "Yes" or "No" with a msdn reference will suffice as an answer.

A: You might not be able to get to bindings from IIS config unless you're elevated (and you shouldn't run elevated) but you should be able to get the host part of the binding from:
Request.ServerVariables["URL"];

From there you can load it into the URI class and get the host portion.
Be aware however that it's the url that the request came in on.  If you have multiple bindings in the IIS config you won't get those.


text:
Q: How to get my background images to loop through I am trying to loop through background images every few seconds using jquery fadeIn
here is my HTML

and here is my Jquery
function changeBackground () {
    $(".bg").first().fadeIn("slow", function showNext() {
        $(this).next("div").delay(1000).fadeIn("slow", showNext);
    });
}

$(document).ready(function() {
    setTimeout(changeBackground, 0);
});

I'm not sure how to hide the previous image so I can reintroduce it next time. The function loops or maybe could be done using z-index to bring images to top?

A: function changeBackground() {
    $(".bg").first().fadeIn("slow", function showNext() {
        var next = $(this).next('div').length ? $(this).next('div') : $(".bg").first();
        $(this).siblings().fadeOut('slow').delay(1000);
        next.fadeIn("slow", showNext);
    });
}

$(document).ready(function () {
    setTimeout(changeBackground, 100);
});

FIDDLE

A: Okay, so I know this is a JQuery question, but I just wanted to give you another option. This type of effect can be achieved with just one div and some keyframes.
HTML

CSS
.bg {
  height: 500px;
  width: 500px;
  -webkit-animation: change-bg 10s ease infinite;
  animation: change-bg 10s ease infinite;

}

@-webkit-keyframes change-bg{
  0%  { background-image: url(http://lorempixel.com/500/500); }
  50% { background-image:  url(http://lorempixel.com/501/501);  }
  100% { background-image: url(http://lorempixel.com/503/503); }
}

@keyframes change-bg {
  0%  { background-image: url(http://lorempixel.com/500/500); }
  50% { background-image:  url(http://lorempixel.com/501/501);  }
  100% { background-image: url(http://lorempixel.com/503/503); }
}

/* add the other vendor prefixes if needed. */

Oh and also, if you wanted it to be a fullscreen background, you could use 0 divs. Just the keyframes and the rest of the css.
CSS
body {
  background: no-repeat center center fixed;
  height: 100%;
  width: 100%;
  -webkit-animation: change-bg 10s ease infinite;
  animation: change-bg 10s ease infinite;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

@-webkit-keyframes change-bg{
  0%  { background-image: url('http://lorempixel.com/500/500'); }
  50% { background-image:  url('http://lorempixel.com/501/501');  }
  100% { background-image: url('http://lorempixel.com/503/503'); }
}

@keyframes change-bg {
  0%  { background-image: url('http://lorempixel.com/500/500'); }
  50% { background-image:  url('http://lorempixel.com/501/501');  }
  100% { background-image: url('http://lorempixel.com/503/503'); }
}

/* add the other vendor prefixes if needed. */

Fullscreen BG Demo
Div Demo

A: A fantastic plugin for background image slideshows is Vegas. It is extremely easy to set-up and use. I know this doesn't directly answer your question, but hopefully it will make coding easier for you.

A: I found it! I answered a question Very similar to this one here
Ok, the way i've done this is a little different from your layout. Though you could probably adjust it if you don't like my layout. I chose this layout because it seemed optimal.
I made a parent div that stretches for the background (also, you could set it to any size, place it anywhere, etc...). Next I put three img tags inside it with their respective links (replace links with your own).
Next comes a little CSS. You'll note I hide all images to start with and then set the first image to display: block, thus making it visible. The other key here is to set the images height and width to 100% so they stretch to parent.
Finally, just a little easy JS. Write it how you want it. In my example I simply grab currently visible, then look for what's next. If their are no images next, then I go back to the first one!
jsFiddle Example
jsFiddle [Modded using your jQuery style of code]
jsFiddle [Modded Example using your HTML Layout as well]

Below is example code from my original layout and style

HTML

CSS
#myBackground {
    bottom: 0;
    left: 0;
    position: fixed;
    right: 0;
    top: 0;
}
#myBackground img {
    display: none;
    height: 100%;
    /* this will remove "white flash" between fade */
    position: absolute;
    width: 100%;
}
#myBackground img:first-child {
    display: block;
}

JS
function changeBackground() {
    //    here i select the current one visible,
    //    then i check if there is another omage after it, else i go back to the first
    var cur = $("#myBackground img:visible"),
        nxt = cur.next().length ? cur.next() : $("#myBackground img:first");
    cur.fadeOut("slow");
    nxt.fadeIn(1500);
}

$(function() {    //    starts when page is loaded and ready
    setInterval(changeBackground, 2250);    //    2 second timer
})

A: Visit  http://www.javascriptkit.com/howto/show2.shtml It explains everything for a slideshow in javascript I used css and html5 my self. I go to http://coding.smashingmagazine.com/2012/04/25/pure-css3-cycling-slideshow/ for that.


text:
Q: SQL query not working as expected | Duplicates and wrong results HEyo folks.
alright, So i'm working on this little snippet of code here
        SELECT
                current.name,
                current.status,
                current.votes,
                current.info,
                current.votes_required,
                current.sid as sid,
                current.previous_required,
                previous.sid as psid,
                previous.status as status
            FROM
                systems as current
            INNER JOIN
                systems as previous
            WHERE
                (previous.status = 1 and current.previous_required = previous.status)
                OR
                (current.previous_required = 0)
            '

Which Ideally I would like to show the results where either previous_required == 0 or where the previous_required's status == 1. However, for some reason, i keep either getting triple the results from my search (EG duplicates) or only a single result for the first one.
I'm pretty dang sure I know where i'm messing up (It's either the Inner Join or the OR statement). but I cannot seem to nail it down and fix the issue. Any input would be greatly appreciated.

A: It looks like you need to link the current records to their previous records somehow. Does your systems table have something like "previous_sid", which links a current record back to a previous one? If so, you need to use that in you inner join. Something like:
FROM
    systems AS current
INNER JOIN
    systems AS previous on current.previous_sid = previous.sid

A: You need to move the condition from where to join
    SELECT
            current.name,
            current.status,
            current.votes,
            current.info,
            current.votes_required,
            current.sid as sid,
            current.previous_required,
            previous.sid as psid,
            previous.status as status
        FROM
            systems as current
        INNER JOIN
            systems as previous
          ON
            (previous.status = 1 and current.previous_required = previous.status)
            OR
            (current.previous_required = 0)


text:
Q: Using HttpClient to read encrypted URL on Windows Phone I was reading a normal URL from my app, and it was working fine with the code:
string returnedTaskTResult = await new HttpClient().GetStringAsync(url);

then I used a new url, this time encrypted, and now is returning the exception:

System.InvalidOperationException: An invalid request URI was provided.
  The request URI must either be an absolute URI or BaseAddress must be
  set.

Why is this happening and how o fix it?

A: When you use GetStringAsync, you need to use a absolute URI.  It sounds like your encrypted URI is relative.  Try this...
var client = new HttpClient() {  BaseAddress = new Uri("http://yourhosthere.com");
}
string returnedTaskTResult = await client.GetStringAsync(url);


text:
Q: Concatenating lists horizontally C# I'm using the CsvHelper library tool to help write lists that I've created to CSV file.
using (var sr = new StreamReader(inPath))
{
    using (var sw = new StreamWriter(outPath))
    {
        var reader = new CsvReader(sr);
        var writer = new CsvWriter(sw);

        IEnumerable records = reader.GetRecords<DataRecord>().ToList();

        List<CountAndFrequencyClass> list1 = new List<CountAndFrequencyClass>();
        list1 = CountAndFrequency(records, "ShipperName", 1);

        List<CountAndFrequencyClass> list2 = new List<CountAndFrequencyClass>();
        list2 = CountAndFrequency(records, "ShipperCity", 1);

        list1 = list1.Concat(list2).ToList();

        writer.WriteRecords(list2);
    }
}

The list1=list1.Concat(list2).ToList(); does indeed concatenate the strings, but it stacks them on top of each other when they're written out to the CSV file. I want to find a way to concatenate the lists horizontally (so they're displayed next to eachother) instead of vertically.
Thanks for any help and please let me know if additional information is needed!

A: You can use a loop to add list2 column to records of list1
foreach (var i=0 ; i< list1.Count; i++)
{
    if(i>=list2.Count ) break;
    var rec1 = list1[i];
    var rec2 = list2[i];
    rec1.NewColumn = rec2.ColumnToAdd;
}

A: You could write them to the file as you loop through the lists.
using (var sr = new StreamReader(inPath))
{
    using (var sw = new StreamWriter(outPath))
    {
        var reader = new CsvReader(sr);
        var writer = new CsvWriter(sw);

        IEnumerable records = reader.GetRecords<DataRecord>().ToList();

        List<CountAndFrequencyClass> list1 = new List<CountAndFrequencyClass>();
        list1 = CountAndFrequency(records, "ShipperName", 1);

        List<CountAndFrequencyClass> list2 = new List<CountAndFrequencyClass>();
        list2 = CountAndFrequency(records, "ShipperCity", 1);

        for (int i = 0; i < list1.Count; i++)
        {
            writer.WriteRecord(list1[i]);
            writer.WriteRecord(list2[i]);
            writer.NextRecord();
        }
    }
}


text:
Q: Laravel 5.8 Session not being written to cookies after Git Branch checkout I have a team who are developing a Laravel app. We are at the early stages so almost no code has been written. One of my teammates ran the 'php artisan make:auth' command on his branch to activate authentication which worked fine and continues to work on their machine.
Once I did a checkout on this branch however, I would attempt to login and would get a "419-page expired" error in spite of it working on my team mates machine. After some research I found that there is no cookie being saved for the session. Instead, each time a page request is made, a new file is created in storage/frameworks/sessions.
My project has the following details:

*

*storage folder has correct permissions to read and write

*All csrf tokens are in place in the auth files.

*Session.php hasn't been touched from the default

Any suggestions about what could cause this would be much appreciated.

A: We had the same issue. Check all files for extra chars before php opening tag, especially for invisible one.
In our case  the reason was in  invisible symbol (UTF BOM) in one of config files. Notepad++ and PHPStorm do not show it! We can detect it only with FAR editor!
PHP and Laravel show no warnings about it (it is strange), but http response header with cookies is broken.


text:
Q: SQL - concatenate results from 2 tables First I need to get exact match like
SELECT * FROM movies WHERE title='STRING' ORDER BY x DESC

and then append to these results query with LIKE match
SELECT * FROM movies WHERE title LIKE '%STRING&' AND title<>'STRING' ORDER BY x DESC

and limit these results with maximum of 10 results.
UNION wont`t do the jobs as it sorts all results together and returns wrong order (I need exact match first, then with LIKE)
SELECT * FROM movies WHERE title='STRING' UNION
SELECT * FROM movies WHERE title LIKE '%STRING%' ORDER BY x DESC LIMIT 10

The best solution I got is to use multi_query()
$query  = "SELECT * FROM movies WHERE title='STRING' ORDER BY x DESC; ";
$query .= "SELECT * FROM movies WHERE title LIKE '%STRING%' AND title<>'red' ORDER BY x DESC";
$Dbi->multi_query($query);
do {
    $sql = $Dbi->store_result();
    while($x = $sql->fetch_array()) {
        ...
    }
} while($Dbi->next_result());

but in this case it is not possible to use any mysql inside the inner loop and there also must be better looking solution!

A: You can do this with one query, by using the order by clause:
SELECT *
FROM movies
WHERE title like '%STRING%'
ORDER BY title = 'STRING' desc,
         title like '%STRING%' desc
LIMIT 10;

The first clause in the ORDER BY puts the exact matches first.  The second then orders by the partial matches.  The WHERE clause ensures that there is a match of some kind.

A: You don't need the UNION, it's accessing the same table twice:
SELECT *
FROM movies
WHERE title LIKE '%STRING&'
ORDER BY CASE WHEN title='STRING' THEN 1 ELSE 2 END
LIMIT 10

A: (SELECT * FROM movies WHERE title='STRING')
UNION
(SELECT * FROM movies WHERE title LIKE '%STRING%' ORDER BY x DESC LIMIT 10)


text:
Q: Как сортировать строки без учета регистра в postgresql? Как сортировать строки без учета регистра в postgresql? Желательно не использовать тип данных CITEXT. Пробовал ORDER BY LOWWER(colname), не сработало.

A: Вы можете использовать разные COLLATE с ORDER BY
select * from users order by nick COLLATE "default";

select * from users order by nick COLLATE "C";

PostgreSQL fiddle


text:
Q: Rename files in bash script I am writing a script to rename my files, The current syntax for filename is program 1.c and I want to change this to cprogram-program1.c.
I am unable to get this format. Few conditions for simplicity are:

*

*assume that there are only 10 files i.e: 0,1,2,3..9

My procedure to achieve this:

*

*First we need to filter the files to find out files that follow the given pattern

*Then we need to filter the filename into substrings ignorer to verify whether they are in a proper format

*If they are in a proper format, then we can edit the filename in the way we need it.
I am stuck on step 1 and 2, this is sort of what I am doing:
for fn in *; do --> this loops over the files
 program=${fn:0:7}
 number=${..} --> number between 0 and 9
 extension=${..} --> gets file extension like .c

if [ "$program" == "program"  ]
 then
    if [ "$number" -ge 0 ] && [ "$number" -le 9 ]
     then

         if [ "$extension" == ".c" ]
          then
            --> edit code
          fi

     fi
fi
done

My problem: I have tried many permutations of the above example, but I am unable to get what I want. Any help, simple method of doing this would be highly appreciated.
Thanks

A: for fn in *
do  case $fn in
    (program*[1-8].c)
        : do something;;
    (other*program*[09].ext)
        : do something with this match;;
    (this*match|*or*|*any*"$of"*these*matches)
        : do something with these matches
        : do as many lines as you want;;
    (*) : catch all last default match
    esac
done

A commonly used technique in case statements is to prune unwanted matches with more specific patterns than your generally desired pattern. For example:
for fn in *
do  case $fn in
    (*[0-9][0-9].c) ;;
    (program*[1-8].c)
        echo mv "$fn" "${fn%???}0${fn#"${fn%???}"}"
    esac
done

In the above example the first *[0-9][0-9].c pattern matches all $fn values where two or more digits might occur to the left of the extension. The execution block for those matches is empty - null - nothing at all happens when a match is found. Most importantly, though, because case statements work top-down, what this means is the only results ever matched for the action block will contain only the one digit to the left of the extension, and the example echo command would insert a 0 before each and every one of those occurring between 1 and 8.

A: Alternatively, dispense with the script and use a rename tool instead.
Frustratingly there are (at least) two different instances of rename depending on your distribution. On some systems the Perl version may be called prename. However, you can tell which one you have by running rename -n ';' /dev/null. If nothing happens you have the Perl version. If you get an error it's the other one.

The current syntax for filename is program 1.c and I want to change this to cprogram-program1.c. Assume that there are only 9 files i.e: 0,1,2,3..9

*

*The Perl-based rename (prename)
rename 's/^/cprogram-/; s/\s//' program\ ?.c

*The other rename
rename -v 'program ' cprogram-program program\ ?.c


text:
Q: Add methods to Func I have a list of Func and I want to add elements.
If I add them on Start like below, no problem:
        public List<System.Func<bool>> conditions = new List<System.Func<bool>>();

        void Start()
        {
        conditions.Add(Iamdead);
        conditions.Add(Iamalive);
        }

        bool Iamdead()
        {
        ...
        return ...;
        }
        bool Iamalive()
        {
        ...
        return ...;
        }

But I want to define the list without Start so that I have a clean list of methods that I can see as elements in a row. I have tried the classic format:
public List<System.Func<bool>> conditions = new List<System.Func<bool>>()
{
        bool Iamdead()
        {
        ...
        return ...;
        }
        ,
        bool Iamalive()
        {
        ...
        return ...;
        }
};

This gave me parsing error
I tried like that:
public List<System.Func<bool>> conditions = new List<System.Func<bool>>()
    {
Iamdead,Iamalive
    };

        static bool Iamdead()
        {
        ...
        return ...;
        }
        static bool Iamalive()
        {
        ...
        return ...;
        }

This worked only if the methods are static but I do not want them to be static. Without static, it doesn't work. It seems I couldn't understand the data structure here. Can anyone tell me the correct way of defining Func in a list?
Thanks

A: I strongly suspect the problem is that you're trying to access this (implicitly) within a field initializer. You're not allowed to do that. Just move the initialization into a constructor:
// You don't really use public fields, do you?
private readonly List<Func<bool>> conditions;

public MyClass()
{
    conditions = new List<Func<bool>> { Method1, Method2 };
}

private bool Method1() { ... }
private bool Method2() { ... }

(I'm assuming you actually want your conditions to depend on state within the instance. If they don't, you don't need this. If the methods aren't used other than for these conditions, and they're short enough, you might want to use lambda expressions instead.)

A: Like so:
    public List<System.Func<bool>> conditions = new List<System.Func<bool>>()
                                                    {
                                                        () => false,
                                                        () => true,
                                                    };

A: You can just use lambdas:
public List<System.Func<bool>> conditions = new List<System.Func<bool>>()
{
    () =>
    {
        return false;
    }
    ,
    () =>
    {
        return true;
    }
};


text:
Q: jQuery Add css to dynamically-added html elements I'm adding new li & div elements on a page by means of jQuery .html() function. The string that I pass has a hard-coded class. But it is still not stylized though the class are defined already in the css file. So I did add style by using jQuery .css() function, but still no style at all. How can I add css to these dynamically-added html elements?
for(i=0; i<directionList.length; i++) {
    html += "
 \

" + directionList[i].location + "

 \

 \

 \

Ride to
 \

" + directionList[i].destination + "
 \

";

    // add routes
    var routes = directionList[i].routes;
    for(j=0; j<routes.length; j++){
        html += "
 \

 \

" + routes[j].name + "
 \

";
    }

    html += "
 \

 \

";

    /*
    var index = parseFloat(i)+1;
    directions += "
" + directionList[i].location + "";
    //get routes
    var routes = [];
    routes = directionList[i].routes;
    directions += "
";
    for(j=0; j<routes.length; j++){
        directions += "
  (" + routes[j].type + ") " + routes[j].name + "
" ;
    }
    directions += "
";
    directions +=  "
";
    */
}

html += "
";
$('#directions').html(html);

CSS:
#directions div {
    display:inline;
    vertical-align:middle;
}
#directions ul#dir {
    list-style:decimal;
}
#directions ul.dir-routes {
    list-style: none;
}

.dir-va-mid {
    vertical-align:middle;
}

Adding the CSS by force:
$("#directions div").css({'display':'inline', 'vertical-align':'middle'});
$("#directions ul#dir").css({'list-style':'decimal'});
$("#directions ul.dir-routes").css({'list-style':'none'});
$(".dir-va-mid").css({'vertical-align':'middle'});

Edit: I had included my files here. Please look at it if you have the time.

A: It sounds like you're having a problem with CSS specificity.
Purely as a test to see if this is indeed your problem, you should remove your jQuery .css() lines, and add !important to each declaration in your CSS, like this:
#directions div {
    display: inline !important;
    vertical-align: middle !important;
}
#directions ul#dir { list-style: decimal !important;}
#directions ul.dir-routes { list-style: none !important;}

.dir-va-mid {
    vertical-align: middle !important;
}

If this works, then you need to show more of the surrounding HTML, so we can give you a proper solution which will properly take advantage of the rules of specificity.
You shouldn't use !important to band-aid problems unless there is no other way.
If it still doesn't work, then there is some other problem, and you probably need to show us more of your code anyway.

I can't recreate your problem with the files you posted, because lots of files are missing.
However, I did notice one thing inside your CSS file which isn't right:
<![if lt IE 7]>
* html #outer{
    width:100%;/* box model hack for ie5.+*/
}
<![endif]>

You should change that to this:
* html #outer{
    width:100%;/* box model hack for ie5.+*/
}

*

*Conditional comments are not valid inside a CSS file.

*You're using the Star HTML hack, which by definition will only apply styles to IE less than 7.

See if anything has changed after fixing this.


text:
Q: systemfit Error in eval(predvars, data, env) : object not found I am trying to use the systemfit package to estimate an econometric model. I keep on getting the error: Error in eval(predvars, data, env) : object 'gdp_gro' not found. The thing is gdp_gro is definitely in my dataset.
I tried to Google this error, but I couldn't figure out the solution. Based on other questions on Stackoverflow and elsewhere I think the issue lies with the way R handles formula environments. I would appreciate some guidance on why my code doesn't work and how to fix it. Thank you very much.
I am attaching a reprex and a partial data set (below):
library(systemfit)
#> Loading required package: Matrix
#> Loading required package: car
#> Loading required package: carData
#> Loading required package: lmtest
#> Loading required package: zoo
#>
#> Attaching package: 'zoo'
#> The following objects are masked from 'package:base':
#>
#>     as.Date, as.Date.numeric
#>
#> Please cite the 'systemfit' package as:
#> Arne Henningsen and Jeff D. Hamann (2007). systemfit: A Package for Estimating Systems of Simultaneous Equations in R. Journal of Statistical Software 23(4), 1-40. http://www.jstatsoft.org/v23/i04/.
#>
#> If you have questions, suggestions, or comments regarding the 'systemfit' package, please use a forum or 'tracker' at systemfit's R-Forge site:
#> https://r-forge.r-project.org/projects/systemfit/

#Prepare a new list
DF = list()

#Splitting the data in list elements by years
for (i in seq(from = 1, by =1, to =length(unique(as.numeric(df$year))))){

  DF[[i]] <- df[df$year == unique(as.numeric(df$year))[i],]

}
#> Error: object of type 'closure' is not subsettable

Equation = list()
Inststruments = list()

#### SPECIFCIATION OF EQUATIONS
for (i in seq(from = 1, by =1, to =length(unique(as.numeric(df$year))))){

  #Automatically pick up the instruments
  instruments <- select_vars(colnames(as.data.frame(DF[i])), ends_with("_I", ignore.case = FALSE))

  #Variables picked out automatically
  variables <- colnames(as.data.frame(DF[i]))[!colnames(as.data.frame(DF[i])) %in% c(instruments, "gdp_gro")]

  #Automatizing the equation specification
  Equation[[i]] <- with(DF[i] , as.formula(paste("gdp_gro ~ ", paste(variables, collapse="+"))) )

  Inststruments[[i]] <- with(DF[i] , as.formula(paste("~ ", paste(instruments, collapse="+"))) )

}
#> Error: object of type 'closure' is not subsettable

#Finally run the key regressions
reg <- systemfit(Equation, method = "3SLS", inst = Inststruments, methodResidCov = "noDfCor" )
#> Error in formula[[i]]: subscript out of bounds

Partial data (generated with dput):
  structure(list(country_code = c("AUS", "AUS", "AUS", "AUS", "AUT",
"AUT", "AUT", "AUT", "BEL", "BEL", "BEL", "BEL", "BGR", "BGR",
"BGR", "BGR"), year = c(1995L, 2000L, 2005L, 2010L, 1995L, 2000L,
2005L, 2010L, 1995L, 2000L, 2005L, 2010L, 1995L, 2000L, 2005L,
2010L), tot_lif = c(0.0128486367909746, 0.0126208212768577, 0.0123698898778096,
0.0122406329302881, 0.0130432016288096, 0.0127997002997003, 0.0126053003750845,
0.0124099521762818, 0.0130139312547017, 0.0128663779576979, 0.0126613550738064,
0.0124714828897338, 0.0140739189685534, 0.0139541215710299, 0.013781512605042,
0.0136031851360319), cap_aset = c(NA, 6.9, 6.9, 5.43, NA, 5.2,
4.8, 7.49276, NA, 2.8, 2.7, 4.96531, NA, 15.3, 7.4, 10.4677),
    cb_assets = c(3.06318, 2.46202, 2.20076, 3.33956, 0.399895,
    0.536933, 0.551538, 0.815212, 0.972776, 0.466959, 0.248117,
    0.823367, 7.90828, 8.51751, 3.15831, 0.095416), tot_fert = c(1.822,
    1.756, 1.807, 1.928, 1.42, 1.36, 1.41, 1.44, 1.56, 1.67,
    1.76, 1.86, 1.23, 1.26, 1.37, 1.57), nat_res = c(2.09714172369929,
    3.51179102271941, 7.72238072354596, 8.01628506180971, 0.11853075155191,
    0.150961988690622, 0.206953989580903, 0.216777594515187,
    0.0223053533152314, 0.0203362079028292, 0.0177518400351335,
    0.019336002220052, 1.47167055527445, 1.33790542432826, 2.31972541945117,
    2.08046786610067), trad_term = c(NA, 100, 131.0849232, 178.9001645,
    NA, 100, 95.91930131, 92.25883781, NA, 100, 98.77006835,
    96.59919868, NA, 100, 84.20837461, 125.8550667), gov_cons = c(0.1471103005,
    0.1474746565, 0.151790273666667, NA, 0.149812934333333, 0.154511682833333,
    0.1511594605, NA, 0.171062330333333, 0.180379932166667, 0.174480045833333,
    NA, 0.289015879333333, 0.323738674333333, 0.276189208166667,
    NA), gdp_gro = c(3.8293687531652, 3.94318908229896, 3.19031634041626,
    2.05294200395332, 2.66798366552709, 3.37572197324998, 2.24406681223554,
    1.83709459152502, 2.3847572377606, 3.63365201492995, 2.09427270847185,
    2.74421327182894, 2.86018944148833, 4.94055377635733, 7.12351107638302,
    1.32408780093829), gross_inv = c(0.266632934333333, 0.260118643666667,
    0.300801128, 0.264703502, 0.335587352333333, 0.260061338333333,
    0.270549208, 0.287363499333333, 0.2805128, 0.246921166666667,
    0.308350493333333, 0.324811398666667, 0.0818940103333333,
    0.136577869666667, 0.236514484, 0.19643417), gdp_cap_1 = c(0.00192864730372135,
    0.00222430451645368, 0.00250264618548625, 0.00273814839048662,
    0.0027345490098763, 0.0032819778735874, 0.00334421790851598,
    0.0037646138629738, NA, 0.00344158786452203, 0.00350312141684792,
    0.00395886153650055, 0.000862928006781417, 0.000734707837639529,
    0.000935582564325206, 0.0013229694175178), gdp_cap_2 = c(0.00191622588648934,
    0.00221469960943122, 0.00254717484680898, 0.00285420952389829,
    0.00252904621475959, 0.00305993171114882, 0.00329798344078102,
    0.00354070266940731, NA, 0.00289716367632824, 0.00329402073984151,
    0.00365521257262544, 0.000834744862348611, 0.000765775240349386,
    0.000991473707456532, 0.0012880711598984), econ_open = c(1.11564470333333,
    1.07036188216667, 1.31764187416667, NA, 1.19112350533333,
    1.13605700933333, 1.37068624266667, NA, 1.14728215333333,
    1.1020498675, 1.34182663783333, NA, 1.01287280516667, 0.982563148,
    1.2535847325, NA), demo_2 = c(0.0156360833333333, NA, NA,
    0.0272981816666667, 0.0162439233333333, 0.016152265, 0.0163356866666667,
    0.0192567566666667, 0.0179158466666667, 0.02126817, 0.023894505,
    0.0293736833333333, NA, 0.05795811, 0.0639238566666667, 0.052836915
    ), male_edu_1 = c(5.81, 5.82, 5.84, 5.87, 4.09, 3.86, 3.86,
    3.87, 5.53, 5.59, 5.63, 5.59, 5.38, 5.43, 5.9, 6.3), male_edu_2 = c(4.78,
    4.76, 4.81, 4.61, 5.48, 5.77, 6.08, 6.28, 3.79, 3.96, 4.31,
    4.38, 2.87, 3.11, 3.72, 4.31), male_edu_3 = c(0.88, 0.78,
    0.93, 1.12, 0.35, 0.48, 0.64, 0.71, 0.8, 0.88, 0.95, 1.05,
    0.53, 0.58, 0.61, 0.71), male_edu_4 = c(11.48, 11.35, 11.58,
    11.6, 9.92, 10.11, 10.58, 10.86, 10.12, 10.43, 10.88, 11.02,
    8.79, 9.13, 10.23, 11.32), tot_lif_I = c(0.0128682464785598,
    0.0127095722174518, 0.012465515344814, 0.0122834370967119,
    0.0131404621173837, 0.0128830665052315, 0.012685638515979,
    0.0124510515974525, 0.0130783197148458, 0.0129052789260619,
    0.0127617321099324, 0.0125262669490894, 0.0140154543995514,
    0.0140966755510497, 0.0138573536026272, 0.0136964325672041
    ), tot_fert_I = c(1.822, 1.756, 1.807, 1.928, 1.42, 1.36,
    1.41, 1.44, 1.56, 1.67, 1.76, 1.86, 1.23, 1.26, 1.37, 1.57
    ), gov_cons_I = c(0.147556354666667, 0.147787615333333, 0.14822341,
    0.154233063333333, 0.143237327333333, 0.154914428666667,
    0.150818939, 0.160776774333333, 0.167895371666667, 0.174698651,
    0.174371118333333, 0.185355464666667, 0.318261792333333,
    0.319208641666667, 0.313319266, 0.274927805), gross_inv_I = c(0.271324028333333,
    0.263693382333333, 0.298435052333333, 0.269873092666667,
    0.342670599333333, 0.287529100666667, 0.262940883333333,
    0.273333341, 0.290991584333333, 0.259098499666667, 0.269275173666667,
    0.313822090666667, 0.0746616733333333, 0.12165235, 0.171543354666667,
    0.245303109333333), gdp_cap_1_I = c(0.00192864730372135,
    0.00222430451645368, 0.00250264618548625, 0.00273814839048662,
    0.0027345490098763, 0.0032819778735874, 0.00334421790851598,
    0.0037646138629738, NA, 0.00344158786452203, 0.00350312141684792,
    0.00395886153650055, 0.000862928006781417, 0.000734707837639529,
    0.000935582564325206, 0.0013229694175178), gdp_cap_2_I = c(0.00191622588648934,
    0.00221469960943122, 0.00254717484680898, 0.00285420952389829,
    0.00252904621475959, 0.00305993171114882, 0.00329798344078102,
    0.00354070266940731, NA, 0.00289716367632824, 0.00329402073984151,
    0.00365521257262544, 0.000834744862348611, 0.000765775240349386,
    0.000991473707456532, 0.0012880711598984), econ_open_I = c(1.08680443966667,
    1.05545339966667, 1.146271606, 1.401552578, 1.17984314766667,
    1.122572442, 1.21375773333333, 1.43774867033333, 1.14471817,
    1.08343706533333, 1.18125647333333, 1.41352349533333, 1.00123712466667,
    0.956378658666667, 1.057932824, 1.33654979833333), demo_2_I = c(0.0174405,
    0.0141582, NA, 0.02649142, 0.01485111, 0.01894116, 0.01685453,
    0.01725761, 0.01650168, 0.01752877, 0.02481076, 0.02306411,
    0.0366033, 0.0530792, 0.06323963, 0.05811036)), row.names = c(NA,
16L), class = "data.frame")

A: You need to supply the data argument to systemfit and also run the function on the individual items of the lists.
reg <- systemfit::systemfit(Equation[[1]], method = "3SLS", inst = Inststruments[[1]],
methodResidCov = "noDfCor", data = DF[[1]])
> Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) :
   index larger than maximal 0

This fixes your first problem but then gives you another :)

A: I contacted the packages developer and thanks to his efforts my problem is resolved in systemfit 1.1-23. This version is not yet availible on CRAN, but can be obtained from R-Forge: http://r-forge.r-project.org/R/?group_id=242 or using the command:
install.packages("systemfit",repos="http://R-Forge.R-project.org")


text:
Q: What can I spend Prestige on? I have thousands of Prestige and no idea what to do with it. I have read that you can spend it on actions, but I can't figure out which actions those are or where I find them.

A: The main purpose of Prestige is to add to your Dynasty Score: this shows how powerful and successful your dynasty is. If your final Dynasty Score is higher than your buddy's Dynasty Score, you're a better ruler than him. You are usually going to get a lot more Prestige than you can spend over the course of a ruler's life.
That said, there are a few things you can spend Prestige on, though none of them are particularly expensive, unless you're a new ruler of a young dynasty or otherwise poor in prestige:

*

*Creating an Antipope costs 500 prestige.

*Marrying one of your kids to someone of lower rank than your kid reduces your kid's prestige; it costs -100 prestige per difference in rank. Marrying a commoner with awesome skills can be worth it, but those skills had better be good!

*Fabricating a claim costs around 150 prestige, in addition to the gold required to bribe the locals to "remember" some facts about your claim.

*A White Peace (if you're the aggressor) or surrendering a war will cost you some prestige, but you don't need to have prestige in those cases.

Though it's not an action, remember that you get an opinion bonus of +1 per 100 prestige, that applies to everyone.  It caps at +20, but it's still quite useful!


text:
Q: Django models.Textfield automatically wrapped in  in template I have a the following class defined in models.py:
class Entry(models.Model):
    content = models.TextField()

In my template I render it with {{ entry.content|linebreaks }}. The output is automatically wrapped in
Output of entry.content
 tags. Yet I would like to give the paragraph a certain class
Output of entry.content
. How can I specify that in my template?

A: You can't. The tag is hard coded into the filter.
Wrap it with another element
 to use your selector or see if linebreaksbr is an appropriate filter to use within your own paragraph class (depends how long the content is / how you style your paragraphs).


text:
Q: Subset grouped data I'm trying to subset a grouped data set. Although there are many questions (e.g. Select the first and last row by group in a data frame) on this subject, none of them fit into my case described here. An example data is
df<-data.frame("id"=c(1,1,1,2,2,2,3,3,3),
           "x1"=c(NA,1,1,1,1,1,0,0,1),
           "x2"=c(10,8,13,4,7,6,9,10,6))

I want to retain data for cases where "x1" is first seen to be equal to 1 for each id. I expect to have
df<-data.frame("id"=c(1,2,3),
           "x1"=c(1,1,1),
           "x2"=c(8,4,6))

I tried
df<-df %>%
group_by(id) %>%
filter(first(x1)==1)

but it provides undesired output. Any help on this is greatly appreciated.

A: You can first filter the dataframe according to your condition and then use the slice function to select the first row for each group.
df %>%
  group_by(id) %>%
  filter(x1 == 1) %>%
  slice(1)

# A tibble: 3 x 3
# Groups:   id [3]
#      id    x1    x2
#   <dbl> <dbl> <dbl>
# 1     1     1     8
# 2     2     1     4
# 3     3     1     6

A: A base R option using subset + ave
subset(
  df[complete.cases(df), ],
  ave(x1 == 1, id, FUN = function(x) min(which(x)) == seq_along(x))
)

giving
  id x1 x2
1  1  1  8
2  2  1  4
3  3  1  6


text:
Q: Software rendering is used instead of Nvidia GPU (1060) on Ubuntu 18.04 I have issues with Nvidia 1060 GTX not being used by the OS. This has started after a recent regular update.
Os Ubuntu 18.04.4. I don't use any sort of VM. This is my desktop.
I would really appreciate your help in fixing this since I've already spent quite some time with completely zero efficiencies.
Output of inxi -G
Graphics:  Card: NVIDIA GP106 [GeForce GTX 1060 6GB]
               Display Server: x11 (X.Org 1.19.6 ) drivers: nvidia (unloaded: modesetting,nouveau)
               Resolution: 1920x1080@60.00hz
               OpenGL: renderer: llvmpipe (LLVM 7.0, 256 bits) version: 3.3 Mesa 19.1.4 (git-b84ffa028d)

Output of glxinfo -B
name of display: :0
display: :0  screen: 0
direct rendering: Yes
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: llvmpipe (LLVM 7.0, 256 bits)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 19.1.4 (git-b84ffa028d)
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 3.1 Mesa 19.1.4 (git-b84ffa028d)
OpenGL shading language version string: 1.40
OpenGL context flags: (none)

OpenGL ES profile version string: OpenGL ES 3.0 Mesa 19.1.4 (git-b84ffa028d)
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00

/var/log/Xorg.0.log
xorg.conf.d was generated by the last nvidia driver install. No success without it either.
Tested drivers:

*

*435.21 from the official repo

*390 from NVIDIA website. Using them now

*nouveau. Results are similar (llvmpipe used as a renderer)
Tried different display managers. gdm3, lightdm, kde (using now)


text:
Q: Opentext -Webservice to add Records to Database Dears,
I have OpenText ECM with Several Documents, I need to add one more Column to an existing table of OpenText DB.I have another DB in DB2 with all the information, I need a solution for updating Column from DB2 Table to SQL Table of OpenText both tables has a unique value.

A: Don't change OpenText core tables. Never. I'm sure you can achive your goal by create a new table and a foreign key that reference the table you would like to modify.


text:
Q: What does $$('foo') mean in JavaScript source code? I have the following in javascript:
var entriesString = '';
        $$('select[id=shopId]').each(function(elem, i){
            shops[i] = elem.value;
            entries[i] = new Array();

            $$('input[id=entry'+i+']').each(function(elem, c){
                if(elem.value != '') entries[i][c] = elem.value.replace(".", "").replace(",", "."); else entries[i][c] = '0.0'
            });
            entriesString += '&entry'+i+'=' + entries[i];
            });

Now I'm new to JS and therefore do not know what the first $$('select[id=shopId]') part means.
It must be some sort of array or collection, due to the .each part it is followed by.
In that loop is again a nested loop that uses the loop variable i in its head.
But again, I don't know what exactly does %%('input[...]') mean. What kind of syntax is this?
Also, where does the data.
This is what entryString looks like for example:
&entry0=65.8,75.5,72.9,67.9,51.1,8.2,47.9&entry1=55.9,33.5,33.8,35.2,26.8,7.0,25.8

Thanks a lot or your help!

A: That looks like the $$ method of the Prototype library. The documentation is here:
http://www.prototypejs.org/api/utility#method-$$
It selects DOM elements given a CSS-style selector.

A: $$() is not something of javascript. It seems to be likely that you're using the Prototype Javascript Framework. Here you find the documentation of $$: http://api.prototypejs.org/language/dollardollar/

A: You are using the Prototype library.
See http://www.prototypejs.org/api/utility/dollar-dollar

A: your code uses the prototype JS framework. $$('ELEMENTNAME') instanciates all DOM element with ELEMENTNAME (so i.e. all input fields) and returns them as array of objects.
with id==xy it returns that one with id xy
<input type="blah" id="xy" value="123" />

will be found

A: It use a great function to get elements with css selectors.


text:
Q: $\lim_{s\to1}\frac{t-s}{1-s}$ when $0\leq s\leq t\leq 1$ I was working on a topology exercise and got to a point (no pun intended) where I had to analyze the behaviour of $f(t,s)=\frac{t-s}{1-s}$ as s goes to $1$, under the assumption that $t\geq s$. It seems pretty obvious that the limit should exist and be equal to $1$, but I haven't been able to prove this. I'm still thinking about it, but in the meantime I figured I would ask here for advice on how to approach this. Of course I haven't ruled out the possibility that the solution is right in front of me, but I don't see it at the moment.
EDIT: I forgot to mention that $0\leq t,s\leq 1$.

A: Let $t=s+\lambda(1-s)$ with $0\le \lambda\le 1$ then
$$\frac{t-s}{1-s}=\frac{\lambda(1-s)}{1-s}=\lambda$$
therefore the limit doesn't exist.

A: The limit does not exist unless $t-s$ tends to $0$. If $t$ does not depend on $s$ then $t$ must be equal to $1$ for the limit to exist.
If $t$ does depend on $s$ then anything can happen. Try for example $t=2s$ and $t=s$.


text:
Q: How to actually bind mount a file in Docker for Windows I'm attempting to update the sebp/elk Logstash configuration following the documentation here. I'm running into a situation in which the host file that I am attempting to mount is being mounted as a directory in the container.
I found this related question How to mount a single file in a volume but the notion of running with PWD didn't work for me on Windows as I got the following error:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: invalid reference format
I'm running Docker on Windows 10 (Build 16299.192)
λ docker version
Client:
 Version:      17.09.1-ce
 API version:  1.32
 Go version:   go1.8.3
 Git commit:   19e2cf6
 Built:        Thu Dec  7 22:22:26 2017
 OS/Arch:      windows/amd64

Server:
 Version:      17.09.1-ce
 API version:  1.32 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   19e2cf6
 Built:        Thu Dec  7 22:28:28 2017
 OS/Arch:      linux/amd64
 Experimental: true

My Docker run command is:
docker run -p 5601:5601 -p 9200:9200 -p 5044:5044 -it -v d:/docker/elk/logstash-snmp.conf:/etc/logstash/conf.d/logstash-snmp.conf --rm --name elk sebp/elk
I've been able to run other containers with persistent storage out of this disk (SQL Server, Redis, Exist-DB), but I'm not sure if I'm missing something on this. How can I tell Docker to actually mount this as a file and not as a directory.

A: This works for me:
Note: This approach addresses W10 Home Edition with Docker Toolbox and VirtualBox.
Overview: Create a folder in local-machine, mount this as a shared folder in Docker VM, use this shared folder as a bindmount to Docker container.

*

*Stop docker VM using docker-machine stop default

*Open VirtualBox, find default go to Settings > Shared Folder

*You will see c/Users is binded to your c:\Users

*Add a new shared folder, note the name it is assigned. Let's name this as [local-shared]

*Exit Settings

*docker-machine start default

*Once started, docker-machine ssh default

*sudo vi /mnt/sda1/var/lib/boot2docker/profile

*Append the following:
  # create a directory in VM
  mkdir /home/docker/[foldername]
  # mount/map shared folder on localmachine to directory
  sudo moun -t vboxsf -o uid=1000,gid=50 [local-shared] /home/docker/[foldername]

*Save and exit ssh.

*docker-machine stop default

*docker-machine start default (or perhaps docker-machine restart default)

*now docker container run -d -p 1234:6789 -v /[local-shared]/sub-dir:/[container-dir] dockerImage2Run
And it should work.
Ref: http://support.divio.com/local-development/docker/how-to-use-a-directory-outside-cusers-with-docker-toolbox-on-windowsdocker-for-windows

A: If you are on windows, there is a problem in mapping the paths. I am using Git bash terminal on windows and the command which works for me is in this format.

*

*To copy a file named runtime_config.yml from host to container. The host path is given relative by using PWD as below. And the container path is from root.

docker run -d -p 5000:5000 -v "/${PWD}/etc/runtime_config.yml":/demand_forecast/etc/runtime_config.yml ....

*To copy a directory named etc from host to container. The host path is given relative by using PWD as below. And the container path is from root.

docker run -d -p 5000:5000 -v "/${PWD}/etc/":/demand_forecast/etc/ ....

Notice the / at the beginning in host path, that is very important, otherwise you will run into errors.


text:
Q: Is there a calculation for flow loss through a venturi tube vs a full bore? I understand that the volumetric flow either side of a venturi tube is the same - that makes total sense to me. However, what I'm interested in finding out is how to calculate the difference in flow rate vs the total potential flow without said tube section. Here's a rough diagram explaining things:

So, in the bottom system the venturi effect tells us that v2 equals v3. However, assuming all other variables are the same between the two systems, my assumption is that v1 does not equal v2/v3 - the constriction of the pipe will cause some loss of volumetric flow vs the larger one. Firstly, is this assumption correct?
Secondly, is there a formula or theory for calculating/explaining this? Of course the exact dimensions will mean the flow loss will vary - in particular the throat diameter and length, as well as the angles of the converging and diverging cones. But it doesn't seem to be covered by the venturi effect per se.

A: Assuming the fluid is viscous (which is a very reasonable assumption), then you are correct in your assumption that the restriction will reduce the overall flow rate the tube can accommodate (all else equal).
The typical explanation of the Venturi effect is a simplified analysis that only applies to incompressible, inviscid fluids along a streamline.
When you include viscosity, the restriction of the pipe would create friction loss, where the fluid loses energy due to interactions between the fluid and the walls.  There are many empirical ways to approximate how much friction loss is expected based on pipe roughness, flow velocities, pipe sizes, fluid, and any flow restrictions such as orifices or elbows.
The one I can recall using is the Darcy–Weisbach equation which would allow you to determine the expected head loss (and therefore affect on flow rate) that would be introduced by adding a Venturi tube compared to not having one.


text:
Q: Cannot fully delete an object in Amazon S3 How do you completely delete an object via the Amazon S3 Console? "Completely delete" meaning the object is entirely gone and isn't visible when enabling "Show versions." I cannot delete the "Show versions" objects themselves as the button is greyed out when they're selected. I've also tried deleting them via CLI but have had no luck.

A: If you have versioning enabled, deleting an object just adds another version of the object, the so called "delete marker".  If you want to remove all versions, including the delete marker, you'll need to enumerate and delete all versions of the object.  For instance, with the Python SDK, you can enumerate and delete them with one line after some setup:
import boto3
s3 = boto3.resource("s3")
bucket = s3.Bucket("-example-bucket-")  # ARN without the 'arn:aws:s3:::' prefix
key = "example_object.txt"
object = bucket.object_versions.filter(Prefix=key)
versions = len(list(object.all()))
object.delete()
print(f"Deleted {versions} versions for '{key}'")

A: Looks like your IAM User accessing the bucket does not have s3:DeleteObjectVersion permission. Once you add this permission to your policy, you should be able to delete the versions as well.


text:
Q: Is it possible to burn a DVD out of the Lion app store install? Is it possible to burn a DVD out of the Lion app store install?

A: Yes http://lifehacker.com/5812997/burn-the-mac-app-store-version-of-os-x-lion-to-a-dvd

A: Yes!
After you purchase and download Lion from the App Store, the "Install" screen will appear:

Before you click Continue, open your Applications folder and look for the icon labelled Install Mac OS X Lion:

If you missed this chance (and the App is deleted from your system), you can always re-download the package using the App Store app. Even if it shows Lion Installed, you can hold the option key pressed, then press the button to re-download the Lion installer app.
Right-click (or Ctrl+Click) on this and choose Show Package Contents. Navigate to Contents > SharedSupport and look for InstallESD.dmg.

Use Disk Utility (in the Utilities folder inside the Applications folder) to burn InstallESD.dmg to a DVD. Drag the InstallESD.dmg file to the Disk Utility window, select it, then choose Burn... from the Images menu.
A dialog appears allowing you to burn it to a DVD. The name of the DVD doesn't really matter, but I named mine Mac OS X Lion.

A: You can copy Install Mac OS X Lion.app — in its entirety — to a DVD that is not bootable.
A widely promoted hack involves using only a part of the .app for 10.7 (Build 11A511) to create a DVD (or USB flash drive, or external hard disk partition) that is bootable. Bootable media produced in this way from this source may be good for some uses but please, proceed with caution: other uses may leave a system unusable.
Be aware of the known risks, and unknowns, associated with straying from what is recommended by Apple.


text:
Q: Angular Material Filter Table With Complex Data I'm using the table component of angular material 13, with filter and pagination, however, when searching nothing is found, the table is empty.
Below is how my interface file is.

export interface ITecnicos {
  status: boolean;
  adult: boolean;
  technician: {
    idtechnician?: number;
    document: string;
    name: string;
    age: string;
  };
}

This table component is inserted into another component that receives data through observable, as follows:
 <app-list-table *ngIf="listaTecnicos$ | async as tecnicos" [listaTecnicos]="tecnicos"></app-list-table>

And inside that list.ts component, I have the code:
export class ListTableComponent implements OnInit, AfterViewInit {

  @Input() listaTecnicos: ITecnicos[] = [];
  readonly displayedColumns = ['nome',  'document', 'age', 'status', 'adult', 'action'];
  dataSource = new MatTableDataSource<ITecnicos>([]);
  @ViewChild(MatPaginator) paginator: MatPaginator;
  confirm: number;

  constructor() { }

  ngOnInit(): void {

    console.log('listagem chegando para preencher a tabela => ', this.listaTecnicos);
    this.confirm = this.listaTecnicos.length;
    if (this .confirm === 0) {
      this.listaTecnicos = [];
    } else {
      this.dataSource = new MatTableDataSource<ITecnicos>(this.listaTecnicos);
    }

  }

  applyFilter(event: Event) {
    const filterValue = (event.target as HTMLInputElement).value;
    this.dataSource.filter = filterValue.trim().toLowerCase();
  }

  ngAfterViewInit() {
  this.dataSource.paginator = this.paginator;
  }

}

In the html I have this form below, where all the data appears correctly in the table and without errors.
   <mat-form-field class="filtro example-full-width voxel-mt-8">
      <mat-label>Filtrar</mat-label>
      <input matInput (keyup)="applyFilter($event)"  #input >
    </mat-form-field>

      <ng-container matColumnDef="name">
        Name
         {{element.technician.name | titlecase}}
      </ng-container>

      <ng-container matColumnDef="adult">
        Adult
         {{element.adult}}
      </ng-container>

      <ng-container matColumnDef="document">
        Document
         {{element.technician.document}}
      </ng-container>

      <ng-container matColumnDef="age">
        Age
         {{element.technician.age}}
      </ng-container>

       <ng-container matColumnDef="action">
        Action
         ACTIOS
      </ng-container>

        No data matching the filter "{{input.value}}"

    <mat-paginator [pageSizeOptions]="[10, 25, 50, 100]"  showFirstLastButtons      aria-label="Select page of periodic elements"></mat-paginator>

No error is displayed on the console, however, as I said, when typing any value in the filter field, the table is clean, that is, it does not filter anything.


text:
Q: Parsing redundant MySQL result into structured array my MySQL query output is
dbcol_a | dbcol_b
dataA1 | dataB1
dataA1 | dataB2
dataA2 | dataB3
dataA2 | dataB4
dataA2 | dataB5
I wanna parse into struturized array like this:
arcol_a | arcol_b
dataA1 | dataB1
----------| dataB2
dataA2 | dataB3
----------| dataB4
----------| dataB5
thanks

A: This should do it:
$desired_array = array();
foreach ($query_output as $value)
{
  $desired_array[$value['arcol_a']][] = $value['arcol_b'];
}

This way you add each value in the second column to an array with an index of the first column.

A: *

*Make an hashtable called
arcol_a_array.

*Loop through your
data.  For each row, check and see
if the current arcol_a value is a key in
the arcol_a_array array.  If not,
add it.  The value of this key should be an array with one element - the value of the current row's arcol_b

*If the arcol_a value existed in the arcol_a_array hashtable, modify the array to add the new value from arcol_b.

A: $arr = array();

while($row = mysql_fetch_assoc($result)) {
   if(isset($arr[$row['arcol_a']])) {
    $arr[$row['arcol_a']][] = $row['arcol_b'];
  } else {
    $arr[$row['arcol_a']] = array($row['arcol_b']);
  }
}


text:
Q: Not able to generate required data structure using asn1 compiler I am converting NGAP asn1c to c data structure , i am able to compile all the file successfully , it generating .c and .h files but , it containing nested structure ,when i grep that nested structure that structure are are not present. i am using asn1c-0.9.29 version . and asn1 file's given in NGAP spec 138 413.

A: At the moment you need to use asn1c from the mouse07410's fork as it has support for Aligned PER encoding and better support for Information Object Class and Information Objet Set definitions.
See also https://github.com/mouse07410/asn1c/issues/44


text:
Q: Jersey Rest service: 'Resource /Servers is not open' I am new to Java EE and am trying to learn the same using tutorials and examples online.
I am trying to follow http://www.vogella.com/articles/REST/article.html#first and create a RESTful service using Jersey.
Since this is my first RESTful service, I have basically copy-pasted whatever code is present till http://www.vogella.com/articles/REST/article.html#first_run.
However, when I try to run the service, I am getting an error:
Could not load the Tomcat server configuration at /Servers/Tomcat v7.0 Server at localhost-config. The Servers project is closed.

When I tried looking into the server configuration, I see that the configuration path is showing an error for the value: /Servers/Tomcat v7.0 Server at localhost-config.
When I try to change any (server) configuration and save it, I get the message: "Error while saving. Resource '/Servers' is not open."
Five differences between my project and what is described in the page:

*

*I am using JDK 1.7, while the page mentions JDK1.6.

*I am using Apache Tomcat Server 7.0, while the page mentions Tomcat version 6.0.

*The Dynamic web module version is set to 3.0 in my project, while it is 2.5 in the page.

*I have a couple of practise spring apps configured on my tomcat server. I am not sure how to remove them. :(

*I have updated my web.xml to use web-app_3_1.xsd in the place of web-app_2_5.xsd.

I am not able to understand why this is happening.
If this does not seem to be solvable, I would be thankful, if you can point me to any resource that explains creating a RESTFul service using Jersey using Java EE7, Apache Tomcat 7 and, preferably, Eclipse.

A: The solution turned out to be simple. When I looked at the Project Explorer, I saw that there was a project called "Servers". Once I "opened" this project, the problem got resolved.
Seems like marking all projects and selecting "Close Project" has a side effect in Java EE Perspective. :)


text:
Q: Implementing OAuth protocol in Java I'm looking for an open source library that implements the OAuth protocol , I need the server side implementation . Say I have a Social network system , and I want to give my users an OAuth abiliy to my API , like facebook.
Do you have any suggestion , sure examples .

A: There are few Java libraries list here,
http://oauth.net/code/
You should use the first one. It's the only one with server support. You can find an example,
http://oauth.googlecode.com/svn/code/java/example/oauth-provider/
You might want also look at OAuth 2.0,
https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-02
Which greatly simplifies OAuth flow and you don't really need a library to implement it.

A: You can try https://github.com/apifest/apifest-oauth20
It's written in Java and uses Netty as a server. As a storage, it currently uses Hazelcast(by default), MongoDB or Redis. Also, you can easily add another backend storage.

A: http://code.google.com/p/oauth/ is the reference library, or there's also http://github.com/fernandezpablo85/scribe as an alternative.

A: If you are willing to implement oauth server using a Java Spring technologies.
Here is  an implementation using Spring Boot.
https://github.com/dsyer/sparklr-boot


text:
Q: Pweave cannot import local module I'm trying to import code from a local module into a pweave document, and I can't get it to work.
I have the following files
- foo.pmd
- bar.py
- __init__.py

Contents of foo.pmd:
```python
import bar
bar.foobar()
```

Contents of bar.py:
def foobar():
    return(1)

Then I run pweave foo.md and the output fails:
---------------------------------------------------------------------------ImportError
Traceback (most recent call last)<ipython-input-1-1c3509f6dae7> in <module>()
----> 1 import bar
      2 bar.foobar()
ImportError: No module named
'bar'

I think this should work?  Or am I trying to do something that's not possible?

A: I had the same problem. My solution:
import os
import sys
sys.path.append(os.getcwd())
import myfantasticmodule

I think the problem is, that the current working directory is not in the Python-Path  where Python looks for modules (I have no idea why this problem only occurs with pweave).
os.getcwd()

gives you the "current working directory" and
sys.path.append()

adds this directory to the Python-path (only for this session! So you don't have to delete it at the end).


text:
Q: How can i capture an event in a component which is emitted from another component? I want to capture the event in a component which is emitted event from another component.
I did the following code
myservice.ts
private _event = new EventEmitter<any>();

get event(): EventEmitter<any> {
  return this._event;
}

mycomponent_2.ts
this.myservice.event.emit(true);

mycomponent_1.ts - Added the below code in ngOnInit()
this.myservice.event.subscribe((value) =>  {
  console.log(value);
});

The expected console log not printed. Looks the event is not captured in the component_2
How can I solve this? Do I need to move the code to some other life cycle hook?

A: You should use a ReplaySubject so that it emits the previously emitted value. The EventEmitter losses any values after they are emitted.
If the service tries to emit the value before the component is created, then the value will be lost unless you use one of the buffering subjects.
private _event = new ReplaySubject<any>(1);

get event(): EventEmitter<any> {
  return this._event;
}

There is also the BehaviorSubject which allows you to define a default value that is emitted before next() is called for the first time.

A: Use Subject: A Subject is like an Observable, but can multicast to many Observers. Subjects are like EventEmitters: they maintain a registry of many listeners.
in service
   @Injectable({
    providedIn: 'root',
})
export class YourService {

    private yourVariable: Subject<any> = new Subject<any>();

    public listenYourVariable() {
        return this.yourVariable.asObservable();

    }

    public yourVariableObserver(value : type) {
        this.yourVariable.next(value);
    }

You import in yours components where you want use it this service.
import{ YourService } from ...

In component you want write the data call:
this.yourService.yourVariableObserver(yourData);

while where you want read the data:
  this.yourService.listenYourVariable().subscribe(
        variable => {
          this.data = variable;
        }

)

A: If you want to use an event, read on. I created a repo and got this working by adding an @output to the event like so:
export class MyServiceService {
@Output() event = new EventEmitter<any>();

constructor() {}

}
then to make sure there were no timing issues I created one button to add the listener in one component and another button to fire the event. Thus I think the main mistake is the lack of the @Output decorator.

A: One of the preferred choice is BehaviorSubject.
Here , a service can be used to share the data between the 2 component.
It highly useful when the components are not related to each other.
Ex:
Service : StringService
private testString=new BehaviorSubject<string>("Test") //Default value can be passed
public stringValue=this.testString.asObservable();

  passStringChange(project:string){
    this.testString.next(project)
  }

Component 1:
str:string

clickHere(){
this.stringService.passStringChange(str)
}

Component 2:
stringObtained:string
this.stringService.stringValue.subscribe(message=>this.stringObtained=message)


text:
Q: Windows Phone: Different Icon per Language is it possible to have a different appIcon in the app itself and in the Store, based on the current language of the phone/store page?

A: No, It's not possible to have language specific Icons neither in Store nor in Application.
If you want to detect current language of device you can use System.Threading.Thread.CurrentThread.CurrentCulture or CultureInfo.CurrentUICulture. But it's inside the application. So if you want to change any icon or image from inside Application in any of it's page, you can, but you can't change App Icon in the All Apps section of phone.
Hope that helps..


text:
Q: Trying to get TRACE level logging from Geckodriver I'm trying to get trace logging information out of the gecko driver, in order to debug some issues we're having with moving to newer versions of Python, Robot Framework, Selenium, Firefox.
See in the DEBUG robot output below, I'm setting the capabilities to include log level arguments as part of moz:firefoxOptions.
When the capabilities are printed out for Open Browser, the moz:firefoxOptions value has been replaced with the profile info, so I never get tracing set.
20190219 13:07:22.461 - INFO - {'browserName': 'firefox', 'marionette': True, 'acceptInsecureCerts': True, 'moz:firefoxOptions': {'prefs': {'log': {'level': 'trace'}}, 'args': ['-headless', '-profile', '/tmp/tmpimda__f2']}, 'binary': '/usr/bin/firefox'}

20190219 13:07:22.461 - INFO - +--- END KW: BuiltIn.Log (1)

20190219 13:07:22.461 - INFO - +--- START KW: CustomLib.AdminClass.Open Browser [ ${LOGIN URL} | ${BROWSER} | desired_capabilities=${dc} | ff_profile_dir=${profile} ]

20190219 13:07:22.462 - INFO - Opening browser 'Firefox' to base url 'https://HOST:PORT/bmmadmin/login.jsp'.

20190219 13:07:22.480 - DEBUG - POST http://127.0.0.1:38132/session {"capabilities": {"firstMatch": [{}], "alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts": true, "moz:firefoxOptions": {"profile": "UEsDBBQAAAAIAOtoU04+3NKsfgMAAM0MAAAHAAAAdXNlci5qc6VWTW/UMBC98ytQTyCx1rbABU6lFAkJUcSq4mg59mTjrmMbe7zp/nvGyaYsbb6AWz7e89hvZt44RQjcByhfnBXBNfTGlKtZo61yDVOp9gysKAyos1fPMSR4+f5ZesoxAiGEZE/ApTBxBG2hQVGwFAzhzkThEr4rjLC7sym8F1tYtn5EETB5lhmEXE+jKlfDEblgL49Z3O3p5FoBqyM6266it9YFGFmAPqkb+6MVOJ6vmbYY3O33L9Phc1Jqcc9lFSgwjzJoj5wU56jrHPT1epiwDBnAu4BcGMPvIod7CR61s3Ew6XdiL7plmetgLFau+Wyv6NEZGCRZwMaFHZOCKHtY5XjCrAiw13ImrxFkChoPTMa+HEeAj5PTgJFZr9lSm2IyoZTO5xQzizRQqECHC1zIrCBPlNsUERSXEHBYzRNSjClHfCBp+gBhhtXpwa3IsnLYgx0JJLxnySvqVCYSumEFT0CLWk3p6I04gLo+X2++OqRcEuHNCNg11jihqDAtaRzasvlRgd1k9bXdTse6vv1yyfp2m7SjFvmadVmYsy5td1THYKnsycS6JF/MYcmSOo8cB7uyJPxIpfagAEJlZQBB0k4/6RDxkrSQI230YEOihPaZVFtoiqeMWphGhKV2CiLI6lgWc1BTxuRzc/f2PuajEGO2DiSnJBXayi/J27gMIlYzUSowhskK5O4jlCIZ/ND9mabRDImMjm1v7JVxceYoJ+gbyvgwmBQRnXdmVSsQBqvunS1ytgl+8rlVrv+R3Ucvc0F9T3+/feO22/xRdp7+F/vwzmh5YPnjJhW1bvP8v/xv7cfL3w09tAzs0TkTGTmEC8eNT15f8ugjB2sNtG1rRXPGbnlWfjhG9gjbFm5roh878kYSO7vu+XoUXhgnd0ZHnK6IE0Zb4Feu9mTthTZ5AFq9rdAcZqlLLPwp3JJ/l4fb0UY6GfxTqvajvnP51dEHVzRiMcXhlXtKhUjXtkrH6rDKvz3NxJUBu8VsCRdv3/5J65emqUX5MMY1vDhw1XnC4N48WYzHmLub104Js/DmUWoD9MRc0NQWvKvRfJmawUcMWiJ/TBsKlW+NlqywhrqAsGlfR+TKZb7TyI6y9eP0WMqDB+8pCIYiYDiwTor25Bdz2EmRnsID3LXjbHAn916T7VO2WD4y1QS5PzF+Jh3GIvymNJWmMLmLBhi/AFBLAQIUAxQAAAAIAOtoU04+3NKsfgMAAM0MAAAHAAAAAAAAAAAAAACkgQAAAAB1c2VyLmpzUEsFBgAAAAABAAEANQAAAKMDAAAAAA=="}}}, "desiredCapabilities": {"browserName": "firefox", "acceptInsecureCerts": true, "moz:firefoxOptions": {"profile": "UEsDBBQAAAAIAOtoU04+3NKsfgMAAM0MAAAHAAAAdXNlci5qc6VWTW/UMBC98ytQTyCx1rbABU6lFAkJUcSq4mg59mTjrmMbe7zp/nvGyaYsbb6AWz7e89hvZt44RQjcByhfnBXBNfTGlKtZo61yDVOp9gysKAyos1fPMSR4+f5ZesoxAiGEZE/ApTBxBG2hQVGwFAzhzkThEr4rjLC7sym8F1tYtn5EETB5lhmEXE+jKlfDEblgL49Z3O3p5FoBqyM6266it9YFGFmAPqkb+6MVOJ6vmbYY3O33L9Phc1Jqcc9lFSgwjzJoj5wU56jrHPT1epiwDBnAu4BcGMPvIod7CR61s3Ew6XdiL7plmetgLFau+Wyv6NEZGCRZwMaFHZOCKHtY5XjCrAiw13ImrxFkChoPTMa+HEeAj5PTgJFZr9lSm2IyoZTO5xQzizRQqECHC1zIrCBPlNsUERSXEHBYzRNSjClHfCBp+gBhhtXpwa3IsnLYgx0JJLxnySvqVCYSumEFT0CLWk3p6I04gLo+X2++OqRcEuHNCNg11jihqDAtaRzasvlRgd1k9bXdTse6vv1yyfp2m7SjFvmadVmYsy5td1THYKnsycS6JF/MYcmSOo8cB7uyJPxIpfagAEJlZQBB0k4/6RDxkrSQI230YEOihPaZVFtoiqeMWphGhKV2CiLI6lgWc1BTxuRzc/f2PuajEGO2DiSnJBXayi/J27gMIlYzUSowhskK5O4jlCIZ/ND9mabRDImMjm1v7JVxceYoJ+gbyvgwmBQRnXdmVSsQBqvunS1ytgl+8rlVrv+R3Ucvc0F9T3+/feO22/xRdp7+F/vwzmh5YPnjJhW1bvP8v/xv7cfL3w09tAzs0TkTGTmEC8eNT15f8ugjB2sNtG1rRXPGbnlWfjhG9gjbFm5roh878kYSO7vu+XoUXhgnd0ZHnK6IE0Zb4Feu9mTthTZ5AFq9rdAcZqlLLPwp3JJ/l4fb0UY6GfxTqvajvnP51dEHVzRiMcXhlXtKhUjXtkrH6rDKvz3NxJUBu8VsCRdv3/5J65emqUX5MMY1vDhw1XnC4N48WYzHmLub104Js/DmUWoD9MRc0NQWvKvRfJmawUcMWiJ/TBsKlW+NlqywhrqAsGlfR+TKZb7TyI6y9eP0WMqDB+8pCIYiYDiwTor25Bdz2EmRnsID3LXjbHAn916T7VO2WD4y1QS5PzF+Jh3GIvymNJWmMLmLBhi/AFBLAQIUAxQAAAAIAOtoU04+3NKsfgMAAM0MAAAHAAAAAAAAAAAAAACkgQAAAAB1c2VyLmpzUEsFBgAAAAABAAEANQAAAKMDAAAAAA=="}, "binary": "/usr/bin/firefox", "marionette": true}}

Anyone have any ideas what I may be doing wrong here?  And/OR some alternative methods of getting trace logging from geckodriver?
BTW:  the moz:firefoxOptions I'm setting may not be correct, they're just the latest combination I have tried, but I can't tell what is going to work until the options I set are actually being sent to firefox.
Environment:

Python 3.6.3
geckodriver 0.24.0 ( 2019-01-28)
Mozilla Firefox 60.4.0

PIP:

requests (2.21.0)
robotframework (3.1.1)
robotframework-requests (0.5.0)
robotframework-selenium2library (3.0.0)
robotframework-seleniumlibrary (3.3.1)
selenium (3.141.0)
setuptools (40.8.0)
urllib3 (1.24.1)

ROBOT:

Open Browser To Login Page
    ${dc}=    CustomLib.Get Desired Capabilities    ${BROWSER}
    Set To Dictionary   ${dc}
    ...                 binary                         ${PATH TO MARIONETTE}
    Log    ${dc}
    ${profile}=    CustomLib.Create FF Profile
    Open Browser    ${LOGIN URL}    ${BROWSER}    desired_capabilities=${dc}    ff_profile_dir=${profile}

PYTHON:

@keyword
def get_desired_capabilities(browser):
        _capabilities = {'ff' : DesiredCapabilities.FIREFOX,
                    'firefox' : DesiredCapabilities.FIREFOX
                    }

        browserKey = str(browser).lower()
        desired = _capabilities[browserKey]
        BuiltIn().log("get_desired_capabilities B4 :" + str(desired))
        #THIS IS ASSUMING FIREFOX
        desired['marionette'] = True
        desired['acceptSslCerts'] = True
        desired['ignoreProtectedModeSettings'] = True
        desired['headless'] = True
        desired['moz:webdriverClick'] = True
        desired['moz:firefoxOptions'] = {'log':{'level':'trace'}, 'args':['-headless']}
        #desired['moz:firefoxOptions']['log'] = {'level':'trace'}
        #desired['moz:firefoxOptions']['args'] = ['-headless']
        BuiltIn().log("get_desired_capabilities returning :" + str(desired))
        return desired

@keyword
def create_ff_download_profile(path):
        from selenium import webdriver
        BuiltIn().log('PATH: ' + path)
        fp = webdriver.FirefoxProfile()
        fp.set_preference("browser.download.folderList", 2)
        fp.set_preference("browser.download.manager.showWhenStarting", False)
        fp.set_preference("browser.helperApps.alwaysAsk.force", False);
        fp.set_preference("browser.helperApps.neverAsk.saveToDisk", 'text/xml,text/plain,application/octet-stream')
        fp.set_preference("browser.download.dir", path)
        fp.update_preferences()
        return fp.path

thanks,
Tom

A: This is how I set the log level to be trace in Firefox:
*** Settings ***
Library    SeleniumLibrary

*** Keywords ***
    ${options}=    Evaluate  sys.modules['selenium.webdriver.firefox.options'].Options()    sys
    ${options.log.level}=    Set Variable    trace
    ${driver}=    Create Webdriver    Firefox    options=${options}
    Go To    https://www.google.com

It's basically following this python pattern from the firefox docs and translating it into Robotframework
Hope this helps!


text:
Q: How to give .requestFocus() for first search of a text in the layout in Android Studio using Java? In my android app, I want to give .requestFocus() for the first search of a text which is in textView using Java in an android studio. Here is my code snippet that I had gone through...
String mytext = "Menu1";
mytext.requestFocus();

But here I got error..

A: Request focus is only for the views not for the primitive data types.
For the Textview to keep in focus by using XML or programmatically,
// Parent view
LinearLayout ll = …
final int childCount = ll.getChildCount();
for (int i = 0; i < childCount; i++) {
  View v = ll.getChildAt(i);
  // Check is v is instanceof TextView.
}

Xml attributes,
// Based on the requirement
android:focusable="true"
android:focusableInTouchMode = "true"

Programmatically,
TextView text = view.findViewById(R.id.textView);
text.requestFocus();

A: requestFocus is for a View like EditText, not a string. You can use it like this:
textview.requestFocus();

or
    <TextView...>
        <requestFocus />
    </TextView>


text:
Q: Wave shaped responsive header with CSS I'm trying to realize a wave-shaped header for a website...
It should look like that (no comment on the gradient, not my choice lol)

I tested some part of codes I found online to make this effect with CSS but when I try to edit something to make the wave adaptive to different kind of devices, everything goes down... With percentage it's quite difficult to me to find the exact point where the first curved shaped has to end and the next has to begin, I am left with some no needed straight line...
I even tried to use a SVG file to solve the issue but... you can imagine...
Anyone can help me to realize this? Thanks in advance!
Here's my code:

#wave {
position: relative;
height: 100px;
width: 100%;
background: purple;

}
  #wave:before {
    content: "";
    display: block;
    position: absolute;
    border-radius: 100% 40%;
    width: 65%;
    height: 100px;
    background-color: white;
    right: -50px;
    top: 85px;
  }
  #wave:after {
    content: "";
    display: block;
    position: absolute;
    border-radius: 100% 40%;
    width: 65%;
    height: 120px;
    background-color: purple;
    left: -10%;
    top: 57px;
  }
    <header id="wave">
      ...
    </header>


text:
Q: How to run sdkmanage on JDK 11 sdkmanage can not run on JDK 11.
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
        at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
        at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
        at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 5 more

After add -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee
Show
Error occurred during initialization of boot layer
java.lang.module.FindException: Module java.se.ee not found

I know JDK 11 has removed ee module.
So, any idea to run sdkmanage on JDK 11?


text:
Q: Hazelcast Jet - Use Cases What are the use-cases of Hazelcast Jet? Has anyone started using it?
Our project uses Hazelcast for Distributed Map holding Key-Value pair and Distributed computing on those Keys to run the task at the node holding the Key. We use NearCache solution as well.
I was curious to know how different is Hazelcast Jet and what problems does it solve?

A: As of current version (0.3), Jet's advantage over just submitting a Runnable to each partition is the ability to perform grouping by a key other than the one used in the Hazelcast map. For this to work in a distributed environment you have to send each item to the processing unit responsible for its grouping key, and this is something that is easy to get from Jet.
Further from that, you can build a multistage cascade of groupBy operations, you can have forks in your data stream to reuse the same intermediate result in more than one way, you can build a pipeline where an I/O task distributes the processing of the data it reads across all CPU cores, etc... in short, all the advantages that a full-blown DAG computation engine offers.
By the time it reaches 1.0 Jet will also support fault-tolerant infinite stream processing, event time-based windows, and more.

A: 2021 answer for use cases:

*

*Change data capture streaming - Use Debezium/Hazelcast to detect changes to your database and stream to other microservices (if data is common), stream changes to a data lake, or update a search engine

*Real time analytics - Take market data stream and perform technical analysis in realtime or twitter analysis

*Async job processing - PDF conversion service


text:
Q: React Native TouchableOpacity OnPress not Working with loop I have a scrollview in which multiple items are generated with loop. I added TouchableOpacity above these items because i want these objects to be touchable. But when i add a method on onPress method it shows error not a function , is undefined
List_Data Component:
class List_Data extends React.Component {

    fetchData = () => {
        console.log("DONE");
    }

    _renderView = () => {
        return (
            <View style={{flex:1, padding: 20}}>
                        <View style={styles.container}>
                            <ScrollView horizontal={true} showsHorizontalScrollIndicator={false} >
                                {
                                    this.state.Data.map(function (data, index) {
                                        return (
                                            <TouchableOpacity key={index} onPress={() => this.fetchData()}>
                                                <Image source={{uri: data.imageSrc}}
                                                       resizeMode={'cover'}
                                                       style={{width: '100%', height: imageHeight}}
                                                />
                                            </TouchableOpacity>
                                        );
                                    })
                                }
                            </ScrollView>
                        </View>
                    </View>
        )
    }

    render() {
        return (
            {this._renderView()}
        );
    }
}

I don't know whats the issue, it just a method which prints on console.

A: The issue is coming from your .map. Basically you are losing the value of this as you are not using an arrow function. If you change your .map(function(data, index) to .map((data,index) => it should work.
import * as React from 'react';
import { Text, View, StyleSheet, ScrollView, TouchableOpacity, Image } from 'react-native';
import { Constants } from 'expo';

export default class App extends React.Component {

  state = {
    Data: [
      {imageSrc :'https://randomuser.me/api/portraits/men/39.jpg'},
      {imageSrc: 'https://randomuser.me/api/portraits/women/38.jpg'},
      {imageSrc: 'https://randomuser.me/api/portraits/men/37.jpg'},
      {imageSrc: 'https://randomuser.me/api/portraits/women/36.jpg'},
      {imageSrc: 'https://randomuser.me/api/portraits/men/35.jpg'},
      {imageSrc: 'https://randomuser.me/api/portraits/women/34.jpg'},
    ]
  }

  // let's pass something so that we know that it is working
  fetchData = (index) => {
    alert(`you pressed ${index}`)
  }

  _renderView = () => {
    return (
      <View style={{flex: 1, padding: 20}}>
        <View style={styles.container}>
        <ScrollView horizontal={true} showsHorizontalScrollIndicator={false} >
            {
              this.state.Data.map((data, index) =>  { // change this to an arrow function
                  return (
                      <TouchableOpacity key={index} onPress={() => this.fetchData(index)}>
                          <Image source={{uri: data.imageSrc}}
                                  resizeMode={'cover'}
                                  style={{width: 100, height: 100}}
                          />
                      </TouchableOpacity>
                  );
              })
            }
          </ScrollView>
        </View>
      </View>
    );
  }

  render() {
    return (
      this._renderView()
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
    padding: 8,
  }
});

You can see it working in the following snack https://snack.expo.io/@andypandy/map-with-arrow-function

A: Try keyboardShouldPersistTaps={true} under ScrollView. <ScrollView keyboardShouldPersistTaps={true}>


text:
Q: Using multiple modules in Android NDK I having trouble setting up my Android NDK based project with multiple modules which depend on each other.
What I would like to accomplish:
jni
  Application.mk
  Android.mk          (includes make files from modules)
  app
    Android.mk        (needs libpng & libzip modules)
    JniModules.cpp
  libpng
    Android.mk
    ...               (more source files)
  libzip
    Android.mk
    ...               (more source files)

The JniModules.cpp file just include headers from libpng and libzip but the compiler can't seem find the libpng/png.h or libzip/zip.h files.
jni/app/JniModules.cpp:2:24: fatal error: libpng/png.h: No such file or directory
compilation terminated.
make: *** [obj/local/armeabi/objs/JniModules/JniModules.o] Error 1

I've put a bare bones project on github: https://github.com/niob/JniModules.
Any pointers to how I should use another module from within a module?

A: In your jni/app/android.mk, set LOCAL_C_INCLUDES
to LOCAL_C_INCLUDES += $(LOCAL_PATH)
or to ``LOCAL_C_INCLUDES += $(LOCAL_PATH)/libpng`
Source


text:
Q: Metalsmith.js: How to build to same directory as build script? I am completely new to metalsmith. I've been following this tutorial: http://www.robinthrift.com/post/metalsmith-part-1-setting-up-the-forge/
I want to build my site to the root directory of my project (the same dir as the build script). I want to do this because I want github pages to play nicely with it. But when I try to build, I get this error: Error: EBUSY, resource busy or locked
Here is my dir structure:

*

*project_folder/

*

*_site-src/

*

*index.html

*node_modules

*build.js

*package.json

Here is my build.js source:
var Metalsmith = require("metalsmith");

Metalsmith(__dirname)
    .source("_site_src")
    .destination(".")
    .build();

What I want my project dir to look like:

*

*project_folder/

*

*_site-src/

*

*index.html

*node_modules

*build.js

*package.json

*index.html

I don't know what I'm doing wrong. I appreciate any help.

A: The error message:

Error: EBUSY, resource busy or locked

seems to be a file locked/in use error. (I'm not that familiar with Node.js errors)
I would assume this is happening when Metalsmith tries to clean the build folder (which is your solution folder i.e. a really bad idea). This is on by default but it can be turned off.
To turn this off use:
.clean(false)

before you build.

BUT if you remove items from your source folder they won't be removed from your build folder. You might be able to handle this by a custom clean-up script or plugin.
I'm not experienced with github pages but I think there should be a better alternative to the avoid the problem.
You could possibly add a symbolic link to the build folder from the project folder for the index.html file.


text:
Q: Discrete Variables and Regression I have only discrete independent variables (gender, religious affiliation etc) and continuous dependent variables.  Is it possible to use a regression model?

A: Yes, though you will want to convert the categorical variables into dummy/indicator variables.  Most statistical packages will do this for you as long as it is clear that they are categorical.
Technically when all predictors are categorical you are doing ANOVA, but since many of the statistical packages use their regression code to do ANOVA anyways, it does not matter.  If you design your dummy variables appropriately then the regression approach can give more insight than a simple ANOVA fit.


text:
Q: Get data from an API with Flask I have a simple flask app, which is intended to make a request to an api and return data. Unfortunately, I can't share the details, so you can reproduce the error. The app looks like that:
from flask import Flask
import requests
import json
from requests.auth import HTTPBasicAuth

app = Flask(__name__)

@app.route("/")
def getData():
    # define variables
    username = "<username>"
    password = "<password>"
    headers = {"Authorization": "Basic"}
    reqHeaders = {"Content-Type": "application/json"}
    payload = json.dumps(
        {
            "jobType": "<jobType>",
            "jobName": "<jobName>",
            "startPeriod": "<startPeriod>",
            "endPeriod": "<endPeriod>",
            "importMode": "<importMode>",
            "exportMode": "<exportMode>"
        }
    )
    jobId = 7044

    req = requests.get("<url>", auth=HTTPBasicAuth(username, password), headers=reqHeaders, data=payload)
    return req.content

if __name__ == "__main__":
    app.run()

However, when executed this returns error 500: Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
The same script but outside a flask app (just the function as it is defined here) runs with no problems at all.
What am I doing wrong?

A: flask app return format json. If you return req.content, it will break function. You must parse response request to json before return it.
from flask import jsonify
return jsonify(req.json())

It's better with safe load response when the request fail
req = requests.get()
if req.status_code !=200:
   return {}
else:
   return jsonify(req.json())


text:
Q: How to run Cornelsen's "Tobi" software (for Windows) on linux, using Wine There are a lot of resources on how to run Windows software with Wine, but this question is specifically about how to run a software called "Tobi Fibel" from the German Cornelsen Verlag on (Ubuntu) linux, using Wine.
I got it partially working by just using the default settings from Wine, when installing the Wine Windows Program Loader using the Ubuntu Software Center.
The introducory screen of the software, where an avatar explains the software (with audio and animations) are just fine, also the mouse is working properly. However, certain buttons do not work and it's not possible to go beyond this introduction.
What I have tried

*

*Selecting between Windows XP and Windows 7 emulation mode

*Mapped Drive D:\ in Wine to point to the software

*Start from console instead from Gnome like wine d:\Start.EXE

*Start with the debug output like WINEDEBUG=loaddll wine d:\Start.exe The Debug output did not reveal anything useful to me.

Update 1:
When running the program in the debugger using winedbg d:\Start.exe and press CTRL+C right after pressing one of the non-working buttons I get
Ctrl-C: stopping debuggee
0xf772b430 __kernel_vsyscall+0x10 in [vdso].so: popl    %ebp

What can I do with this?
Update 2:
When starting the program using WINEDEBUG=+relay wine d:\Start.exe it just filled the terminal with a tremendous amount of logs and actually caused the program to show an error message right after startup. I did not manage to get to the point where I was stuck originally.
How can I make the thing running all stuff, not just the introducory screen? I have no Idea what prevents the mentioned buttons from working.
Note: I know that I could and have successfully run it on a Windows XP virtual machine, but I like to avoid using a copy of Windows altogether, for licensing reasons, and because the screen resolution (fullscreen required) is a bit flaky with the VMWare Player.


text:
Q: www e sem www para uma pasta e qualquer outro subdomínio para outra pasta Eu tenho um domínio configurado no nginx da seguinte forma:
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name   .dominio.com.br ~^(www\.)?(?<domain>.+)$;
    root /home/dominio.com.br/public;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

Isso faz com que qualquer um destes links funcione:
dominio.com.br
subdominio.dominio.com.br
Caso eu configure um DNS de um outro domínio apontando para o IP deste meu servidor o app também funcione por causa dessa linha:
server_name   .dominio.com.br ~^(www\.)?(?<domain>.+)$;

Eu gostaria de poder direcionar para uma outra pasta caso o link for:
www.dominio.com.br
dominio.com.br
Ou seja, qualquer subdomínio (menos www) deve ir para uma pasta ja o subdomínio www e sem www ir para uma outra pasta.
Já tentei criando um novo bloco server {} como no exemplo abaixo, mas não funcionou:
server {
    listen 80;
    listen [::]:80;

    server_name   dominio.com.br www.dominio.com.br;
    root /home/outra_pasta/public;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

Como posso resolver esta questão?


text:
Q: how to install libevent on eclipse c/c++ I am trying and using libevent in my eclipse c/c++ project.
I downloaded the libevent library using this command
 sudo apt-get install libevent-dev

It is working normally so that in the specific directory
I was looking for a libevent.a file to include it as library in my eclipse project but I can only find a libevent.la
How can I use it in this case?
I am using ubuntu 12.04 and eclipse Version: Kepler Release

A: do you see it with command:
dpkg -L libevent-dev|grep libevent.a

In normally, libevent-dev will install libevent to standard system library location, so you just need to add event to Project Properties -> C/C++ General -> Path And Symbols -> Library Paths