text:
Q: Button not laid out against top of relatively positioned container in Firefox I'm building a toggle switch and the head (button) isn't positioned all the way to the top as I'd expect it to be in Firefox. Works fine in Chrome, so maybe has something to do with default browser styles?
Edit: I know how to make it work, I want to know why it happens.
codepen https://codepen.io/warhammered_cat/pen/qBZYZVy

const toggleSwitch = document.querySelector('.toggle-switch')
const toggleSwitchHead = document.querySelector('.head')

function handleToggle(e) {
  toggleSwitch.classList.toggle('active')
}

toggleSwitchHead.addEventListener('click', handleToggle)
* {
  box-sizing: border-box;
}

document, body {
  margin: 0;
  padding: 0;
}

.head {
  width: 1.25rem;
  height: 1.25rem;
  border: 0.125rem solid gray;
  border-radius: 50%;
  background-color: white;
  cursor: pointer;
  transition: all 0.4s;
  outline: none;
  box-shadow: none;
}

.rail {
  height: 0.75rem;
  width: 100%;
  background-color: gray;
  border: 0.125rem solid gray;
  position: absolute;
  top: 0.25rem;
  z-index: -1;
  border-radius: 0.3rem;
  transition: all 0.4s;
}

.toggle-switch {
  position: relative;
  height: 1.25rem;
  width: 2rem;
}

.toggle-switch.active > .head {
  background-color: #F7941E;
  border-color: #F7841E;
  transform: translateX(1rem);
}

.toggle-switch.active > .rail {
  border: 0.125rem solid #F7941E;
  background-color: white;
}

  <button class='head'></button>

A: try this instead,
Add display:inline-flex; to head class
.head{
    display:inline-flex;
}

Click below to see codepen demo

Result :

const toggleSwitch = document.querySelector('.toggle-switch')
const toggleSwitchHead = document.querySelector('.head')

function handleToggle(e) {
  toggleSwitch.classList.toggle('active')
}

toggleSwitchHead.addEventListener('click', handleToggle)
* {
  box-sizing: border-box;
}

document, body {
  margin: 0;
  padding: 0;
}

.head {
  width: 1.25rem;
  height: 1.25rem;
  border: 0.125rem solid gray;
  border-radius: 50%;
  background-color: white;
  cursor: pointer;
  transition: all 0.4s;
  outline: none;
  box-shadow: none;
  display:inline-flex;
}

.rail {
  height: 0.75rem;
  width: 100%;
  background-color: gray;
  border: 0.125rem solid gray;
  position: absolute;
  top: 0.25rem;
  z-index: -1;
  border-radius: 0.3rem;
  transition: all 0.4s;
}

.toggle-switch {
  position: relative;
  height: 1.25rem;
  width: 2rem;
}

.toggle-switch.active > .head {
  background-color: #F7941E;
  border-color: #F7841E;
  transform: translateX(1rem);
}

.toggle-switch.active > .rail {
  border: 0.125rem solid #F7941E;
  background-color: white;
}

  <button class='head'></button>

A: The <button> element is what is specifically being rendered differently in Firefox and Chrome.
If you change the <button> to a
 the problem fixes itself.
The reason is that the button element is not a block element by default. You have to explicitly set the button to be a block element to get the desired behavior.
.head {
    ...
    display: block;
    ...
}


text:
Q: Clocking scheme for LAN8720A - Cortex M4 This is regarding a design choice involving LAN8720, specific to clocking schemes.
We are interfacing an ARM cortex M4 (with inbuilt MAC) to the 8720 PHY via RMII in the REFCLKO configuration. In the datasheet for the 8720, Fig 3.9/page 36 (sorry but i do not have enough points to upload an image) shows the 8720 receiving its clock from an external source(25 Mhz) and the MAC is fed an output reference clock of 50MHz from the 8720.
 The text in the datasheet prior to this figure reads: *"In some system architectures, a 25MHz clock source is available. The device can be used to generate the REF_CLK to the MAC as shown in Figure 3.9. It is important to note that in this specific example, only a 25MHz clock can be used (clock cannot be 50MHz). Similar to the 25MHz crystal mode, the nINT function is disabled."* Absolutely nothing else on this scheme is mentioned.
Now, the controller itself is clocked by a 25MHz crystal. The controller generates a 25MHz signal on its MCO. From the figure mentioned above, it should be a correct design to clock the 8720 via the MCO output of 25MHz from the controller and providing the REF_CLK output to the controller's MAC. However as mentioned earlier there is hardly any information(read none) regarding this. There are development boards of 8720 which support every other clocking scheme but this. I even checked the schematic review checklist provided by SMSC which describes quite a few clocking schemes but doesnt mention this at all. Are there any issues known with such a clocking scheme?
See the third document in the link below.
http://www.smsc.com/Products/Ethernet_and_Embedded_Networking/Ethernet_Transceivers/LAN8710A_LAN8720A/Download
(As mentioned earlier, I do not have enough points to upload an image)

A: Circuits depicted by figures 3.8 & 3.9 actually work the same way, from the MAC's point of view. The only difference between them is the way the clock signal is generated for the PHY: 3.8 uses the internal crystal oscillator, 3.9 uses an external oscillator. Since 3.8 is demonstrated by the eval board of SMSC, I'd expect 3.9 to work as well.
However, there is a single note in the data sheet that you should pay attention to: "The REF_CLK Out Mode is not part of the RMII Specification. Timing in this mode is not compliant with the RMII specification. To ensure proper system operation, a timing analysis of the MAC and LAN8720 must be performed."
I have never tried to build a circuit with this PHY, so I don't know the exact implications of this note, but I'd expect the problem to lie in the fact that having a common, external oscillator being fed into both the MAC and the PHY can give you a controllable delay between them (you can play with the lengths of the two clock lines), but having the PHY sourcing the clock to the MAC will not give you this freedom, probably limiting the distance between them considerably.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Copy filtered data into specific sheet So i have the following code which uses the advancedfilter function in the excel to filter for me few criteria and then copy this into new workbook wit the name of the criteria. What I would like it to do now is to, hmm, lets say filter criteria1, copy it, and instead of creating new workbook and paste it there, I want it to paste it into the current workbook with the same name, but the trick here is that I do not want it to overwrite the current data that i have but to find the last row (i know how to do it) and paste it there.
Dim cell As Range
Dim curPat As String

curpath = ActiveWorkbook.Path & "\"

Application.ScreenUpdating = False
Application.DisplayAlerts = False

For Each cell In Range("fbtlist")
    [valsalesman] = cell.Value
    Range("myFBT").AdvancedFilter Action:=xlFilterCopy, _
        criteriarange:=Range("criteria"), copytorange:=("extract"), unique:=False
    Range(Range("extract"), Range("extract").End(xlDown)).Copy
    Workbooks.Add
    ActiveSheet.Paste
    ActiveWorkbook.SaveAs Filename:=curpath & cell.Value & Format(Now, "ddmmyyyy - hhmmss") & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWindow.Close
    Range(Range("extract"), Range("extract").End(xlDown)).ClearContents
Next cell

End Sub

any help or guidance would be appreciated.

A:  Hope the below code will match your expectations
Dim cell As Range
Dim curPat As String

curpath = ActiveWorkbook.Path & "\"

Application.ScreenUpdating = False
Application.DisplayAlerts = False

For Each cell In Range("fbtlist")
     [valsalesman] = cell.Value
     Range("myFBT").AdvancedFilter Action:=xlFilterCopy, _
    criteriarange:=Range("criteria"), copytorange:=("extract"), unique:=False
Range(Range("extract"), Range("extract").End(xlDown)).Copy
Workbooks.Add  'Instead of creating use the Workbook.open and perform as below
'You may insert this code to find the last used row
a = 2
do while cells(a, 2) <>""
a = a+1
loop
cells(a,1).select
Activesheet.paste
ActiveWorkbook.SaveAs Filename:=curpath & cell.Value & Format(Now, "ddmmyyyy - hhmmss") & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close
Range(Range("extract"), Range("extract").End(xlDown)).ClearContents
Next cell

End Sub


text:
Q: How to restore XML code style settings in Android Studio File > Settings. After I change rules to languages (spaces, wrappings, imports, etc.) and restart Android Studio, they apply again. But if I change XML settings, they will be lost after restart. So every time after restart of AS I have to change these settings again. How can I make AS to save and restore XML settings?

A: In order to save XML settings do following.

*

*Open Settings: Ctrl+Alt+S.

*Find XML in Editor > Code Styles > XML, Android tab.

*Select two checkboxes. Select scheme and press Copy to Project....

*Now you can redefine a Project scheme. Also check two checkboxes. Now your scheme becomes Project with your settings, and after restart you will have this new scheme.


text:
Q: Is it necessary for $A$ to be symmetric with non-zero determinant? Today, in a Differential Geometry test, I was asked to prove that:
$$S:=\{x \in \mathbb{R}^3: x^TAx+c=0\}$$
where $A$ is a symmetric $3\times 3$ matrix  and $c \in \mathbb{R}$ is a regular surface whenever $\det A \neq 0$ and $c \neq 0$. Talking to a friend, he gave me his resolution:
(Let's, first, define:
$$f: \mathbb{R}^3 \rightarrow \mathbb{R}$$
$$x \mapsto \langle Ax,x\rangle$$

If you assume that $A$ is symmetric, the gradient of $f$ in $p$ is $Ap$. Since $c \neq 0$, we have that if $p \in S$, $p$ must not be $0$. Since $\det A \neq 0$, we have that $Ap$ is not $0$, and therefore the derivative is surjective and every point of $S$ is regular.

I gave another solution, where I don't use the fact that $A$ is symmetric and neither the fact that $\det A$ is different than $0$. Therefore, I suspect that there may be something wrong, which I ask of you to verify if that's the case:
Solution:
The derivative of the map $x \mapsto \langle Ax,x\rangle$ at a point $p$ is the linear map:
$$f'(x)=\langle A (~~\cdot~~),p\rangle + \langle Ap,~~\cdot~~\rangle$$
Take a point $p \in S$. We know that $\langle Ap,p\rangle=-c$. We show that the derivative is surjective. For that, since it is a linear functional, it is sufficient to show that it is not the zero functional.
But this follows from applying the functional at $p$:
$$f'(x)p=2\langle Ap,p\rangle=-2c \neq 0$$

A: You are right that you do not need to use the two facts $\det A \neq 0$ and $A = A^T$.
First of all, $A^T = A$ is not needed, as for any $A$,
$$x^T A x = x^T\frac 12 (A+A^T) x \ \ \ \ \ \text{(direct checking)}$$
for all $x$. So it is "no harm" to assume that it is symmetric (That is, use $\frac 12 (A+A^T)$ instead of $A$).
So assuming that $A$ is symmetric, then there are eigenvalues $\lambda _i$ with eigenvectors $v_i$ ($v_i$'s can be chosen to be orthonormal), where $i = 1, 2, 3$.
Then under a change of basis, assume that $A$ is diagonal: so
$$x^TA x = \lambda_1 x_1^2 + \lambda_2 x_2^2 +\lambda_3 x_3^2.$$
Now $\det A\neq 0$ if and only if $\lambda_i \neq 0$ for $i = 1, 2, 3$. But one easily sees that even if some of them are zero,
$$\{ x^T Ax + c = 0\}$$
for $c\neq 0$ still defines a smooth surface in $\mathbb R^3$.
(In particular, I think your proof is correct, and the assumptions are not needed)


text:
Q: How can I convert a list to return a Json? I have the following code and need to retrieve faq type questions from a bd, how can I convert the list returned to a json, the following code presents: Object of type 'Question' is not JSON serializable
I'm using flask and Python3
@app.route("/faq/<question>")

@app.route("/faq/",defaults={"question":None})

def teste(question):
   r=Question.query.all()

   return jsonify(r)

Object of type 'Question' is not JSON serializable

A: Your list contains Question objects that aren't serializable as JSON. If you want the output to be a list of strings, you should use
jsonify(list(map(str, r)))

(This assumes that the question objects can be converted to string.)


text:
Q: How do I search for questions with (or without) specific tags? How do I search for questions with specific tags?

*

*How do I search for questions that have specific tags?

*How do I search for questions that contain specific text, as well as specific tags?

*Are there any more powerful search options?

For more information about searching, see "How do I search?" in the Help Center.

Return to FAQ index

A: How to Search with Multiple Tags?
There are two basic ways to search for questions with specific tags:
Search Box
Simply type the tag you're looking for inside square brackets. You can search for questions with multiple tags and/or search for other terms within those tags.
A simple example search looks like:

[python] [beginner] tutorials

That searches for the term 'tutorials' within the set of questions tagged with both [python] and [beginner].
If you wish to do a text-search for a term that is also a tag, or for a phrase that contains common words, you may need to escape the text term by surrounding it entirely with double quotes. Multiple text-search terms can be specified if necessary.

URL Location Bar
You can specify the tags to search for in the URL Location bar in the following format:

https://stackoverflow.com/questions/tagged/apples oranges

This way is more powerful because you can also specify operators like 'or' or 'not'. The Search Box method defaults all searching to AND.
To search for questions with one tag OR another tag:

tagged/apples or oranges

To search for questions with one tag but NOT another tag:

tagged/apples -oranges

Note that a search cannot begin with a NOT, and any such leading NOT will be removed from the search.
To search for questions with tags that match a wildcard pattern:

tagged/apples~

These options can be mixed and matched as you see fit.

A: On Stack Overflow (only, ATM) there is a new advanced search option: collective.
Example usage: collective:"Go Language"

*

*Resulting URL: https://stackoverflow.com/collectives/go
Example usage: collective:"Google Cloud"

*

*Resulting URL: https://stackoverflow.com/collectives/google-cloud
Additional search terms will apply to further filter the results from those URLs.
In addition to accepted answers such searches also feature recommended answers.

The command doesn't appear in Stack Overflow's full search help but it does appear in the search bar helper:

A: There seems to be an undocumented (so far) use of the search box.  Searching for questions tagged with one tag or another.  I'm writing it down here instead of putting it in the current answer since what I write here might not be "official".  If it's good enough, then by all means, move it up there.
Search box
To search for questions with one tag OR another tag:

[apples] [or] [oranges]

or

[apples] or [oranges]

To search for questions with one tag but NOT another tag:

[apples] -[oranges]

Note that these searches may be combined to perform more complex searches:

[functional-programming] -[ocaml] [or] [c] [c++]

This searches for questions tagged functional-programming excluding ocaml or both c and c++.

A: Click on the "Tags" button near the top of the page. That takes you to a list of tags. The default list is the most popular tags, sorted in descending order of popularity. Another tab takes you to an alphabetized list of tags. Click on the tag name to get a list of questions associated with that tag.

A: If you can see the tag you want, e.g. 'Perl' in a post on the screen, you can click on it.


text:
Q: How can I feature detect carousel  tags? I have a <select> tag that I'm using the native behavior for on both desktop and mobile. On desktop it does a dropdown; on iPhone it does a carousel. Now I'd like to make it so that small and medium devices that don't have carousels for dropdowns use a menu dialog instead. Is it possible to feature detect carousels?

A: There has been extensive work done to detect the device that a website is executing in.
The process for detection centers around a best guess based on the feature set examined.
You will need to include the set of features that identify an iPhone (or other mobile devices) to the specificity that makes sense for your needs.
These can include gesture features, touch features, certain audio and video features, camera features, etc.


text:
Q: How to deal with $A^{26}=I$? I got stuck in this problem:
Let $A:\mathbb{R}^{6}\rightarrow \mathbb{R}^{6}$ be a linear transformation. Assume $A^{26}=I$, prove that $R^{6}=\oplus_{i=1}^{3} V_{i}$, with $AV_{i}\subset V_{i}$(the explicit condition is $V_{i}$ are 2-dimensional invariant subspaces of $\mathbb{R}^{6}$ under $A$).
My thought is $A$ must have a minimal polynomial of degree less or equal to 6. Thus since it divides $x^{26}-1$, the only choices are: $$x-1,x+1,x^{2}-1$$ since the rest term $$(x^{13}-1)/(x-1)*(x^{13}+1)/(x+1)$$ has factors irreducible and degree higher than 6. And the claim is trivial in the case $A=\pm I$. But I do not know how to deal with the case $A^{2}-I=0$ - $A$ can only have eigenvalues $1$ and $-1$, but how this helps to solve the problem?

Edit:
In the light of did's comments $\sum^{12}_{i=0}x^{i}$ and $\sum^{12}_{i=0}(-1)^{i}x^{i}$ can be reducible over the reals in pairs of 6 quadratics, and the corresponding $A$'s are rotations. But I still feel rather confused as if problem is solved at this stage by suggesting $A$'s minimal polynomial must be a product of $$x-1,x+1,x^{2}-1, x^{2}-\cos[\theta]x+1$$
which are dealt with respectively by $I,-I$, selecting linearly independent vectors and run with $A$, and selecting the rotational invariant subspace. Since obviously cases like $$(x\pm 1)(x^{2}-\cos[\theta]x+1)$$ or even $$(x+1)(x-1)^{2}$$ could happen.

A: The decomposition of $x^{26}-1$ into irreducible factors over $\mathbb R$ is $$
(x-1)\cdot(x+1)\cdot\prod\limits_{k=1}^{12}p_k(x),\qquad p_k(x)=x^2-2\cos(k\pi/13)x+1.
$$
This almost determines the minimal polynomial $\mu_A(x)$ of $A$, since $\mu_A(x)$ divides $x^{26}-1$. Hence $\mu_A(x)$ is the product of at most three factors $p_k(x)$ and possibly a factor $x-1$ and possibly a factor $x+1$. In any case, $\mu_A(x)$ has no repeated irreducible factor hence $A$ is equivalent over $\mathbb R$ to a matrix diagonal by blocks, with (1.) possibly an even number of blocks of size $1\times1$ equal to $+1$ or to $-1$ and (2.) possibly some blocks of size $2\times2$ equal to rotation matrices
$$
\begin{pmatrix}\cos(k\pi/13)&\sin(k\pi/13)\\ -\sin(k\pi/13)&\cos(k\pi/13)\end{pmatrix}.
$$
This yields the desired decomposition as follows: choose each plane left invariant by one of the rotation matrices, if there are some, and complete by any planes made of eigenvectors with eigenvalues $\pm1$, if necessary. (Note that the result is such that $AV_i=V_i$ for every $i$.)

A: Suppose $A^2 = I$. Let $x$ be any nonzero vector. Then the space spanned by $x$ and $Ax$ is invariant. Repeat.

A: Consider $$B=\sum_{i=0}^{12}A^{2i}$$
You will find easy invariant subspace by considering $B(x)$, because $A^2(B(x))=B(x)$. So take $B(x)$ and $A(B(X))$ to build a 2 dimensional invariant subspace. There are some degenerate case (for example $B(x)=0$), but they should not be too hard...
EDIT :
A has 6 eigen values $\lambda_i$ in $\mathbb C$. As $A^{26}=I$, $\lambda_i^{26}=1$, they are non zero values.
Either

*

*$\lambda_i\in{\mathbb R}$

*$\lambda_i\notin{\mathbb R}$ and $\exists j \lambda_j=\bar{\lambda_i}$

So you can build 3 2-dimensional spaces by grouping the complex values with their respective conjugate, or any real value with any other real value...


text:
Q: creating web form to display questions from a database P.S. I am new to php & webform scripting;
Currently I have the following multiple choice question table inside MySQL database :
     |MCQ_ID|Question|Opt_1|Opt_2|Opt_3|Opt_4|Opt_5|
     |1|What is the port|23|21|22|80|53

My objective is to create a quiz in a web form, using php scripting where
(1) The Questions are selected from the database & displayed in a multiple choice form with only a single answer to each question
(2) Each webform should display only one question as there will be a timer to record the amount of time spend at a particular question.
Below is my begining script & how should I go from here to achieve my above objectives?
 <!DOCTYPE html>

                Test Quiz

            <?php
                //Start Variables
                $username   =   "root";
                $password   =   "";
                $database   =   "Test";
                //End Variables

                //Connect To Database
                $link   =   mysql_connect(localhost,$username,$password) or die ('Could not connect :'.  mysql_error());
                mysql_select_db($database) or die( "Unable to select database");

                //SQL Get Questions
                $query  =   "SELECT * FROM MCQuestionBank";
                $result =   mysql_query($query) or die ('Query failed:'. mysql_error());
                $row    =   mysql_fetch_array($result,MYSQLI_ASSOC);

                //Get results
                /*
                while ($row = mysql_fetch_array($result,MYSQLI_ASSOC))
                    {
                        echo '
 QuestionName : ' .$row{'Question'} ;
                        echo '
 Option 1 : ' .$row{'MCQ_Opt1'};
                        echo '
 Option 2 : ' .$row{'MCQ_Opt2'};
                        echo '
 Option 3 : ' .$row{'MCQ_Opt3'};
                        echo '
 Option 4 : ' .$row{'MCQ_Opt4'};
                        echo '
 Option 5 : ' .$row{'MCQ_Opt5'};
                    }
                */
                mysql_free_result($result);
                mysql_close($link);
            ?>

A: That table structure is going to be unmanageable.  If you're going to use a database you need to normalize it.  Questions go in one table. Answers in another.  That way is much more flexible.  What are you are going to do when, for example, a question needs to have more (or less than) 5 choices?
Get some general background on relational databases and then come back to the problem.  This might be a good start:
http://www.deeptraining.com/litwin/dbdesign/FundamentalsOfRelationalDatabaseDesign.aspx

A: *

*You can use radio button to display your options

www.echoecho.com/htmlforms10.htm

*

*You can use HTML form to submit the answer by user back to the server.

www.w3schools.com/html/html_forms.asp

*

*Unless you've the correct answer stored in the database, you have to correct the answers manually. For a multiple choice questions, it is very easy to store the correct answer in database. Have one more column to denote the correct answer.

www.w3schools.com will be a good starting point to learn these stuff.

A: Doing this properly is no simple task. You should use at least three different tables:
1. A table with your questions and a unique id.
2. A table with your answers, the id of the question they go to, and a boolean that indicates whether it is true or false.
3. A way to track your users' answers. This should, at minimum, store a session id and an id to the answer. Without this, you will not be able to do a question per page properly (right now you are dumping all the questions onto one page).
4. A user table is almost non-optional, with a field for it's unique id in the above table (instead of a session id).
Making these tables talk to each other is not that difficult if you read up on JOIN queries.
Once you have a good database set up, you are ready to look at the php. We have all started out doing it your way and we foresee a lot of hair pulling in your future.


text:
Q: Get values from the last JSON object In VBA I use the following JSON Converter https://github.com/VBA-tools/VBA-JSON to parse through simple JSON responses.
However, I have a JSON response that has multiple objects and I wish for my code to always take the value in the last (ie. more recent) object.
Here is my JSON :
[
  {
    "masterDataID": 26941,
    "testRunID": 66929
  },
  {
    "masterDataID": 26941,
    "testRunID": 67485
  },
  {
    "masterDataID": 26941,
    "testRunID": 67926
  }
]

As you can see, there is no apparent name to the objects, so I am forced to use numbers to designate them.
Here is my code :
Public Sub GETID()

Dim http As Object, JSON As Object, i As Integer
Dim URL As String

URL = Range("B3")

Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", URL, False
http.send
Set JSON = ParseJson(http.responseText)

ID = JSON(1)("testRunID")

Range("B4") = ID

End Sub

In
ID = JSON(1)("testRunID")

JSON(1) gets me the first object (ie. ID = 66929) However I wish to get the last object no matter how many objects there are (maybe by counting the number of objects and doing +1)...I'm afraid my knowledge of VBA is very basic :s
Thank you very much in advance !

A: Here your JSON object is a Collection of Dictionaries (each dictionary represents an object element in the source JSON array)
Collection has a Count property so this will give you what you want:
ID = JSON(JSON.Count)("testRunID")


text:
Q: Mute Windows 10 Notification using C# or WPF I'm currently researching on how to mute the windows 10 notification but it i havent found any concrete solution yet.
What i want to do is to disable all notifications when i press a button or check a checkbox.
It is similar on what you do on the notification settings, but i want it to do it progmatically on my application.
I'm currently reading the document of microsoft about Notification Listener.
https://learn.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/notification-listener

A: NotificationListener allows you to access the notifications, but not to the configuration of the system. And you must think it's a UWP Api...
You want to do something that can not be done in UWP Api(impossible) nor WPF(possible, i wish you good luck).
You can't change system settings inside the UWP app box -safety and things-. The way to do it is "Open the Configuration App where you want the user make the change".
If you wan't to this in WPF/.net you'd have to play with PInvoke and WinApi seriously. And that means thinking about privileges, run as admin, find the functions in WinApi .h files, etc...
Keeping simple, in UWP, nope; in WPF, you have to read a lot of source code/documentation of Windows .h files, make the c# version of the structs, etc...
The real question here is... It's necessary? Windows provides Focus Assist with two clicks (corner, Focus Assist)

A: I really appreciate your feedbacks! I did some tinkering and found out the service responsible for the notification. I'm not really confident that this is the best approach, but it is working for me.
What I did was I stopped the service using C#. Here is my sample code:
  ServiceController[] services = ServiceController.GetServices();

        foreach (ServiceController service in services)
        {
            if (service.ServiceName.Contains(serviceName))
            {
                service.Start();

            }

        }

Here is the service responsible for the notifications:
Notification Service
I dont know if this is a good practice or not so I'm still open for feedbacks and suggestions.
Thank you!


text:
Q: How use vue datepicker in nuxt3 I trying to use the vue-datepicker (https://vue3datepicker.com/installation/) with no success
First I create one class on my \plugins directory: ('\plugins\vue-datepicker.js')
import Datepicker from '@vuepic/vue-datepicker';

export default defineNuxtPlugin(nuxtApp => {
  nuxtApp.vueApp.use(Datepicker)
})

then I try to use in my app
<Datepicker />

but I got this erro:
runtime-core.esm-bundler.js:38 [Vue warn]: Failed to resolve component: DatePicker
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.


text:
Q: data structure for quick access The given data is input to an algo:
F1----    P1----    P2 ----   P3   .....
2  ---- 4 ------5 ------2.......
5 ----2-------10------1.....
1----4--------15------0......  (numbers under F1 are unique and non zero..numbers under P1,P2,P3 can be same and may be zero)
The algo chooses some numbers from F1 and gives the positions as 0,1,2 for which the numbers have to be accessed according to selected F1 number.(position 0 correspond to P1,1 to P2 and so on)
Again processing has to be done on numbers from selected positions.
I have made a data structure and attached the link to it where all the numbers in F1 will go in Part I of Portion A in sorted order and Part II of portion A will point to array consisting of numbers from P1,P2,P3 so that when number of F1 and position is selected by algo, the position can be quickly accessed and number retrieved from that position.
DS Image is in the link.
https://www.dropbox.com/s/iz9nqfg8jy4iekn/DS.png
(In case the image is not accessible--the DS consist of an array of structure having two members.Member 1 stores sorted number from F1 and member 2 points to an array consisting of numbers from P1,P2,P3 corresponding to a particular number in F1)
The access time has to be reduced.That is why i have taken everything into memory and quickly access the positions through that index in the horizontal array.Using a simple 2-D would have an overhead in moving the numbers of horizontal array because the numbers of F1 have to be in sorted order in Part I.
How Can i  improve this?


text:
Q: How to set non-blinking text cursor (assembly)? My program should set non-blinking text cursor. I only have found how to hide cursor (using 10h).
Cursor should be visible but non-blinking. Is it possible?

A: The VGA uses bit 7 of the attribute byte to indicate blinking.  You can turn off this feature so that you can use bit 7 to indicate intensity.
An old note I have is now only Archive.org'ed, but I have been using some code that has worked for some time.
       ; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
       ; make sure the 'blink' bit is off
       ; this is so we can print bright colors instead of the
       ;  vga using bit 7 as the blink bit.
       mov  dx,3DAh             ; reset the flip-flop
       in   al,dx

       mov  dx,3C0h             ; index 0x10  (20h + 10h)?
       mov  al,30h
       out  dx,al

       inc  dx                  ;  clear bit 3 to disable blink
       in   al,dx
       and  al,(~(1<<3))
       dec  dx
       out  dx,al

Please note that this assumes there is a standard VGA, these particular registers are at 0x3DA, 0x3C0, and 0x3C1, this will be run from TRUE DOS--not a Windowed Session, along with a lot of other assumptions.
Again, this must be on a TRUE DOS machine, or at least a platform that actually is using the VGA hardware instead of emulating it.  Also, don't be surprised if modern hardware doesn't even have the VGA hardware anymore.
With all of these assumptions, as Jester stated, it would be best to hide the cursor and draw your own.
However, if you do get this to work, and it should in a standard older style machines, it allows you to use the intensity colors, i.e.: bright white, bright blue, etc.


text:
Q: Measurability of $E\subseteq \mathbb{N}\times X$ implies measurability of sections $E_{k}$ I am attempting the following problem from Royden Fitzpatrick's text on Real Analysis:

Consider $(\mathbb{N}, 2^{\mathbb{N}}, c)$ where $c$ is the counting measure and let $(X, \mathcal{A}, \mu)$ be a general measure space. Consider the space with $\mathbb{N}\times X$ with the product measure $c\times \mu$ (here the product measure is defined on the completion of the product $\sigma$-algebra). Show that if a subset $E$ of $\mathbb{N}\times X$ is measurable with respect to $c\times \mu$ then for each natural number $k$ $$E_{k} = \{x\in X:(k, x)\in E\}$$ is measurable with respect to $\mu$.

This question is closely related. Note that the problem is easy if $E$ lies in the product $\sigma$-algebra but I don't know how to deal with the case when $E$ lies in its completion (i.e. the $\sigma$-algebra of $(c\times \mu)^{*}$-measurable sets). Any help would be appreciated.
Attempt: We have $E = \bigcup_{k = 1}^{\infty}\{k\}\times E_{k}$ and intersecting with the measurable set $\{k\}\times X$ we get that $\{k\}\times E_{k}$ is measurable for each $k$. But I'm not sure how this implies the measurability of $E_{k}$.
The statement might even incorrect. For instance, let $(X, \mathcal{A}, \mu)$ be incomplete and let $N\subseteq Z$ such that $\mu(Z) = 0$ and $N\notin \mathcal{A}$. Then $\{1\}\times N$ is $(c\times \mu)$ measurable since it has outer measure zero (it is covered by the measurable rectangle $\{1\}\times Z$).


text:
Q: Let $V$ be a $\mathbb{C}$-vector space and $T: V \rightarrow V$ such that $||T(u)-T(v)||=||u-v||$ and $iT(v)=T(iv)$ Let $V$ be a vector space over $\mathbb{C}$ and $T$ a function from $V$ to $V$ such that for every $u,v\in V$, $||T(u)-T(v)||=||u-v||$ and $T(iv)=iT(v)$. Prove that $T$ is linear and $||T(v)||=||v||$ for every $v\in V$.
My attempt:
Since $T(iv)=iT(v)$ we can conclude that $T(-v)=-T(v)$ because if $T(iv)=iT(v)$ then $T(-v)=T(i^2v)=iT(iv)=i^2T(v)=-T(v)$.
With this in mind, we can use the polarization identities like:
$4\left< u,v\right>=||u+v||^2-||u-v||^2$
$4\left< T(u),T(v)\right>=||T(u)+T(v)||^2-||T(u)-T(v)||^2$
And we have that
$4\left< u,v\right>=||u+v||^2-||u-v||^2=||T(u)+T(v)||^2-||T(u)-T(v)||^2=4\left< T(u),T(v)\right>$
And then $\left< T(u),T(v)\right>=\left< u,v\right>$ for every $u,v\in V$
From this, we can inmediatily conclude that $||T(v)||=||v||$ for every $v\in V$ (doing $u=v$ above).
For the linearity: If $r\in\mathbb{C}$ then
$\left< T(ru+v),T(w)\right>=\left< ru+v,w\right>=r\left< u,w\right>+\left< v,w\right>=r\left< T(u),T(w)\right>+\left< T(v),T(w)\right>=\left< rT(u)+T(v),T(w)\right>$
So here is where I have dubs, I want to prove $\left< T(ru+v),T(w)\right>=\left< rT(u)+T(v),x\right>$ for every $x\in V$ to conlude that $T(ru+v)=rT(u)+T(v)$, but I proved that $\left< T(ru+v),T(w)\right>=\left< rT(u)+T(v),T(w)\right>$, what can I do then?


text:
Q: Unable to create Android Virtual Device
For some reason, the OK button is not clickable when I try to create an AVD. Does anyone know what I'm doing wrong?

A: For Ubuntu and running android-studio run to install the packages (these are not installed by default):
android update sdk

A: I had the same problem while creating AVD with 4.2.2 images, I resolved it by doing the following :

*

*Check if there exist a "default" folder in adt-bundle-windows-x86_64-20131030\sdk\system-images\android-17.

*If it exists then move the contents(downloaded system images) of the "default" folder to
adt-bundle-windows-x86_64-20131030\sdk\system-images\android-17.
Hope this helps.

A: Had to restart the Eclipse after completing the installation of ARM EABI v7a system image.

A: Simply because  CPU/ABI says "No system images installed for this target". You need to install system images.
In the Android SDK Manager check that you have installed "ARM EABI v7a System Image" (for each Android version from 4.0 and on you have to install a system image to be able to run a virtual device)
In your case only ARM system image exsits (Android 4.2). If you were running an older version, Intel has provided System Images (Intel x86 ATOM). You can check on the internet to see the comparison in performance between both.
In my case (see image below) I haven't installed a System Image for Android 4.2, whereas I have installed ARM and Intel System Images for 4.1.2
As long as I don't install the 4.2 System Image I would have the same problem as you.
UPDATE : This recent article Speeding Up the Android Emaulator on Intel Architectures explains how to use/install correctly the intel system images to speed up the emulator.
EDIT/FOLLOW UP
What I show in the picture is for Android 4.2, as it was the original question, but is true for every versions of Android.
Of course (as @RedPlanet said), if you are developing for MIPS CPU devices you have to install the "MIPS System Image".
Finally, as @SeanJA said, you have to restart eclipse to see the new installed images. But for me, I always restart a software which I updated to be sure it takes into account all the modifications, and I assume it is a good practice to do so.

A: I want to update this question with a screenshot of a recent Android Studio. It took a bit of poking around to find where to install new system images.
You get to the SDK Manager through one of two paths.
Option 1. Tools > Android > SDK Manager
Option 2. Android Studio > Preferences > Appearance & Behavior > System Settings > Android SDK (This is for Mac; adapt for others.)
In the pane "SDK Platforms," check the "Show Packages" box to see the system images.
Select the ones you want, click "Apply" and voilà!

A: This can happen when:

*

*You have multiple copies of the Android SDK installed on your machine.
You may be updating the available images and devices for one
copy of the Android SDK, and trying to debug or run your application in another.
If you're using Eclipse, take a look at your "Preferences | Android
| SDK Location". Make sure it's the path you expect. If not, change
the path to point to where you think the Android SDK is installed.

*You don't have an Android device setup in your emulator as detailed in other answers on this page.

A: I had to move the folders inside a folder named "default" to the android-## folder so Eclipse could see the images.

A: There is a new possible error for this one related to the latest Android Wear technology.  I was trying to get an emulator started for the wear SDK in preparation for next week.  The API level only supports it in the latest build of 4.4.2 KitKat.
So if you are using something such as the wearable, it starts the default off still in Eclipse as 2.3.3 Gingerbread.  Be sure that your target matches the lowest possible supported target.  For the wearables its the latest 19 KitKat.


text:
Q: How to capture error page screenshot of Apache error page? I would like to configure Apache to capture screenshot of error page to save into a directory from where a cron script will attach it to email and send to my testing/developer colleague to debug and fix it.
I was exploring MOD_PERL to write a OutputFilter, is this right approach? Please suggest alternatives?

A: If you only want the error message displayed, why not using Cpanel feature?


text:
Q: How to convert specific format date with msk time zone to another format? I'm trying to format date in Java. I need this format:
2017-06-10T12:38:15.687+03:00

How correctly convert this from standard Date format which I have got in a String?
Tue Jun 18 00:00:00 MSK 2024

A: Using new calendar API in Java 8.
API Class             Default Format
+-----------------------------------+
LocalDate              2021-12-25
LocalTime                         12:30:30
LocalDateTime          2021-12-25T12:30:30
OffsetTime                        12:30:30+01:00
OffsetDateTime         2021-12-25T12:30:30+01:00
ZonedDateTime          2021-12-25T12:30:30+01:00 Europe/Paris
Year                   2021
YearMonth              2021-12
MonthDay                   -12-25
Instant                2021-12-25T12:30:30.274Z


text:
Q: Is there any way to control sent mail in ASP.NET? I have two questions.
First one is simple: Is there any way to control priority of mails while sending those in ASP.NET? For example i have a dating website and there are few types of mails send. One is registration mail and other are less important like new message in inbox for those who want this information. There are many users on website and lots of mails are send which makes important mails like registration one which should come instantly to come after dozen of new message in inbox messages.
Second one: Is there a way to check whether user opened certain email or not? Let's say i want to check how much users received new message in inbox mail and just viewed it opposite to those who viewed and entered the website afterward with link available in email.
thanks, any info is appreciated.

A: *

*No. If you send though your own SMTP server, this one might allow for some kind of traffic shaping, but as soon as the mail is released "into the wild", you are out of luck.

*There were some methods for that, such as Web bugs; the Wikipedia article on E-mail tracking has a nice overview. However, most modern mail clients block these things, for example, by not showing images by default. Note also that it is considered extremely impolite to do something like that, since you are violating the privacy of your customers.

A: First question:

*

*Step 1. Create a table containing email data in rows, including subject, content, recipients, etc, along with a priority flag.

*Step 2. Build a windows service that will query the database for the next 50 most important email to send, then repeat the process.

This will allow you to scale a lot. You must handle hundred of mails per minute ? No problem, install your service on a second machine that access the same database (cluster).
Second question:

*

*Add an hidden tracking image in the mail body. When the image will be called (the user is reading the mail), the tracking will be done, and you will update the row of the table mentionned in first question answer.

*Create proper reporting based on the table above.

A: your case is one of the many reason there are full time email campaign companies. they handle all of this heavy lifting and have worked through the issues you are inevitable to encounter.
We use responsys and from what I gather they are happy with them. There are literally hundreds, if not thousands of email marketing companies that charge pennies for emails sent. If you plan to do any sort of routing or analytics they are well worth the investment.


text:
Q: How to use mysql trim function in cakephp I am working on cakephp. I want to use
    ORDER BY TRIM( `table`.`name` ) ASC

in my sql query. But I really don't know how to do it in cakephp.
My current query is
'order' => array(
        'table.name' => 'ASC'
          )

please help me out of this.
thanks.

A: Try:
'order' => array(
            'TRIM(`table`.`name`)' => 'ASC'
           )


text:
Q: How to interpret changing of scroll viewer offset in WP7? I have an image inside a scroll viewer which scrolls horizontally.Is there any way to find the scroll offset or set the maximum value till which the scroll viewer can scroll

A: The following blog post provides an attached behaviour that exposes the vertical / horizontal offsets of a scrollviewer so that you can bind to them, or set them in code:
http://www.scottlogic.co.uk/blog/colin/2010/07/exposing-and-binding-to-a-silverlight-scrollviewer%E2%80%99s-scrollbars/
This allows the following markup:
<ScrollViewer
    local:ScrollViewerBinding.VerticalOffset="{Binding YPosition, Mode=TwoWay}"
    local:ScrollViewerBinding.HorizontalOffset="{Binding XPosition, Mode=TwoWay}">
    <!-- Big content goes here! -->
</ScrollViewer>


text:
Q: Elementwise AND or OR operations in python for 2D array Is there any method in python to compute elementwise OR or AND operations for 2D arrays across rows or columns?
For example, for the following array, elementwise OR operations across row would result in a vector [1, 0, 0, 0, 0, 0, 0, 0].
array([[1, 0, 0, 0, 0, 0, 0, 0],
       [1, 0, 0, 0, 0, 0, 0, 0],
       [1, 0, 0, 0, 0, 0, 0, 0],
       [1, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)

A: numpy has logical_or, logical_xor and logical_and which have a reduce method
>> np.logical_or.reduce(a, axis=0)
array([ True, False, False, False, False, False, False, False], dtype=bool)

as you see in the example they coerce to bool dtype, so if you require uint8 you have to cast back in the end.
since bools are stored as bytes you can use cheap viewcasting for that.
with the axis keyword you can select along which axis to reduce. it is possible to select multiple axes
>> np.logical_or.reduce(a, axis=1)
array([ True,  True,  True,  True], dtype=bool)
>>> np.logical_or.reduce(a, axis=(0, 1))
True

the keepdims keyword is useful for broadcasting, for example to find all "crosses" of rows and columns >= 2 in array b
>>> b = np.random.randint(0,10, (4, 4))
>>> b
array([[0, 5, 3, 4],
       [4, 1, 5, 4],
       [4, 5, 5, 5],
       [2, 4, 6, 1]])
>>> rows = np.logical_and.reduce(b >= 2, axis=1, keepdims=True)
# keepdims=False (default) -> rows.shape==(4,)  keepdims=True -> rows.shape==(4, 1)
>>> cols = np.logical_and.reduce(b >= 2, axis=0, keepdims=True)
# keepdims=False (default) -> cols.shape==(4,)  keepdims=True -> cols.shape==(1, 4)
>>> rows & cols # shapes (4, 1) and (1, 4) are broadcast to (4, 4)
array([[False, False, False, False],
       [False, False, False, False],
       [False, False,  True, False],
       [False, False, False, False]], dtype=bool)

notice the slight abuse of the & operator which stands for bitwise_and. since the effect is the same on bools (in fact trying to use and in this place would have thrown an exception) this is common practice
as @ajcr points out the popular np.any and np.all are shorthand for np.logical_or.reduce and np.logical_and.reduce.
note, however, that there are subtle differences
>>> np.logical_or.reduce(a)
array([ True, False, False, False, False, False, False, False], dtype=bool)
>>> np.any(a)
True

OR:
if you want to stick with uint8 and know for certain all your entries will be 0 and 1 you can use bitwise_and, bitwise_or and bitwise_xor
>>> np.bitwise_or.reduce(a, axis=0)
array([1, 0, 0, 0, 0, 0, 0, 0], dtype=uint8)


text:
Q: Excel Consolidating Text String (Yes/No) Trying to combine the data into one master sheet. I have something like below:
Sheet 1                Sheet 2                 Sheet 3
Name    Gain(Y/N)      Name    Gain(Y/N)       Name    Gain(Y/N)
AAA     Y              AAA     Y               AAA
BBB     N              BBB                     BBB     N
CCC                    CCC     Y               CCC     Y
DDD                    DDD                     DDD     Y
EEE                    EEE                     EEE     N

Ultimately would look something like (merging all the sheets into sheet1)
Sheet 1
Name    Gain(Y/N)
AAA     Y
BBB     N
CCC     Y
DDD     Y
EEE     N

The problem is that consolidate function won't work for Text string (Y/N)
I am thinking something like 'if vlookup' or match index? but for multiple reference?
and not overriding each other. Maybe there is simpler way...
Thanks for your help :D

A: If you don't mind creating an extra column on each sheet, you could turn "Y" and "N" into a number. Assuming your labels are in column A, you insert a new column B and put the following in B2:
=IF(A2="Y", 3, IF(A2="N", 2, 1))

Repeat for all sheets. Now you can do consolidation, using the "MAX" function. It will return 2 if the letter "Y" appeared anywhere, etc.  Now you can get back to Y/N/blank by putting the following formula in a column next to the consolidated data:
=INDEX({" ","N","Y"}, B2)

This will return " " if B2 is 1, "N" if B2 is 2, etc. Finally you can copy the entire column, and "paste special - values" to get exactly what you wanted.

A: =IF(OR(Sheet1!B2="Y",Sheet2!B2="Y",Sheet3!B2="Y"),"Y",IF(OR(Sheet1!B2="N",Sheet2!B2="N",Sheet3!B2="N"),"N",""))

in B2 of a new sheet and copied down may suit.
Edit Simplification of revised formula to reflect edit to question:
Filter Sheet1 for Gain (Y/N) (assumed to be ColumnB) for (Blanks) and in the cell with the smallest visible row number enter:
=IF(OR(VLOOKUP(A4,Sheet2!A:B,2,0)="Y",VLOOKUP(A4,Sheet3!A:B,2,0)="Y"),"Y",IF(OR(VLOOKUP(A4,Sheet2!A:B,2,0)="N",VLOOKUP(A4,Sheet3!A:B,2,0)="N"),"N",""))

Change 4s in A4s to smallest visible row number (adjust column references as necessary) and copy down as required.

A: You might as well use Microsoft Query to fetch all the data into a pivot with a code similar to this:
SELECT Name, Gain, 'Sheet1' as [Sheet#]
FROM Sheet1
UNION
SELECT Name, Gain, 'Sheet2' as [Sheet#]
FROM Sheet2
UNION
SELECT Name, Gain, 'Sheet3' as [Sheet#]
FROM Sheet3


text:
Q: Connect laravel jenssegers to mongodb atlas cluster I'am starting with Mongodb atlas and i trying  to connect my laravel/jenssegers project to the cluster i config  my conf/database
'mongodb' => [
  'driver'   => 'mongodb',
  'host'     => env('DB_HOST'),
  'port'     => env('DB_PORT', '27017'),
  'database' => env('DB_DATABASE'),
  'username' => env('DB_USERNAME'),
  'password' => env('DB_PASSWORD'),
  'options'  => [
      'database' => 'admin' // sets the authentication database required by mongo 3
  ]
  ],

And my .env file
DB_HOST="xxxx-shard-00-00-uggj0.mongodb.net"
DB_PORT=27017
DB_DATABASE=xxx
DB_USERNAME=xxx
DB_PASSWORD=xxx

And i get this error

No suitable servers found (serverSelectionTryOnce set): [connection closed calling ismaster on 'xxxx-shard-00-00-uggj0.mongodb.net:27017'

I cold conect with Mongodb Compass without problem.
My Atlas  Ip Whitelist is open (0.0.0.0/0).
Am I missing something?

A: Following works for me, MongoDB Atlas and Laravel 5.7:
update config/database.php:
'mongodb' => [
            'driver' => 'mongodb',
            'dsn' => 'mongodb+srv://<username>:<password>@cluster0.kxxi7.mongodb.net/mydatabase?retryWrites=true&w=majority',
            'database' => 'mydatabase',
        ],

Set your connection string at dsn and db name at database.

A: In Laravel, Use 'dsn' key in config/database.php as shown below to mention the complete cluster url.
'mongodb_conn' => [
        'driver' => 'mongodb',
        'dsn'=>'mongodb://username:password@host1,host2/database?ssl=true&replicaSet=replicaSet&authSource=admin',
        'database' => 'my_data',
    ]

A: By default, when assembling the connection string, the Jenssegers\Mongodb package assembles a DSN that starts with mongodb://. In order to connect to a mongoDB atlas instance, the DSN needs to start with mongodb+srv://.
The simplest and most flexible way to handle this is to add the following entry to your .env:
MONGO_DB_BASE_URI=mongodb+srv://

Then, in your database.php, your mongodb entry should look like the following:
    'mongodb' => [
        'driver' => 'mongodb',
        'host' => env('MONGO_DB_HOST', 'localhost'),
        'port' => env('MONGO_DB_PORT', 27017),
        'database' => env('MONGO_DB_DATABASE'),
        'username' => env('MONGO_DB_USERNAME'),
        'password' => env('MONGO_DB_PASSWORD'),
        'options' => [],
        'dsn' => env('MONGO_DB_BASE_URI','mongodb://').env('MONGO_DB_HOST', 'localhost')
    ],

This gives you control over whether you're connecting to a local instance - in which case you can use a DSN of mongodb://, or a cloud instance such as Atlas - in which case you use a DSN of mongodb+srv://.

A:  'mongodb' => [
        'driver'   => 'mongodb',
        'host'     => [
                       'abc-00-00.mongodb.net',
                        'abc-00-01.mongodb.net',
                        'abc-00-02.mongodb.net'
                    ],
        'port'     => env('MONGO_DB_PORT', 27017),
        'database' => env('MONGO_DB_DATABASE'),
        'username' => env('MONGO_DB_USERNAME'),
        'password' => env('MONGO_DB_PASSWORD'),
        'options'  => [
            'ssl'        => 'true',
            'replicaSet' => 'abc-0',
            'authSource' => 'admin',
            'retryWrites' => 'true',
           'w' => 'majority'
       ]
    ],

This works for laravel 6 and MongoDB 1.2 or later with MongoDB atlas


text:
Q: Window Navigation in Catel I am working on a WPF Application with Catel that has a Login Screen. How would I, after a user has entered his details and may proceed) close the Login Screen and display a 'Home' Screen using Catel?
I tried using the IUIVisualizerService, but I cannot pass it the user's name, for example, to be used within the viewmodel of the view that sits on the window to be opened, unless I am doing it wrong.
I have other scenarios in my application where I would need to open a new window from a currently opened one(I may require to close it before the new one is opened) and pass some data to the contained view's viewmodel.
Any suggestions?
SOME CODE AS REQUESTED:
/// <summary>
    /// ViewModel for the Login Screen
    /// </summary>
    public class LoginWindowViewModel : ViewModelBase
    {
        public LoginWindowViewModel()
        {
            ShowHomeWindow = new Command(OnShowHomeWindowExecute);
        }

        public string Username { get; set; }

        public override string Title { get { return "Login"; } }

        public Command ShowHomeWindow { get; private set; }

        private void OnShowHomeWindowExecute()
        {
            var viewModel = new HomeWindowViewModel();

            var dependencyResolver = this.GetDependencyResolver();
            var uiVisualizerService = dependencyResolver.Resolve<IUIVisualizerService>();
            uiVisualizerService.Register(typeof(HomeWindowViewModel), typeof(HomeWindow));
            uiVisualizerService.Show(viewModel, OnWindowClosed);
        }

        private void OnWindowClosed(object sender, EventArgs e)
        {

        }

    }

    /// <summary>
    /// ViewModel for the Home Window
    /// </summary>
    public class HomeWindowViewModel : ViewModelBase
    {
        public HomeWindowViewModel()
        {
        }

    }

    /// <summary>
    /// ViewModel for the Home View that sits in Home Window
    /// </summary>
    public class HomeViewModel : ViewModelBase
    {
        public HomeViewModel()
        {

        }

        public string Username { get; set; }

    }

So what needs to happen is that the Username from the LoginView's ViewModel (which is a UserControl on the LoginWindow) must get passed along to the Username on the HomeView's ViewModel (which is also a UserControl and sits on the HomeWindow).
This code is not important as this is a made up scenario. The core of what I am trying to figure out is how one would pass info along to other Windows' View's ViewModel when it is generated elsewhere.

A: See the getting started with WPF part of the docs. Normally there are services that manage selections / contain application-wide states. Then you let them be injected into your view models whenever you need them.


text:
Q: rsyslog not logging message from program I'm trying to write (the beginning) of a daemon on Ubuntu 15.04 and for some reason rsyslog is refusing to output my logged statements - I've tried multiple localities (LOG_LOCAL1, LOG_LOCAL0, LOG_SYSLOG, LOG_DAEMON), restarted the rsyslog service, and have tested the code on an Arch Linux VM (it works fine).
Application Code:
#include <syslog.h>
#include <unistd.h>
#include <cstdlib>

int main(int argc, char* argv[])
{
  setlogmask(LOG_UPTO(LOG_CRIT));
  openlog("floded", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_SYSLOG);
  syslog(LOG_INFO, "floded entered");
  closelog();
  return(0);
}

/etc/rsyslog.d/50-default.conf:
#  Default rules for rsyslog.
#
#                       For more information see rsyslog.conf(5) and /etc/rsyslog.conf

#
# First some standard log files.  Log by facility.
#
auth,authpriv.*                 /var/log/auth.log
*.*;auth,authpriv.none          -/var/log/syslog
#cron.*                         /var/log/cron.log
daemon.*                        -/var/log/daemon.log
kern.*                          -/var/log/kern.log
#lpr.*                          -/var/log/lpr.log
mail.*                          -/var/log/mail.log
#user.*                         -/var/log/user.log

#
# Logging for the mail system.  Split it up so that
# it is easy to write scripts to parse these files.
#
#mail.info                      -/var/log/mail.info
#mail.warn                      -/var/log/mail.warn
mail.err                        /var/log/mail.err

#
# Logging for INN news system.
#
news.crit                       /var/log/news/news.crit
news.err                        /var/log/news/news.err
news.notice                     -/var/log/news/news.notice

#
# Some "catch-all" log files.
#
#*.=debug;\
#       auth,authpriv.none;\
#       news.none;mail.none     -/var/log/debug
#*.=info;*.=notice;*.=warn;\
#       auth,authpriv.none;\
#       cron,daemon.none;\
#       mail,news.none          -/var/log/messages

#
# Emergencies are sent to everybody logged in.
#
*.emerg                                :omusrmsg:*

#
# I like to have messages displayed on the console, but only on a virtual
# console I usually leave idle.
#
#daemon,mail.*;\
#       news.=crit;news.=err;news.=notice;\
#       *.=debug;*.=info;\
#       *.=notice;*.=warn       /dev/tty8

# The named pipe /dev/xconsole is for the `xconsole' utility.  To use it,
# you must invoke `xconsole' with the `-file' option:
#
#    $ xconsole -file /dev/xconsole [...]
#
# NOTE: adjust the list below, or you'll go crazy if you have a reasonably
#      busy site..
#
daemon.*;mail.*;\
        news.err;\
        *.=debug;*.=info;\
        *.=notice;*.=warn       |/dev/xconsole

What am I missing?

A: The line setlogmask(LOG_UPTO(LOG_CRIT)) discards your log message
syslog(LOG_INFO, "floded entered");

The priority of LOG_INFO is lower than the priority of LOG_CRIT. Therefore
#include <syslog.h>
#include <unistd.h>
#include <cstdlib>

int main(int argc, char* argv[])
{
  // setlogmask(LOG_UPTO(LOG_CRIT));
  openlog("floded", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_SYSLOG);
  syslog(LOG_INFO, "floded entered");
  closelog();
  return(0);
}

or
#include <syslog.h>
#include <unistd.h>
#include <cstdlib>

int main(int argc, char* argv[])
{
  setlogmask(LOG_UPTO(LOG_INFO));
  openlog("floded", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_SYSLOG);
  syslog(LOG_INFO, "floded entered");
  closelog();
  return(0);
}


text:
Q: CollectionView SelectedItem is not highlighted in Xamarin Forms I am trying to highlight Xamarin Forms CollectionView Item, but it seems it doesn't highlight. While debugging I found out that if I remove the SwipeView Gesture event it works as expected. Additionally, in the current code the selection item is changed, but the color is not changning. How can I highlight the selected item?
<CollectionView ItemsSource="{Binding SomeList}"
SelectedItem="{Binding CurrentItem}" SelectionMode="Single" x:Name="itemView">
<CollectionView.ItemsLayout>
     <GridItemsLayout Orientation="Vertical" Span="1"/>
  </CollectionView.ItemsLayout>
  <CollectionView.ItemTemplate>
    <DataTemplate>
    <SwipeView>
     <SwipeView.GestureRecognizers>
         <SwipeGestureRecognizer Direction="Right"
          Command="{Binding BindingContext.SwipGestureCommand, Source={x:Reference itemView}}"
                                                            CommandParameter="right"/>
   </SwipeView.GestureRecognizers>
   <StackLayout Orientation="Vertical" Padding="5">
    <VisualStateManager.VisualStateGroups>
         <VisualStateGroup Name="CommonStates">
        <VisualState Name="Normal" />
        <VisualState Name="Selected">
             <VisualState.Setters>
                     <Setter Property="BackgroundColor" Value="Yellow" />
             </VisualState.Setters>
       </VisualState>
      </VisualStateGroup>
      </VisualStateManager.VisualStateGroups>
          <Label LineBreakMode="WordWrap"  Text="{Binding SomeText}"/>
        </StackLayout>
      </SwipeView>
    </DataTemplate>
  </CollectionView.ItemTemplate>
</CollectionView>

How to highlight the selected collectionview item?

A: Please upgrade Xamarin.Forms version to 4.6 and above, then modify your code like the following code,setting swip background color as white, and adding VisualStateManager.VisualStateGroups for swip.
 <CollectionView
            x:Name="itemView"
            ItemsSource="{Binding SomeList}"
            SelectionMode="Single">
            <CollectionView.ItemsLayout>
                <GridItemsLayout Orientation="Vertical" Span="1" />
            </CollectionView.ItemsLayout>
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <SwipeView BackgroundColor="White">
                        <SwipeView.GestureRecognizers>
                            <SwipeGestureRecognizer
                                Command="{Binding BindingContext.SwipGestureCommand, Source={x:Reference itemView}}"
                                CommandParameter="right"
                                Direction="Right" />
                        </SwipeView.GestureRecognizers>
                        <StackLayout Padding="5" Orientation="Vertical">
                            <Label LineBreakMode="WordWrap" Text="{Binding SomeText}" />

                        </StackLayout>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup Name="CommonStates">
                                <VisualState Name="Normal" />
                                <VisualState Name="Selected">
                                    <VisualState.Setters>
                                        <Setter Property="BackgroundColor" Value="Yellow" />
                                    </VisualState.Setters>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </SwipeView>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>


text:
Q: How to download a full HTML page as pdf using DOMPDF? I used dompdf to download a receipt that is initially in HTML format. But as soon as it gets converted, the orientation and the format gets distorted. Is there  way to download an HTML page as pdf with the same height and width as the HTML page?

A: No there is not. Every html->pdf tool are different. some doesnt allow css some allow html5 but very bad. some allow gif etc. lots of variations. You shouldnt look for a tool that render the html page and convert to pdf. You should find something like view the page and get its screenshots of it and print as pdf. because today's complex html pages are just too overwhelming for html->pdf tools. Those tools are made for html coders to create fancy pdfs.
Try to search browser plug-ins. If you find one you can automatize the process via linux konsole. (fire-fox, maybe chrome too not sure though)


text:
Q: How to Represent a Graph using Dijkstra's Algorithm, Given a .txt file as Input I'm having trouble using Dijkstra's algorithm when given a text file in this format.
The first line represents the number of vertexes. Should I store this value as a 2-Dimensional Array?
I was thinking that I could have the second part of the 2D array be the actual value each vertex holds.
For example vertex 3 holds 78. Vertex 4 holds 87... etc.
The problem I run into is having to store the edges.
1 4 98
Where 1 is vertex 1, 4 is vertex 4, and the distance between them is 98. How would I store this value of 98?
I'm just stumped here, any advice would be greatly appreciated.
Below is the input
Number of Vertexes
Number of Edges
Vertex NumValue
Vertex Vertex NumValue
Where if there are two vertexes, the NumValue that comes after is the Distance between the two.
Input

5
7
3 78
4 87
5 98
1 4 98
5 4 45
1 5 140
4 3 87
2 5 150
3 5 109
3 2 73

Output
388

A: There are many ways to do this, here are some:
public class Edge {
    private class Node {
        private int value;
    }

    private Node from, to;
    private double distance;
}

With this, you can have an arraylist of Edges to represent the graph
public class Graph {
    private class Node {
        private Node adjacent;
        private double distance;
        private int value;
    }

    private Node[] nodes;
}

Here you create a graph class which contains a list of nodes
public class Graph {
    private double[][] matrix;
}

Again this is a graph class but using a matrix. If node 1 has an edge to node 5 with distance 75.9, then matrix[1][5] == 75.9

A: check this approach to represent edge weighted graph http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/EdgeWeightedGraph.java.html


text:
Q: Reload all js file after ajax success Here in my project i am using ajax to change the content of a div on click of button.
Here is my code :
  $('#geo_location').click(function(){

    $.ajax({
        url: '/get_geo_locations/',
        type: 'GET',

        success: function(response){

            currentPage.getTemplateOnly('/static/template/geo_location.html', function(template){
                $('#dataset_container').html(template({
                    geo_location: response
                }));

     $('#dataset_about').html('...')

            });
        }

But i need some js file to be reloaded as it loads on page refresh.
And i am able to change the content but style that is implemented because of some js file is not applicable.
How i can do that ?


text:
Q: Drawing broken Path in Android I'm trying to create the graph of: 1 / (x Squared - 1 )
As you can see, the graph looks nice:

The code below draws the graph above. But I don't want the vertical asymptotes to show.
path.moveTo(valx, valy);
path.quadTo(x, y, middle2, middle);
path.lineTo(x, y); // I think this is what causes the vertical asymptotes to show
canvas.drawPath(path, points);
path.reset();

By looking at the line path.lineTo above, I can see the path is connecting points with a line. That is
why the vertical asymptotes are drawn.
The idea I have implemented is as follows In pseudo code:
//split the x axis into regions and compute a limiting value for each region
Boolean drawMe = false;
//region1: those x values less than the first asymptote = -1
if(Float.compare(x values , first asymptote = -1) < 0 && Float.compare(absolute value of
(Math.abs(x value) - Math.abs(first asymptote) , 0.01f ) > 0)drawMe = true

//region2: those x values between both asymptotes which are -1 and 1:
if(Float.compare(x values , first asymptote) > 0 && Float.compare(x values , second asymptote) < 0
   && Float.compare(absolute value of(Math.abs(x value) - Math.abs(first asymptote) , 0.01f) > 0
   && Float.compare(absolute value of(Math.abs(x value) - Math.abs(second asymptote) , 0.01f) > 0)
   drawMe = true;

//region3: those x values greater than the second asymptote = 1:
if(Float.compare(x values , second asymptote) > 0 && Float.compare(absolute value of(Math.abs(x value) - Math.abs(second asymptote) , 0.01f) > 0 ) drawMe = true;

if(drawMe){
path.moveTo(valx, valy);
path.quadTo(x, y, middle2, middle);
path.lineTo(x, y); // I think this is what causes the vertical asymptotes to show
canvas.drawPath(path, points);
path.reset();
}

However, splitting the x axis into regions is drawing the same exact thing again.
I need to find a way to stop the asymptotes from drawing, and I think the big problem lies
into the line of code:  path.lineTo
Any suggestions

A: The solution is as follows:

*

*Do split the x axis into regions based on where the vertical asymptotes lie

*as points are added to the path, check that the x value of the point does not lie within
a certain threshold of the vertical asymptote

*DONT reset the path and DONT draw the path. Wait for the for loop to add all the points
except those that fall within a certain threshold of the vertical asymptotes

*By not adding those points to the path, the path will be broken up and show the correct graph

*AFTER the for loop finishes adding the points to the path, draw the path
First close the path:
path.close();
Then:
canvas.drawPath(path, points);
The logic was correct, except that I was not transforming the x values and vertical asymptote values as I did for the rest of the points. That is why , the path was being drawn exactly the same all over again.
See the pictures, I was even able to dashed the asymptotes:


text:
Q: How to prevent a checkbox within a table using an onclick event from propagating its own click event? I have a table that handles mouse clicks using onclick for the entire row. The problem is that these rows also contain checkboxes that should not be activating the onclick event. Clicking on a row should cause an event but selecting a checkbox should not.
I found a lot of answers to this but I've been unable to make it work. I'm using simple html/css/js without anything like jQuery.
The answer seems to be due to event propagation and lots of answers say to use stopPropagation(). But Chrome says this function undefined for the event.

Here is my test example.
Clicking on the table results in a "table!" alert. I don't want clicks on the checkbox within the table to cause this alert.

function clickTable(e) {
   alert('table!');
}

function clickCheckbox(e) {
   // Error: e.stopPropagation is not a function
   e.stopPropagation();
}
table {
   border: 1px solid black;
   width: 120px;
   height: 120px;
}

input {
   width: 32px;
   height: 32px;
}
<!DOCTYPE html>

   <meta charset="utf-8">
   <title>Checkbox Click</title>

         <input type="checkbox" name="test" onclick="clickCheckbox(this);">

I can however use window.event.stopPropagation(); which works as expected. But my IDE PhpStorm reports that using window.event in this way is deprecated.
What is the correct use of stopPropagation() for this event?

A: You should use Event delegation where you will get clicked element in table  using event.target and do stuff accordingly.

document.querySelector("table").addEventListener("click", function(event) {
  event.target ? console.log(event.target.nodeName) : console.log(event.target.nodeName)
});
table {
  border: 1px solid black;
  width: 120px;
  height: 120px;
}

input {
  width: 32px;
  height: 32px;
}
<!DOCTYPE html>

  <meta charset="utf-8">
  <title>Checkbox Click</title>

         <input type="checkbox" name="test">

What is DOM Event delegation?

A: Inline event listeners do not pass the event object to the function.
Therefore, the function doesn't receive the event object(e) argument, preventing you from invoking the stopPropagation() method.
That is why I would also advice you avoid inline event listeners.
If you need the element that invoked the event, rather than using this you can use e.target to get the event's targeted element

function clickTable(e) {
  alert('table!');
}

function clickCheckbox(e) {
  e.stopPropagation();
}

const tr = document.querySelector('tr');
const input = document.querySelector('input[type=checkbox]');

tr.addEventListener('click', clickTable);
input.addEventListener('click', clickCheckbox);
table {
  border: 1px solid black;
  width: 120px;
  height: 120px;
}

input {
  width: 32px;
  height: 32px;
}
<!DOCTYPE html>

  <meta charset="utf-8">
  <title>Checkbox Click</title>

         <input type="checkbox" name="test">

A: .stopPropagation() is the correct method, but in order to use it, you must call it on the event object reference that is passed to your event handler. This object reference is automatically passed to DOM event handlers that are set up using the .addEventListener() method and not using the legacy onXyz inline event attributes (which should not be used in today's code).
And, when setting up DOM event handlers using .addEventListener(), there's no need to pass this as this will automatically be bound to the element that triggered the event in the first place, so you can just use this in your callback functions without passing it.
Additionally, your HTML is not valid.  elements belong inside of
 elements, not
 elements.
So, just rework the event handler setup:

table {
   border: 1px solid black;
   width: 120px;
   height: 120px;
}

input {
   width: 32px;
   height: 32px;
}

         <input type="checkbox" name="test">


text:
Q: "Type" in specifying a ring/ field In the definition of fields on wikipedia, it says:

A field is therefore an algebraic structure $\langle \Bbb F, +, \cdot , −, ^{−1}, 0, 1\rangle$; of type $\langle 2, 2, 1, 1, 0, 0\rangle$, consisting of two abelian groups...

I understand that a field is a set containing a set of numbers, some operations, and some identities, but what exactly does "type" mean in this context?


text:
Q: Question about convergence in complex numbers field It may be a simple question, but if we want to show that $(z_n)\subset\mathbb{C}$ is convergent to $z\in\mathbb{C}$ then we should just check that absolute value of $z_n$ is convergent to absolute value of $z$ or we should check real part convergence and imaginary part convergence?

A: No. You should check that
$$|z_n-z|\xrightarrow{n\to\infty}0$$
which's equivalent to the convergence of the real and the imaginary part of $(z_n)$ and notice that we may have $|z_n|\xrightarrow{n\to\infty}|z|$ but $(z_n)$ isn't even convergent: take for example $z_n=(-1)^n$.

A: It's certainly not enough to check that $|z_n|\to |z|$. This doesn't even work in $\mathbb{R}$, since there are two separated numbers with any nonzero absolute value. It's even worse in $\mathbb{C}$, where there's a whole circle's worth of numbers of a given absolute value. It is possible to check that $|z_n-z|\to 0$. This might look similar, but it works, in a sense because $0$ is the only complex number with absolute value zero. A more careful argument uses continuity of the square and square root functions to show this convergence is equivalent to the convergence of each of the terms in the absolute value, which is precisely convergence in real and imaginary parts.


text:
Q: The center of the map at production is not equal at development I created an example and when I upload in Heroku the center of the map is not working how it works on my machine.
<%= gmaps("map_options" => {
        "center_latitude" => 42.359562,
        "center_longitude" => -3.698387,
        "container_id" => "mapaContainer",
        "disableDefaultUI"=> false,
        "disableDoubleClickZoom" => true,
        "id" => "mapa",
        "type" => "ROADMAP",
        "zoom" => 7
},
         "markers" => { "data" => @locales_markers }
    ) %>

Why it happens?


text:
Q: StackOverflowError while traversing a binary search tree in Java I have a method that returns the deepest node in a BST. I have this code which raises a StackOverflow error:
public int getDeepestNode(AvlNode head) {
    if (head == null) {
        return 0;
    } else {
        return (Math.max(getDeepestNode(head.getLeftNode()), getDeepestNode(head.getRightNode())) + 1);
    }
}

To me it looks fine, why is it raising the error?

A: getDeepestNode must occur repeatedly on the stack.
More than likely you have a cycle in the AVL tree. The naming, head, already might be an indication of unclean thoughts. Debugging helps.
Alternatively, you might harden your code as:
public int getDeepestNode(AvlNode head) {
    return getDeepestNodeSafe(head, new ArrayList<AvlNode>());
}

public int getDeepestNodeSafe(AvlNode head, List<AvlNode> pathFromRoot) {
    if (head == null) {
        return 0;
    } else {
        if (pathFromRoot.contains(head)) {
            StringBuilder sb = new StringBuilder("Cycle: ");
            for (AvlNode node : pathFromRoot) {
                if (node == head) {
                   sb.append("***");
                }
                sb.append(node).append("; ");
            }
            Logger.getLogger(getClass().getName()).log(Level.WARN, sb.toString());
            return 0;
        }
        pathFromRoot.add(head);
        int depth = Math.max(getDeepestNodeSafe(head.left, pathFromRoot),
                             getDeepestNodeSafe(head.right), pathFromRoot) + 1;
        pathFromRoot.remove(pathFromRoot.size() - 1); // Undo
        return depth;
    }
}

Throwing an IllegalStateException would definitely be better, but with this code you might find the error faster (or not).


text:
Q: Pdf generators from an xml template? Are there any PDF generators out there be it commercial or open source which can be used for research purposes? That i can use such as pdfnow.com or any standalone desktop apps which allow me to generate a PDF from a XML template. I have tried researching but there is allot of ambiguity going around.

A: Applidok is generating PDF based on an original (raw) PDF, a template definition and dynamic/user data (e.g. from a form): http://go.applidok.com/en/howitworks.gz.html
Template format there is JSON, not XML, but approach is the same.


text:
Q: How to test the https connection of a Nexus Repository Management server I've just setup a Nexus server. I know that my http connection works since I get the "Welcome" page which gets loaded via http. However, I don't see any components when I browse the repositories (the default repos like "Maven Central" are configured).
I don't really know whether it's normal that there aren't any components shown or if my https connection doesn't work (it's quite a hassle with the company's proxy that's why I'm suspicious). So, how can I test whether the https connection works?

A: This is normal. Repositories will only contain artifacts once you have retrieved some of them via the repository manager. E.g. configure Maven as documented in the tools chapter and they proxied artifacts will show up in proxy repos.
You can try to use the Browse Remote tab on the Central proxy repository to verify that a connection to it does work.
For hosted repos you would publish to them.
If you need to connect to the internet via a proxy server you can configure that as well http://books.sonatype.com/nexus-book/reference/configxn-sect-customizing-server.html
Check out the documentation for more tips.


text:
Q: Matplotlib figure facecolor (background color) Can someone please explain why the code below does not work when setting the facecolor of the figure?
import matplotlib.pyplot as plt

# create figure instance
fig1 = plt.figure(1)
fig1.set_figheight(11)
fig1.set_figwidth(8.5)

rect = fig1.patch
rect.set_facecolor('red') # works with plt.show().
                          # Does not work with plt.savefig("trial_fig.png")

ax = fig1.add_subplot(1,1,1)

x = 1, 2, 3
y = 1, 4, 9
ax.plot(x, y)

# plt.show()  # Will show red face color set above using rect.set_facecolor('red')

plt.savefig("trial_fig.png") # The saved trial_fig.png DOES NOT have the red facecolor.

# plt.savefig("trial_fig.png", facecolor='red') # Here the facecolor is red.

When I specify the height and width of the figure using fig1.set_figheight(11) fig1.set_figwidth(8.5) these are picked up by the command plt.savefig("trial_fig.png"). However, the facecolor setting is not picked up. Why?
Thanks for your help.

A: savefig has its own parameter for facecolor.
I think an even easier way than the accepted answer is to set them globally just once, instead of putting facecolor=fig.get_facecolor() every time:
plt.rcParams['axes.facecolor']='red'
plt.rcParams['savefig.facecolor']='red'

A: I had to use the transparent keyword to get the color I chose with my initial
fig=figure(facecolor='black')

like this:
savefig('figname.png', facecolor=fig.get_facecolor(), transparent=True)

A: It's because savefig overrides the facecolor for the background of the figure.
(This is deliberate, actually... The assumption is that you'd probably want to control the background color of the saved figure with the facecolor kwarg to savefig. It's a confusing and inconsistent default, though!)
The easiest workaround is just to do fig.savefig('whatever.png', facecolor=fig.get_facecolor(), edgecolor='none') (I'm specifying the edgecolor here because the default edgecolor for the actual figure is white, which will give you a white border around the saved figure)


text:
Q: terms query does not support minimum_match in Elasticsearch 2.3.3 I want to search documents which match at least two key words using terms query like this:
{
  "query": {
     "terms": {
        "title": ["java","编程","思想"],
        "minimum_match": 2
    }
  },
  "highlight": {
    "fields": {
       "title": {}
    }
  }
}

It returns "terms  query does not support  minimum_match".What's wrong with my query?

A: The correct name was minimum_should_match and that setting has been deprecated in ES 2.0.
What you can do instead is to use a bool/should query with three term queries and the minimum_should_match setting for bool/should queries:
{
  "query": {
    "bool": {
      "minimum_should_match": 2,
      "should": [
        {
          "term": {
            "title": "java"
           }
        },
        {
          "term": {
            "title": "编程"
          }
        },
        {
          "term": {
            "title":  "思想"
          }
        }
      ]
    }
  },
  "highlight": {
    "fields": {
      "title": {}
    }
  }
}


text:
Q: Spring boot , CrudRepository findbyid or findOne is not getting One to many table details of role table @Entity
@NamedQuery(name="User.findAll", query="SELECT u FROM User u")
public class User implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    private Long  id;

    private String email;

    private String password;

    private String username;

    @Transient
    private String passwordConfirm;

    //bi-directional many-to-one association to Role
    @ManyToOne(fetch=FetchType.LAZY ,cascade = {CascadeType.PERSIST})
    private Role role;

    public User() {
    }

    public Long  getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return this.username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Role getRole() {
        return this.role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    @Transient
    public String getPasswordConfirm() {
        return passwordConfirm;
    }

    public void setPasswordConfirm(String passwordConfirm) {
        this.passwordConfirm = passwordConfirm;
    }

}

@Entity
@NamedQuery(name="Role.findAll", query="SELECT r FROM Role r")
public class Role implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    private Long id;

    private String name;

    //bi-directional many-to-one association to User
    @OneToMany(fetch=FetchType.LAZY, mappedBy="role", cascade = {CascadeType.PERSIST})
    private List<User> users;

    public Role() {
    }

    public Long  getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<User> getUsers() {
        return this.users;
    }

    public void setUsers(List<User> users) {
        this.users = users;
    }

    public User addUser(User user) {
        getUsers().add(user);
        user.setRole(this);

        return user;
    }

    public User removeUser(User user) {
        getUsers().remove(user);
        user.setRole(null);

        return user;
    }

}

public interface UserRepository extends CrudRepository <User, Long> {

public UserDto getUserDetailsById(Long userId)  throws commonException  {
        //ArrayList<UserDto> arr = new ArrayList<>();
        User user = userRepository.`findOne`(userId);

            UserDto userDto = new UserDto();
            userDto.setId(user.getId());
            userDto.setUsername(user.getUsername());
            userDto.setEmail(user.getEmail());
            userDto.setPassword(user.getPassword());
            userDto.setRoleId(user.getRole().getId());
            userDto.setRoleName(user.getRole().getName());
           // arr.add(userDto);

        return userDto;

    }

find by Id is not getting role details by using user object.lazy initialization is not happening.When I use to get user ID from user object, I can not get role details.
userDto.setRoleId(user.getRole().getId()); is having null value

A: In your User entity, you have configured the Role collection to load lazily. Therefore when you first call user.getRole(), you get a proxy object. If you want to call methods on the proxy object that need to fetch data, you should initialize the proxy. There is a technique to initialize it. Try the following:
Before the following line of code
userDto.setRoleId(user.getRole().getId());
add the following;
user.getRole().size();

A: For situations where you know that you need a particular association, its generally recommended that you specify that the association be join-fetched.
If the association is optional, you'd use something like:
FROM User u LEFT JOIN FETCH u.role WHERE u.id = :userId

If the association is not-optional, you could improve the above by specifying an inner join like:
FROM User u JOIN FETCH u.role WHERE u.id = :userId

With Spring data, you can use the @Query annotation on methods and specify the JPQL/HQL above to suit your needs.


text:
Q: Draggable and DragTarget, How can I build a widget after a Draggable has been accepted in a DragTarget? I'm building a simple game using flutter,
I tried the code Below,
called a positioned widget after the dragTarget runs the onAccept function...Really don't know why the widget isn't built.

Code
      Positioned(
        bottom: 0,
              child: DragTarget(

                onWillAccept: (data){
                  print(data);
                  return true;
                },

              onAccept: (String value) {
                print(caughtValue);

                    //HERE IS THE THING I WANT TO BUILD
                          Positioned(
                            child: Container(
                              width: 50,
                              height: 50,
                              child: Center(
                                child: Text('data'),
                              ),
                            ),
                          );

                   setState(() {
                        caughtValue = value;
                  });

              },

Really Would appreciate if you could help.

A: You can copy paste run full code below
You can use Visibility wrap Positioned and put under Stack
When onAccept change isVisible to true
code snippet
    Stack(
        alignment: Alignment.center,
        children: <Widget>[
          Draggable(
            feedback: Text('draging'),
            child: Text('drag me'),
          ),
          Positioned(
              top: 30,
              child: DragTarget(
                onAccept: (data) {
                  print(" onAccept");
                  setState(() {
                    isVisible = true;
                    targetText = "data";
                  });
                },
          ...
          Visibility(
            visible: isVisible,
            child: Positioned(
              top: 450,
          ...

working demo

full code
import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new Scaffold(
          appBar: new AppBar(
            title: new Text("DraggableDemo"),
          ),
          body: Drag2TargetPage()),
    );
  }
}

bool isVisible = false;

class Drag2TargetPage extends StatefulWidget {
  @override
  _Drag2TargetPageState createState() => _Drag2TargetPageState();
}

class _Drag2TargetPageState extends State<Drag2TargetPage> {
  var targetText = "Target";

  @override
  Widget build(BuildContext context) {
    return ConstrainedBox(
      constraints: BoxConstraints.expand(),
      child: Stack(
        alignment: Alignment.center,
        children: <Widget>[
          Draggable(
            feedback: Text('draging'),
            child: Text('drag me'),
            //data: "123"
          ),
          Positioned(
              top: 30,
              child: DragTarget(
                onWillAccept: (data) {
                  print("data = $data onWillAccept");
                  return true;
                },
                onAccept: (data) {
                  print(" onAccept");
                  setState(() {
                    isVisible = true;
                    targetText = "data";
                  });
                },
                onLeave: (data) {
                  print("data = $data onLeave");
                },
                builder: (context, candidateData, rejectedData) {
                  return Container(
                    width: 150.0,
                    height: 150.0,
                    color: Colors.blue[500],
                    child: Center(
                      child: Text(targetText),
                    ),
                  );
                },
              )),
          Visibility(
            visible: isVisible,
            child: Positioned(
              top: 450,
              child: Container(
                width: 40,
                height: 20,
                child: Center(
                  child: Text('show'),
                ),
              ),
            ),
          )
        ],
      ),
    );
  }
}


text:
Q: Incorrect Operand Type in Dynamo DB Dynamo DB table
I am trying to append a list to the "Hi" List , but coming up with invalid operator type in the list_append call, which says one of them is a Map but these still look list to me ...
Here is the API call :
response =    node_table.update_item(
              TableName='xyz',
              Key={......},
              UpdateExpression='SET #ri = list_append(:vals, #ri)',
              ExpressionAttributeNames={'#ri':'Hello.Hi'},
              ExpressionAttributeValues={":vals": {"L": [ { "S": "Something" }]}})

Error: Invalid UpdateExpression: Incorrect operand type for operator or function; operator or function: list_append, operand type: M
I referred DynamoDB : SET list_append not working using aws sdk, but could not figure out
Please let me know what am I missing

A: Looking at your table, Hi is a List of Maps.  You're trying to update it with a List of Strings here:
 ExpressionAttributeValues={":vals": {"L": [ { "S": "Something" }]}})

That seems to be what the error message is trying to say.

A: As Matt pointed out the String constraint was infact the error ,
Here is the correct version
response =  node_table.update_item(
        TableName='xyz',
        Key={'..},
        UpdateExpression='SET #ri = list_append(:vals, #ri)',
        ExpressionAttributeNames={'#ri':'Hello.Hi'},
        ExpressionAttributeValues={":vals": ["Something"]})


text:
Q: Energy and colours of the stars We know that stars have different colours because they have different energy. So blue stars have a lot of energy because the blues's frequency is very high $E = h\nu$. The colour of the star is its electromagnetic radiation which is influenced by the elements of the star. All stars issue white light, but we know that the absorption spectrum isn't a continue spectrum because some elements absorb some radiations. So does the blue star contain elements which absorb low radiations and so there are only high radiations which color the star with blu/violet? And what are these elements? How can we know if an element absorb radiations with low or high frequency?

A: Is your question not a contradiction in itself? You say that because of different star energies the colors occur, and then you switch this thesis with stars emitting white light, and elements absorbing the nonblue-parts.
Essentially this is not completely correct (unless I understand you wrongly). Saying that stars have different energy is not precise and I think uncorrect in this case.
What you should look into is black body radiation and Plancks law of radiation. Essentially this topic states that a higher temperature responds to different wavelengths, that are emitted off the star. Take a look at this image.

As you can see this shows the intensity dependent on wavelenght. The different curves correspond to different temperatures and higher temperatures cause more energetic radiation, thus radiation with lower wavelength and higher frequency. This so called black body radiation describes the different colors of objects at different temperatures. Think of metal that doesn't (or almost) emit visible light on its own when it is at room temperature, but heated up to sufficient temperatures it will start glowing. So yes the temperatures of stars correlate with their colors, the more detailed understanding of this comes from nuclear fusion and the different types of stars. This is represented in the Hertzsprung-Russel diagram.

The diagram represents a correlation between stellar color and size, which has to do with the nuclear processes involved in the star. I think you should research on this topic as well, as writing it out here would take some time.
But as to your final statement, yes indeed there are elements absorbing light in stars, especially in the stars outer sphere. I am sure you have heard of the Fraunhofer lines, and won't give an explanation here, but as to our current understanding of stars the color is not influenced due to complete absorption of gigantic parts of the electromagnetic spectrum, the line spectra give us clues about the elements that the star consists of, which again also has some relation to the size of the star (and its age). To understand this even better, I think the following image will help.

You see the exact correlation of stellar spectra as predicted by the black body radiation (the first image). Resonance absorption due to stellar elements cause the discrete absorption lights, the temperature however is the main factor governing the color.

A: The observed color of a star depends on the surface temperature of the star, not on the mixture of elements in the photosphere.  Cool stars are reddish (3000-4000 K) whether they are big or small, fusing hydrogen or helium in the core.  Their size is determined partly by the mass and what is fusing in the core (which depends on the age of the star).
Elements in the photosphere (the visible outer layer of the star) produce absorption lines, but these have no noticeable  effect on the gross color appearance of the star. High resolution spectroscopy is used to determine the trace elements of the photosphere which helps in determining the history of the star.
Hotter stars (5000-6000 k) appear bright yellow to white and are more massive than small, red stars.
Blue stars are very hot (8000-10000 K or more) because their very large masses cause intense core compression, increasing the fusion rate in the core which makes the surface very hot.  They are not blue because of different elemental makeup, although they might be slightly different due to being younger stars in general (blue stars tend to burn out faster than yellow and small red stars).


text:
Q: JavaScript / Paginating Divs I am battling with a situation and figured I'd post the problem here to see if someone can figure out where I am going wrong.
The idea behind what I am doing is as follows:
I have a page (this is actually and iPad application) that allows to the user to scroll left and right moving forward and backward.  Each time the user swipes left (moving forward) we want to show them a new 768px page (width).  Being that each div is 768 pixles in width and that we can have 50+ divs the idea behind it was to remove the leading page.
So at all times I have 4 divs on the screen, only 1 div at a time will show.  So at startup we have something like below.
<content>

content

content

content

content

</content>

When the user swipes right I want to remove wrapper_1, add wrapper_5 and basically have everything re position properly.
The problem that I am having is each time I remove the leading div my content div obviously changes width and I lose the page I am looking at.  So the obvious "fix" in my mind was to reposition content taking into account for the div I just removed.
However I am battling with the jquery offset method.  Either I am using this incorrectly, or I am overlooking something.
 $('#wrapper_'+this.pageArray[0]).remove();
 this.pageArray.shift();

 var n = pageIndex - 1;
 var t = 768 * n;

 $("#content").offset({ left: t})

I am keeping track of what divs are on the page by storing the in an array.  Each time I add a page I basically do a remove() on the div and then a shift on the array.  Now the problem is the offset doesn't work the way I had expected it to.  Basically it doesn't appear that the left values give me an absolute x position.
Firstly, does this approach seem correct?  Secondly is my understanding / implementation of offset incorrect?
Edit:
For anyone following the thread, it seems my biggest problem was how I was handling the gesturing.  It appears there were some event conflicts, using a gesturing library certainly seems to have cleared up a lot of the confusion on my end.
Below is my updated code, which is seems to be working well.  Feel free to critique the approach.

Page 0

Page 1

Page 2

Page 3

Previous

Next

A: There is a great swipeview plugin for mobile apps (android, iphone) and browsers here: http://cubiq.org/swipeview .
It works exactly the way you need it to (you can disable the looping effect) - this is the demo page.
In case you don't want to use a plugin it may help you with some ideas on how to do it.


text:
Q: Unexpected result combining 3 URIs I have the following code to concat some URIs:
public static Uri BuildUri()
{
    Uri baseUri = new Uri("http://192.168.1.60:8080");
    Uri restUri = new Uri(baseUri, "/rest/api/2");
    Uri url = new Uri(restUri, "/mypreferences?key=my.config.value");

    return url;
}

I expect the following address, in the result URI:
http://192.168.1.60:8080/rest/api/2/mypreferences?key=my.config.value

But I'm getting:
http://192.168.1.60:8080/mypreferences?key=my.config.value

Would someone please could explain why?

A: Try this ie, you need to change the last url. You are passing the baseUri however you should pass the restUri:
Uri baseUri = new Uri("http://192.168.1.60:8080");
Uri restUri = new Uri(baseUri, "/rest/api/2/");
Uri url = new Uri(restUri, "mypreferences?key=my.config.value");
                   ^^^^^^---Here

A: void Main()
{
    Uri baseUri = new Uri("http://192.168.1.60:8080");
    Uri restUri = new Uri(baseUri, "/rest/api/2/");
    Uri url = new Uri(restUri, "mypreferences?key=my.config.value");

    Console.WriteLine (url);
}

This correctly prints
http://192.168.1.60:8080/rest/api/2/mypreferences?key=my.config.value

The difference must be because of how it interprets the forward slash in different URI's. Where exactly this is mentioned in the docs I haven't found yet, but at least you have your solution already.

A: You use the baseUri in both creating the restUri and url. You probably meant to do this instead:
public static Uri BuildUri()
{
    Uri baseUri = new Uri("http://192.168.1.60:8080");
    Uri restUri = new Uri(baseUri, "rest/api/2");
    Uri url = new Uri(restUri, "mypreferences?key=my.config.value");
    return url;
}

Use baseUri to create restUri and use restUri to create the final url. Also notice how i have left out the leading slashes in the sub urls. The Uri class will handle the correct concatenation for you.

A: Related: Appending multiple segments with System.Uri
You want to append a / to the end of your path, and remove it from the first path.
Uri baseUri = new Uri( "http://192.168.1.60:8080" );
Uri restUri = new Uri(baseUri, "/rest/api/2/");