text:
Q: SFTP file transfer using Apache Commons Vfs2 I am using Apache Commons VFS2 to upload a file to server. Below is the code for the same. I have all the credentials right. The code printed "File uploaded successfully" String as well. But, I could not find the file on server when i cross checked it. Is there anything i am missing here in the code ?
I have all the Jars required (Apache Commons VFS jars, JSH jar)
public static void main(String[] args) {

    SendMyFiles sendMyFiles = new SendMyFiles();

    sendMyFiles.startFTP("C:/useragent.log");

}

public boolean startFTP(String fileToFTP) {

    props = new Properties();
    StandardFileSystemManager manager = new StandardFileSystemManager();

    try {

        // props.load(new FileInputStream("properties/" +
        // propertiesFilename));
        String serverAddress = "10.111.111.11";
        String userId = "username";
        String password = "password";
        String remoteDirectory = "local/home/client/files/";

        // check if the file exists
        String filepath = fileToFTP;
        File file = new File(filepath);
        if (!file.exists())
            throw new RuntimeException("Error. Local file not found");

        // Initializes the file manager
        manager.init();

        // Setup our SFTP configuration
        FileSystemOptions opts = new FileSystemOptions();
        SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no");
        SftpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, true);
        SftpFileSystemConfigBuilder.getInstance().setTimeout(opts, 10000);

        // Create the SFTP URI using the host name, userid, password, remote
        // path and file name
        String sftpUri = "sftp://" + userId + ":" + password + "@" + serverAddress + "/" + remoteDirectory;

        // Create local file object
        FileObject localFile = manager.resolveFile(file.getAbsolutePath());

        // Create remote file object
        FileObject remoteFile = manager.resolveFile(sftpUri, opts);

        // Copy local file to sftp server
        remoteFile.copyFrom(localFile, Selectors.SELECT_SELF);
        System.out.println("File upload successful");

    } catch (Exception ex) {
        ex.printStackTrace();
        return false;
    } finally {
        manager.close();
    }

    return true;
}

A: I'd assume that the sftpUri should be a path to the destination file, not directory:
String sftpUri =
    "sftp://" + userId + ":" + password + "@" + serverAddress + "/" + remoteDirectory + "/" +
    file.getName();


text:
Q: What would be a good way of creating graph on a website? I got a bunch of data in a database. The goal is to present them to a user in a readable way, and since they're stock-data, there needs to be a graph there.
Now it brings one question: which approach would be better, to create a graph on a server side dynamically or let the server just push raw data, allowing the client to generate graph? I saw there are some jQuery libraries for doing this, flot for example.
I usually prefer to do as little as possible on the client side, but this time I wonder: generating the graph on client side would produce lower server load.
Also, changing some parameter (like displaying data for bit diffrent timespan) would require only to fetch missing data from server with ajax and redraw graph, instead of fetching completly diffrent image. This would give a more responsive UI.
I saw that Google Finance uses flash for their graphs, but I'd like to avoid it if it's possible...

A: What about using the Google Chart API?

The Google Chart API lets you dynamically generate charts. To see the Chart API in action, open up a browser window and copy the following URL into the address bar:
https://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World

Press the Enter or Return key and - presto! - you should see the following image:

Pros of this solution:

*

*It won't generate more load on your servers.

*It doesn't involve the client.

*The charts look sexy (IMHO).

Cons of this solution:

*

*It needs an internet connection.

*You rely on a third party (but it's Google and they have decent uptime).

*You pass informations to Google and this might be a problem.

A: There are several issues with client side charting:

*

*For Javascript / Flash based charts your clients must have javascript / flash enabled. If your application is already js-dependent that's not a problem.

*What is a problem, though, is when sometime down the line you'll get a requirement to send reports to customers via emails (be they HTML emails or embedded PDFs or what have you). Suddenly flash / javascript are no help at all, so you end up implementing server side charting and now either have to maintain both or refactor your UI.

*Using Google Charts avoids both of the above issues; however it introduces an external dependency. Something you may or may not want to live with.

If all of the above don't scare you, client side charting is great, especially the interactivity of it.

A: The client-side offers more opportunities for the user here. Generating a bitmap on the server is pretty lame in that regard, and as you mentioned, it adds to your server load.
I'd go for flot in that case. Browser support is really good, it isn't wasteful with client resources, and you can easily give your users a couple of extra features like zooming in or activating and deactivating part of the data. Of course, flot graphs also look quite nice.

A: Having extremely CPU heavy JS libraries can actually hamper user experience (nothing like having my FireFox 3.5 freeze up for 1 minute while Yahoo Mail's latest and supposedly greatest code does something which I never wanted or needed for it to do). So, if you can afford server side resources, do it on a server.
However, make sure to cache the graph images with the same input data - it may make a difference between acceptable and DOA server utilization.
At the very least, allow user a "lite" option - ala Yahoo Finance which allows you to switch to simple non-flash graphs or Google Maps that has a lite HTML-only interface.

A: If the users are customizing what data is displayed in the graph, I might consider drawing the graph on the client side.  If the graph is going to be relevant to more than one user, I'd definitely generate it once on the server side and cache it for everyone.

A: Also depends on how important it is for your users to see the graphs, and whether they are in a controlled environment. If you can not be sure they will have javascript enabled, better generate the graphs server side.

A: I'd probably just find a charting library that works with your chosen development language and go with it - unless you have a strong justification for writing your own charting system.
If your using Asp.Net then the new charting control is probably a safe bet - it generates charts server (as images)

redpajama_set_name: RedPajamaStackExchange


text:
Q: Add library 'Gradle:' to classpath in Android Studio The project is a generated LibGDX project. It used to work fine, but when I updated to Android Studio Chipmunk, the android module din't work fine anymore. So recently, I've updated to the Dolphin version which I thought could fix the problem. Well, it's still the same:
Error Image
As you can see, the external dependencies aren't detected and causing unresolved symbol errors. The library includes: the 'core' module, libgdx Android backend, and Play Service Ads (Admob).
I've tried rebuilding the project, updating everything that is possible, and tried solving it in the build.gradle file. However, it seems to be a problem in the IDE or me...
The project still builds and runs well, as if there's nothing wrong at all.
How can I fix this problem?


text:
Q: Excel Macro R1C1 formula not retaining values I have an excel macro that creates a new excel sheet and fills it with a variable number of rows. I have a count of the number of rows stored in a variable. I'm using an R1C1 formula to multiply two cells together based on my row count. In the macro the formula looks like it's correct (if I add a break point and put a watch on it) but when the macro finishes the formula in the cell is incorrect.
VB Code to generate formula:
MainSheet.Cells(RowCount + 6, 6).FormulaR1C1 = "=R[" & RowCount + 3 & "]C" & "*" & "R[" & RowCount + 4 & "]C"

Watch on the formula with a break point reveals this: "=R[430]C*R[431]C"
Actual cell data after macro finishes: =F863*F864. I need this to be =F430*F431

A: By using the [] you are telling vba that you want the relative positioning.  Which means it will add(or subtract) the number in the [] to the current row and/or column in which the formula is being placed.
Remove the RowCount:
MainSheet.Cells(RowCount + 6, 6).FormulaR1C1 = "=R[3]C*R[4]C"


text:
Q: How to read a JSON object in Go without decoding it (for use in reading a large stream) I am reading JSON in response to an HTTP endpoint and would like to extract the contents of an array of objects which is nested inside.  The response can be large so I am trying to use a streaming approach instead of just json.Unmarshal'ing the whole thing.  The JSON looks like so:
{
"useless_thing_1": { /* etc */ },
"useless_thing_2": { /* etc */ },
"the_things_i_want": [
  { /* complex object I want to json.Unmarshal #1 */ },
  { /* complex object I want to json.Unmarshal #2 */ },
  { /* complex object I want to json.Unmarshal #3 */ },
  /* could be many thousands of these */
],
"useless_thing_3": { /* etc */ },
}

The json library provided with Go has json.Unmarshal which works well for complete JSON objects.  It also has json.Decoder which can unmarshal full objects or provide individual tokens.  I can use this tokenizer to carefully go through and extract things but the logic to do so is somewhat complex and I cannot then easily still use json.Unmarshal on the object after I've read it as tokens.
The json.Decoder is buffered which makes it difficult to read one object (i.e. { /* complex object I want to json.Unmarshal #1 */ }) and then consume the , myself and make a new json.Decoder - because it will try to consume the comma itself.  This is the approach I tried and haven't been able to make work.
I'm looking for a better solution to this problem.  Here is the broken code when I tried to manually consume the commas:
// code here that naively looks for `"the_things_i_want": [` and
// puts the next bytes after that in `buffer`

// this is the rest of the stream starting from `{ /* complex object I want to json.Unmarshal #1 */ },`
in := io.MultiReader(buffer, res.Body)

dec := json.NewDecoder(in)

for {

    var p MyComplexThing
    err := dec.Decode(&p)
    if err != nil {
        panic(err)
    }

    // steal the comma from in directly - this does not work because the decoder buffer's its input
    var b1 [1]byte
    _, err = io.ReadAtLeast(in, b1[:], 1) // returns random data from later in the stream
    if err != nil {
        panic(err)
    }
    switch b1[0] {
    case ',':
        // skip over it
    case ']':
        break // we're done
    default:
        panic(fmt.Errorf("Unexpected result from read %#v", b1))
    }
}

A: Use Decoder.Token and Decoder.More to decode a JSON document as a stream.
Walk through the document with Decoder.Token to the JSON value of interest. Call Decoder.Decode unmarshal the JSON value to a Go value. Repeat as needed to slurp up all values of interest.
Here's some code with commentary explaining how it works:
func decode(r io.Reader) error {
    d := json.NewDecoder(r)

    // We expect that the JSON document is an object.
    if err := expect(d, json.Delim('{')); err != nil {
        return err
    }

    // While there are fields in the object...
    for d.More() {

        // Get field name
        t, err := d.Token()
        if err != nil {
            return err
        }

        // Skip value if not the field that we are looking for.
        if t != "the_things_i_want" {
            if err := skip(d); err != nil {
                return err
            }
            continue
        }

        // We expect JSON array value for the field.
        if err := expect(d, json.Delim('[')); err != nil {
            return err
        }

        // While there are more JSON array elements...
        for d.More() {

            // Unmarshal and process the array element.

            var m map[string]interface{}
            if err := d.Decode(&m); err != nil {
                return err
            }
            fmt.Printf("found %v\n", m)
        }

        // We are done decoding the array.
        return nil

    }
    return errors.New("things I want not found")
}

// skip skips the next value in the JSON document.
func skip(d *json.Decoder) error {
    n := 0
    for {
        t, err := d.Token()
        if err != nil {
            return err
        }
        switch t {
        case json.Delim('['), json.Delim('{'):
            n++
        case json.Delim(']'), json.Delim('}'):
            n--
        }
        if n == 0 {
            return nil
        }
    }
}

// expect returns an error if the next token in the document is not expectedT.
func expect(d *json.Decoder, expectedT interface{}) error {
    t, err := d.Token()
    if err != nil {
        return err
    }
    if t != expectedT {
        return fmt.Errorf("got token %v, want token %v", t, expectedT)
    }
    return nil
}

Run it on the playground.


text:
Q: How to make DataContractSerializer safer? I ran into a scenario recently where one of our devs added an object to our data contract that was not marked as a data member.  We are using using the DataContractSerializer to store a configuration file for a piece of hardware we are controlling.  The serialize operation did not succeed, obviously.
The major problem this uncovered was that the configuration file got destroyed during the process.  Does anyone know of a way to make sure the object graph will serialize prior to trying to serialize it?
The stack trace from the serialization exception fails at a call to XmlObjectSerializerContext.CheckIfTypeSerializable(..)  I'm wondering if there is something like this, that I can use prior to trying to serialize.
I would like to avoid having to stream the graph to memory and then to file, but I guess this would work...
Any suggestions?

A: Scott, I think you mean that serialize succeeded, but *de*serialize didn't succeed. If you add an additional data member but forgot to annonate, the serializer would just ignore it during serialization. Also, if it sees an additional member during deserialization, it will throw if you're requiring strict schema validity or requiring the member to be present; but otherwise, it will simply not parse that value and move on.
There are a few ways to handle this -- using IExtensibleDataObject, requiring DataMembers, using surrogates, etc. See http://msdn.microsoft.com/en-us/library/ms731138.aspx [Data Contract Versioning] and http://msdn.microsoft.com/en-us/library/ms731083.aspx [Forward-Compatible Data Contracts] for more specific guidance.
Hope this helps!


text:
Q: Почему Ajax запускает новый обработчик функции каждый раз при success? function getUserInfo(username) {
    if (getUserInfo_var) return false;
    $.ajax({
        url: '/url.php',
        type: 'post',
        dataType: 'json',
        data: {username:username},
        success: function(json) {
            if (typeof json.success !== 'undefined') {
                $(document).find('.innerTwo').empty();
                $(document).find('.innerTwo').html(json.success);
                compl(); // эта функция обрабатывается каждый раз по новой
            } else if (typeof json.error !== 'undefined') {
                return $.jGrowl(json.error);
            }
        },
        error: .....
    });
}

Функция compl
function compl() {
    if($(document).find('#complaint').length>0) {
        usernameTocomplaint = $(document).find('.tuName').text();
        $(document).on('click', '#complaint', function() {
            $('#complaintForm').find('input[name="usernameTocomplaint"]').val(usernameTocomplaint);
            alert($(document).find('#complaintForm').length); // этот алерт показывается поочередно столько раз сколько раз тыкнул на выбранного пользователя
        });
    }
    if ($(document).find('#complaintBtn').length>0) {
        $(document).on('click', '#complaintBtn', function() {
            complaintFunc();
        });
    }
}

А теперь на словах - на страницы есть вывод пользователей.
Тык на пользователя->тык на кнопку "Пожаловаться"-> Алерт 1 раз
2-ой так на этого же или другого пользователя->тык на кнопку "Пожаловаться"-> Алерт 2 раза
3-ий так на этого же или другого пользователя->тык на кнопку "Пожаловаться"-> Алерт 3 раза
И так до бесконечности.


text:
Q: How to use a map in java when dealing with objects So, I'm creating a program that allows users to specify the insurance cover they want as part of an insurance policy. As part of it, I need to use a map in order to track the owner of each specific insurance policy.
I have seen examples of how to use a map with regards to String and int values, but nothing for self made classes (InsurancePolicy in my case).
So, I'm trying to do it like this, but I get the illegal expression warnings:
Map<String, InsurancePolicy> coverOwnerMap<String, InsurancePolicy>();

Any help would be very appreciated.

A: Right, that's invalid Java. Try,
Map<String, InsurancePolicy> coverOwnerMap = new HashMap<String, InsurancePolicy>();


text:
Q: How can I send an object as part of the JSON Web Token? I'm trying to create a web token using the jjwt library, but I can't figure out how to send an object as one of the claims.  If I parse the object or manually create the string the entire string is coming through as the value instead of a separate JSON object.  For instance, I want to send something that looks like this:
{
    "iss": "NQoFK1NLVelFWOBQtQ8A",
    "iat": 1511963669,
    "user": {
        "id": "exampleuser",
        "email": "example@mail.com",
        "name": "A User",
    }
}

But all I've been able to create is:
{
    "iss": "NQoFK1NLVelFWOBQtQ8A",
    "iat": 1511963669,
    "user": "{\"id\": \"example@mail.com\",\"email\": \"example@mail.com\",\"name\": \"A User\"}"
}

A: Welcome to StackOverflow!
This feature will be natively supported by JJWT when using Jackson in the upcoming JJWT 0.11.0 release (and you can read the docs for this feature too).  But it is not available natively in 0.10.X and earlier.
Prior to 0.11.0, and assuming you're using Jackson, you'll have to do this yourself manually with the ObjectMapper:
// when creating:
User user = getUser();
ObjectMapper objectMapper = new ObjectMapper(); // or use an existing one
String json = objectMapper.writeValueAsString(user);
byte[] bytes = json.getBytes(StandardCharsets.UTF_8)
String base64 = Encoders.BASE64.encode(bytes);
String jws = Jwts.builder()
  ...
  .claim("userJsonBase64", base64)
  ...
  .compact();

//when parsing:
String userJsonBase64 = Jwts.parser()....parseClaimsJws(jws).getBody().get("userJsonBase64", String.class);
bytes = Decoders.BASE64.decode(userJsonBase64);
json = new String(bytes, StandardCharsets.UTF_8);
user = objectMapper.readValue(json, User.class);

A: Thank you for your answer, that will be a nice feature to have, once it's available.  I wanted to follow up and post a workaround that I found, in case it helps anyone else in the meantime.  I was able to create the JSON I needed using a Java HashMap (I found out the hard way that a Scala Map does not work) and then passing that as the value of the claim:
val user: util.Map[String, String] = new util.HashMap[String,
String]() user.put("id", email.value) user.put("email", email.value)
user.put("name", name.displayName)

...
val jws: String = Jwts.builder()
.claim("user", user)
.signWith(key).compact()


text:
Q: If $f: X \to Y$ diffeomorphism and $X,Y$ manifolds with boundary then $f(\partial X) = \partial Y$ Well, the exercise is the following:

If $f: X \to Y$ diffeomorphism and $X,Y$ manifolds with boundary then $f(\partial X) = \partial Y$

My idea to prove this is the following:
By the definition of $\partial X$ I use that if $x \in \partial X$ then $\exists \ \phi : U \subset H^k \to U' \subset X $ with $\phi$ a diffeomorphism. Also,  $x \in U' \cap \partial X = \partial U'$ and $\phi^{-1}(x) = u \in \partial U$.  So as I know that $f$ is also a diffeomorophism I used that $f(U') = V$ with $f(x) = y \in V \subset Y$.  And also $f : U' \to V$ is a diffeomorphism. So if I compone $f \circ \phi : U \subset H^k \to V \subset Y$ we can see that $f \circ \phi (u) = y \in V \subset Y$. So by definition of boundary of a manifold we have that $f(x) = y \in \partial V \subset \partial Y $. So right now I have prove that $f(\partial X) \subset \partial Y$. To prove $\partial Y \subset f(\partial X)$ we prove $f^{-1}(\partial Y) \subset \partial X$ as we have prove $f(\partial X) \subset \partial Y$.
I don't know if my idea is correct or not.


text:
Q: Not getting all the records using CTE CREATE TABLE test_tab (
    col_name  VARCHAR2(20),
    log_time  TIMESTAMP(6),
    status    VARCHAR2(20)
);

INSERT INTO test_tab VALUES('Engineering','08-06-22 08:09:16.366000000 PM','UP');
INSERT INTO test_tab VALUES('Engineering','09-06-22 08:28:16.366000000 PM','UP');
INSERT INTO test_tab VALUES('Engineering','09-06-22 08:13:16.366000000 PM','DOWN');
INSERT INTO test_tab VALUES('Commerce','07-06-22 4:59:16.366000000 PM','DOWN');
INSERT INTO test_tab VALUES('Commerce','07-06-22 6:34:16.366000000 PM','UP');
INSERT INTO test_tab VALUES('Commerce','07-06-22 6:49:16.366000000 PM','DOWN');
INSERT INTO test_tab VALUES('Commerce','01-06-22 2:15:16.366000000 PM','UP');
INSERT INTO test_tab VALUES('Commerce','07-06-22 07:04:16.366000000 PM','UP');
COMMIT;

Tool used: Oracle Developer(18c)

I have one table test_tab in which there are multiple col_name values like 'Engineering', 'Commerce' etc just for testing purpose I have given two column names.
I need to find out the start log time and end log time for particular col_name
Start_time logic : For particular col_name say 'Commerce' I need to check the minimum log time whose status is DOWN.
End_time logic: For the same col_name say 'Commerce' I need to check the start_time derived from above logic and see which is just greater than that time in status UP. That would be my end_time.
My attempt (Working only for 'Commerce'):
WITH a AS(
SELECT col_name,MIN(log_time)start_time
FROM test_tab WHERE status = 'DOWN'
GROUP BY col_name
),
b AS(
SELECT col_name,log_time end_time
    FROM( SELECT col_name,log_time,
        dense_rank() over (order by log_time asc)rnk
        FROM test_tab WHERE status = 'UP')
        WHERE rnk = 2
)
SELECT a.col_name,a.start_time,b.end_time FROM a
JOIN b ON(a.col_name = b.col_name);

But the above solution is not giving the result for 'Engineering'. It is just fetching details only for 'Commerce'
Expected Output:
Col_name    start_time                          end_time
Commerce    07-06-22 4:59:16.366000000 PM     07-06-22 6:34:16.366000000 PM
Engineering 09-06-22 08:13:16.366000000 PM    09-06-22 08:28:16.366000000 PM

A: From Oracle 12, you can use MATCH_RECOGNIZE to perform row-by-row processing:
SELECT *
FROM   test_tab
MATCH_RECOGNIZE(
  PARTITION BY col_name
  ORDER BY log_time
  MEASURES
    FIRST(down.log_time) AS start_time,
    FIRST(up.log_time) AS end_time
  PATTERN (^ other*? down+ up)
  DEFINE
    down AS status = 'DOWN',
    up   AS status = 'UP'
)

Which, for the sample data, outputs:

COL_NAME
START_TIME
END_TIME

Commerce
07-JUN-22 16.59.16.366000
07-JUN-22 18.34.16.366000

Engineering
09-JUN-22 20.13.16.366000
09-JUN-22 20.28.16.366000

db<>fiddle here

A: You can find the minimum "down" time using an analytic function for each col_name
partition and then filter to only have the subsequent "up" times and find the minimum of those:
SELECT col_name,
       MIN(min_down) AS start_time,
       MIN(log_time) AS end_time
FROM   (
  SELECT t.*,
         MIN(CASE status WHEN 'DOWN' THEN log_time END)
           OVER (PARTITION BY col_name) AS min_down
  FROM   test_tab t
)
WHERE log_time >= min_down
AND   status = 'UP'
GROUP BY col_name

Which, for the sample data, outputs:

COL_NAME
START_TIME
END_TIME

Commerce
07-JUN-22 16.59.16.366000
07-JUN-22 18.34.16.366000

Engineering
09-JUN-22 20.13.16.366000
09-JUN-22 20.28.16.366000

db<>fiddle here


text:
Q: Groovy invokes adb command to pull a file but the new file is invisible My Situation
I am learning gradle plugin and groovy. Now I need to invoke adb command to pull a file from my device and then I will operate this new file on my PC.
def command = 'adb pull /sdcard/com.hackerli.sample.trace ./'
['bash','-c',command].execute()
// now I list all file
println(['bash','-c','ls'].execute())

My Problem
When I first execute above script, ls does not display the new file. The second time executed, it appears. I guess that the file directory does not refresh. So how can I do with it while I need to operate the new file.
Thanks in advance.

A: You need to wait for the first process to finish:
def command = 'adb pull /sdcard/com.hackerli.sample.trace ./'
['bash','-c',command].execute().waitFor()

println(['bash','-c','ls'].execute())


text:
Q: Как в SQL запросе вывести ещё одно поле со своим условием День добрый! Есть такая структура:
PeopleID | Name   | Father | Mother
-----------------------------------
1        | Vasia  | null   | null
2        | Sveta  | 4      | 3
3        | Lena   | null   | null
4        | Andrey | null   | null
5        | Kostik | 1      | null
6        | Olga   | 4      | 3

Т.е. у Андрея 2 ребенка Света и Ольга, у Васи 1 - Костик.
Мне нужно вывести запросом отца у которого больше всего детей.
Я научился находить ИД отца, который чаще всего встречается в столбце Father.
Но нужно ещё вывести Name который соответствует этому отцу. Т.е. как-то так сделать, примерно,  ещё один вывод с условием "Name FROM Family WHERE PeopleID=COUNT(Father)"
SELECT Father, COUNT(Father) AS value_occurrence
    FROM     FAMILY
        WHERE Father IS NOT NULL
    GROUP BY Father
    ORDER BY value_occurrence DESC
    LIMIT    1;

A: Самое простое — подзапрос или соединение. Вариант с соединением вам уже дали в комментариях. Вариант с подзапросом будет как-то так:
SELECT *
  FROM Value_Occurrence
 WHERE PeopleID = (
  SELECT Father
    FROM Value_Occurrence
   WHERE Father IS NOT NULL
   GROUP BY Father
   ORDER BY COUNT(*) DESC
   LIMIT 1
);

Если вам надо вывести всех отцов с максимальным числом детей, запрос становится несколько сложнее:
WITH FatherCounts AS (
  SELECT Father
       , COUNT(*) AS Count
    FROM Value_Occurrence
   WHERE Father IS NOT NULL
   GROUP BY Father
),
FatherRanks AS (
  SELECT Father
       , RANK() OVER (ORDER BY Count DESC) AS Rank
    FROM FatherCounts
)
SELECT Value_Occurrence.*
  FROM Value_Occurrence
  JOIN FatherRanks
    ON PeopleID = FatherRanks.Father
 WHERE Rank = 1;

Опять же, вариант без JOINов:
-- …
SELECT *
  FROM Value_Occurrence
 WHERE PeopleID IN (
  SELECT Father
    FROM FatherRanks
   WHERE Rank = 1
);

A: Вариант 1 используем inner join что бы выбрать только соединенные строки исключая нулевые записи:
SELECT F2.NAME, F1.Father, COUNT(F1.Father) AS value_occurrence
FROM FAMILY F1
JOIN FAMILY F2 on F1.Father = F2.PeopleID
GROUP BY F1.Father, F2.NAME
ORDER BY value_occurrence DESC LIMIT 1;

Вариант 2 делаем select из двух таблиц где столбец father равен столбцу peopleID:
SELECT F2.NAME, F1.Father, COUNT(F1.Father) AS value_occurrence
FROM FAMILY F1, FAMILY F2 where F1.Father = F2.PeopleID
GROUP BY F1.Father, F2.NAME
ORDER BY value_occurrence DESC LIMIT 1;

Требуется проверка, в настоящий момент нет под рукой БД.


text:
Q: How to access some Server's folder in QGIS Somehow access some file from server in QGIS is so easy just drop in your QGIS project. But some case you need access your server from QGIS "search directory" then your server is did not show up, such as for "Repair Data Source".

A: This problem can handle easily by add directory in your Favorites Browser


text:
Q: Multiple Calibration plots with val.prob.ci.2 I am trying to create two calibration plots (for two different models) but it does not seem to work. My data (a subset of them):
structure(list(X1 = c(0.0205881308065423, 0.030107400545467,
0.0224902821967529, 0.067082269138019, 0.0128933436225658, 0.010528298470225,
0.0448801718109416, 0.0147825838164296, 0.00127338570492985,
0.0187288824619526, 0.0166935353708351, 0.000827013756910522,
0.000268624600100464, 0.00022554771787564, 0.000239290116892055,
0.00046320712675918, 0.0127930773405932, 0.123559021969098, 0.00196413334593659,
0.00267343502355055, 0.0119560304531064, 0.0151288958940289,
0.0450932732709064, 0.284128554073485, 0.0435626434150131, 0.00919667587971063,
0.241220354905637, 0.0188148171033879, 0.0116570772346002, 0.0159496690575734,
0.00518918742249186, 0.0319701660388646, 0.100234998067917, 0.0119794232466471,
0.00123658099677804, 0.00178774726967923, 0.00215162606048125,
0.028398874195245, 0.02727277199735, 0.0536089031118459, 0.00567355556708304,
0.00182798929912398, 0.0221311523302337, 0.0317268552025847,
0.241167765332718, 0.201815176728704, 0.00750328900855035, 0.00346824263327472,
0.00859464311717095, 0.00488864781312837), X2 = c(0.0123677690429329,
0.0275541038901166, 0.0166991553536275, 0.0260168210079643, 0.00693728726147325,
0.00464096927279578, 0.0124618831179862, 0.0184586073538044,
0.00569866130459529, 0.00293809224808261, 0.00119326039429657,
0.00316749683866091, 0.00419982136508501, 0.00140900547876921,
0.00110999833888004, 0.00276678547598108, 0.0162868658191231,
0.0649037872628959, 0.00123222675644274, 0.00171687152904065,
0.0152583510689248, 0.0258721612337077, 0.0392641646035583, 0.361960538193137,
0.0357326269142103, 0.0107540980920499, 0.22279499286353, 0.0301267823507665,
0.0144535141006957, 0.0124677305707919, 0.00520476987173168,
0.0320510777198151, 0.0770024283430764, 0.00793648556749427,
0.000401508352378066, 0.000498605187176815, 0.000982487695277534,
0.0399009464278308, 0.0698023981838097, 0.0506533144316593, 0.00462517180839983,
0.00275731807224233, 0.0374332227392187, 0.0582978817333271,
0.121896031487931, 0.236774303454737, 0.0106755443754257, 0.00398238213200619,
0.0113833654830731, 0.00708983623072867), X3 = c(0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0)), row.names = c(NA, 50L), class = "data.frame")

and the code I use:
par(mfrow = c(1,2),
    oma=c(5,5,0,0) + 0.0,
    mar=c(0,0,1,1) + 0.0)
val.prob.ci.2(p = lo$X1, y = lo$X3, smooth="loess", legendloc=F, lwd.smooth=2, lwd.ideal=2, lty.ideal=2, dostats = F, axes = F)
axis(side=2,at=c(0,0.2,0.4,0.6,0.8,1))
box(which="plot")
text(x=0, y=1, adj=0, "LG", cex=1.3)
val.prob.ci.2(p = lo$X2, y = lo$X3, smooth="loess", legendloc=F, lwd.smooth=2, lwd.ideal=2, lty.ideal=2, dostats = F, axes = F)
box(which="plot")
text(x=0, y=1, adj=0, "rf", cex=1.3)
title(xlab = list("Estimated probability",cex=1.5),
      ylab = list("Observed proportion",cex=1.5),
      outer = TRUE)#, line=3)

the output is:

The problem lies with the second plot. Why it does not appear?


text:
Q: Search Filter with React Native on FlatList I am trying to search through a flatlist based on a search bar text. The problem I am running into is that when the user mistypes...say they wanted to type "burger" but typed "burget" by mistake then it returns nothing as it should. When the user deletes the "t" then it should re-render the flatlist again with the last text matching the "burge" part.
note: using react-native-elements search bar which allows me to call the text with just e or event.
What I have so far in the Main.js file:
searchText = (e) => {
    let text = e.toLowerCase();
    let trucks = this.state.data;

    // search by food truck name
    let filteredName = trucks.filter((truck) => {
      return truck.name.toLowerCase().match(text);
    });

    // if no match and text is empty
    if(!text || text === '') {
      console.log('change state');
        this.setState({
          data: initial
        });
      }
    // if no name matches to text output
    else if(!Array.isArray(filteredName) && !filteredName.length) {
      console.log("not name");
      this.setState({
        data: [],
      });
    }
    // if name matches then display
    else if(Array.isArray(filteredName)) {
      console.log('Name');
      this.setState({
        data: filteredName,
      });
    }
   };

<View style={styles.container}>
  <SearchBar
    round
    lightTheme
    containerStyle={styles.search}
    ref="search"
    textInputRef="searchText"
    onChangeText={this.searchText.bind(this)}
    placeholder='Search by Truck Name...'
   />
   <TruckList getTruck={(truck) => this.setTruck(truck)} truckScreen={this.truckScreen} data={this.state.data}/>
</View>

then the TruckList.JS:
export default class TruckList extends Component {
    // rendering truck screen
    renderTruckScreen = (item) => {
        this.props.truckScreen();
        this.props.getTruck(item);
    }

    render() {
        return(
            <List style={styles.list}>
                <FlatList
                    data={this.props.data}
                    renderItem={({ item }) => (
                        <ListItem
                            roundAvatar
                            avatar={{uri: item.pic1}}
                            avatarStyle={styles.avatar}
                            title={item.name}
                            titleStyle={styles.title}
                            subtitle={
                                <View style={styles.subtitleView}>
                                    <Text style={styles.subtitleFood}>{item.food}</Text>
                                    <View style={styles.subtitleInfo}>
                                        <Icon
                                            name="favorite"
                                            size={20}
                                            color={"#f44336"}
                                            style={styles.subtitleFavorite}
                                        />
                                        <Text style={styles.subtitleFavoriteText}>{item.favorited} favorited</Text>
                                    </View>
                                </View>
                            }
                            onPress={() => this.renderTruckScreen(item)}
                        />
                    )}
                    keyExtractor={(item) => item.uid}
                    ListFooterComponent={this.footer}
                />
            </List>
        )
      }
    }

I have tried a few other ways to no avail. Also the only solutions I have seen working for React Native are with ListView which will be depreciated in time. So I am trying to do this with the new FlatList Component.
Thanks for your help!

A:  Make Search Bar Filter for List View Data in React Native
For Real-Time Searching in List View using Search Bar Filter

*

*We will load the list from the network call and then show it to the user.

*The user can search the data by entering the text in TextInput.

*After inserting the text SearchFilterFunction will be called We will
compare the list data with the inserted data and will make a new Data
source.

*We will update the data source attached to the ListView.

*It will re-render the list and the user will be able to see the
filtered data.

//This is an example code to Add Search Bar Filter on Listview//
import React, { Component } from 'react';
//import react in our code.

import {
  Text,
  StyleSheet,
  View,
  FlatList,
  TextInput,
  ActivityIndicator,
  Alert,
} from 'react-native';
//import all the components we are going to use.

export default class App extends Component {
  constructor(props) {
    super(props);
    //setting default state
    this.state = { isLoading: true, text: '' };
    this.arrayholder = [];
  }

  componentDidMount() {
    return fetch('https://jsonplaceholder.typicode.com/posts')
      .then(response => response.json())
      .then(responseJson => {
        this.setState(
          {
            isLoading: false,
            dataSource: responseJson
          },
          function() {
            this.arrayholder = responseJson;
          }
        );
      })
      .catch(error => {
        console.error(error);
      });
  }
  SearchFilterFunction(text) {
    //passing the inserted text in textinput
    const newData = this.arrayholder.filter(function(item) {
      //applying filter for the inserted text in search bar
      const itemData = item.title ? item.title.toUpperCase() : ''.toUpperCase();
      const textData = text.toUpperCase();
      return itemData.indexOf(textData) > -1;
    });
    this.setState({
      //setting the filtered newData on datasource
      //After setting the data it will automatically re-render the view
      dataSource: newData,
      text: text,
    });
  }
  ListViewItemSeparator = () => {
    //Item sparator view
    return (
      <View
        style={{
          height: 0.3,
          width: '90%',
          backgroundColor: '#080808',
        }}
      />
    );
  };
  render() {
    if (this.state.isLoading) {
      //Loading View while data is loading
      return (
        <View style={{ flex: 1, paddingTop: 20 }}>
          <ActivityIndicator />
        </View>
      );
    }
    return (
      //ListView to show with textinput used as search bar
      <View style={styles.viewStyle}>
        <TextInput
          style={styles.textInputStyle}
          onChangeText={text => this.SearchFilterFunction(text)}
          value={this.state.text}
          underlineColorAndroid="transparent"
          placeholder="Search Here"
        />
        <FlatList
          data={this.state.dataSource}
          ItemSeparatorComponent={this.ListViewItemSeparator}
          renderItem={({ item }) => (
            <Text style={styles.textStyle}>{item.title}</Text>
          )}
          enableEmptySections={true}
          style={{ marginTop: 10 }}
          keyExtractor={(item, index) => index.toString()}
        />
      </View>
    );
  }
}
const styles = StyleSheet.create({
  viewStyle: {
    justifyContent: 'center',
    flex: 1,
    marginTop: 40,
    padding: 16,
  },
  textStyle: {
    padding: 10,
  },
  textInputStyle: {
    height: 40,
    borderWidth: 1,
    paddingLeft: 10,
    borderColor: '#009688',
    backgroundColor: '#FFFFFF',
  },
});

Click Hear for more idea

A: Here is my solution:
You need to have a backup of your data
this.state = {
    data: [],
    backup: []
}

on search method
search = txt => {
    let text = txt.toLowerCase()
    let tracks = this.state.backup
    let filterTracks = tracks.filter(item => {
    if(item.name.toLowerCase().match(text)) {
      return item
    }
  })
  this.setState({ data: filterTracks })
}

Explanation: when calling setState on your data it will changed to current state and cannot be changed again.
So backup data will handle to filter your data.

A: ref - https://medium.freecodecamp.org/how-to-build-a-react-native-flatlist-with-realtime-searching-ability-81ad100f6699
constructor(props) {
super(props);
this.state = {
  data: [],
  value: ""
};

this.arrayholder = [];
}

Next fetching data :-
_fetchdata = async () => {
const response = await fetch("https://randomuser.me/api?results=10");
const json = await response.json();
this.setState({ data: json.results });

this.arrayholder = json.results;
};

Next define searchFilterFunction :-
searchFilterFunction = text => {
this.setState({
  value: text
});

const newData = this.arrayholder.filter(item => {
  const itemData = item.email.toLowerCase();

  const textData = text.toLowerCase();

  return itemData.indexOf(textData) > -1;
});

this.setState({ data: newData });
};

rendering searchView:-
    <TextInput
      style={{ height: 40, borderColor: "gray", borderWidth: 1 }}
      onChangeText={text => this.searchFilterFunction(text)}
    />

Don't forget to  import TextInput from "react-native";

A: I came across this same issue today when trying to implement a filter / search function on the new FlatList component. This is how I managed to solve it:
By creating another item in the state of the parent component called noData, you can set that to true when there are no results that match your search and then render your FlatList conditionally.
My implementation is slightly different to yours, but if I had to adjust your code it would look something like this:
Searchtext function:
searchText = (e) => {
    let text = e.toLowerCase()
    let trucks = this.state.data
    let filteredName = trucks.filter((item) => {
      return item.name.toLowerCase().match(text)
    })
    if (!text || text === '') {
      this.setState({
        data: initial
      })
    } else if (!Array.isArray(filteredName) && !filteredName.length) {
      // set no data flag to true so as to render flatlist conditionally
      this.setState({
        noData: true
      })
    } else if (Array.isArray(filteredName)) {
      this.setState({
        noData: false,
        data: filteredName
      })
    }
  }

Then pass the noData bool to your TruckList component:
<TruckList getTruck={(truck) => this.setTruck(truck)}
truckScreen={this.truckScreen} data={this.state.data} noData={this.state.noData}/>

Then render your FlatList in the TruckList component only if there are results:
<List style={styles.list}>
{this.props.noData ? <Text>NoData</Text> : <FlatList {...} />}
</List>

That should then take care of handling user typing errors - as it will re-render the flatlist as soon as there are no results, and will remember the previous search state when you remove the typing error..
Let me know if that helps!

A: For a useful in-memory search you should keep initial data seperately.
I have more simple solution for this.
This solution for in-memory search on FlatList's data and uses it String.prototype.includes() method to search substring.
You can find full source code of this component in this gist;
https://gist.github.com/metehansenol/46d065b132dd8916159910d5e9586058
My initial state;
this.state = {
  searchText: "",
  data: [],
  filteredData: []
};

My SearchBar component (it comes from react-native-elements package);
<SearchBar
  round={true}
  lightTheme={true}
  placeholder="Search..."
  autoCapitalize='none'
  autoCorrect={false}
  onChangeText={this.search}
  value={this.state.searchText}
/>

My search method;
search = (searchText) => {
  this.setState({searchText: searchText});

  let filteredData = this.state.data.filter(function (item) {
    return item.description.includes(searchText);
  });

  this.setState({filteredData: filteredData});
};

And last my FlatList's DataSource expression;
<FlatList
  data={this.state.filteredData && this.state.filteredData.length > 0 ? this.state.filteredData : this.state.data}
  keyExtractor={(item) => `item-${item.id}`}
  renderItem={({item}) => <ListItem
    id={item.id}
    code={item.code}
    description={item.description}
  />}
/>

Happy coding...

A: Update:
This blog can help you better understand the searching in a FlatList.
FYI:
If you have huge online data then you can also use algolia.
I adjusted the above code for me in order to make it work properly. The reason is that when user removes the last wrong character, code search this new string from a previous search list (state) which does not contain all objects, although it had to search from a full list available. So, I have two list now. One contains full list of objects and second contains only rendered list of objects which is changing upon search.
handleSearchInput(e){
    let text = e.toLowerCase()
    let fullList = this.state.fullListData;
    let filteredList = fullList.filter((item) => { // search from a full list, and not from a previous search results list
      if(item.guest.fullname.toLowerCase().match(text))
        return item;
    })
    if (!text || text === '') {
      this.setState({
        renderedListData: fullList,
        noData:false,
      })
    } else if (!filteredList.length) {
     // set no data flag to true so as to render flatlist conditionally
       this.setState({
         noData: true
       })
    }
    else if (Array.isArray(filteredList)) {
      this.setState({
        noData: false,
        renderedListData: filteredList
      })
    }
  }

A: You can Search your data by following these steps :
<TextInput onChangeText={(text) => searchData(text)} value={input} />

***Please Note *searchData is my function whom I passing a text prop***

const searchData = (text) => {
    const newData = restaurantsData.filter((item) => {
        return item.title.search(text) > -1;
    });
    setRestaurantsData(newData);
    setInput(text);
};

Note RestaurantsData is my data array

A: FYI : data is the subtext to be searched, this is a basic search implemented as the data to be searched is looked into every list item of an array which is a copy of the actual array/array of objects and finally its state is set whether match found or not between 0 to (actualArray.length-1) and the temporary arrayData is rendered if there is at least one match else actualArray is rendered

implementSearch(data) {
    temp = [];
    var count = 0;
    var searchData = data.toUpperCase();
    var arr = this.state.personDetail;
    for (var i = 0; i < arr.length; i++) {
      var actualData = arr[i].name.toUpperCase();
      if (actualData.includes(searchData)) {
        temp.push(arr[i]);
        count++;
      }
    }
    this.setState({
      tempArray: temp,
      matches: count,
      searchValue: data
    });
  }

Hope this helps

A:
My search method; from @metehan-senol

search = (searchText) => {
 this.setState({searchText: searchText});

 let filteredData = this.state.data.filter(function (item) {
   return item.description.includes(searchText);
 });

 this.setState({filteredData: filteredData});
};

the search method of could be simplify and Eslint proof like so
search = (searchText) => {
  const searched = searchText.toLowerCase();
  this.setState(prevState => ({
    searchText: searched,
    filteredData: prevState.data.filter(item =>
      item.description.toLowerCase().includes(searched)
    ),
  }));
};

A: Do filter by applying
let filterData= data.filter((item) => {
  return item.name.toLowerCase().match(text)
})
if (!text || text === '') {
  this.setState({
    datasource: initial
  })
} else if (!Array.isArray(filterData) && !filterData.length) {
  // set no data flag to true so as to render flatlist conditionally
  this.setState({
    noData: true
  })
} else if (Array.isArray(filterData)) {
  this.setState({
    noData: false,`enter code here`
    dataSource: filterData
  })`enter code here`
}

A: This is not the best solution in terms of performance, but if you do not have a large amount of data, then feel free to use this function:
  searchFilter () {
    return this.props.data.filter((item) => {
       const regex = new RegExp(this.state.searchInput, "gi")
       return item.label.match(regex);
    })
  }

And then in your FlatList component:
  <FlatList
    data={this.searchFilter()}
    renderItem={this.renderItem}
    keyExtractor={(item) => item.value}
  />

A: const SearchUser = (e) =>{
console.log(e)
const setProject = Project.filter(item => item.name.toLowerCase().includes(e.toLowerCase()) )
console.log(setProject)
setfetch(setProject)
}


text:
Q: Show $\int_{-\infty}^{\infty} e^{-it^2}dt=(1-i)(\frac{\pi}{2})^{0.5}?$ Show $\int_{-\infty}^{\infty} e^{-it^2}dt=(1-i)(\frac{\pi}{2})^{0.5}?$ This is in my formula sheet but I'm intrigued as to how it is proved?

A: for $R \gt 0$ define $A,O,B$ as the points $(R,0),(0,0),(R\frac{\sqrt{2}}{2},-R\frac{\sqrt{2}}{2})$ which we connect by straight lines $AO,OB$ and a circular arc of radius $R$ joining $B$ to$A$
then (since the integrand) has no poles in the sector $AOB$ we know that
$$
\int_A^O + \int_O^B +\int_B^A e^{-it^2}dt= 0
$$
and
$$
\lim_{R \to \infty}\int_A^Oe^{-it^2}dt = -\frac12\int_{-\infty}^\infty e^{-it^2}dt
$$
if the integral on the circular arc tends to zero (see note*) as $R$ approaches $\infty$. the integral along $OB$ can be obtained via the substitution
$$
t=\frac{(1-i)}{\sqrt{2}} s
$$
which gives
$$
\int_O^B e^{-it^2}dt = \frac{(1-i)}{\sqrt{2}}\int_0^\infty e^{-s^2} ds = \frac{1-i}2 \sqrt{\frac{\pi}2}
$$
from which the required result follows

*

*note
the gory details would not enliven this particular discussion, but the method is straightforward - split the arc into a long and a short piece separated by the  point whose argument is $-\sin^{-1}(R^{-\frac32})$

A: We have $$\int_{-\infty}^{\infty}e^{-it^{2}}dt=\int_{-\infty}^{\infty}\cos\left(t^{2}\right)dt-i\int_{-\infty}^{\infty}\sin\left(t^{2}\right)dt
 .$$ Now we have $$\int\cos\left(t^{2}\right)dt=\sqrt{\frac{\pi}{2}}C\left(\sqrt{\frac{2}{\pi}}t\right)+cost
 $$where $C\left(*\right)
 $ is the Fresnel C integral and $$\int\sin\left(t^{2}\right)dt=\sqrt{\frac{\pi}{2}}S\left(\sqrt{\frac{2}{\pi}}t\right)+cost$$
 is the Fresnel S integral. Using the special values $$C\left(\infty\right)=S\left(\infty\right)=\frac{1}{2}
 $$ and $$C\left(-\infty\right)=S\left(-\infty\right)=-\frac{1}{2}
 $$ your claim follows.


text:
Q: Bash command to cat multiple files to be used as a variable I use an application that has the following syntax:
mccli backup delete --name=X --labelnum=X

I can manually execute the command each time, which would look like this:
mccli backup delete --name=server1 --labelnum=12
mccli backup delete --name=server2 --labelnum=33

The problem is that I have 1000 hosts to run this command against. I have a file (name.txt) that has a list of all the --name= variables, and a file (labelnum.txt) that has a list of all the --labelnum= variables.
I am familiar with the following bash command, which works for one variable (--name=), but I can't figure out to make this bash command work with two variables:
for i in $(cat name.txt); do mccli backup delete --name=$i ; done

This doesn't work:
for i in $(cat name.txt) for j in $(cat labelnum.txt); do mccli backup delete --name=$i --labelnum=$j ; done

A: If I understand you right, you want to get the values for your --name and --labelnum arguments from the corresponding lines of those two files. Assuming there's no tab characters in the lines of the first file and that the files have the same number of lines:
while IFS=$'\t' read -r name label; do
  mccli backup delete --name="$name" --labelnum="$label"
done < <(paste name.txt labelnum.txt)

should do it.

A: You can do a bash script and make two for loops, one for each file. If you really need to use a shell command rather than a shell script then you can make nested for loops.
Such a thing would look kind of like this:
for filename in "name.txt", "labelnum.txt"; do for i in $filename; do mccli backup delete --name=$i ; done done

A: cat command understand multiple arguments and file masks, so
for i in $(cat name.txt labels.txt); do mccli backup delete --name=$i ; done

or even
for i in $(cat *.txt); do mccli backup delete --name=$i ; done

If the files contains only one argument per line all should be fine.


text:
Q: How can i add Scrollbar to nav-tab Contents? I am using lionbars scrollbar plugins for overlay scrollbar and i want to apply scrollbar to content but unfortunately its not showing. Below is my snippets for reference and help me to solve the issue.

$(document).ready(function(){
  $('#activity, #locations').lionbars({
    autohide: true
  });
});
.right-sidebar-wrapper{
  position: absolute;
  right: 0;
  width: 24%;
  top:0;
  bottom: 0;
  height: 100%;
  background: #FFF;
  box-shadow: 0 -1px 24px rgba(0,0,0,0.4);
  z-index: 1;
}
#r-s-tab{
  display: inline-block;
  height: 80%;
  width: 100%;
  margin-bottom: 10px;
}
#r-s-tab #activity a, #r-s-tab #locations a{
  padding-top: 8px;
  border-radius: 3px;
  display: block;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>

<link href="http://bootswatch.com/paper/bootstrap.min.css" rel="stylesheet"/>
<link href="http://charuru.github.io/lionbars/css/lionbars.css" rel="stylesheet"/>

A: add overflow: auto; and specified some height
.right-sidebar-wrapper{
  overflow: auto;
  height: 500px;
}

A: Try this
#activity {
   float: right;
   height: 325px;
   overflow: auto;
}

A: use position:fixed; for your .nav-tabs and give some margin-top to your tabs. so it will not hide under nav-tabs.

$(document).ready(function(){
  $('#activity, #locations').lionbars({
    autohide: true
  });
});
.right-sidebar-wrapper{
  position: absolute;
  right: 0;
  width: 24%;
  top:0;
  bottom: 0;
  height: 100%;
  background: #FFF;
  box-shadow: 0 -1px 24px rgba(0,0,0,0.4);
  z-index: 1;
  overflow: hidden;
    overflow-y: scroll;
}
#r-s-tab{
  display: inline-block;
  height: 80%;
  width: 100%;
  margin-bottom: 10px;
  margin-top: 50px;
}
#r-s-tab #activity a, #r-s-tab #locations a{
  padding-top: 8px;
  border-radius: 3px;
  display: block;
}
.nav-tabs{
    position: fixed;
    z-index: 999;
    background: white;
    width: 100%;

}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>

<link href="http://bootswatch.com/paper/bootstrap.min.css" rel="stylesheet"/>
<link href="http://charuru.github.io/lionbars/css/lionbars.css" rel="stylesheet"/>


text:
Q: Summing measurements I have this code:
@Name("Creating_hourly_measurement_Position_Stopper for line 2")
insert into CreateMeasurement
select
    m.measurement.source as source,
    current_timestamp().toDate() as time,
    "Line2_Count_Position_Stopper_Measurement" as type,
    {
        "Line2_DoughDeposit2.Hourly_Count_Position_Stopper.value",
        count(cast(getNumber(m, "Status.Sidestopper_positioning.value"), double)),
        "Line2_DoughDeposit2.Hourly_Count_Position_Stopper.unit",
        getString(m, "Status.Sidestopper_positioning.unit")
    } as fragments
from MeasurementCreated.win:time(1 hours) m
where getNumber(m, "Status.Sidestopper_positioning.value") is not null
  and cast(getNumber(m, "Status.Sidestopper_positioning.value"), int) = 1
  and m.measurement.source.value = "903791"
output last every 1 hours;

but it seems to loop. I believe it's because new measurement will modify this group, meaning it is constantly extending. This mean that recalculation will be performed each time when new data will be available.
Is there a way to count the measurement or get the total of the measurements per hour or per day?

A: The stream it consumes is "MeasurementCreated" (see from) and that isn't produced by any EPL so one can safely say that this EPL by itself cannot possibly loop.
If you want to improve the EPL there is some information at this link: http://esper.espertech.com/release-8.2.0/reference-esper/html_single/index.html#processingmodel_basicfilter
By moving the where-clause text into a filter you can discard events early.

A: Doesn't the insert into CreateMeasurement then cause an event in MeasurementCreated?


text:
Q: Javascript date.getDay() inconsistency I think I have found an issue in Javascript's date.getDay() function. This week, my 'day-of-the-week' (mon,tues, etc) started to be off by one in one of my applications. I have dug in further and have been able to isolate the date(s) when the date broke. I understand that getDay() returns [0-6] corresponding to [sun-sat]. However, it is returning 5 for both March 31, 2015 and April 1, 2015. Anyone have any insight as to why? My date object looks like both:
var date = new Date('2015','02','31');

and
var date = new Date('2015','03','01');

The alert you see is
alert(date.getDay());

See screenshots below for example

EDIT: See Fiddle

A: The month is expressed by numbers from 0-11.
From https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Date
month
Integer value representing the month, beginning with 0 for January to 11 for December.
The error appears because  the initializing of the date-object is wrong - its initialized like that: new Date('2015','04','01');, which is the first of may, and new Date('2015','03','31'); which is the 31st of april, a day that doesnt exist, so JS does the best of it and takes the day after the 30th of april, 1st of may


text:
Q: Find words starting with user input symbol and count in which text line they are C++ I have an exercise in which I need to find words in a text file starting with user input symbol. I also need to determine in which line that word is and output that in text different text file.
I managed to write code to output words starting with symbol and count word's position in text, but i cannot figure out how to count in which line that word is. Also i need to find those words which have symbols like ? ! etc. not only ' '
For example if i wanna find words starting with c then my program finds only "cerebral, cortex, could, create" but not "construct, capable, computers" from my example input which is below my code.
#include <iostream>
#include <fstream>
using namespace std;

int main() {

    fstream input;
    fstream output;
    string word, line;
    char startOfWord;

    cout << "I wanna find words starting with symbol: \n";

    cin >> startOfWord;

    int lineNumber = 0;

    input.open("f.txt");
    output.open("f1.txt");

    while (!input.eof()) {

        input >> word;
        lineNumber++;
        if (word.length() > 40) {
            continue;
        }
        if (word[0] == startOfWord) {
            output << word << ' ' << lineNumber << '\n';
        }
    }

    input.close();

    output.close();

    return 0;

}

Example input: user wanna find words starting with a.
f.txt:
A Stanford University project to?construct a model
of the cerebral cortex in silicon could help scientists
gain a better understanding of the brain, in order to
create more,capable.computers and advanced
neural prosthetics.

Output: f1.txt
a 1
a 3
and 4
advanced 4

A: To point you in the right direction without completing your exercise for you, there are a few functions available to you through std::ifstream and std::basic_istream, which is the class from which std::ifstream inherits many of its capabilities.
std::ifstream::getline()
std::ifstream::get()
std::ifstream::peek()
std::ifstream::putback()

These functions deal with capturing entire lines of input, reading characters from an input stream, looking at characters without extracting them from a stream, and putting characters back into a stream.
All of these may be found on the C++ Documentation site for std::ifstream.


text:
Q: Mouseover() event for multiple divs from a class in jQuery I have three divs in one line, aligned with the css prop "display: table-cell":

 Opción 1

 Opción 2

 Opción 3

Then I have this problem trying to animate one single div when mouse is passing over.
I'm trying this:
$(".divMenu").mouseover(function()
{
    target = "#" + $(this).attr("ID");
    $(target).stop(true, false);
    $(target).animate({opacity: '+=' + (parseFloat(oFin) - parseFloat($(target).css("opacity"))) + '',  height: '+=' + (parseFloat(hFin) - parseFloat($(target).css("height"))) + ''}, {duration: 1000, easing: "easeOutCirc"});
});

$(".divMenu").mouseleave(function()
{
    target = "#" + $(this).attr("ID");
    $(target).stop(true, false);
    $(target).animate({opacity: '-=' + (parseFloat($(target).css("opacity")) - parseFloat(oIni)) + '', height: '-=' + (parseFloat($(target).css("height")) - parseFloat(hIni)) + ''}, {duration: 1000, easing: "easeOutCirc"});
});

What really happens with this code is that every div from the class do the animation.
As I said before: what I'm trying to do is to animate a single div when mouse enters in an element from the class.
What I already tried:

*

*Using "startswith" identifier instead of using ".divMenu".

*Using delegate instead of mouseover and mouseleave events.

NOTE: "oFin", "hFin", etc. are just constants.

A: Working demo
    $(".divMenu").mouseover(function()
{
  $( this ).animate({
    fontSize: "50",
  }, 1000, function() {
    // Animation complete.
  });
});

A: Another option would be to put each divMenu within it's own divMaster.  That prevents the height from propagating across.
eg.

Opción 1

http://jsfiddle.net/yn8j9ryp/3/


text:
Q: Unknown levels in `f`:() but the columns are already factors I've seen many posts concerning the warning Unknown levels in `f`: , however, all of them concerned the fact that the variable wasn't a factor before using fct_collapse(). All my variables are already factors, but I'm getting this warning nevertheless. How can I get rid of Unknown levels in `f`: ?
Data contains number of hours (in Portuguese, I'm sorry) as very big strings. I want to make the strings shorter. Hence, for example 'Mais de 10 horas em língua adicional' (more than 10 hours in additional language) should become '> 10'. That's the idea.

*

*my code:

data %>%
       mutate(across(-SCHOOL, ~ fct_collapse(.,
                                     'Não oferta' = c('Não oferecemos este nível de ensino na escola',
                                                      'Não oferecemos este nível de ensino bilíngue na escola'),
                                     '> 20h' = c('Mais de 20 horas/ períodos semanais'),
                                     '> 10h' = c('Mais de 10 horas/ períodos semanais',
                                                 'Mais de 10 horas em língua adicional'),
                                     '= 20h' = c('20 horas/ períodos semanais'),
                                     'Até 10h' = c('Até 10 horas/períodos semanais'),
                                     '= 1h' = c('1 hora em língua adicional'),
                                     '100% CH' = c('100% da carga-horária em língua adicional'),
                                     '> 15h' = c('Mais de 15 horas/ períodos semanais'),
                                     '> 30h' = c('Mais de 30 horas/ períodos semanais'),
                                     '50% CH' = c('50% da carga- horária em língua adicional',
                                     '= 3h' = c('3 horas em língua adicional'),
                                     '= 6h' = c('6 horas em língua adicional'),
                                     '= 5h' = c('5 horas em língua adicional'),
                                     '= 2h' = c('2 horas em língua adicional'),
                                     '= 10h' = c('10 horas em língua adicional'),
                                     '9h' = c('9 horas em língua adicional'),
                                     '8h' = c('8 horas em língua adicional',
                                              '8 horas em aíngua adicional'), ## digitação
                                     '3h' = c('3 horas em língua adicional'),
                                     '4h' = c('4 horas em língua adicional'),
                                     '7h' = c('7 horas em língua adicional'),
                                     '2h' = c('2 horas em língua adicional')))))

*

*How can I come over this? I'm getting 14  Unknown levels in `f`:. Thanks in adv!

*my data:
# Note: I've excluded the ```school``` column to preserve participants' id

dput(my_data)
structure(list(Q21 = structure(c(5L, 5L, 5L, 4L, 3L, 5L, 4L,
5L, 5L, 5L, 5L, 1L, 2L, 5L, 5L, 5L, 5L, 1L, 5L, 5L, 5L, 5L, 5L,
5L, 4L, 5L, 5L, 2L, 5L), .Label = c("20 horas/ períodos semanais",
"Até 10 horas/períodos semanais", "Mais de 10 horas/ períodos semanais",
"Mais de 20 horas/ períodos semanais", "Não oferecemos este nível de ensino na escola"
), class = "factor"), Q22 = structure(c(1L, 2L, 1L, 4L, 3L, 4L,
5L, 1L, 6L, 6L, 6L, 1L, 2L, 6L, 6L, 6L, 2L, 1L, 6L, 6L, 6L, 6L,
3L, 6L, 5L, 2L, 6L, 2L, 5L), .Label = c("20 horas/ períodos semanais",
"Até 10 horas/períodos semanais", "Mais de 10 horas/ períodos semanais",
"Mais de 15 horas/ períodos semanais", "Mais de 20 horas/ períodos semanais",
"Não oferecemos este nível de ensino na escola"), class = "factor"),
    Q23 = structure(c(4L, 2L, 4L, 4L, 3L, 4L, 5L, 1L, 5L, 5L,
    1L, 1L, 2L, 6L, 4L, 3L, 2L, 1L, 3L, 6L, 6L, 4L, 3L, 4L, 4L,
    1L, 1L, 2L, 1L), .Label = c("20 horas/ períodos semanais",
    "Até 10 horas/períodos semanais", "Mais de 10 horas/ períodos semanais",
    "Mais de 15 horas/ períodos semanais", "Mais de 20 horas/ períodos semanais",
    "Não oferecemos este nível de ensino na escola"), class = "factor"),
    Q24 = structure(c(5L, 3L, 1L, 4L, 3L, 4L, 5L, 4L, 1L, 1L,
    1L, 1L, 2L, 7L, 4L, 3L, 1L, 1L, 3L, 5L, 2L, 5L, 3L, 5L, 4L,
    6L, 1L, 4L, 1L), .Label = c("20 horas/ períodos semanais",
    "Até 10 horas/períodos semanais", "Mais de 10 horas/ períodos semanais",
    "Mais de 15 horas/ períodos semanais", "Mais de 20 horas/ períodos semanais",
    "Mais de 30 horas/ períodos semanais", "Não oferecemos este nível de ensino na escola"
    ), class = "factor"), Q25 = structure(c(5L, 3L, 5L, 4L, 4L,
    4L, 5L, 2L, 1L, 1L, 1L, 1L, 2L, 7L, 4L, 3L, 1L, 1L, 3L, 5L,
    2L, 5L, 3L, 5L, 4L, 6L, 5L, 4L, 1L), .Label = c("20 horas/ períodos semanais",
    "Até 10 horas/períodos semanais", "Mais de 10 horas/ períodos semanais",
    "Mais de 15 horas/ períodos semanais", "Mais de 20 horas/ períodos semanais",
    "Mais de 30 horas/ períodos semanais", "Não oferecemos este nível de ensino na escola"
    ), class = "factor"), Q26 = structure(c(5L, 7L, 5L, 4L, 4L,
    4L, 5L, 2L, 5L, 5L, 1L, 1L, 2L, 4L, 5L, 4L, 7L, 7L, 3L, 6L,
    2L, 5L, 3L, 5L, 1L, 6L, 5L, 4L, 5L), .Label = c("20 horas/ períodos semanais",
    "Até 10 horas/períodos semanais", "Mais de 10 horas/ períodos semanais",
    "Mais de 15 horas/ períodos semanais", "Mais de 20 horas/ períodos semanais",
    "Mais de 30 horas/ períodos semanais", "Não oferecemos este nível de ensino na escola"
    ), class = "factor"), Q27 = structure(c(6L, 7L, 6L, 1L, 4L,
    4L, 5L, 2L, 6L, 6L, 7L, 5L, 3L, 4L, 5L, 7L, 7L, 7L, 3L, 6L,
    7L, 7L, 4L, 6L, 7L, 6L, 7L, 5L, 6L), .Label = c("20 horas/ períodos semanais",
    "Até 10 horas/períodos semanais", "Mais de 10 horas/ períodos semanais",
    "Mais de 15 horas/ períodos semanais", "Mais de 20 horas/ períodos semanais",
    "Mais de 30 horas/ períodos semanais", "Não oferecemos este nível de ensino na escola"
    ), class = "factor"), Q28 = structure(c(1L, 1L, 1L, 1L, 7L,
    5L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 9L, 1L, 6L, 1L, 4L, 1L, 1L,
    1L, 1L, 1L, 2L, 1L, 1L, 1L, 8L, 1L), .Label = c("", "1º a 4º ano do Fundamental 1: 27h/aula total, 21h/aula em Língua Portuguesa\n5º ano Fundamental 1: 30h/a total, 24h/a em Língua Portuguesa\n6º ao 8º Fundamental II: 29h/a total, 27h/a em Língua Portuguesa\n9º, Fundamental II: 36h/a total, 34h/a em Língua Portuguesa\n1ª série, EM: ainda em discussão\n2ª série, EM: ainda em discussão\n3ª série, EM: ainda em discussão",
    "Até 4 anos: 1 aula de cultura brasileira\n5 anos: 5 aulas por semana\n6-10 anos: 7 aulas - sendo 5 portugues, 2 estudos sociais\nAcima: 9 aulas",
    "Em inglês, L2, oferecemos no EI 22h30 e no EFI 10h semanalmente",
    "Inglês: Nível 1 e 2 (1 ano a 2 anos) 30min semanais; nível 3, 4 e 5 (3 a 5 anos) 1h20semanal; ensino fundamental 1h30 (semanal) obs. Carga horaria tradicional: 2 encontros de 50min",
    "Na educação infantil, cerca de 15% do currículo é ministrado em língua portuguesa. No Ensino Fundamental 1, 50% são ministradas em língua portuguesa. No Ensino Fundamental 2, 60% são ministradas em língua portuguesa.",
    "No ensino médio a prática de Laboratório  de redação é mais latente.",
    "O aumento da carga horária é gradativa, conforme a idade e os segmentos.",
    "Temos duas trilhas no Ensino Médio: trilha nacional e a trilha internacional. Na Nacional, os tempos em inglês são reduzidos, do total de 32 aulas de aula (sem contar intervalos e almoço) somente 4 aulas de 1 hora são em inglês. Na trilha internacional, das 32 aulas 14 delas são em língua inglesa. "
    ), class = "factor"), Q29 = structure(c(5L, 5L, 5L, 5L, 5L,
    1L, 5L, 5L, 5L, 5L, 5L, 5L, 2L, 5L, 5L, 5L, 5L, 3L, 5L, 5L,
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 4L, 5L), .Label = c("1 hora em língua adicional",
    "100% da carga-horária em língua adicional", "50% da carga- horária em língua adicional",
    "Mais de 10 horas em língua adicional", "Não oferecemos este nível de ensino bilíngue na escola"
    ), class = "factor"), Q30 = structure(c(7L, 3L, 5L, 9L, 1L,
    1L, 9L, 4L, 9L, 9L, 9L, 4L, 2L, 9L, 9L, 9L, 6L, 6L, 9L, 9L,
    9L, 9L, 2L, 9L, 9L, 4L, 9L, 8L, 1L), .Label = c("1 hora em língua adicional",
    "10 horas em língua adicional", "100% da carga-horária em língua adicional",
    "3 horas em língua adicional", "5 horas em língua adicional",
    "50% da carga- horária em língua adicional", "6 horas em língua adicional",
    "Mais de 10 horas em língua adicional", "Não oferecemos este nível de ensino bilíngue na escola"
    ), class = "factor"), Q31 = structure(c(10L, 3L, 11L, 10L,
    12L, 1L, 5L, 5L, 6L, 5L, 7L, 5L, 3L, 13L, 7L, 12L, 8L, 8L,
    2L, 13L, 2L, 9L, 2L, 9L, 10L, 7L, 4L, 12L, 7L), .Label = c("1 hora em língua adicional",
    "10 horas em língua adicional", "100% da carga-horária em língua adicional",
    "2 horas em língua adicional", "3 horas em língua adicional",
    "4 horas em língua adicional", "5 horas em língua adicional",
    "50% da carga- horária em língua adicional", "6 horas em língua adicional",
    "8 horas em aíngua adicional", "9 horas em língua adicional",
    "Mais de 10 horas em língua adicional", "Não oferecemos este nível de ensino bilíngue na escola"
    ), class = "factor"), Q32 = structure(c(12L, 8L, 2L, 11L,
    12L, 1L, 6L, 5L, 7L, 7L, 9L, 5L, 3L, 13L, 10L, 8L, 4L, 2L,
    2L, 11L, 2L, 10L, 2L, 9L, 12L, 7L, 5L, 12L, 7L), .Label = c("1 hora em língua adicional",
    "10 horas em língua adicional", "100% da carga-horária em língua adicional",
    "2 horas em língua adicional", "3 horas em língua adicional",
    "4 horas em língua adicional", "5 horas em língua adicional",
    "50% da carga- horária em língua adicional", "6 horas em língua adicional",
    "7 horas em língua adicional", "8 horas em aíngua adicional",
    "Mais de 10 horas em língua adicional", "Não oferecemos este nível de ensino bilíngue na escola"
    ), class = "factor"), Q33 = structure(c(7L, 8L, 2L, 11L,
    12L, 1L, 6L, 5L, 7L, 7L, 10L, 5L, 3L, 13L, 10L, 8L, 4L, 2L,
    2L, 11L, 2L, 10L, 2L, 9L, 12L, 7L, 5L, 12L, 7L), .Label = c("1 hora em língua adicional",
    "10 horas em língua adicional", "100% da carga-horária em língua adicional",
    "2 horas em língua adicional", "3 horas em língua adicional",
    "4 horas em língua adicional", "5 horas em língua adicional",
    "50% da carga- horária em língua adicional", "6 horas em língua adicional",
    "7 horas em língua adicional", "8 horas em aíngua adicional",
    "Mais de 10 horas em língua adicional", "Não oferecemos este nível de ensino bilíngue na escola"
    ), class = "factor"), Q34 = structure(c(7L, 11L, 2L, 5L,
    2L, 1L, 6L, 4L, 5L, 7L, 8L, 11L, 3L, 10L, 8L, 10L, 11L, 11L,
    11L, 9L, 8L, 9L, 11L, 11L, 2L, 7L, 5L, 10L, 7L), .Label = c("1 hora em língua adicional",
    "10 horas em língua adicional", "100% da carga-horária em língua adicional",
    "2 horas em língua adicional", "3 horas em língua adicional",
    "4 horas em língua adicional", "5 horas em língua adicional",
    "7 horas em língua adicional", "8 horas em aíngua adicional",
    "Mais de 10 horas em língua adicional", "Não oferecemos este nível de ensino bilíngue na escola"
    ), class = "factor"), Q35 = structure(c(5L, 9L, 9L, 4L, 9L,
    9L, 4L, 3L, 3L, 3L, 9L, 9L, 6L, 8L, 7L, 9L, 9L, 9L, 9L, 9L,
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 2L, 1L), .Label = c("1 hora em língua adicional",
    "10 horas em língua adicional", "2 horas em língua adicional",
    "3 horas em língua adicional", "5 horas em língua adicional",
    "50% da carga- horária em língua adicional", "6 horas em língua adicional",
    "Mais de 10 horas em língua adicional", "Não oferecemos este nível de ensino bilíngue na escola"
    ), class = "factor")), row.names = c(NA, -29L), class = "data.frame")

A: Simple solution is to make sure that all factors have all the possible levels you may need - the warning messages are just letting you know that they're not all noted in all columns.
You can simply assign all columns the correct set of levels first, which will eliminate the warning messages. This will not change the values in any of the coluns, but will tell R that in principle it should expect all of these to be a valid value in all columns.
The line:
all_levels <- lapply(my_data, levels) |> reduce(c) |> unique()

Will concatenate all the levels you have already across all columns into a vector. fct_expand will then expand the list of possible values for each column, so that when fct_collapse checks each one it finds what it expects there.
library(tidyverse)

all_levels <- lapply(my_data, levels) |> reduce(c) |> unique()

my_data %>%
  mutate(
    across(everything(), fct_expand, all_levels),
         across(everything(), fct_collapse,
                                        'Não oferta' = c('Não oferecemos este nível de ensino na escola',
                                                         'Não oferecemos este nível de ensino bilíngue na escola'),
                                        '> 20h' = c('Mais de 20 horas/ períodos semanais'),
                                        '> 10h' = c('Mais de 10 horas/ períodos semanais',
                                                    'Mais de 10 horas em língua adicional'),
                                        '= 20h' = c('20 horas/ períodos semanais'),
                                        'Até 10h' = c('Até 10 horas/períodos semanais'),
                                        '= 1h' = c('1 hora em língua adicional'),
                                        '100% CH' = c('100% da carga-horária em língua adicional'),
                                        '> 15h' = c('Mais de 15 horas/ períodos semanais'),
                                        '> 30h' = c('Mais de 30 horas/ períodos semanais'),
                                        '50% CH' = c('50% da carga- horária em língua adicional',
                                                     '= 3h' = c('3 horas em língua adicional'),
                                                     '= 6h' = c('6 horas em língua adicional'),
                                                     '= 5h' = c('5 horas em língua adicional'),
                                                     '= 2h' = c('2 horas em língua adicional'),
                                                     '= 10h' = c('10 horas em língua adicional'),
                                                     '9h' = c('9 horas em língua adicional'),
                                                     '8h' = c('8 horas em língua adicional',
                                                              '8 horas em língua adicional'), ## digitação
                                                     '3h' = c('3 horas em língua adicional'),
                                                     '4h' = c('4 horas em língua adicional'),
                                                     '7h' = c('7 horas em língua adicional'),
                                                     '2h' = c('2 horas em língua adicional'))))

fct_expand increases the levels of a factor - i.e. the list of valid values it can take - without modifying the data itself. The levels are distinct from the values, e.g.:
l <- factor(letters[1:3])

l
#> [1] a b c
#> Levels: a b c

l <- forcats::fct_expand(l, letters[1:5])

l
#> [1] a b c
#> Levels: a b c d e


text:
Q: GADBannerViewDelegate.h file not found in TOLAdAdapterAdMobAds.h I got GADBannerViewDelegate.h file not found error in TOLAdAdapterAdMobAds.h although i have already included that file as shown in image below. I have used
pod 'LARSAdController', '~> 3.0'

to install the pod file for it

A: Just replace
#import "GADBannerViewDelegate.h"
#import "GADBannerView.h"

with
#import <GoogleMobileAds/GoogleMobileAds.h>

This has to be done as GoogleMobileAds SDK is now a framework instead of static library.
After making this change, you may get an error at request.testing = YES; in TOLAdAdapterGoogleAds.m. To correct that, just replace that line with: request.testDevices = @[kGADSimulatorID]; and everything should work fine.


text:
Q: How does DirectShow decide between two codecs with the same merit value? Given two codecs with the same merit value, how does DirectShow decide which one to use through the 'intelligent connect' mechanism?

A: It throws a dice.
Seriously the behavior is undefined, both decoders have chances to be taken first. In case of rejection, filter graph would try the other one.

A: The intelligent connect msdn page sheds some light on this.
Starting from Windows 7, a new system is used, and the merit system is only used as a fallback when no filter is found after searching for one using the new approach.

Starting in Windows 7, DirectShow has a list of preferred filters for
  certain media subtypes. If there is a preferred filter for the media
  type that is being rendered, the Filter Graph Manager tries that
  filter next. An application can modify the list of preferred filters
  by using the IAMPluginControl interface. Changes to the list affect
  the application's current process, and are discarded after the process
  ends.

In case the merit system is used, the msdn page only mentions the following:

Then it tries them in order of merit, from highest to lowest. (It uses additional criteria to choose between filters with equal merit.)


text:
Q: Bookmarked page redirect I recently converted a site from asp to CF.  Unfortunately, alot of the old users had the "homepage" bookmarked.  www.example.com/homepage.asp
Is there a sort of catch all way I could redirect any traffic from that page to the current index.cfm?
I would normally just delete those files, but the owner(s) wanted to keep it around for their own comparison reasons.
Any ideas?
Thanks

A: Put this in the old homepage.asp
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "/index.cfm"
%>

A: If you don't want run an onerous asp file at all on the new site, you can do a custom 404 on the web server.  If you point the 404 page to a .cfm file, you can extract all the various features from the request by including:
<!--- parse out the text in the URL parameters into an array --->
<cfset variables.requestparams = listtoarray(cgi.query_string,'/?&')>

<!--- get rid of the first 2 items in the array since they dont represent request info --->
<cfset foo = arraydeleteat(variables.requestparams,1)>
<cfset foo = arraydeleteat(variables.requestparams,1)>

You'll be left with an array representing the parameters that were passed in the original request.  You can follow up on this by doing whatever analysis you need to on the url components to map it against the analogous pages in your CF site.

A: I'm surprised nobody has mentioned URL Rewriting. You can use mod_rewrite on *nix/apache, or ISAPI Rewrite or Ionics ISAPI Rewrite on Windows/IIS. I prefer Ionics if I'm on IIS.

A: The best bet is to do either a meta refresh in the actual homepage.asp page, it is quick and dirty, but works.
A better solution would be to have the .asp page do a 301 redirect to the new homepage, that way when search engines access the page as well they know it has moved.

A: What I do on Linux machines when I run into something like this is to create a symbolic link (ln -s /path/to/source /path/to/target).
Not sure what the Windows equivalent would be, so going with @Patrick's answer is probably best.
EDIT - The NTFS way of making a symlink:
http://en.wikipedia.org/wiki/NTFS_symbolic_link
see also http://en.wikipedia.org/wiki/Symbolic_link


text:
Q: Android split not working correctly I've been developing an Android app for the past 4 Months now and came across the following regarding the split function:
String [] arr;
SoapPrimitive result = (SoapPrimitive)envelope.getResponse();
arr = result.toString().trim().split("|");

The result variable is what I get after accessing my WebService, now this works perfectly. But, for some reason my split("|") method is not splitting at "|" but rather splitting at every single char in my result String. So my array looks like this:
arr[0] is "H",
arr[1] is "e",
etc......
I don't know why this is happening because I have used it before in the same project and it worked perfectly.
Thank you in advance

A: arr = result.toString().trim().split("\\|");

the param of String.split accept a regular expression.

A: Following code can be used for any pattern splitting.
String.split(Pattern.quote("any pattern you would like here !"));


text:
Q: redirect in before action is running infinitely in yii2 i have added access filter to web.php and in login action consists following code
public function actionLogin() {
    return $this->render('loginform', ['model' => $model, 'iv' => $iv, 'key' => $key]);

}

A: In Yii2 you don't have to do workarounds like that to achieve checking if user is logged in. Yii2 has own Access Controll behaviours, which will do all for you.
To use it, add in your controller this behaviour:
public function behaviors()
{
    return [
        'access' => [
            'class' => yii\filters\AccessControl::className(),
            'rules' => [
                [
                    'allow' => true,
                    'roles' => ['@']
                ],
            ],
        ],
    ];
}

It will check if user whos trying access all actions in this controller is logged in. For more options you should look here: YIi2 - Access Control Filter


text:
Q: Ubuntu, Git (git-http-backend) and Apache I am trying to setup a repository server based on git combine with its git-http-backend and apache. My problem? I can clone perfectly, but when i try ti push, i hit a wall
$ git push origin master
* Couldn't find host git.local in the .netrc file; using defaults
* About to connect() to git.local port 80 (#0)
*   Trying 127.0.0.1... * connected
* Connected to git.local (127.0.0.1) port 80 (#0)
> GET /new/info/refs?service=git-receive-pack HTTP/1.1
User-Agent: git/1.7.1
Host: git.local
Accept: */*
Pragma: no-cache

< HTTP/1.1 401 Authorization Required
< Date: Tue, 23 Nov 2010 16:21:51 GMT
< Server: Apache/2.2.16 (Ubuntu)
< WWW-Authenticate: Basic realm="Private Git Access"
< Vary: Accept-Encoding
< Content-Length: 476
< Content-Type: text/html; charset=iso-8859-1
<
* Ignoring the response-body
* Connection #0 to host git.local left intact
* Issue another request to this URL: 'http://shoaibi:shoaibi@git.local/new/info/refs?service=git-receive-pack'
* Couldn't find host git.local in the .netrc file; using defaults
* Re-using existing connection! (#0) with host git.local
* Connected to git.local (127.0.0.1) port 80 (#0)
* Server auth using Basic with user 'shoaibi'
> GET /new/info/refs?service=git-receive-pack HTTP/1.1
Authorization: Basic c2hvYWliaTpzaG9haWJp
User-Agent: git/1.7.1
Host: git.local
Accept: */*
Pragma: no-cache

< HTTP/1.1 200 OK
< Date: Tue, 23 Nov 2010 16:21:51 GMT
< Server: Apache/2.2.16 (Ubuntu)
< Last-Modified: Tue, 23 Nov 2010 15:30:17 GMT
< ETag: "8853-0-495ba0cca2f10"
< Accept-Ranges: bytes
< Content-Length: 0
< Content-Type: text/plain
<
* Connection #0 to host git.local left intact
* Couldn't find host git.local in the .netrc file; using defaults
* Re-using existing connection! (#0) with host git.local
* Connected to git.local (127.0.0.1) port 80 (#0)
* Server auth using Basic with user 'shoaibi'
> GET /new/HEAD HTTP/1.1
Authorization: Basic c2hvYWliaTpzaG9haWJp
User-Agent: git/1.7.1
Host: git.local
Accept: */*
Pragma: no-cache

< HTTP/1.1 200 OK
< Date: Tue, 23 Nov 2010 16:21:51 GMT
< Server: Apache/2.2.16 (Ubuntu)
< Last-Modified: Tue, 23 Nov 2010 12:05:07 GMT
< ETag: "88b7-17-495b72f0814f0"
< Accept-Ranges: bytes
< Content-Length: 23
< Content-Type: text/plain
<
* Expire cleared
* Connection #0 to host git.local left intact
* Couldn't find host git.local in the .netrc file; using defaults
* About to connect() to git.local port 80 (#0)
*   Trying 127.0.0.1... * connected
* Connected to git.local (127.0.0.1) port 80 (#0)
> PROPFIND /new/ HTTP/1.1
User-Agent: git/1.7.1
Host: git.local
Accept: */*
Depth: 0
Content-Type: text/xml
Content-Length: 167
Expect: 100-continue

< HTTP/1.1 401 Authorization Required
< Date: Tue, 23 Nov 2010 16:21:51 GMT
< Server: Apache/2.2.16 (Ubuntu)
< WWW-Authenticate: Basic realm="Private Git Access"
< Vary: Accept-Encoding
< Content-Length: 476
< Content-Type: text/html; charset=iso-8859-1
<
* Expire cleared
* Closing connection #0
* Issue another request to this URL: 'http://shoaibi:shoaibi@git.local/new/'
* Couldn't find host git.local in the .netrc file; using defaults
* About to connect() to git.local port 80 (#0)
*   Trying 127.0.0.1... * connected
* Connected to git.local (127.0.0.1) port 80 (#0)
* Server auth using Basic with user 'shoaibi'
> PROPFIND /new/ HTTP/1.1
Authorization: Basic c2hvYWliaTpzaG9haWJp
User-Agent: git/1.7.1
Host: git.local
Accept: */*
Depth: 0
Content-Type: text/xml
Content-Length: 167
Expect: 100-continue

< HTTP/1.1 100 Continue
* The requested URL returned error: 405
* Expire cleared
* Closing connection #0
error: Cannot access URL http://shoaibi:shoaibi@git.local/new/, return code 22
fatal: git-http-push failed

Apache's Logs say:
127.0.0.1 - - [23/Nov/2010:21:21:51 +0500] "GET /new/info/refs?service=git-receive-pack HTTP/1.1" 401 725
127.0.0.1 - shoaibi [23/Nov/2010:21:21:51 +0500] "GET /new/info/refs?service=git-receive-pack HTTP/1.1" 200 231
127.0.0.1 - shoaibi [23/Nov/2010:21:21:51 +0500] "GET /new/HEAD HTTP/1.1" 200 256
127.0.0.1 - - [23/Nov/2010:21:21:51 +0500] "PROPFIND /new/ HTTP/1.1" 401 725
127.0.0.1 - shoaibi [23/Nov/2010:21:21:51 +0500] "PROPFIND /new/ HTTP/1.1" 405 553

git-http-backend requires cgi, alias and env mods enabled, these are already enabled, i even tried enabled and disabling dav related modules after reading some results on google. Apache's enabled modules:
 $apache2ctl -M
Loaded Modules:
 core_module (static)
 log_config_module (static)
 logio_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 alias_module (shared)
 auth_basic_module (shared)
 authn_file_module (shared)
 authz_default_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cache_module (shared)
 cgi_module (shared)
 dav_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 mem_cache_module (shared)
 mime_module (shared)
 security2_module (shared)
 negotiation_module (shared)
 php5_module (shared)
 proxy_module (shared)
 proxy_ajp_module (shared)
 proxy_balancer_module (shared)
 reqtimeout_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 ssl_module (shared)
 status_module (shared)
 unique_id_module (shared)
 userdir_module (shared)
Syntax OK

Apache's Vhost:
<VirtualHost *:80>
        ServerName www.git.local
        ServerAlias git.local
        ServerAdmin webmaster@git.local
        DocumentRoot /var/www/git/

        SetEnv GIT_PROJECT_ROOT /var/www/git
        SetEnv GIT_HTTP_EXPORT_ALL
        ScriptAlias /git/ /usr/lib/git-core/git-http-backend
        <Directory />
            Options +ExecCGI
            Allow From All
        </Directory>

        <Location />
                AuthType Basic
                AuthName "Private Git Access"
                Require group committers
                AuthUserFile /var/www/git/.htpasswd
                AuthGroupFile /var/www/git/.htgroup
        </Location>

        ErrorLog /var/log/apache2/git-error_log
        CustomLog /var/log/apache2/git-access_log common

</VirtualHost>

htpasswd:
$ cat .htpasswd
shoaibi:HSt/9CzkstIUM

htgroup:
$ cat .htgroup
committers: shoaibi

Directory Structure:
$ ls -al
total 28
drwxrwxr-x  4 www-data shoaibi 4096 2010-11-23 17:05 .
drwxrwxr-x 17 www-data shoaibi 4096 2010-11-23 11:46 ..
-rwxrwxr-x  1 www-data shoaibi   20 2010-11-23 16:51 .htgroup
-rwxrwxr-x  1 www-data shoaibi   22 2010-11-23 16:50 .htpasswd
-rwxrwxr-x  1 www-data shoaibi    9 2010-11-23 15:46 index.html
drwxrwxr-x  7 www-data shoaibi 4096 2010-11-23 11:53 myrepo.git
drwxrwxr-x  7 www-data shoaibi 4096 2010-11-23 17:05 new

$ ls -al new
total 40
drwxrwxr-x 7 www-data shoaibi 4096 2010-11-23 17:05 .
drwxrwxr-x 4 www-data shoaibi 4096 2010-11-23 17:05 ..
drwxrwxr-x 2 www-data shoaibi 4096 2010-11-23 17:05 branches
-rwxrwxr-x 1 www-data shoaibi   66 2010-11-23 17:05 config
-rwxrwxr-x 1 www-data shoaibi   73 2010-11-23 17:05 description
-rwxrwxr-x 1 www-data shoaibi   23 2010-11-23 17:05 HEAD
drwxrwxr-x 2 www-data shoaibi 4096 2010-11-23 17:05 hooks
drwxrwxr-x 2 www-data shoaibi 4096 2010-11-23 20:30 info
drwxrwxr-x 4 www-data shoaibi 4096 2010-11-23 17:05 objects
drwxrwxr-x 4 www-data shoaibi 4096 2010-11-23 17:05 refs

 $ ls -al myrepo.git
total 40
drwxrwxr-x 7 www-data shoaibi 4096 2010-11-23 11:53 .
drwxrwxr-x 4 www-data shoaibi 4096 2010-11-23 17:05 ..
drwxrwxr-x 2 www-data shoaibi 4096 2010-11-23 11:53 branches
-rwxrwxr-x 1 www-data shoaibi   66 2010-11-23 11:53 config
-rwxrwxr-x 1 www-data shoaibi   73 2010-11-23 11:53 description
-rwxrwxr-x 1 www-data shoaibi   23 2010-11-23 11:53 HEAD
drwxrwxr-x 2 www-data shoaibi 4096 2010-11-23 11:53 hooks
drwxrwxr-x 2 www-data shoaibi 4096 2010-11-23 16:20 info
drwxrwxr-x 4 www-data shoaibi 4096 2010-11-23 11:53 objects
drwxrwxr-x 4 www-data shoaibi 4096 2010-11-23 11:53 refs

A: Looking at your VHost file I'm not sure the git backend is firing at all.
ScriptAlias /git/ /usr/lib/git-core/git-http-backend

This won't actually do anything unless you're on a page such as http://git.local/git/somethingelse - As your DocumentRoot is /var/www/git/ , and your repositories are folders under /var/www/git/ the ScriptAlias line serves no purpose as you will never be navigating http://git.local/git/

A: Have you set git config http.receivepack true in /var/www/git/new?


text:
Q: Proof for intersection. Really stuck on this one, seemed simple but I just couldn't get it for some reason.
Suppose that $\mathcal U$ is the universal set, and that $A$, $B$ and $C$ are three arbitrary sets
of elements of $\mathcal U$. Prove that if $C \setminus A = B$, then the intersection of $A$ and $B$ is empty. Hint: use an indirect proof.

A: Show $C$ \ $A=B$ implies $A \cap B=\emptyset$.
Assume $A\cap B \not =  \emptyset.$
Then there is a $x$ s.t $x \in A$ and $x \in B$.
Since $x \in B$, and $C$ \ $A =B$ , we have $x \in C$\ $A,$
then $x \not \in A$, a contradiction.

A: The following is a direct proof:
$1$. Assume $C-A = B$
$2$. Then, by substitution,
$$A \cap B = A \cap \big(C-A \big)$$
$3$. By definition of set difference,
$$=A \cap \big(C \cap A^c\big)$$
$4$. By commutative law,
$$=A \cap \big(A^c \cap C\big)$$
$5$. By associative law,
$$=\big(A \cap A^c\big) \cap C$$
$6$. By negation law,
$$=\emptyset \cap C$$
$7$. By domination law,
$$=\emptyset$$
Therefore, if $C-A = B$, then $A \cap B = \emptyset$


text:
Q: Permanently Change Environment Variables in Windows I found a way to change the default home directory of a user but I am having trouble with it.

Doing this will change the home drive to C:
But then when I check the environment variable:

It is still H:, with a system restart the Enviroment variables in windows settings will also return to H:/
I have also tried changing it like this:

Which appears to work but if i open a new cmd it will have reverted back to H:/
Now I am trying to do this so that OpenSSH will recognise C as my home directory instead of H: which is a network drive, forcing OpenSSH not to work unless I cam connected to my university network via VPN.
What can I do to set this permanently and in the eyes of OpenSSH?

A: Sounds like the AD profile on the domain is overwriting the user defined variables.  I see your screenshot says you are connected to the eait.org.edu.au domain.  That will be the root of your issue.  Just to include some details here that I spotted elsewhere, that may be of help to you:
HOMEDRIVE, HOMEPATH & HOMESHARE are set and updated via Active Directory. HOMEDRIVE & HOMEPATH are set even without a home drive set on the account; however they will be overridden by any user account properties set in AD.
Also see these KB articles:
http://support.microsoft.com/kb/841343
http://support.microsoft.com/kb/237566
http://support.microsoft.com/kb/101507

On a side-note for another way around the issue:
-I have in the past created a new instance of the windows command-line shell executable that automatically runs a custom script, so everytime you launch the shell, the environment variable could be overriden.
-To do that you could just put the code you posted to change the environment variable into a batch script, stored wherever you like, then edit the shortcut(s) used to launch the shell by going to properties > then alter the Target box: %SystemRoot%\system32\cmd.exe /K "C:\Documents and Settings\Administrator\My Documents\customshellscript.cmd" (Obviously the part of the path after /K is the location of your custom script)
This way, if you are using openSSH over the console anyway, it will always have the homedrive set correctly.

A: Changing those environment variable's values is not "supported", at least it will not work as you expect because Windows changes them back.
According to this Microsoft knowledge base article (KB841343), you should use policies, if you need to change these settings. The article also contains links for how to do that (but personally, I never tried). Note that the article was originally written for Windows 2000, but I would strongly suspect, that it is still valid for current Windows versions.

A: Nowhere does it mention a dependency between the HOMEDRIVE value and the HOMEDIRECTORY value, what was happening (I think) is that it was failing to map the home directory to the HOMEDRIVE and therefore defaulting back to a safe value (C:)
I wrote a script to update the local AD, replace the values in [] with your values. Copy and paste into a .vbs file and double click on it to run it.
Set objUser = GetObject("WinNT://[COMPUTERNAME]/[USERNAME],user")
objUser.homeDirDrive = "H:"
objUser.HomeDirectory = "[URNPATH]"
objUser.SetInfo

e.g.
Set objUser = GetObject("WinNT://UQBDART-2328/BEN,user")
objUser.homeDirDrive = "H:"
objUser.HomeDirectory = "\\SERVER\SHARE"
objUser.SetInfo

run this, reboot and test. It worked for me.

A: Back in the days of DOS the environment variables were part of the Program Segement which meant that you basically got a local snapshop of the variables limited to the scope of that program.
I'm guessing Windows hasn't changed this and the environment variables available to the CMD window only have the scope of that window and any further windows it spawns. This is supported by this little experiment:
in a CMD window type
set homedrive=h:\

and then test it's updated by typing
set h

from this same window type
start cmd

and in this new window type
set h

when I've done this I get HOMEDRIVE=H:\
if I then just open a new CMD window from the start menu and do the same SET H I get HOMEDRIVE=C:\
I don't know anything about OpenSSH but I suspect like the START CMD got the updated HOMEDRIVE environment variable, if you write a batch to update the environment variable and then execute OpenSSH that'll work.

A: I had a similar issue, the HOMEDRIVE variable was set to U: which was a drive we no longer used.  This was just for one particular user.  I went to that user's profile in AD and clicked the Attribute Editor tab.  There was an attribute for HOMEDRIVE which I changed from U: to C: - when the user logged in again, it was set correctly.  I also updated the HomeDirectory attribute here.

A: On windows 8:

*

*Hit "windows key".

*type "system environment variables".

*Allow "Advance system settings" to make changes.

*Select "Advance" tab.

*Click on "Enviroment Variables...".

*Double click on "Path" from "User variable for XXXXXXXX"

*Add at the end the variable the new path that you want separated by semicolon.
e.g. C:\Program Files\;C:\Python27\
shareeditdelete (1)flag

A: This issue had been really frustrating me trying to find a solution, but I have found what I think is the definitive answer and posted it at:
https://stackoverflow.com/a/60235759/12903197
You need to run 'net user USERNAME /homedir:PATH' where USERNAME is the name of the user you are trying to change and PATH is the drive letter and full path to the desired home folder, which must already exist.


text:
Q: Pass function pointer as part of a hash, perl The script runs such that THE USER defines some function:
sub userFunction
{
 my ($msg, $id) = @ARG;
 # do things
}

This function, $func is passed with a specific message name, $msg, into my class to be stored as a $msg/$userFunc pair in {_Handles}:
sub new
{
  my ($class, ...) = @_;
  my $self = {};
  $self->{_Handles} = {};
  .
  .
  .
}

Then I add a message handler:
$Class->AddMsgHandler($msgName1, \&userFunction);
sub AddMsgHandler
{
  my ($self, $msg, $func) = @ARG;
  my $funcPtr = $func->();
  $self->{_Handles}{'msg'} = $msg;
  $self->{_Handles}{$msg}{'funcPtr'} = $funcPtr;
}

The intention is to transfer my message wirelessly across a device; another device will receive this message. Assuming the device receives the message in another function, I'm trying to call the user defined function on specific $id as follows:
sub Receive
{
 .
 .
 .
 my $funcPtr = $self->{_Handles}{$msg}{'funcPtr'};
 $funcPtr->($msg, $self->{_devices}{$id});
}

somehow there's no response. Perhaps I have misused the function pointer?

A: When you do this: my $funcPtr = $func->();, you're executing the subroutine and assigning the function's return value to $funcPtr, not the function's code reference itself, which I think is what you're after. You need to remove the ->() from that assignment. Here's a brief example:
use warnings;
use strict;

my %store;

sub user_func {
    return 5;
}
sub set {
    my $func = shift;
    $store{func} = $func;
}

set(\&user_func);

print $store{func}->();

Here's an example that shows the difference:
sub func {
    return 5;
}

my $cref = \&func;

my $called = $cref->();
my $not_called = $cref;

print "$called\n";
print "$not_called\n";

Output:
5
CODE(0x801c82ed0)

A: Clearly the best possible help is to guide you to debug your own code. You can use the -d flag to turn on Perl debugger so you can stop the execution of code to ensure:

*

*You are really storing a sub reference

*You are really restoring it and calling it

Saying that, I would turn on my quick solution:
instead of
$funcPtr->($msg, $self->{_devices}{$id});

try
&$funcPtr($msg, $self->{_devices}{$id});