text:
Q: How to compare images and determine which has more content? Goal: I want to grab the best frame from an animated GIF and use it as a static preview image. I believe the best frame is one that shows the most content - not necessarily the first or last frame.
Take this GIF for example:

--
This is the first frame:

--
Here is the 28th frame:

It's clear that frame 28th represents the entire GIF well.
How could I programmatically determine if one frame has more pixel/content over another? Any thoughts, ideas, packages/modules, or articles that you can point me to would be greatly appreciated.

A: One straightforward way this could be accomplished would be to estimate the entropy of each image and choose the frame with maximal entropy.
In information theory, entropy can be thought of as the "randomness" of the image. An image of a single color is very predictable, the flatter the distribution, the more random. This is highly related to the compression method described by Arthur-R as entropy is the lower bound on how much data can be losslessly compressed.
Estimating Entropy
One way to estimate the entropy is to approximate the probability mass function for pixel intensities using a histogram. To generate the plot below I first convert the image to grayscale, then compute the histogram using a bin spacing of 1 (for pixel values from 0 to 255). Then, normalize the histogram so that the bins sum to 1. This normalized histogram is an approximation of the pixel probability mass function.
Using this probability mass function we can easily estimate the entropy of the grayscale image which is described by the following equation
H = E[-log(p(x))]

Where H is entropy, E is the expected value, and p(x) is the probability that any given pixel takes the value x.
Programmatically H can be estimated by simply computing -p(x)*log(p(x)) for each value p(x) in the histogram and then adding them together.
Plot of entropy vs. frame number for your example.

with frame 21 (the 22nd frame) having the highest entropy.

Observations

*

*The entropy computed here is not equal to the true entropy of the
image because it makes the assumption that each pixel is independently sampled from the same distribution. To get the true entropy we would need to know
the joint distribution of the image which we won't be able to know without
understanding the underlying random process that generated the images
(which would include human interaction). However, I don't think the true entropy would be very useful and this measure should
give a reasonable estimate of how much content is in the image.

*This method will fail if some not-so-interesting frame
contains much more noise (randomly colored pixels) than the most
interesting frame because noise results in a high entropy. For example, the
following image is pure uniform noise and therefore has maximum entropy (H = 8 bits), i.e. no compression is possible.

Ruby Implementation
I don't know ruby but it looks like one of the answers to this question refers to a package for computing entropy of an image.
From m. simon borg's comment

FWIW, using Ruby's File.size() returns 1904 bytes for the 28th frame
  image and 946 bytes for the first frame image – m. simon borg

File.size() should be roughly proportional to entropy.

As an aside, if you check the size of the 200x200 noise image on disk you will see that the file is 40,345 bytes even after compression, but the uncompressed data is only 40,000 bytes. Information theory tells us that no compression scheme can ever losslessly compress such images on average.

A: There are a couple ways I might go about this. My first thought (this may not be the most practical solution, but it seems theoretically interesting!) would be to try losslessly compressing each frame, and in theory, the frame with the least repeatable content (and thus the most unique content) would have the largest size, so you could then compare the size in bytes/bits of each compressed frame. The accuracy of this solution would probably be highly dependent on the photo passed in.
A more realistic/ practical solution might be to grab the predominant color in the GIF (so in the example, the background color), and then iterate through each pixel and increment a counter each time the color of the current pixel doesn't match the color of the background.
I'm thinking about some more optimized/ sample based solutions, and will edit my response to include them a little later, if performance is a concern for you.

A: I think that you can choose an API such as Restful Web Service for do that because without it that's so hard.
For example,these are some famous API's:
https://cloud.google.com/vision/
https://www.clarifai.com/
https://vize.ai
https://azure.microsoft.com/en-us/services/cognitive-services/computer-vision/
https://imagga.com


text:
Q: How to create custom validation using Vuetify rules to check existing item I'm currently making my first web app (CRUD) using Vue 2 + Vuetify, but I've encountered a problem with a feature I wanna add into a form, which is validation to ensure that there's no item with the same title in the database already.
Here is the code sample using a fake API. Below is the block of code if you prefer it (using the real API).
The HTML part:
<v-form ref="form" lazy-validation>
  <v-text-field
    v-model="editedItem.title"
    :rules="[rules.required, checkDuplicate]"
    label="Title"
  ></v-text-field>
</v-form>

The Method part:
data() {
  return {
    editedItem: {
      title: '',
    },
    rules: {
      required: value => !!value || 'Required.',
    },
  }
},
methods: {
  checkDuplicate(val){
    let params = {};
    params["title"] = val;

    if (val){ //If null, don't call the API
      InventoryDataService.findExactTitle(params)
      .then((response) => {
        if(response.data != ""){ // Same title are found
          if (val == response.data.title) { // Can be discarded, but just to make it same as code sample
            return `Inventory titled ${val} already exists`;
          }
        }
        else{ // No same title found
          return true;
        }
      })
      .catch((e) => {
        console.log(e);
      });
    }
    else{ // Text field is empty
      return true;
    }
  },
}

The actual API returns no data if no same title are found, or exactly 1 record if the same title exists. It works if I put the checking part outside the axios.then (in code sample, uncomment the part and run it if you wanna try); it is compared to "test" and does validate correctly. But when it's only inside the .then block, it doesn't work at all! (both using the "test" and the response.data.title)
I tried to store the response in a variable outside the axios.then to compare it outside, but from what I've read (and tried too), it's not possible because it's async (I still don't really understand it?). I've tried async-await, and all sorts of stuff in Stack Overflow, but none has solved this issue.
Is there any way to solve this problem? As long as the feature are implemented, I don't mind changing my method.
Sorry if the code are a mess, I followed a tutorial and just played around with it. Let me know if you need more info, thanks for the help!

A: Sorry, I don't have the reputation to comment so answering, basically you are trying to implement asynchronous rule in vuetify text field which vuetify doesn't support directly, there are few workarounds that you can check out here. How to make a Vuetify rule async and await with a ajax call
This is an open issue in github: https://github.com/vuetifyjs/vuetify/issues/4231
Few more workaround references: How to validate Vuetify text field asynchronously?
Let me know if it solves your issue.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Enters or enter? Which of these sentences is correct?

*

*Why does she ask him to stand every time she enters the room?

*Why does she ask him to stand every time she enter the room?

*Why does she ask him to inform her every time he goes somewhere?

I think the rule is that 'does' affects only the verbs that we want to ask about. In this case, only 'ask'. Can someone tell me if I'm right about that?
Thank you!

A: It is not about "does" affecting a verb.  It is about what the verb is.
The main clause is the question "Why does she ask [...]"  The verb phrase here is "does ask", and it is in the third person (does) because the subject is "she"
There are two more dependent clauses. An infinitive clause "to stand" and a dependent clause "every time she enters the room".  The verb in this separate clause is "enters" and it is also third person singular.  As this clause isn't a question it doesn't have an auxiliary verb.
The form of the verb in each clause is dependent on the subject of that clause, and not on the structure of any other clauses

Why do you ask him to stand every time she enters the room?

Why does she ask him to stand every time I enter the room?

Why does she ask him to stand when she enters the room?


text:
Q: Help me to understand examples What is the difference between these sentences.Especially,  what does the first example mean?

1) I have been there.
2) I had been there.
3) I was there.

A: I think you should learn the basic grammar of English. It must be mentioned that, you need to provide context for your questions and pinpoint the bottleneck. But, as a learner, I answer this question since it seems to be an exercise! Also,  I strongly recommend you to see StoneyB's priceless post What is the perfect, and how should I use it?.

*

*I have been there (Present Perfect)
This tense is extensively used in English and can be very complicated. This sentence could mean you were there (last year, yesterday or just a minute ago) and you are somewhere else now. However, present perfect tense is usually used to talk about the events that started some time ago and continued up to now. Consider:

I have worked in this company since I was 16 years old.

*I had been there (Past Perfect)
This tense is used to talk about the events that happened before some other events. Therefore, your second sentence is regularly used in a sentence like:

I had been there before the flood ruined the city.

*I was there (Simple Past)
It implies a fact in the past which is "you were there". This tense is usually used to talk about the actions finished in the past; an event finished in the past.

He played only 5 matches for Manchester United last season. He was not very successful.


text:
Q: How to solve the JSON Exception? I am getting bellow exception when using JSON.
06-21 18:59:43.418: W/System.err(682): org.json.JSONException: Value null at PunchTime of type org.json.JSONObject$1 cannot be converted to JSONObject
06-21 18:59:43.428: W/System.err(682):  at org.json.JSON.typeMismatch(JSON.java:96)
06-21 18:59:43.428: W/System.err(682):  at org.json.JSONObject.getJSONObject(JSONObject.java:573)
06-21 18:59:43.428: W/System.err(682):  at com.android.epay.TestClass1.getEmployeeList(TestClass1.java:281)
06-21 18:59:43.428: W/System.err(682):  at com.android.epay.TestClass1$GroupPunch_task.doInBackground(TestClass1.java:214)
06-21 18:59:43.438: W/System.err(682):  at com.android.epay.TestClass1$GroupPunch_task.doInBackground(TestClass1.java:1)
06-21 18:59:43.438: W/System.err(682):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
06-21 18:59:43.438: W/System.err(682):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-21 18:59:43.438: W/System.err(682):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-21 18:59:43.438: W/System.err(682):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
06-21 18:59:43.448: W/System.err(682):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
06-21 18:59:43.448: W/System.err(682):  at java.lang.Thread.run(Thread.java:1096)

My code is..
j_obj = new JSONObject(responseBody);
JSONArray sites = j_obj.getJSONArray("details");
String date_new = null;
for (int i = 0; i < sites.length(); i++) {
    JSONObject list_obj = sites.getJSONObject(i);
    JSONObject type = list_obj.getJSONObject("****");
    JSONObject time = type.getJSONObject("@@@@@");
    String name = list_obj.getString("#####");
    String id = list_obj.getString("id");
    String _no = list_obj.getString("num");
    String type = type.getString("type");

    if (punchtime == null || punchtime.equals("")) {
        date_new = "Null Values";

    } else {

        year = time.getString("Year");
        month = time.getString("Month");
        day = time.getString("Day");
        hours = time.getString("Hours");
        minutes = time.getString("Minutes");
        seconds = time.getString("Seconds");
        millisec = time.getString("Milliseconds");
        date_new = month + "-" + day + "-" + year + " " + hours + ":" + minutes + ":" + seconds + ":" + millisec;
        System.out.println("New Date " + date_new);
    }

    _arrayList.add(id);
    arryList.add(name);
    _arrayList.add(_no);
    punchType_arrayList.add(type);
    punchTime_arrayList.add(date_new);

}

System.out.println("----------------------------------------");

} finally {
    httpclient.getConnectionManager().shutdown();
}
}

Why ia m getting this error? I used if else, still am having same problem.
I searched so many sites but i didn't get answer for it.
please help ...

A: a few things here:
 if (punchtime == null || punchtime.equals("")) {
    date_new = "Null Values";
    punchtime.getString(date_new);
 }

What do you think is going to happen here if the first condition of this if statement is fulfilled? It will be null. Calling a method on an object that is null will give you a NullPointerException.
Secondly can you post the JSON string that you're trying to parse? It's possible that there's an error in the JSON string.


text:
Q: Why memoization can speed up factorial in Python even if there is no repeated computing? Here's my code.
import timeit

fac_mem = {}

def fac(k):
  if k < 2: return 1
  if k not in fac_mem:
    fac_mem[k] = k*fac(k-1)
return fac_mem[k]

def fact(k):
  if k < 2: return 1
  return k*fact(k-1)

if __name__ == "__main__":
  print timeit.timeit("fac(7)","from __main__ import fac")
  print timeit.timeit("fact(7)","from __main__ import fact")
  print timeit.timeit("fac(70)","from __main__ import fac")
  print timeit.timeit("fact(70)","from __main__ import fact")

Here's output
0.236774399224
0.897065011572
0.217623144304
14.1952226578

Well, before the program run, the dict is empty, why memoization still sped up factorial? I mean, the number of invocation is the same for these 2 version.
Then I changed the code a bit, moved the dict into the function.
def fac(k):
  fac_mem = {}
  if k < 2: return 1
  if k not in fac_mem:
    fac_mem[k] = k*fac(k-1)
  return fac_mem[k]

The output changed
1.92900857225
0.910026658388
25.5475004875
14.2164999769

Why slower? Is that because the value generated inside the function is stored in stack temporarily? Variable outside is global, but what makes it so faster?
Would somebody please be kind enough to clear it up for me? I'd be grateful.

A: When you run timeit.timeit without specifying an argument to the keyword number, it executes the code that you pass it 1000000 times. If you keep a global dictionary called fac_mem in the global scope for Python, it will save the results of the first execution in that dictionary.
Therefore your memoized factorial function will only be slow on the first execution where it actually has to do the computations. The rest of the 999999 times it will simply look up the answers in the dictionary and avoid doing computations.
If you keep the dictionary inside the function, it will be destroyed after every time Python leaves the scope within the function (since all references to the dictionary will be destroyed when the function returns). Thus the dictionary will not be able to save its answers and will still remain slow for future executions.
Check out the documentation for timeit.

A: *

*The memoization you wrote hangs on the answer permanently. This means that asking for the same answer multiple times is really fast. Only the first call ever needs to compute anything.

*The way timeit benchmarks a function is to run it hundreds of times and taking an average of all the calls. This helps it be more accurate

This means 1 normal speed call and 99 super fast ones, are averaged together. That makes the memoized function look faster.
If you want to measure actual speed you need to clear your memoization dictionary after each test invocation.


text:
Q: Links to sections in DT in rmarkdown I want to use DT and inside DT I want to link to sections of the rmarkdown document. I tried the below code but it does not work. How to make proper links to sections in DT in rmarkdown?
---
title: "Test links to sections in DT"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo=FALSE)
```

## DT

How to make links work in DT in rmarkdown?

```{r echo=FALSE}
library(DT)
testDF <- data.frame(text=paste0("Section", 1:5),
                     linksTest1=paste0("[", "Section", 1:5, "]", "(#Section", 1:5, ")"))
datatable(testDF, rownames=FALSE, escape=FALSE)
```

## Section 1 {#Section1}

Section 1

## Section 2 {#Section2}

Section 2

## Section 3 {#Section3}

Section 3

## Section 4 {#Section4}

Section 4

## Section 5 {#Section5}

Section 5

A: You should use the normal HTML hyperlink tag, not markdown:
library(DT)
testDF <- data.frame(text=paste0("Section", 1:5),
                     linksTest1=paste0("Section", 1:5, ""))
datatable(testDF, rownames=FALSE, escape=FALSE)


text:
Q: Order various elements floating on the right I have a header with a nav bar floating right, and a logout image that must also float right, being on the right side of the nav bar.
Even when both are floating right, bar always takes the last place, which should be for the logout image.
Here's a working example (take "X" as logout image): http://jsfiddle.net/c2ccB/
HTML is built positioning first the nav bar and then the logout image:

        ...........

And Style has both floating right (see jsfiddle for an extended style version):
nav{
    float: right;
    background: -webkit-linear-gradient(bottom, #DFDFDF , white 80%);
    border-radius: 5px;
    border:  1px solid #9F9D9D;
    margin: 42px 80px 0 0;
}

.logout{
    background-image: url(images/logout.png);
    height: 50px;
    width: 50px;
    float: right;
}

A: Another option, if you don't want to change the order in the html elements, is to just wrap them in a
 with float:right;, then change the individual elements to  float:left;
Here's a fiddle for it : fiddle


text:
Q: Where is the source of firefox.desktop to send a pull request? There is a small bug in /usr/share/applications/firefox.desktop:
https://bugs.launchpad.net/ubuntu/+source/firefox/+bug/1615549
and I'd like to fix it and send a patch but I can't find a repository where the source of it is located. Can anyone point me please?

A: It's in multiple bazaar repositories based on the release. For example:

*

*17.04: https://code.launchpad.net/~mozillateam/firefox/firefox.zesty

*14.04: https://code.launchpad.net/~mozillateam/firefox/firefox.trusty
The file you're interested is in debian/firefox.desktop.in (example: 17.04).
How did I find out?

*

*The Firefox code page in LP doesn't list any active repos.

*Recent builds were all by Chris Coulson, and

*The list of repos to which he's registered includes these.


text:
Q: C++ need help figuring out word count in function. (Ex. Hello World = 2) I'm figuring out the algorithm on this function and it keeps crashing at runtime, here's the code snippet:
int wordCounter(char usStr[]) {
    int index= 0, punct= 0;

    while(usStr[index]!= '\0') //If it's not the end of the sentence
        if(usStr[index]== ' ') //If it finds a space
            index++;

    while(usStr[index]== '\0') //If it's the end of the sentence.
        punct++;
    int allChar= punct+ index;

    return allChar;
}

I shall post the full program if need arises, but for now I need someone to help me crack down the source of the problem.
UPDATE: Here's my int main. Assume numWords is a function that accepts a string class object as its argument and asks the user for input:
int main()
{
string userVal;
    numWords(userVal);
    char *conStr= new char[' ']; //I'm very doubtful and worried about the contents insing the [].
    strcpy(conStr, userVal.c_str()); //String converted to a C-string.
    int fin= wordCounter(conStr);
    cout<< "The number of words in the sentence is "<< fin<< "."<< endl;
    pause();
    return 0;
}

A: Though I have no idea what you're really asking for, I think you should have a condition to end your 1st while() loop to adjust at beginning of words:
int wordCounter(char usStr[]) {
    int index= 0, punct= 0;

    while(usStr[index]!= '\0') {  // <<< Use effin' braces
        if(usStr[index]== ' ') { // <<< Use effin' braces
            index++;
        }
        else {
            break;
        }
    }

    // index points to a non ' ' character or '\0' here
    // No idea, what you're trying to achieve with the following lines
    // of code.

    while(usStr[index] == '\0') { // If it's the end of the sentence ...
                                  // ... this part loops forever!
        punct++;
    }

    int allChar = punct + index;

    return allChar;
}

A:                 int wordCounter(char usStr[]) {
        int index= sizeof(usStr);
        int result = 0;

        for (int i=0; i<index; i++){
            if(usStr[index]== ' ')
                   result++;
            }//end of the loop

        return result+1;

        } //try this one.

A: Simple array way:
int wordCounter(char usStr[])
{
    int wordcount = 0;
    int charcount = 0;
    int index = 0;
    while (usStr[index] != '\0')
    {
        if (usStr[index] == ' ')
        {
            if (charcount)
            { //only count non-empty tokens
                wordcount++;
                charcount = 0;
            }
        }
        else
        {
            charcount++;
        }
        index++;
    }
    if (charcount)
    {  // get last word, if any.
         wordcount++;
    }
    return wordcount;
}

Simple C++ way:
int wordCounter(char usStr[])
{
    int wordcount = 0;
    std::stringstream stream(usStr);
    std::string temp;
    while (stream >> temp)
    { // got a token
        wordcount++;
    }
    return wordcount;
}

Breakdown of what went wrong:
while(usStr[index]!= '\0') //good
    if(usStr[index]== ' ') //good
        index++; //bad

Lets look at a simple case "Hi!"
Iteration 1:
index = 0, usStr[index] = H
while(usStr[index]!= '\0')

H != '\0', enter
    if(usStr[index]== ' ') //good

H != ' ', do not enter. Do not increment index
Iteration 2:
index = 0, usStr[index] = H
while(usStr[index]!= '\0')

H != '\0', enter
    if(usStr[index]== ' ') //good

H != ' ', do not enter. Do not increment index
Iteration 3:
index = 0, usStr[index] = H
while(usStr[index]!= '\0')

H != '\0', enter
    if(usStr[index]== ' ') //good

H != ' ', do not enter. Do not increment index
See the problem yet? If not, I can cut and past all night. Rather get some food and sleep, though.

A: Be warned, I'm a beginner. Sorry, I feel like I have to say that in case I'm totally wrong. :) Hopefully I won't have to say that for too long.
Anyways, I would do this in the simplest way I can come up with. Instead of a char array, I would just use a std::string. Here's a little function I made, which is derived from a function I made to split std::strings into substrings.
// split the string s into substrings and count the number of substrings
int count_substrings(const string& s)
{
    int count{ 0 };
    stringstream ss{ s };
    for (string buffer; ss >> buffer;)
        ++count;
    return count;
}

So what this does is it takes the string and stores it into a stringstream. Then the "ss >> buffer" will go through the characters in the string and when it hits whitespace, it'll store that substring into "buffer" and go into the for loop, which increments "count". It goes into the for loop each time it finds a substring, which is how it counts the number of substrings. Notice that "buffer" isn't actually being used anywhere. I'm sorry if this is a bad explanation of what's going on, but I'm trying. :) I hope this can help you a bit to understand what I'm doing. Please, if I'm wrong about something, correct me.
Then a very simple test of this function could be something like this:
cout << "Enter a string:\n";
string str;
getline(cin, str);

int count = count_substrings(str);
cout << "Number of substrings == " << count << '\n';


text:
Q: Fix HTML Submenu I can not open the submenu, I want to open the submenu when I hover over "Services" submenu, I think I have some mistakes in CSS.
I try to fix the menu using only CSS.
I have tried this code and this one, Unfortunately, the problem has not been resolved.
This is the CSS and HTML code:

@import url(https://fonts.googleapis.com/css?family=Lato:300,400,700);
/* Starter CSS for Flyout Menu */
#cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 0;
}
#cssmenu ul {
  position: relative;
  z-index: 597;
  float: left;
}
#cssmenu ul li {
  float: left;
  min-height: 1px;
  line-height: 1em;
  vertical-align: middle;
}
#cssmenu ul li.hover,
#cssmenu ul li:hover {
  position: relative;
  z-index: 599;
  cursor: default;
}
#cssmenu ul ul {
  margin-top: 1px;
  visibility: hidden;
  position: absolute;
  top: 1px;
  left: 99%;
  z-index: 598;
  width: 100%;
}
#cssmenu ul ul li {
  float: none;
}
#cssmenu ul ul ul {
  top: 1px;
  left: 99%;
}
#cssmenu ul li {
  float: none;
}
#cssmenu ul ul li {
  font-weight: normal;
}
/* Custom CSS Styles */
#cssmenu {
  font-family: 'Lato', sans-serif;
  font-size: 18px;
  width: 200px;
}
#cssmenu ul a,
#cssmenu ul a:link,
#cssmenu ul a:visited {
  display: block;
  color: #848889;
  text-decoration: none;
  font-weight: 300;
}
#cssmenu > ul {
  float: none;
}
#cssmenu ul {
  background: #fff;
}
#cssmenu > ul > li {
  border-left: 3px solid #d7d8da;
}
#cssmenu > ul > li > a {
  padding: 10px 20px;
}
#cssmenu > ul > li:hover {
  border-left: 3px solid #3dbd99;
}
#cssmenu ul li:hover > a {
  color: #3dbd99;
}
#cssmenu > ul > li:hover {
  background: #f6f6f6;
}
/* Sub Menu */
#cssmenu ul ul a:link,
#cssmenu ul ul a:visited {
  font-weight: 400;
  font-size: 14px;
}
#cssmenu ul ul {
  width: 180px;
  background: none;
  border-left: 20px solid transparent;
}
#cssmenu ul ul a {
  padding: 8px 0;
  border-bottom: 1px solid #eeeeee;
}
#cssmenu ul ul li {
  padding: 0 20px;
  background: #fff;
}
#cssmenu ul ul li:last-child {
  border-bottom: 3px solid #d7d8da;
  padding-bottom: 10px;
}
#cssmenu ul ul li:first-child {
  padding-top: 10px;
}
#cssmenu ul ul li:last-child > a {
  border-bottom: none;
}
#cssmenu ul ul li:first-child:after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  position: absolute;
  left: -20px;
  top: 13px;
  border-left: 10px solid transparent;
  border-right: 10px solid #fff;
  border-bottom: 10px solid transparent;
  border-top: 10px solid transparent;
}
<!DOCTYPE html>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

<meta charset="UTF-8">
<title>Title</title>

 Home

 Services

S1

S1.1

S1.2

S2

 Adress

 Contact

can you help me please
Thanks in advance

A: I recommend not to use visibility: hidden, but instead display:none for the submenu ( changed that in the  #cssmenu ul ul rule in my snippet below).
Apart from that, you need a CSS rule that on hover of the parent li switches the direct child ul to display: block, with this rule:
#cssmenu ul li:hover > ul {
  display: block;
}

@import url(https://fonts.googleapis.com/css?family=Lato:300,400,700);
/* Starter CSS for Flyout Menu */
#cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 0;
}
#cssmenu ul {
  position: relative;
  z-index: 597;
  float: left;
}
#cssmenu ul li {
  float: left;
  min-height: 1px;
  line-height: 1em;
  vertical-align: middle;
}
#cssmenu ul li.hover,
#cssmenu ul li:hover {
  position: relative;
  z-index: 599;
  cursor: default;
}
#cssmenu ul ul {
  margin-top: 1px;
  display: none;
  position: absolute;
  top: 1px;
  left: 99%;
  z-index: 598;
  width: 100%;
}
#cssmenu ul li:hover > ul {
  display: block;
}
#cssmenu ul ul li {
  float: none;
}
#cssmenu ul ul ul {
  top: 1px;
  left: 99%;
}
#cssmenu ul li {
  float: none;
}
#cssmenu ul ul li {
  font-weight: normal;
}
/* Custom CSS Styles */
#cssmenu {
  font-family: 'Lato', sans-serif;
  font-size: 18px;
  width: 200px;
}
#cssmenu ul a,
#cssmenu ul a:link,
#cssmenu ul a:visited {
  display: block;
  color: #848889;
  text-decoration: none;
  font-weight: 300;
}
#cssmenu > ul {
  float: none;
}
#cssmenu ul {
  background: #fff;
}
#cssmenu > ul > li {
  border-left: 3px solid #d7d8da;
}
#cssmenu > ul > li > a {
  padding: 10px 20px;
}
#cssmenu > ul > li:hover {
  border-left: 3px solid #3dbd99;
}
#cssmenu ul li:hover > a {
  color: #3dbd99;
}
#cssmenu > ul > li:hover {
  background: #f6f6f6;
}
/* Sub Menu */
#cssmenu ul ul a:link,
#cssmenu ul ul a:visited {
  font-weight: 400;
  font-size: 14px;
}
#cssmenu ul ul {
  width: 180px;
  background: none;
  border-left: 20px solid transparent;
}
#cssmenu ul ul a {
  padding: 8px 0;
  border-bottom: 1px solid #eeeeee;
}
#cssmenu ul ul li {
  padding: 0 20px;
  background: #fff;
}
#cssmenu ul ul li:last-child {
  border-bottom: 3px solid #d7d8da;
  padding-bottom: 10px;
}
#cssmenu ul ul li:first-child {
  padding-top: 10px;
}
#cssmenu ul ul li:last-child > a {
  border-bottom: none;
}
#cssmenu ul ul li:first-child:after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  position: absolute;
  left: -20px;
  top: 13px;
  border-left: 10px solid transparent;
  border-right: 10px solid #fff;
  border-bottom: 10px solid transparent;
  border-top: 10px solid transparent;
}
<!DOCTYPE html>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

<meta charset="UTF-8">
<title>Title</title>

 Home

 Services

S1

S1.1

S1.2

S2

 Adress

 Contact


text:
Q: MediaElement web Video doesn't stop buffering I m using MediaElement to play a web video. When I left the page I noticed in the Task Manager that my app was still using 10% of network and didn't drop till it finished downloading video.
I tried doing the following but no luck.
    //open link;
    mediaElement.Source = welcomeVideoURL;

    //when I leave the page OnNavigatedFrom()
    mediaElement.Stop();
    mediaElement.ClearValue(MediaElement.SourceProperty);
    mediaElement.Source = null;

Also tried to set the source to a dummy link but still no luck.
I thought that opening the Link as a Stream and use mediaElement.SetSource() could work but I haven't found anything on that...maybe I m not searching correct.
Thank you.

A: Found this MediaElementWithHttpClient in some other question in a comment made by @kiewic. I can manage the stream and download process and easily dispose it.
 HttpRandomAccessStream videoStream = await HttpRandomAccessStream.CreateAsync(new Windows.Web.Http.HttpClient(), videoUrl);
 mediaElement.SetSource(videoStream, videoStream.ContentType);


text:
Q: MEF Recomposition error I get the exception:
1) More than one export was found that matches the constraint:
    ContractName    CompositionTest.C
    RequiredTypeIdentity    CompositionTest.C
When running the program
namespace CompositionTest
{
// [Export]  // Also doesn't work
[Export(typeof(C))]
public class C
{
    //[ImportAttribute(AllowRecomposition = true)]  // also doesn't work
    [Import(AllowRecomposition = true)]
    public C PropertyC { get; set; }
}

class Program
{
    static void Main(string[] args)
    {
        // Declare a composition container.
        CompositionContainer compositionContainer = new CompositionContainer();

        compositionContainer.ComposeParts( new C() );

        compositionContainer.ComposeParts( new C() );  // exception here!
    }
}

}
What am I doing wrong?

A: The first time you call ComposeParts, a new C object is added as an export to the container. Then second time you call ComposeParts, another C object is added as an export. This creates a problem with the import because there are two possible parts for import and MEF cannot make a decision. Hence the cardinality exception.
One solution would be to change the import to:
[ImportMany(AllowRecomposition = true)]
public IEnumerable<C> PropertyC { get; set; }

Another solution is to actually use a catalog when creating the container. This is the common way to use MEF. Pretty much all the examples you can find follow this approach:
//Create a catalog. In this case, a catalog based on an already loaded assembly.
var catalog = new AssemblyCatalog(typeof(C).Assembly);
//Create a container using the catalog. Only the parts from that catalog will be used.
var compositionContainer = new CompositionContainer(catalog);

For more on catalogs you should read this article.
By the way I have never seen such an example of MEF usage before. My answer is mainly based on observations I made while debugging it.


text:
Q: how to check if a record not exist and then insert I mean that when I want to insert a record into MySQL, I first check if it exists.
This is usually used when dealing with user registration, I should check the username submitted whether or not has been registered. I do not want to use a unique index because I have a logical delete in my db.
I try to user select ... for update, but for data not exist, it doesn't work well.

A: For an example:
insert into user_table(id,user_name,deleted)
select 1,'new user name',0 from user_table where `user_name`<>'new user name' and deleted=0 limit 1;


text:
Q: What can cause IllegalMonitorStateException from inside a synchronized block? We hit an extremely surprising exception today. Inside of a synchronized block, we call wait() and it throws IllegalMonitorStateException. What can cause this?
This is happening in well-tested open source code:
http://svn.apache.org/viewvc/river/jtsk/trunk/src/com/sun/jini/jeri/internal/mux/Mux.java?view=markup#l222
We eliminated the obvious causes:

*

*are we synchronized on the right variable? Yes, it's muxLock

*is it a mutable variable? No, muxLock is final

*are we using any weird "-XX:" JVM flags that might affect monitor behavior? No, but we are launching the JVM embedded inside a C++ app via JNI.

*is this a strange JVM? No, it's Sun's 1.6.0_25 win/x64 JRE

*is this a known JVM bug? Can't find anything relevant at http://bugs.sun.com/bugdatabase
So, I'm trying to think of more far-fetched explanations.

*

*could an uncaught out-of-memory error cause the monitor state to be screwed up? We're looking at this, but we're seeing no evidence of memory errors yet.

UPDATE: (based on comment)
I've also verified from the stacktrace and breakpoint that the thread is indeed inside the synchronized block when the exception is thrown. It's not the case that some other unrelated code is emitting the exception (unless something is REALLY confusing Eclipse!)

A: The only suspicious thing I see that you are passing a reference to 'this' to some other object in your constructor. Is it possible (in fact, not unlikely) that, through weird re-ordering of things, if some other thread gets that reference to 'this' and calls the method that uses the muxlock, things can go extremely wrong.
The Java Language Specification is pretty specific about this:

An object is considered to be completely initialized when its constructor finishes. A thread that can only see a reference to an object after that object has been completely initialized is guaranteed to see the correctly initialized values for that object's final fields.

In other words, if another thread gets hold of the 'this' reference before the constructor is finished, the final field 'muxlock' might not be correctly initialized yet. In general, publishing a reference to 'this' before the constructor has finished can be pretty dangerous, especially in threaded situations.
Some potentially useful discussion about such things:
http://madpropellerhead.com/random/20100328-java-final-fields-are-not-as-final-as-you-may-think
For some older, but still useful general discussion of why publishing 'this' in a constructor is a very bad idea in general, see for instance:
http://www.ibm.com/developerworks/java/library/j-jtp0618/index.html

A: http://svn.apache.org/viewvc/river/jtsk/trunk/src/com/sun/jini/jeri/internal/mux/Mux.java?r1=1069292&r2=1135026&diff_format=h
here i can see that timeout was added lately
make sure that startTimeout is > than 0 otherwise you will wait(0) or wait(-n) this probably cause IllegalMonitorStateException
EDIT: Ok above is a disaster But lets try this :
we are in Mux constructor : http://svn.apache.org/viewvc/river/jtsk/trunk/src/com/sun/jini/jeri/internal/mux/Mux.java?view=markup
line 176  we create SocketChannelConnectionIO andd pass this  after that we break and and different thread takes over .
in constructor of SocketChannelConnectionIO defined here : http://svn.apache.org/viewvc/river/jtsk/trunk/src/com/sun/jini/jeri/internal/mux/SocketChannelConnectionIO.java?view=markup
line 112 we register to channel with the new handler().
handler recieaves something on chanel and function let say function handleReadReady is executed we synchronize on muxLock .
now we are still in constructor so object in final is still mutable !!!
let assume it changes , now we have something waiting on different muxLock
One in a million scenario
EDIT
http://svn.apache.org/viewvc/river/jtsk/trunk/src/com/sun/jini/jeri/internal/mux/Mux.java?revision=1135026&view=co
Mux(SocketChannel channel,
    int role, int initialInboundRation, int maxFragmentSize)
    throws IOException
    {
    this.role = role;
    if ((initialInboundRation & ~0x00FFFF00) != 0) {
        throw new IllegalArgumentException(
        "illegal initial inbound ration: " +
        toHexString(initialInboundRation));
    }
    this.initialInboundRation = initialInboundRation;
    this.maxFragmentSize = maxFragmentSize;

    //LINE BELOW IS CAUSING PROBLEM it passes this to SocketChannelConnectionIO
    this.connectionIO = new SocketChannelConnectionIO(this, channel);

    //Lets assume it stops here we are still in constructor
    //and we are not in synchronized block

    directBuffersUseful = true;
    }

now in constructor of SocketChannelConnectionIO
http://svn.apache.org/viewvc/river/jtsk/trunk/src/com/sun/jini/jeri/internal/mux/SocketChannelConnectionIO.java?revision=1069292&view=co
SocketChannelConnectionIO(Mux mux, SocketChannel channel)
    throws IOException
{
    super(mux);
    channel.configureBlocking(false);
    this.channel = channel;
    //Line below we are registering to the channel with mux that is still mutable
    //this is the line that actually is causing the problem move that to
    // start() and it should work
    key = selectionManager.register(channel, new Handler());
}

move this code to start() should work key = selectionManager.register(channel, new Handler()); (i am assuming start is executet when we want to start prosessing)
/**
 * Starts processing connection data.
 */
void start() throws IOException {
    key = selectionManager.register(channel, new Handler());
    key.renewInterestMask(SelectionKey.OP_READ);
}

But it would be much better not to create SocketChannelConnectionIO in the constructor of mux but maybe somewhere after that the same for second constructor creating StreamConnectionIO with this

A: The answer is in my opinion that its either a bug, or someone changed the object behind the reference despite its being final. If you can reproduce it, I recommend to set a read/write breakpoint on muxlock field to see if it is touched or not. You could check the identityhashcode of the muxlock in the first line of the synchronized block, and before waits and notifies with appropiate log entries or breakpoints. With reflection you can change final references. Quote from http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Field.html:
"If the underlying field is final, the method throws an IllegalAccessException unless setAccessible(true) has succeeded for this field and this field is non-static. Setting a final field in this way is meaningful only during deserialization or reconstruction of instances of classes with blank final fields, before they are made available for access by other parts of a program. Use in any other context may have unpredictable effects, including cases in which other parts of a program continue to use the original value of this field."
Maybe its a bug in eclispe, and during debugging it somehow changes the field. Is it reproducable outside eclispe as well? Put a printstractrace in catch and see what happens.

A: Member variables are not as final as one would hope to. You should put the synchronized object into a final local variable, first. This does not explain why the member variable is altered, but if it fixes the problem you at least know that the member variable is really modified.


text:
Q: CMake/CMakeLists.txt: how to list files explicitly (to avoid the use of GLOB) I am a newbie with CMake. Today, I use in my Android/Java/JNI/CMake project, the following code in my CMakeLists.txt file:
include_directories(lib1)
file(GLOB_RECURSE LIB1_SOURCES
"bund.cc"
"bund.h"
"bund_io.cc"
"bund_io.h"
"cam.cc"
"cam.h"
"defines.h"
)

include_directories(lib2)
file(GLOB_RECURSE LIB2_SOURCES
"allocator.h"
"memory.h"
"arguments.cc"
"arguments.h"
"defines.h"
)

add_library(native-lib SHARED ${LIB1_SOURCES} ${LIB2_SOURCES} native-lib.cpp)
find_library(log-lib log)
target_link_libraries(native-lib ${log-lib})

As CMake documentation 'do not recommend using GLOB to collect a list of source files from your source tree', I wonder what is the recommended way to replace this code in my CMakeLists.txt. Note that I have a 'defines.h' in both lib1 and lib2 directory, maybe some specific precautions have to be taken.
My project structure is :
-cpp (with mib-native.cpp and CMakeLists.txt inside)
--lib1 (with .h and .cc files mixed inside)
--lib2 (with .h and .cc files mixed inside)

I would be grateful if you could provide the detailed code I have to put in my Android project.

A: Assuming you have some dependencies that are shared between libraries, why not create a separate dependency and use it in the two other targets?
Also, explicit source specification is probably the best practice out there. In big projects, globs are discouraged and rather smaller targets are created and then added to bigger ones. In your case I would create two libraries (as you do) but explicitly list sources.
I would do it like this: (first try to split code into directories for the libraries, best create a folder for shared headers)
# put all finds in one place
find_library(LOG_LIB log)

add_libary(LIB_1 STATIC
           ${CMAKE_CURRENT_LIST_DIR}/"bund.cc"
           ${CMAKE_CURRENT_LIST_DIR}/"bund_io.cc"
           ${CMAKE_CURRENT_LIST_DIR}/"cam.cc")

target_include_directories(LIB_1
                           ${CMAKE_CURRENT_SOURCE_DIR}/lib1_includes
                           ${CMAKE_CURRENT_SOURCE_DIR}/common_includes)

add_libary(LIB_2 STATIC
           ${CMAKE_CURRENT_LIST_DIR}/"arguments.cc")

target_include_directories(LIB_2
                           ${CMAKE_CURRENT_SOURCE_DIR}/lib2_includes
                           ${CMAKE_CURRENT_SOURCE_DIR}/common_includes)

add_library(NATIVE_LIB SHARED
            ${CMAKE_CURRENT_LIST_DIR}/native-lib.cpp)

target_link_libraries(NATIVE_LIB
                      PRIVATE
                      ${LIB_1} ${LIB_2} ${LOG_LIB}) # I also prefer to use upper case for targets, otherwise you can have nasty to spot linking errors

Another idea is to create the separate directory trees for the libraries and create CMakeFiles.txt for them and just use them as targets. Look at how it is done in here and the accompanying blog post.
You will also learn meaning of the PRIVATE keyword name there (in short it does not expose the symbols from linked to libraries outside the library you created.


text:
Q: Sales Cloud EE license We have a few users with Sales Cloud EE users. We are looking to potentially switch a few of the users to chatter users. Can we swap that user type and go from Sales Cloud EE --> Chatter plus or chatter free or would we need to deactivate the sales cloud user and then create a new profile?

A: You can't "downgrade" users, so you will need to create new users for these users.


text:
Q: R select data frame rows using NA in search pattern I wish to select row indexes from a source data frame given search criteria in a search pattern data frame. For simplicity and clarity, the colnames in the search pattern data frame must be a subset of those in the source data frame. But here is the kicker - both data frames can include NA's and I need to use those NA's in the search criteria so excluding those records beforehand will not fulfill my goal.
I'm including a working solution to my challenge but am interested to see if anyone has suggestions for improvements. I've done it using just base R, which is my preference, but if anyone has a quick that's already done in this package tip, I'd be grateful.
In my real situation my search pattern data frame can comprise 20k records and the data frame being searched is >500k records. Under this situation the run time can be >20 mins, which is unfortunate. thanks
selectRows <- function(df.pattern, df.x){
    output <- lapply(1:nrow(df.pattern), function(i){
        x <- df.pattern[i,]

        res <- lapply(colnames(x), function(col){
            if(is.na(x[,col])){
                which(is.na(df.x[,col]))
            }else{
                grep(x[,col], df.x[,col])
            }
        })

    index.select <- Reduce(intersect, res)
    index.select
    })#END lapply

    output
}#END selectRows

#df.x is the data frame to search
df.x <- expand.grid(a=1:10, b=letters, c=LETTERS, stringsAsFactors = F)
#replace some cells with NA
for(i in 1:3) df.x[i,i ] <- NA
head(df.x)

#for simplicity the search pattern df is taken from the original df, using rows with NA's and complete cases too
df.pattern <- df.x[c(22,1:4,10),c(2,1,3)]
row.names(df.pattern) <- NULL
df.pattern

results <- selectRows(df.pattern, df.x)
unlist(results)

A: We may use inner_join.  Create a column of row sequence, then join with the 'df.pattern' and pull the sequence vector
library(dplyr)
df.x %>%
    mutate(rn = row_number()) %>%
    inner_join(df.pattern, .) %>%
    pull(rn)
#[1] 22  1  2  3  4 10

Or paste the rows to a single string, create a logical vector with %in%, get the positions with which
which(do.call(paste, df.x) %in% do.call(paste, df.pattern[names(df.x)]))
#[1]  1  2  3  4 10 22

If the order needs to be based on the second dataset and the second data doesn't need to consider duplicate matches, use match
match(do.call(paste, df.pattern[names(df.x)]), do.call(paste, df.x))
[1] 22  1  2  3  4 10

Or a use a data.table join
library(data.table)
setDT(df.x)[, rn := .I][df.pattern, rn, on = names(df.pattern)]
#[1] 22  1  2  3  4 10


text:
Q: Why am I getting a React hook and void return type error when I call a sub-function inside useInterval In Javascript, I understand you can define sub-functional components to be used in a functional component inside of other function calls.
In the following code,
I'm defining a functional component called GetProjectScans on line 5 with array and boolean parameters. Then, I'm calling GetProjectScans on line 9 in useInterval with the variables declared on lines 4 (projectScans is an IProjectScan[] object and isProjectScansFetchComplete is a boolean):
1 const ExecutionsPage: React.FC = () => {
2    let user:string|null = sessionStorage.getItem('user')
3    const UPDATE_TABLE_TIMER: number = 30000; // Time (ms) until we call the API again to update the scans table
4    let [projectScans, isProjectScansFetchComplete] = useFetchProjectScansByUser(user)
5    const GetProjectScans = (projectScans: IProjectScan[], isProjectScansFetchComplete: boolean) => {
6        [projectScans, isProjectScansFetchComplete] = useFetchProjectScansByUser(user);
7    };
8    // @ts-ignore
9    useInterval(GetProjectScans(projectScans,isProjectScansFetchComplete), UPDATE_TABLE_TIMER)

Heres the definition of the useFetchProjectScansByUser() on line 4. Notice its return type:
export const useFetchProjectScansByUser = (user: string|null): [IProjectScan[], boolean] => {
    const [projectScans, setProjectScans] = useState<IProjectScan[]>([]);
    //update here
    const [isProjectScansFetchComplete, setIsProjectScansFetchComplete] = useState<boolean>(false);
    const {enqueueSnackbar, } = useSnackbar();

    useEffect(() => {
        ...
    return [projectScans, isProjectScansFetchComplete];
}

Why am I getting "TypeError: savedCallback.current is not a function" from this code? I understand this isn't an MRE, but I don't feel the need to make it one because I think my issue has to do with one of the following:

*

*do i need to somehow declare the variable types of projectScans and isProjectScansFetchComplete on line 4

*why does it say these variables aren't used inside GetProjectScans

*why is it making me use @ts-ignore before the useInterval call on line 9


text:
Q: How to calculate max iterations needed to equally increase row of numbers per some value each iteration? I don't know whether title describes the main idea of my question, so apologize me for it.
I have 6 numbers whose values can vary from 0 to 100, but initial value cannot be more than 35. As example, here is my number list:

20, 31, 15, 7, 18, 29

In one iteration we can distribute some value (5, 7, 10, 15 or so) among these numbers. Let it be 15. And each number must be increased at least once per iteration. So one iteration may look like:

20 + 3 => 23
31 + 2 => 33
15 + 3 => 18
7 + 5 => 12
18 + 1 => 19
29 + 1 => 30

The question is: how to calculate the max amount of iterations for any number row with constant distribution value per iteration? One should know that iterations must stop once one number reaches value of 100.
What math field should I learn to get more info on alike questions?

A: You start with $a_1, \ldots, a_n$, have to distribute $d\ge n$ in each round and stop at $m>\max a_i$.
Then the maximal number of rounds is bounded by two effects:

*

*The maximal value grows by at least one per round, so it reaches $m$ after at most $m-\max a_i$ rounds.

*The total grows by $d$ each round, so you exceed $n\cdot (m-1)$ after at most $\left\lceil\frac{n(m-1)+1-\sum a_i}{d}\right\rceil$ rounds.

Interestingly, these two conditions are all there is, i.e. the maximal number of rounds is indeed
$$ \min\left\{m-\max a_i,\left\lceil\frac{n(m-1)+1-\sum a_i}{d}\right\rceil\right\}.$$
This can be achieved by (in each round) distributing one point to each term and then repeatedly increase the smallest term until all has been distributed.
The field of math this belongs two would be combinatorics.


text:
Q: How to select between 2 data in SQL table? I have 2 tables like this:
Table 1
-------
ID
score

Table 2
-------
ID
score_from
score_to

How do I get ID from Table 2, if I have score='12' in Table1 based on score_from and score_to in Table 2 ?
Contents of Table1:
----------------------
ID          |Score   |
----------------------
1           |12      |
----------------------
2           |40      |
----------------------

Contents of Table2:
------------------------------
ID       |score_from|score_to|
------------------------------
1        |0         |20      |
------------------------------
2        |21        |40      |
------------------------------

If I have score='12' from table1, how can I write a query to get ID='1' in table2?

A: Try this one,
SELECT a.`ID`, a.`Score`, b.`ID`, b.`score_from`, b.`score_to`
FROM   table1 a, table2 b
WHERE  (a.score BETWEEN b.score_from AND b.score_to) AND
        (a.score = 12)

SQLFiddle Demo
or if you want only the ID
SELECT b.`ID`
FROM   table1 a, table2 b
WHERE  (a.score BETWEEN b.score_from AND b.score_to) AND
        (a.score = 12)

SQLFiddle Demo

A: select t2.id from table t1 ,table t2
where t1.score between t2.score_from and t2.score_to;


text:
Q: Let $V$ be the space of $n\times n$ matrices, $B$ a fix matrix, then what is matrix of operator $L_B(A) = BA$ on $V$? I guess the answer is the $n^2\times n^2$ block matrix $diag(B, B, ..., B)$. Where shall I start to prove it? I tried to find the matrix by figuring out the image of the standard basis of $V$, but it gets complicated.
Any idea would be appreciated.
One more question

$\bullet$ Any idea about how to compute $det(L_B)$? I am sure that the answer is $det(B)^n$ if $B$ is invertible.

I found the answer of question $\bullet$ here :)

A: If we use a standard basis in which the matrix
$$
A=\begin{pmatrix}
a_{11}&a_{12}&\cdots &a_{1n}\\
a_{21}&a_{22}&\cdots &a_{2n}\\
\cdots\\
a_{n1}&a_{n2}&\cdots &a_{nn}\\
\end{pmatrix}
$$
is represented as a vector of components
$$
A=\begin{pmatrix}
a_{11}\\\cdot\\\cdot \\a_{1n}\\
a_{21}\\\cdot\\\cdot \\a_{2n}\\
\cdots\\\cdots\\
a_{n1}\\\cdot \\\cdot\\a_{nn}\\
\end{pmatrix}
$$
than the matrix that represents the transformation $L_B(A)=BA$ is a block matrix of the form
$$
\begin{pmatrix}
B_{11}&B_{12}&\cdots &B_{1n}\\
B_{21}&B_{22}&\cdots &B_{2n}\\
\cdots\\
B_{n1}&B_{n2}&\cdots &B_{nn}\\
\end{pmatrix}
$$
where $B_{ij}$ is a diagonal matrix with as diagonal  value the element $b_{ij}$ of the matrix $B$
You can prove this result starting from the case $n=2$ and using induction.

A: Hint If you use the standard basis $E_{ij}$m, then
$$L_B(E_{ij})=BE_{ij}=\begin{bmatrix} 0&0 &...& b_{1i} & 0 & ..0 \\
0&0 &...& b_{1i} & 0 & ..&0 \\
0&0 &...& b_{2i} & 0 & ..&0 \\
...& ...&...&...&...&...&...\\
0&0 &...& b_{ni} & 0 & ..0 \\
\end{bmatrix}$$
where the non-zero elements appear in column $j$. Write this as a linear combination of elementary matrices.


text:
Q: Regex expression to update the div's style properties - width & height Sample string:-

            hello from simple text

            {[C-FULLNAME:LC]}

            asd

I want to pull the ParentDIV elements's style properties i.e. width and height. Then I want to update the width and height css properties with my values. The order of height and width properties in the style tag of ParentDIV may get changed also.
Please suggest the regex. I would be making this code changes in C#.net.
Regex expression can build with the help of online tool http://www.gskinner.com/RegExr/.


text:
Q: Getting users and groups form WLS to Custom Page I have configured users and groups in security realm using SQL Authenticator in WLS 12c.
Eg: ADMIN is a user and MANAGER is group in WLS and I have mapped ADMIN user to MANAGER group.
when I login using the wls user (ie.ADMIN), it gets navigate to corresponding custom page and I can get user using following EL #{securityContext.userName}
    or java code:
ADFContext adfCtx = ADFContext.getCurrent();
SecurityContext secCntx = adfCtx.getSecurityContext();
String user = secCntx.getUserPrincipal().getName();
String userName = secCntx.getUserName();
String[]  Roles = secCntx.getUserRoles();

Similarly I want capture the group for the currently logging user ie. ADMIN and output should be MANAGER.
I used EL as #{securityContext.userRoles} for getting the role and kindly help me to get the user group during login time.
Expected OUTPUT should be MANAGER and my output is NULL.

A: You're getting a NULL output because the securityContext doesnt contain an object called "userRoles" in ADF Bindings.
The securityContext el expression contains the following value :

*

*Authenticated

*regionViewable

*taskflowViewable

*userGrantedPermission

*userGrantedRessource

*userInAllRoles

*userInRole

*userName

Since you seems to know all the expected roles you can display MANAGER doing something like :
<af:outputText value="{securityContext.userInAllRoles['MANAGER']?'MANAGER':'NOT MANAGER'}" id="ot_1"/>

or using the rendered attribute :
<af:outputText rendered="{securityContext.userInAllRoles['MANAGER']}" value="MANAGER" id="ot_1"/>
<af:outputText rendered="{securityContext.userInAllRoles['EMPLOYEE']}" value="EMPLOYEE" id="ot_2"/>

...

Side note :

*

*userInAllRoles['ROLE1','ROLE2'] return true if the user have ROLE1 and ROLE2

*userInRole['ROLE1','ROLE2'] return true if the user have ROLE1 or ROLE2


text:
Q: Find files, rename in place unix bash This should be relatively trivial but I have been trying for some time without much luck.
I have a directory, with many sub-directories, each with their own structure and files.
I am looking to find all .java files within any directory under the working directory, and rename them to a particular name.
For example, I would like to name all of the java files test.java.
If the directory structure is a follows:
./files/abc/src/abc.java
./files/eee/src/foo.java
./files/roo/src/jam.java

I want to simply rename to:
./files/abc/src/test.java
./files/eee/src/test.java
./files/roo/src/test.java

Part of my problem is that the paths may have spaces in them.
I don't need to worry about renaming classes or anything inside the files, just the file names in place.
If there is more than one .java file in a directory, I don't mind if it is overwritten, or a prompt is given, to choose what to do (either is OK, it is unlikely that there are more than one in each directory.
What I have tried:
I have looked into mv and find; but, when I pipe them together, I seem to be doing it wrong. I want to make sure to keep the files in their current location and rename, and not move.

A: If your find command (like mine) doesn't support -execdir, try the following:
find . -name "*.java" -exec bash -c 'mv "{}" "$(dirname "{}")"/test.java' \;

A: The GNU version of find has an -execdir action which changes directory to wherever the file is.
find . -name '*.java' -execdir mv {} test.java \;

If your version of find doesn't support -execdir then you can get the job done with:
find . -name '*.java' -exec bash -c 'mv "$1" "${1%/*}"/test.java' -- {} \;


text:
Q: ldap_search fails when using extensible match in filter My ldap_search is failing with a protocol error if I use an extensible match in the filters. Here's the relevant code:
$conn = ldap_connect(SERVER, PORT);
ldap_bind($conn, LDAP_USER, LDAP_PW);

$filter = "(&(whatever=*)(uid=something)(!(ou:dn:=other)))";
$s = ldap_search($conn, BASE_DN, $filter);
if (ldap_errno($conn) != 0) {
    echo "Error: " + ldap_error($conn);
    exit();
}
$res = ldap_get_entries($conn, $s);
var_dump($res);
exit();

if I use instead:
$filter = "(&(whatever=*)(uid=something))";

it works OK. If I use ldapsearch from the command line with the extensible match part it works fine, so it's not a ldap server version problem.
I also tried to include
ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);

and
ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 2);

and none worked. I'm using PHP 7.0.28.
Anyone has any idea what's happening ?
Edit
Responding to @heiglandreas:
user@mycomp:~$ ldapsearch -VV
ldapsearch: @(#) $OpenLDAP: ldapsearch  (Ubuntu) (May 30 2017 19:20:53) $
    buildd@lgw01-18:/build/openldap-JXEADB/openldap-2.4.42+dfsg/debian/build/clients/tools
    (LDAP library: OpenLDAP 20442)

output from php_info:
LDAP Support    enabled
RCS Version     $Id: cec20da3ccaa477662b8667bef021291fb5bf6f4 $
Total Links     0/unlimited
API Version     3001
Vendor Name     OpenLDAP
Vendor Version  20442
SASL Support    Enabled

Directive       Local Value     Master Value
ldap.max_links  Unlimited       Unlimited

Responding to jwilleke:
vendorName    389 Project
vendorVersion 389-Directory/1.2.11.15 B2016.194.1549

but I'm sure it supports the filter as ldapseach with extensible match from command line works fine.


text:
Q: Using list view in fragments I have a drawer layout fragment (in the main activity) which shows an expandable list, when i click on a sub-item of the expanded item, a popup window appears. This pop up window with custom layout contains text views, a list view and 2 buttons.
I gave the list view the id: android:id="@android:id/list" and return a null from the ViewGroup in the onCreateView function as follow:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_settings, null);

and make the class extends Fragment not ListFragment
I did the previous 3 steps to avoid "Content has view with id attribute 'android.R.id.list' that is not a ListView class in ListFragment" error
but I still have NullPointerException error pointing to
failListView.setAdapter(adapter);

when click on the "Failsafe Setup" item
I've seen some suggestions but all of them don't get useful, like
 rootView .findViewById?() not getActivity().findViewById() ==> I've already do it.
or declaring the list view before the onCreateView function.
I really get annoyed from this, I've tried a lot of suggestions that get work with others.
even though, I've tried to add this snippet to onActivityCreated function
  TestFailsafeAdapter adapter = new TestFailsafeAdapter(getActivity().getApplicationContext(),
      R.layout.dialog,R.id.textView1,
      getResources().getStringArray(R.array.failsafe_list));
    failListView.setAdapter(adapter);

Any help will be appreciated.
The following is the custom layout used in the popup window (dialog.xml):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:id="@+id/headers_container"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:layout_marginTop="5dp"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:text="FailSafe"
            android:textSize="16sp" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="35dp"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/textView1"
            android:text="On"
            android:textSize="16sp" />

    </LinearLayout>

     <ListView
        android:id="@android:id/list"
        android:layout_width="wrap_content"
        android:layout_height="350dp"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/headers_container"
        android:background="#ffeeaa" >
    </ListView>

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_below="@android:id/list"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/dialogButtonReset"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="5dp"
            android:layout_marginTop="5dp"
            android:text="Reset" />

        <Button
            android:id="@+id/dialogButtonSend"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="5dp"
            android:layout_marginTop="5dp"
            android:text="Send" />
    </LinearLayout>

</RelativeLayout>

The following is the fragment that has the expandable list of the drawable layout (SettingsFragment.java):
public class SettingsFragment extends Fragment {

ExpandableListAdapter listAdapter;
ExpandableListView expListView;
List<String> listDataHeader;
HashMap<String, List<String>> listDataChild;

int position = 0;
ListView failListView = null;

public SettingsFragment() {
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // View rootView = inflater.inflate(R.layout.fragment_settings, container, false);
    View rootView = inflater.inflate(R.layout.fragment_settings, null);

     failListView = (ListView) rootView.findViewById(android.R.id.list);

  TestFailsafeAdapter adapter = new TestFailsafeAdapter(getActivity().getApplicationContext(),
  R.layout.dialog,R.id.textView1, getResources().getStringArray(R.array.failsafe_list));
  failListView.setAdapter(adapter);

     return rootView;
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onActivityCreated(savedInstanceState);

    // get the listview
    expListView = (ExpandableListView) getActivity().findViewById(R.id.lvExp);

    // preparing list data
    prepareListData();

    listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild);

    // setting list adapter
    expListView.setAdapter(listAdapter);

    // Listview Group click listener
    expListView.setOnGroupClickListener(new OnGroupClickListener() {

        public boolean onGroupClick(ExpandableListView parent, View v,
                int groupPosition, long id) {
            return false;
        }
    });

    // Listview Group expanded listener
    expListView.setOnGroupExpandListener(new OnGroupExpandListener() {

        @Override
        public void onGroupExpand(int groupPosition) {
            Toast.makeText(getActivity(),
                    listDataHeader.get(groupPosition) + " Expanded",
                    Toast.LENGTH_SHORT).show();
        }
    });

    // Listview Group collasped listener
    expListView.setOnGroupCollapseListener(new OnGroupCollapseListener() {

        @Override
        public void onGroupCollapse(int groupPosition) {
            Toast.makeText(getActivity(),
                    listDataHeader.get(groupPosition) + " Collapsed",
                    Toast.LENGTH_SHORT).show();

        }
    });

    // Listview on child click listener
    expListView.setOnChildClickListener(new OnChildClickListener() {

        @Override
        public boolean onChildClick(ExpandableListView parent, View v,
                final int groupPosition, final int childPosition, long id) {
            // TODO Auto-generated method stub

            if(listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition).equals("USB") ){

                FragmentManager manager = getFragmentManager();

                /** Instantiating the DialogFragment class */
                AlertDialogRadio alert = new AlertDialogRadio();

                /** Creating a bundle object to store the selected item's index */
                Bundle b  = new Bundle();

                /** Storing the selected item's index in the bundle object */
                b.putInt("position", position);

                /** Setting the bundle object to the dialog fragment object */
                alert.setArguments(b);

                /** Creating the dialog fragment object, which will in turn open the alert dialog window */
                alert.show(manager, "alert_dialog_radio");

            }

            if(listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition).equals("Failsafe Setup") ){

                Toast.makeText(getActivity()," Failsafe Setup",Toast.LENGTH_SHORT).show();

                // create a Dialog component
                final Dialog dialog = new Dialog(getActivity());

                //tell the Dialog to use the dialog.xml as it's layout description
                dialog.setContentView(R.layout.dialog);
                dialog.setTitle("Failsafe Setup");

                ListView failListView = (ListView) dialog.findViewById(android.R.id.list);
                Button dialogButtonReset = (Button) dialog.findViewById(R.id.dialogButtonReset);
                Button dialogButtonSend = (Button) dialog.findViewById(R.id.dialogButtonSend);

                dialogButtonReset.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Toast.makeText(getActivity()," Failsafe Reset",Toast.LENGTH_SHORT).show();

                    }
                });

                dialogButtonSend.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Toast.makeText(getActivity()," Failsafe Send",Toast.LENGTH_SHORT).show();
                    }
                });

                dialog.show();

            }

            return false;
        } // end of OnClickChild method
    });

}

private void prepareListData() {
    listDataHeader = new ArrayList<String>();

    listDataChild = new HashMap<String, List<String>>();

  // Adding child data
  listDataHeader.add("Connection");
  listDataHeader.add("Mission Limits");
  listDataHeader.add("Compass Calibration");
  listDataHeader.add("Sensor Calibration");
  listDataHeader.add("Failsafe");

 // Adding child data
  List<String> Connection = new ArrayList<String>();
  Connection.add("USB");
  Connection.add("Wi-Fi");

  List<String> MissionLimits = new ArrayList<String>();
  List<String> CompassCalibration = new ArrayList<String>();
  List<String> SensorCalibration = new ArrayList<String>();

  List<String> Failsafe = new ArrayList<String>();
  Failsafe.add("Failsafe Setup");

  listDataChild.put(listDataHeader.get(0), Connection); // Header, Child data
  listDataChild.put(listDataHeader.get(1), MissionLimits);
  listDataChild.put(listDataHeader.get(2), CompassCalibration);
  listDataChild.put(listDataHeader.get(3), SensorCalibration);
  listDataChild.put(listDataHeader.get(4), Failsafe);

}

}

A: NPE here:
failListView.setAdapter(adapter);

Because ListView with android:id/list id is inside dialog.xml layout which is Dialog layout instead of in fragment_settings.xml which is  SettingsFragment Fragment layout.
So, which using context or object of Dialog it's not possible to access ListView in onCreateView


text:
Q: Error "string indices must be integer" when selecting yahoo finance stock data with "start" and "end" dates I want to create a simple script that pulls stock data from yahoo finance with pandas_datareader package:
from pandas_datareader import data

stocks = data.DataReader('MSFT', 'yahoo', start='2020-01-14', end='2023-01-14')

but the code gets me "string indices must be integers" TypeError message
TypeError                                 Traceback (most recent call last)
Cell In[1], line 3
      1 from pandas_datareader import data
----> 3 stocks = data.DataReader('MSFT', 'yahoo', start='2020-01-14', end='2023-01-14')

File c:\Users\der_L\anaconda3\envs\py39\lib\site-packages\pandas\util\_decorators.py:211, in deprecate_kwarg.<locals>._deprecate_kwarg.<locals>.wrapper(*args, **kwargs)
    209     else:
    210         kwargs[new_arg_name] = new_arg_value
--> 211 return func(*args, **kwargs)

File c:\Users\der_L\anaconda3\envs\py39\lib\site-packages\pandas_datareader\data.py:379, in DataReader(name, data_source, start, end, retry_count, pause, session, api_key)
    367     raise NotImplementedError(msg)
    369 if data_source == "yahoo":
    370     return YahooDailyReader(
    371         symbols=name,
    372         start=start,
    373         end=end,
    374         adjust_price=False,
    375         chunksize=25,
    376         retry_count=retry_count,
    377         pause=pause,
    378         session=session,
--> 379     ).read()
    381 elif data_source == "iex":
...
--> 153     data = j["context"]["dispatcher"]["stores"]["HistoricalPriceStore"]
    154 except KeyError:
    155     msg = "No data fetched for symbol {} using {}"

TypeError: string indices must be integers

The script is almost the same as many seen on the web but I can't understand what's wrong with it.

A: You are using strings for the start and end dates.  Use:
import datetime

start_date = datetime.datetime(2020, 1, 14)
end_date = datetime.datetime(2023, 1, 14)

Then use these in the DataReader call

A: It looks like currently there is a change that is not updated on pandas-datareader yet. The bug report can be found here. As a workaround you can use yfinance package as shown below. For this to work you should install yfinance package with pip install yfinance.
Then, below modified code should set everything going.
from pandas_datareader import data
import yfinance as yfin

yfin.pdr_override()

stocks = data.get_data_yahoo('MSFT', start='2020-01-14', end='2023-01-14')


text:
Q: Destroy shapes on form close Currently when i click on a button it will create some shapes on a new form.  Once i close the new form how can i destroy the shapes it made.
I can add more info if needed but was hopeing there was a simple way to destroy all TMachine instances when the form closed.
TMachine is a TShape Class
procedure TFLayout1.GetClick(Sender: TObject);
var
  azone: string;
  adept: string;
  machine : TMachine;
begin
  fdb.count := 0;  //keeps track of number of machines in zone
  azone := MyDataModule.fDB.GetZone(Name);    //gets name of zone
  adept := TButton(Sender).Name;       //gets name of dept
  fdeptlayout.ListBox1.Clear;

  fdeptlayout.show;
  with fdeptlayout.ADOQuery1 do
    begin
         sql.Clear;
         sql.BeginUpdate;
         sql.Add('SELECT');
         sql.Add(' *');
         sql.Add('FROM');
         sql.Add(' `MList`');
         sql.Add('WHERE `Zone` = :myzone ');
         sql.Add(' AND `Dept` = :mydept');
         sql.EndUpdate;

         parameters.ParamByName('myzone').Value := azone;
         parameters.ParamByName('mydept').Value := adept;
         open;
    end;

  //gets number of machines in total
  while not fdeptlayout.ADOQuery1.Eof do
    begin
      fdb.count := fdb.count+1;
      fdeptlayout.ADOQuery1.Next;
    end;

  //restarts back at first query
  fdeptlayout.ADOQuery1.First;

   //clears the last x value
   fdb.LastX :=0;

  //creates the shape
  while not fdeptlayout.ADOQuery1.Eof do
    begin
        machine := MachineShape.TMachine.Create(self);
        machine.Parent := fdeptlayout;
        machine.PlaceShape(44,44,'CM402','first','123/33/123');
        fdeptlayout.ListBox1.Items.Add(fdeptlayout.ADOQuery1.FieldByName('Name').AsString);
        fdeptlayout.ADOQuery1.Next;
    end;
end;

TMachine Class
unit MachineShape;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, extctrls,myDataModule,Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type

TMachine = class(TShape)
  private
    { Private declarations }
  public
    { Public declarations }
    procedure PlaceShape(sizeW,sizeH :integer; name, order,asset : string);
  end;
implementation

    Procedure TMachine.PlaceShape(sizeW,sizeH :integer; name, order,asset : string);
    begin
       self.width :=  sizeW;
       self.height := sizeH;
       self.top := 136;
       self.left := MyDataModule.fDB.LastX +2;//set left
       MyDataModule.fDB.lastx := left + sizeW;
       showmessage(inttostr(mydatamodule.fDB.LastX));
    end;

end.

FDeptLayout
unit DeptLayout;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls,mydatamodule, Vcl.Forms, Vcl.Dialogs, Data.DB, Data.Win.ADODB, Vcl.StdCtrls,
  Vcl.ExtCtrls;

type
  TfDeptLayout = class(TForm)
    ADOQuery1: TADOQuery;
    ListBox1: TListBox;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fDeptLayout: TfDeptLayout;

implementation

{$R *.dfm}

procedure TfDeptLayout.FormClose(Sender: TObject; var Action: TCloseAction);
begin

end;

end.

A: The shown code is taking advantage of the VCL ownership model and the form will free it for you, as you just pass the form itself as the owner of your components when you create it:
machine := MachineShape.TMachine.Create(self);

as this is called from the TFLayout1 class, when the particular instance of the form is destroying itself, it will free all the owned components.
For a little more info, you can read the article: Owner vs. Parent in Delphi.
Edit
From comments, it resulted you create the TMachine instances on a class different of the form on which you show it, and you don't destroy the form instance when you close it, so, you can reach what you want making this changes:

*

*Make the form in which the shapes are shown the owner, changing your code to create them to this:
//don't use self, now the parent is the instance referenced by fdeptlayout
machine := MachineShape.TMachine.Create(fdeptlayout);

*On your Tfdeptlayout class, add a OnClose handler with this code:
begin
  for I := ComponentCount - 1 downto 0 do
    if Components[I] is TMachine then
      Components[I].Free;
end;

That said, you really have to read the documentation and referenced articles to gain some understanding of what's going on behind the scenes in your Delphi application.

A: You are assigning an Owner to your TMachine objects.  The shapes will be freed automatically when the Owner itself is freed.
Assuming TFLayout1 is your Form class, then by default it will not be freed automatically when it is closed.  A closed Form is hidden by default so you can re-show when needed.  To actually free it on close, you have to either set the Action parameter in the TForm.OnClose event to caFree, or call TForm.Free() directly sometime after the form is closed (such as if you are displaying the Form with ShowModal(), then you can call Free() after ShowModal() exits).
If you want to free the shapes yourself without relying on the behavior of an Owner, then set the Owner to nil when you create the shapes, and store your TMachine pointers in a TList that you can loop through when needed to free each shape, or a TObjectList with its OwnsObjects property set to true that you can Clear() when needed.  Such as in the Form's OnClose event.


text:
Q: event "if" and click enough 2 buttons i have two button is btn_turn1 and btn_turn2 , i want when user click Enough btn_turn1 and btn_turn2 after event "if" will printf to screen at txt_turn but it just printf "0", help me

A: First of all JButton in swing can not be selected. it is a button, it can be clicked, entered, pressed, etc.
it is hard to understand what you are asking for, but i assume you are trying to count clicks from 2 Jbuttons and have to display it in Jtextfield. most simple and easy approach is next.
public class Cit extends JPanel implements ActionListener {

JButton btn_dahn1;
JButton btn_dahn2;
JTextField textField;
static  int step ;

public Cit(){
    btn_dahn1 = new JButton("Button1");
    btn_dahn1.addActionListener(this);
    btn_dahn2 = new JButton("Button2");
    btn_dahn2.addActionListener(this);
    textField = new JTextField();

    btn_dahn1.setPreferredSize(new Dimension(100,30));
    btn_dahn1.setMaximumSize(new Dimension(100,30));
    btn_dahn2.setPreferredSize(new Dimension(100,30));
    btn_dahn2.setMaximumSize(new Dimension(100,30));
    textField.setMaximumSize(new Dimension(100,30));
    textField.setMaximumSize(new Dimension(100,30));

    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    setPreferredSize(new Dimension(300, 30));

    add(btn_dahn1);
    add(btn_dahn2);
    add(textField);
}

you can add Cit class to frame or dialog or whatever you use, then click button1 and button2, jtextfield will display the steps.
if you are not familiar how to do that. look at next code part.
public static void main(String[] args) {
    JFrame frame = new JFrame();
    Cit cit = new Cit();
    frame.getContentPane().add(cit);
    frame.setVisible(true);
    frame.pack();
}


text:
Q: Does Eclipse ship ant with its own distribution? First time using Apache Ant (I'm excited and overwhelmed at the same time!) for automating a Java app.
I did not go to the ant website and download ant directly.  Rather, I'm using the standard plugin that ships with Eclipse.  From Eclipse, I can run test build.xml projects perfectly.  But when I go to run ant directly off the command-line, Windows doesn't recognize it as a recognized command.
This leads me to believe that I either do not have ant installed, or I have not configured it properly (at all). If it's not installed, then why do these build.xml scripts work when I fire them inside of Eclipse?  Does Eclipse ship with its own distrib of ant that isn't accessible from the cmd line?
And if it's just a config issue, what do I need to do in order to get ant to run a buildscript of my own flavor?
I want to start using Apache Ivy and in order to run the demos I first need ant up and running from the command line.
Thanks for any help or insight :-)

A:
Does Eclipse ship with its own distrib of ant that isn't accessible from the cmd line?

Essentially, yes. Eclipse bundles the core Ant runtime plus its own extensions and integration, but it's private to the Eclipse installation.
If you want to run the builds from outside of Eclipse, you need to download and install the full distribution of Ant.


text:
Q: Getting an EntityCollection to talk to the database I believe I have found what I want in terms of a main class for operations in Entity, but do not know how exactly to wire it up to the database, and MSDN is precious short on documentation (Google is even less useful).
Again, pardon my ignorance, as I am new to this, and only recently coming up to speed, but how would I get this to connect or reflect this change with the database? I am just not seeing a path between this, and say DbContext. Do I craft a query by hand? Is there some special class I am missing that provides some functionality I've been missing over the last three days that I've been trying to coax this framework into doing just anything minimally useful? Thanks to anyone who accepts this arduous task.
EntityCollection<T> newCollection = new EntityCollection<T>();
newCollection.Add(objectValue);

I mean, is EntityCollection just a List / Array for Entities? Or does it have some back-end hooks to the database? Can it perform updates / deletes when its methods are called, and are these magical in nature, or is there some prep work that makes the magic work?

A: As I understand, this class behaves just like the List<T> class - i.e. it's an in-memory collection.
Look at this answer: ObjectSet.AddObject() vs. EntityCollection.Add()
But if you'll look at the MSDN documentation about its Add method so you'll see that it could be related to the ObjectContext and eventually to the data-source(Database):

The Add method adds an object to an EntityCollection and
  creates a relationship between the two objects. When the source object
  is attached to an ObjectContext instance, the Add method also adds the
  object to the ObjectContext. This operation is translated into an
  insert operation in the data source when SaveChanges is called. For
  more information, see Adding, Modifying, and Deleting Objects (Entity
  Framework).


text:
Q: Program doesnt work on other laptops which is 32bit Help, my program is using 64bit desktop, and when i try to run it to 32bit laptop it displays error
in command prompt:

npm run dev

it displays an error of : %1 is not  is not a valid win32 application

A: Figured out my problem, there is a specific node_sqlite3.node (located at node_modules\sqlite3\lib\binding) file for 32bit and 64 bit


text:
Q: SetBounds not working properly I want to make 3 panels, where one is to the west side, one to the east, and one to the south. When I complie this, it gives me frame with colors all one above another and it doesn't give me buttons.
frame = new JFrame();
frame.setBounds(600, 200, 500, 350);
frame.setTitle("Dr. Idrizovic");
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

panelWest = new JPanel();
panelWest.setBounds(0, 0, 175, 310);
panelWest.setLayout(null);
panelWest.setBackground(Color.green);

regUslugaButt = new JButton("Registar usluga");
regUslugaButt.setBounds(12, 35, 150, 25);

regMaterijalaButt = new JButton("Registar materijala");
regMaterijalaButt.setBounds(12, 95, 150, 25);

regIntervencijaButt = new JButton("Registar intervencija");
regIntervencijaButt.setBounds(12, 155, 150, 25);

regDijagnozaButt = new JButton("Registar dijagnoza");
regDijagnozaButt.setBounds(12, 215, 150, 25);

panelEast = new JPanel();
panelEast.setBounds(325, 0, 175, 310);
panelEast.setLayout(null);
panelEast.setBackground(Color.red);

evidencijaPacButt = new JButton("Evidencija pacijenata");
evidencijaPacButt.setBounds(324, 35, 150, 25);

zakazivanjePacButt = new JButton("Zakazivanje pacijenata");
zakazivanjePacButt.setBounds(12, 95, 150, 25);

evidencijaStomatologaButt = new JButton("Evidencija stomatologa");
evidencijaStomatologaButt.setBounds(12, 155, 150, 25);

izvrseneUslugeButt = new JButton("Izvrsene usluge");
izvrseneUslugeButt.setBounds(12, 215, 150, 25);

panelSouth = new JPanel();
panelSouth.setBounds(175, 310, 150, 40);
panelSouth.setLayout(null);
panelSouth.setBackground(Color.black);

exitButt = new JButton("Kraj rada");
exitButt.setBounds(174, 260, 150, 25);

panelWest.add(regUslugaButt);
panelWest.add(regMaterijalaButt);
panelWest.add(regIntervencijaButt);
panelWest.add(regDijagnozaButt);

panelEast.add(evidencijaPacButt);
panelEast.add(zakazivanjePacButt);
panelEast.add(evidencijaStomatologaButt);
panelEast.add(izvrseneUslugeButt);

panelSouth.add(exitButt);

frame.add(panelWest);
frame.add(panelSouth);
frame.add(panelEast);

A:
I want to make 3 panels where one is to the west side,one to the east and one to the south.

Don't use a null layout. Don't use setBounds().
Instead you should be using a BorderLayout for you main panel. Your child panels should also use an appropriate layout manager.

A: you have a JFrame you need to set a layout to the frame you have like this:
          frame.setLayout(new BorderLayout());

and later you need to add each panel in the position you like, like this:
    frame.add(panelWest, BorderLayout.WEST);

remember to this at the end, when you alredy set all the properties of all the panels.


text:
Q: Why is the Change of Basis map unique? I've been looking all over, but I haven't found anything satisfactory.
We've been shown in class by a commutative diagram that, given an $n$-dimensional vector space $V$ over a field, $\mathbb{F}$, and bases, $\mathcal{B}=\{v_1,...,v_n\}$ and $\mathcal{C}=\{u_1,...,u_n\}$, the coordinate maps $[]_{\mathcal{B}}:V\rightarrow \mathbb{F}^n$ and $[]_{\mathcal{C}}:V\rightarrow \mathbb{F}^n$ give rise to a unique map $P=[]_{\mathcal{B}}\circ []^{-1}_{\mathcal{C}}:\mathbb{F}^n\rightarrow \mathbb{F}^n$, which is our change of basis matrix.
But I am having a lot of trouble proving that $P$ is unique. Can anyone enlighten me as to why this is necessarily true?

A: A basis is an ordered set of vectors that are independent and generates the whole vector space. If you have two basis $\mathcal B$ and $\mathcal C$ as in your post, then a change of basis $f$ from $\mathcal B$ to $\mathcal C$ must satisfy $f(v_i)=u_i$ for $i=1,\ldots,n$ (in this precise order). There is a unique map satisfying this requirement by a theorem stating that if a linear map is defined over a basis then it is uniquely defined over the whole space. Since the requirement fix the images of the elements of the basis $\mathcal B$ then there is only a unique map that satisfies those conditions.

A: Remember that any linear map on any linear space $\;V\;$ is uniquely and completely determined once we know its action on any basis of $\;V\;$ ...and that's all.
If you want to do this proof, suppose there's another map $\;Q:V\to V\;$ s.t. it coincides on "the old basis" $\;\mathcal B\;$ with $\;P:\;\; Qv_i=Pv_i\;\;\forall\,i=1,2,...,n\;$ , then (using linearity of the maps),  for any
$$v=\sum_{k=1}^n a_iv_i\in V\;,\;\;Qv=\sum_{k=1}^na_iQv_i=\sum_{k=1}^n a_iPv_i=Pv$$
so $\;Q\equiv P\;$.


text:
Q: stop event and set variable to default following problem. i have a long scrolling page which adds classes to every div if its in the viewport with inview.js
var $div1 = $('#div1');
var $div2 = $('#div2');
//.....
var only_once = 0;

$('#div1, #div2, #div3, #div4, #div5').bind('inview', function (event, visible)
{
    if (visible == true) {
        $(this).addClass("inview");
    } else {
        $(this).removeClass("inview");
    }
});

when it adds the class im doing some events and an if condition where something should happen if inview is fired the first time and then stops. i tried it with with switching only_once to 1.
if($div1.hasClass("inview")){
    // here some functions...

    if (only_once == 0) {
        $('.float-second').css('left', 0);
        $('.float-second').css('top', 0);
        only_once = 1;
    }

    if($div2.hasClass("inview")){
        // here some functions...

        if (only_once == 1) {
            $('.float-third').css('left', 0);
            $('.float-third').css('top', 0);
            only_once = 2;
        }
        // and this for the other divs too

the problem is, when i do it this way it doesnt fire when the site loads at middle or bottom and im scrolling up or down because of the if condition needs the first events because of its value before.
hope you get my point, how can i do this work well?

A: I think I understand the problem you are having. You can check how much the page is scrolled using:
$(document).scrollTop();

If it's greater than some value that you decide you can call the functions you need to call otherwise if it loads at the top of the page your plugin will do that for you.