text:
Q: Show that if $u$ is non-negative and harmonic then $|\nabla u(x_0)| \leq \frac{2}{R}u(x_0)$ Suppose $x_0 \in \mathbb{R}^2$ and $u \in C^2(\bar{B}_R(x_0))$ is a non-negative harmonic function. I want to show that $$|\nabla u(x_0)| \leq \frac{2}{R}u(x_0)$$
I know that since $u$ is harmonic it satisfied the mean value property. I'm given two mean value properties (which I earlier proved are equivalent):
$$u(x)=\frac{1}{2\pi r}\int_{B_r(x)}u(y) \, dS(y)$$
and $$u(x)=\frac{1}{\pi r^2}\int_{B_r(x)}u(y) \, dy$$
I think using these is probably the way to get the result, I'm not sure how though.

A: Rotate your coordinates so that $\nabla u(x_0)$ is in the $e_1$ direction. Note that since $u$ is harmonic, its partial derivative $\partial_1 u$ is too; so the mean value property (ball version) plus the divergence theorem give
$$ \partial_1u(x_0) = \frac{1}{\pi R^2}\int_{B_R} \partial_1u = \frac{1}{\pi R^2}\int_{B_R} {\rm div}(u e_1) = \frac{1}{\pi R^2}\int_{\partial B_R} u e_1 \cdot n.$$
Estimating $|e_1 \cdot n | \le 1$ and applying the mean value property (this time the sphere version) along with the fact $u \ge 0$ we get
$$ |\partial_1 u(x_0)| \le \frac{1}{\pi R^2}\int_{\partial B_R} |u|=\frac{2 \pi R}{\pi R^2}u(x_0).$$
The LHS here is exactly $|\nabla u(x_0)|$ by our choice of coordinates, and the RHS is exactly $\frac 2 R u(x_0)$.

A: It is not hard to prove that if $u \geq 0$ is harmonic on $B(x_0,R)$, then for any $x \in B(x_0,R)$ we have $$u(x) \leq \frac{R+||x-x_0||}{R-||x-x_0||}u(x_0).$$ This you can do by using the mean value property you mentioned above and very simple triangle and reverse triangle inequality of the norm. But then $$u(x)-u(x_0) \leq \left(\frac{R+||x-x_0||}{R-||x-x_0||}-1 \right)u(x_0)=\frac{2||x-x_0||}{R-||x-x_0||}u(x_0).$$ Now, take the norms and divide on both sides by $||x-x_0||$ and let $x \to x_0.$


text:
Q: Choosing between multiple executables with same name in Linux The system I am using has gnuplot installed in /usr/bin. I don't have root, but I needed a newer version of gnuplot, so I installed it to $HOME/usr/bin.
I added $HOME/usr/bin to my path, but it still executes the one in /usr/bin if I just use the gnuplot command. I'd rather not have to specify $HOME/usr/bin/gnuplot every time I have to use it.
How do I tell Linux to use the one in my home directory, and not the one in /usr/bin?

A: Executables are found in PATH order. You need to prepend ${HOME}/usr/bin to your path, like so:
export PATH="${HOME}/usr/bin:$PATH"

A: What Bombe says is ok. I would add that you should declare your user specific PATH entries inside your user's bashrc ($HOME/.bashrc), so your PATH settings only apply to your user.

A: Executables are found in PATH order. Your PATH apparently is set up such that /usr/bin precedes ~/usr/bin/.

A: Besides modifying the PATH as has been explained, you can also use aliases like this (in BASH)
alias gn=$HOME/usr/bin/gnuplot

then you just run it with
gn

redpajama_set_name: RedPajamaStackExchange


text:
Q: How do determine if drop was exactly with right mouse button up? I implemented simple wpf drag and drop and it works good with left or right mouse button. But how can I determine  if drop was exactly with the right mouse button?
My drag'n'drop begins with DragDrop.DoDragDrop and ends with
private void OnDropChannelsCommand(DragEventArgs e)
{
    ...
}

e.KeyStates is allways DragDropKeyStates.None.

A: Finally I end up with handling DragEnter event with
e.KeyStates == DragDropKeyStates.RightMouseButton

check. Mouse.RightButton was set to Released for some reasons.

A: The last point to determinate mouse buttons is DragOver event.
You can then use something like:
if ((e.KeyState & 32) == 32) { bool alt = true; }
if ((e.KeyState & 16) == 16) { bool mousebuttonmiddle = true; }
if ((e.KeyState & 8) == 8) { bool control = true; }
if ((e.KeyState & 4) == 4) { bool shift = true; }
if ((e.KeyState & 2) == 2) { bool mousebutton2 = true; }
if ((e.KeyState & 1) == 1) { bool mousebutton1 = true; }

To check what is what, and determinate e.Effect at your desired value.
Then you can decide what to do within OnDrop event usung the just previously modified e.Effect.


text:
Q: Bootstrap: Buttons in a row with no gap between I'm new to this. I'm trying to make a row of buttons in Bootstrap with no gap in between, but trying to adjust margin and padding settings makes no difference, so I think it's something else.

    <button class="btn"></button>

    <button class="btn"></button>

    <button class="btn"></button>

    <button class="btn"></button>

    <button class="btn"></button>

    <button class="btn"></button>

Anyone know what I'm doing wrong?

A: Bro please provide CSS for every id's and classes so that we can get idea.
Or you can put your all buttons in single col-md-12 like

Add buttons

A: Gaps are shown because you put each button inside each col-xs-2. The col in bootstrap has its own width. To solve your issue, try to create just 1 column and call it col-xs-12 and put all your buttons there.

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

     <button class="btn"></button>
     <button class="btn"></button>
     <button class="btn"></button>
     <button class="btn"></button>
     <button class="btn"></button>


text:
Q: Error management I use spring boot in a rest architecture.
I'm a newbee with error management.
My code have this structure
@Transactional
@Override
public void processPayment() throws CreditCardPaymentException{
    List<Payment> payments = paymentRepository.findByDateLessThanEqualAndPaymentModeAndStatus(LocalDate.now(), PaymentModeEnum.CREDITCARD, StatusEnum.STANDBY);
    processCreditCardPayment(payments);
}

private void processCreditCardPayment(List<Payment> payments) throws ProcessPaymentException{
    PaymentGatewayConfig paymentGateway = new PaymentGatewayConfig();
    String crypt_type = "7";
    for (Payment payment : payments) {
        chargeMemberCreditCard(payment, crypt_type, paymentGateway);
    }
}

private ResolverReceipt chargeMemberCreditCard(Payment payment, String crypt_type, PaymentGatewayConfig paymentGateway) throws ProcessPaymentException {

    try {
        if (resreceipt != null) {

            //information about customer we have sent are returned
            ResolveData resdata = resreceipt.getResolveData();
            //todo check auth code
            if (Boolean.valueOf(resreceipt.getComplete()) && !Boolean.valueOf(resreceipt.getTimedOut())) {
                //if (resreceipt != null && resreceipt.getResponseCode() != null && Integer.getInteger(resreceipt.getResponseCode()) < 50) {
                payment.setStatus(StatusEnum.COMPLETE);
            } else {
                payment.setStatus(StatusEnum.FAIL);
            }
        }

    } catch (Exception e) {
        throw new ProcessPaymentException();
        log.error("chargeMemberCreditCard -  payment: " + payment.getPaymentId(), e);
    }

}

If there is an error in a payment, I want to pass to the next one.
If there are many error at the end, I just want to know there are err who happen.
No sure if it's the way to go and if this code will do that.

A: accumulate your failed Payments or Exceptions in processCreditCardPayment
private void processCreditCardPayment(List<Payment> payments) throws ProcessPaymentException{
PaymentGatewayConfig paymentGateway = new PaymentGatewayConfig();
String crypt_type = "7";
List<Payment> failedPayments = new ArrayList<Payments>();
for (Payment payment : payments) {
    try {
        chargeMemberCreditCard(payment, crypt_type, paymentGateway);
    } catch (ProcessPaymentException ppe) {
        filedPayments.add(payment);
        // or you can accumulate excetions instead of Payments
    }
}
// create some higher level exception with failed Payent collection and throw it, or log it.


text:
Q: Value cannot be resolved The purpose of the below code snippet is to create an instance of a matrix and then calculate the determinant of an nxn matrix. However, method computeDet won't return because the following error occurs: value cannot be resolved to a variable. Why is that?
** determinant code edited from here (this code does work - no error)
public class MatrixArrayCR {
long[][] matrix;

public MatrixArrayCR(long[] arr) {
    double len = Math.sqrt(arr.length);
    int counter = 0;
    for (int i=0; i==len; i++) {
        for (int j=0; j==len; j++) {
            matrix[i][j] = arr[counter];
            counter++;
        }
    }
}
// determinant method edited from code off http://www.coderanch.com/t/446179/java/java/Learning-Project
    public long determinant() {
        return computeDet(matrix);
    }
    public long computeDet(long[][] matrix) {
        int matrixSize = matrix.length;
        if (matrixSize==2) {
            return matrix[0][0]*matrix[1][1]-matrix[0][1]*matrix[1][0];
        } else {
            long value = 0;
            for (int i=0; i<matrixSize; i++) {
                long[][] minor=generateMinor(matrix,0,i);
                value += (sgn(i)*matrix[0][i]*computeDet(minor));
            }
        } return value; //ERROR HERE
    }
    private int sgn(int n) {
        if (n%2==0) {
            return 1;
        } else {
            return -1;
        }
    }
    private long[][] generateMinor(long[][] matrix, int row, int column) {
        int matrixSize = matrix.length;
        int minorSize = matrixSize -1;
        int counterOne = 0;
        int counterTwo = 0;
        long[][] minor = new long[minorSize][minorSize];

        for (int i=0; i<matrixSize; i++) {
            if (i==row) {
                continue;
            } for (int j=0; j<matrixSize; j++) {
                if (j==column) {
                    continue;
                } minor[counterOne][counterTwo] = matrix[i][j];
                ++ counterTwo;
            } ++counterOne;
            counterTwo = 0;
        } return minor;
    }
}

A: value is a local variable, i.e it's only visible in the block it has been declared. Since you declared value in the else block and try to return it outside this block, you get this error.
The return statement should be in the else block. I.e :
public long computeDet(long[][] matrix) {
        int matrixSize = matrix.length;
        if (matrixSize==2) {
            return matrix[0][0]*matrix[1][1]-matrix[0][1]*matrix[1][0];
        } else {
            long value = 0;
            for (int i=0; i<matrixSize; i++) {
                long[][] minor=generateMinor(matrix,0,i);
                value += (sgn(i)*matrix[0][i]*computeDet(minor));
            }
            return value;
        }
    }

A: The value variable is declared inside of an if or else block and is only visible within the block it was declared. If you want it visible at the end of the method, declare it at the start of the method, before the if/else blocks.
public long computeDet(long[][] matrix) {
    long value = 0L;
    int matrixSize = matrix.length;
    if (matrixSize==2) {
        value = matrix[0][0]*matrix[1][1]-matrix[0][1]*matrix[1][0];
    } else {
        for (int i=0; i<matrixSize; i++) {
            long[][] minor=generateMinor(matrix,0,i);
            value += (sgn(i)*matrix[0][i]*computeDet(minor));
        }
    }
    return value;
}

Either that or return it from inside of the else block:
public long computeDet(long[][] matrix) {
    int matrixSize = matrix.length;
    if (matrixSize==2) {
        return matrix[0][0]*matrix[1][1]-matrix[0][1]*matrix[1][0];
    } else {
        long value = 0;
        for (int i=0; i<matrixSize; i++) {
            long[][] minor=generateMinor(matrix,0,i);
            value += (sgn(i)*matrix[0][i]*computeDet(minor));
        }
        return value; //ERROR HERE
     }  // this guy moved
}


text:
Q: Cannot Build Anroid Apk using Ionic CLI
I have build tools installed and are in path variable.

*

*Where:
Script 'D:\ProgrammingSource\IonicProjects\ShoppingCartGeneric\platforms\android\CordovaLib\cordova.gradle' line: 68

*What went wrong:
A problem occurred evaluating project ':app'.

No installed build tools found. Install the Android build tools version 19.1.0 or higher.

A: using the following command i came to know that the build tools were not downloaded.
sdkmanager --list
Finally, this solved the problem..
sdkmanager "build-tools;19.1.0"


text:
Q: Make a Windows 7 shortcut to a specific pdf page Is there a way to make a Windows 7 shortcut to a specific pdf page?

A: If you have Adobe Acrobat Reader installed, you can create a shortcut to a command line that opens a PDF file to a specific page:
AcroRd32.exe /A "page=7=OpenActions" myfile.pdf

Will open "myfile.pdf" to page 7.
You can find more command line switches here.

A: In 2021, on Windows 10, it is possible using following commands
Using Acrobat Reader
%acrobat%  /A "page=44=OpenActions" "..\Magazines\2021-05.TA-663.Mai.pdf"

Using Foxit Reader
%foxit% "..\Magazines\2021-05.TA-663.Mai.pdf" /A page=45

Using Chrome
start chrome "file:///D:\Documents\Magazines\2021-05.TA-663.Mai.pdf#page=44"

Using Opera
start opera "file:///D:\Documents\Magazines\2021-05.TA-663.Mai.pdf#page=44"

Using Edge
start msedge "file:///D:\Documents\Magazines\2021-05.TA-663.Mai.pdf#page=44"

Using Firefox
start firefox "file:///D:\Documents\Magazines\2021-05.TA-663.Mai.pdf#page=44"

On my PC, %acrobat% and %foxit% variables are equal to
set acrobat="C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\acroRd32.exe"
set foxit="C:\Program Files (x86)\Foxit Software\Foxit Reader\FoxitReader.exe"

All these solutions are working correctly on my PC.

A: This is a little example using AcroRd32.exe program.
Every month I receive a customer's magazine named "Test-Achats".
On my PC, I have created a folder in which I put all these magazines.
When I read an interesting article in a magazine, I create a BAT file on which I can click to display directly the good page.
My folder structure is following
Test-Achats
    Script
        LOAD-ARTICLES.bat
        2000-00.TA-000.#00.bat
    Magazines
        2021-05.TA-663.Mai.pdf
        2021-06.TA-664.Juin.pdf
        ...
    Favorites
        2021-05.TA-663.#44 - Isolation habitation.bat

2021-05.TA-663.#44 - Isolation habitation.bat contains only following line
call ..\Script\LOAD-ARTICLE.bat %~n0

LOAD-ARTICLES.bat contains
::******************************************************************************
::* LOAD-ARTICLE.bat
::******************************************************************************

:: extract filename prefix and page number

set args=%1
set file=%args:~0,14%
set page=%args:~16%

:: find exact name of PDF file

set folder=..\Magazines

for %%x in ("%folder%\%file%*") do set ta-file=%%x

:: load file at given page using Acrobat Reader

%acrobat% /A "page=%page%=OpenActions" "%ta-file%"

I only hope that this example can help other to implement "shortcut" to read quickly some articles in PDF files.
Using this solution, all %article%.bat file contains all same line.
The only thing to do is copying sample file named 2000-00.TA-000.#00.bat and contained in Script folder and ... rename it !


text:
Q: Using Roles and Claims together in ASP.NET Identity 2 The question is: can I use roles and claims together?
At this moment application has roles like: teacher, student, parent. Could I use claims like: create, read, update, delete for each role?
This means that I want to allow some teachers to do everything with Lessons, but some teachers can only read Lessons.
What is the best way to resolve the task?


text:
Q: Telephone mask (number format) with variable lenght I was looking for the best solution to mask cells with telephone numbers like the example:
(+55 11) 99999-9999
Normally I'd use (+## ##) #####-#### as a custom number format. The problem is that the length of the number may vary. Nine numbers for cellphones and eight for home numbers. So, with a mask like that, an eight number phone would be formated like (+5 51) 19999-9999

A: Well, while posting this question I found the solution I wanted using Custom Number Format with conditions based on the number value.
[<=999999999999](+00 00) 0000-0000; [>999999999999](+00 00) 00000-0000;


text:
Q: Unusual improper integral I was looking for exercises on improper integrals and saw this problem

Evaluate the following integral $$I=\int_0^2 \frac{dx}{\sqrt{\left| 1-x^2\right|}}$$

To begin, I graphed the function $f(x) = \frac{1}{\sqrt{\left| 1-x^2\right|}}$ and saw that it has an asymptote at $x=1$, so I decided to split the integral into
$$\int_0^1 \frac{dx}{\sqrt{\left| 1-x^2\right|}}+\int_1^2 \frac{dx}{\sqrt{\left| 1-x^2\right|}}$$
For the first integral it's quite easy for me to see that the first integral will evaluate to $\pi/2$. But the problem starts when I try to evaluate the second integral. Specifically when I change its bounds. If I let $x=\sin\theta$ and $dx = \cos\theta d\theta$, I'd get
$$\int_{\pi/2}^{\arcsin 2} \frac{\cos \theta d\theta}{\left| \cos \theta \right|}$$
The main problem here is $\arcsin 2$, it's not a real value. As far as I know, the original integral had a real integrand and a real bound, so the result should be a real value, but when the substution comes in, it turns complex. Am I doing something wrong? Is there a way to evaluate this second integral?

A: Hint…for $x\in[1,2]$, $|1-x^2|=x^2-1$, so use $x=\cosh u$

A: $$
\begin{aligned}
I &=\int_0^2 \frac{d x}{\sqrt{\left|1-x^2\right|}} \\
&=\int_0^1 \frac{d x}{\sqrt{1-x^2}}+\int_1^2 \frac{d x}{\sqrt{x^2-1}} \\
&=\left[\sin ^{-1} x\right]_0^1+ [\ln |\sec \theta+\tan \theta|]_{\sec ^{-1} 1}^{\sec ^{-1} 2} \quad (\textrm{ By letting  }x=\sec \theta) \\
&=\frac{\pi}{2}+\ln (2+\sqrt{3})
\end{aligned}
$$


text:
Q: Camunda Data Concurrency Issue I'm facing Camunda concurrency issues while performing the concurrent operation. In case of multiple requests, when we are setting variables of one service task having multiple instances and in another service task, we are getting partial data. But while requesting one at a time isn't causing any issue while getting Camund variable in any service task.
This below is our use case:
We are using rabbitMQ for messaging.

1. Message Received: Consume the messages from the queue and setting all the variables of Camunda while starting the Process
  Engine.

Note : Concurrency of rabbitMQ consumer is 5.

2. Task 1: This service task is not getting all variables when we produce multiple requests to the rabbitMQ producer even though
  rabbitMQ consumers consume concurrent 5 requests at a time but Camunda
  isn't able to fetch all those variables as per concurrent requests.

Note: One request at a time is fetching all data from Camunda variables.

3. Task 3: The Same issue happing in Task 2 as well.

This behavior is random, sometimes in task 1 or task 2 or sometimes works fine.

A: If I understand correctly, some event is creating queued items from rabbitMQ and this one in turn starts processes in Camunda.  If this is the case, consider using the event that creates item in the rabbitMQ queue to create the direct process in Camunda via RestAPI.  Consider using External Task on task 1 of your process, so Camunda would do the orchestration and queue function at the same time, eliminating the need to use rabbitMQ.


text:
Q: Java Transaction service I want to use Java Transaction service for distributed transaction management in my Java application.
I have 3 different databases to which I have to connect using 3 different Connection objects. I want to insert certain data in each of the 3 databases.
My requirement is that atomicity should be maintained. So either data should get inserted in all 3 databases or it should not get inserted in any of the databases.
I searched on net for this kind of transactions and I got Java Transaction service.
I could find its API here http://java.sun.com/products/jts/javadoc/index.html
But I am still not getting how implement transactions using it. Can somebody provide me with links to sample code or tutorials of Java Transaction Service.
Thanks in Advance,
Aniket Kedari

A: Some points:

*

*XA is not the only possible solution for solving this problem, though it probably the simplest because of the maturity of tools around it (search for CAP theorem and BASE - Basically Available Soft-state Eventually consistent).

*XA transactions have failure modes and you can still get windows of inconsistency between the participating databases.

*You don't say which database(s) you are using - maybe one or all of them don't support XA transactions.

*It's unlikely that you want to use the raw JTS/JTA APIs in Java, instead you can use any of the well-known Java application servers as they contain a transaction manager (which uses JTS/JTA).

So assuming you decide to use a Java Application Server, I'd suggest using Spring, EJB 3.0 or something similar for your database interaction as they will allow you to do declarative transactions which is much cleaner than manually writing transaction logic yourself.
Here's a link to Spring's documentation on transactions.

A: The topic you need to search on is XA transactions.
What you need to know is covered well here:
http://www.javaworld.com/javaworld/jw-04-2007/jw-04-xa.html

Distributed transaction processing
  systems are designed to facilitate
  transactions that span heterogeneous,
  transaction-aware resources in a
  distributed environment. Using
  distributed transactions, an
  application can accomplish tasks such
  as retrieving a message from a message
  queue and updating one or more
  databases in a single transactional
  unit adhering to the ACID (Atomicity,
  Consistency, Isolation and Durability)
  criteria. This article outlines some
  of the use cases where distributed
  transactions (XA) could be used and
  how an application can achieve
  transactional processing using JTA
  along with the best of the breed
  technologies. The main focus is on
  using Spring as a server framework and
  how one can integrate various JTA
  implementations seamlessly for
  enterprise level distributed
  transactions.

A: For a simple situations using a single database you don't worry about this, the combination of JDBC and the database's own capabilities are sufficient. Your situation is more complex. There needs to be a Transaction Manager, which looks after all the details managing distributed transactions across the databases. So you need an implementation offering the JTA apis.
Although you could, in principle develop this your self, it's a very speciliased piece of work so practically you need to use an existing implementation. This is one of the things you get when you use a Java EE application server.
So, go and get one of the many available Java EE App Servers, there are good zero-cost ones.
WebSphere Community Edition is IBM's, JBOSS is a widely used server, Glassfish is available from Sun.
Which ever one you pick, make sure you use their JDBC connection pools for your JDBC connections (very easy to do)  and I would suggest using simple Session Bean (in EJB 3 this is also really easy) to demark your transactions.
Overall, you'll need to write about 4 new lines of code (or annotations). over what you have now and "bingo!" you're doing 2PC transactions. There is a bit of a learning curve in getting the App Servers up and learning how to use the facilities but if you need Java distributed transactions you need infrastructure services and prgramming framework so some level of learning is inevitable.


text:
Q: In Xcode 4 version control, what does it mean when there is a question mark near a file that you have just added to the project? How do you change it to ensure that the file is properly added?
I copied some files into my project folder. Then in Xcode I clicked on a group and chose "Add files to project...". Then I selected multiple files.
One of the files was added properly - It had an "A" next to it. The other file had a "?" mark next to it.
Why didn't it add properly? What should I do to add it properly? It is a PNG file.

A: The ? mark means that the file is not under source control (but is part of the project). You can add it to the project by clicking on the file ---> Source Control ----> Add.


text:
Q: why the HIT header are not shown on JS/CSS I have this VCL here https://pastebin.com/RPJvAqZ1  but the varnish Hits are not showing for the JS/CSS
see the headers in the drobpox folder at the bottom (*)
it is a classic/woocomerce/WordPress vcl
I just added:
if (req.http.cookie ~ "learn_press_user_guest_id") {
    return(hash);
  }

and to the has section I added
sub vcl_hash {

hash_data(req.url);

if (req.http.host) {
hash_data(req.http.host);
} else {
hash_data(server.ip);
}

if (req.http.Cookie) {
hash_data(req.http.Cookie);
}

}

The learnpress cookie is a cookie set for the guest users, so that I had to make that hash, am I right here?
do I have to make one for PHPSESSID?
this is my stats in the dropbox folder (*)
(*) dropbox folder
https://www.dropbox.com/sh/lmjkzy0n40vkotq/AAB7p_PK-jaeUsf3cbdasi-Wa?dl=0
please help me.


text:
Q: How to explain the output order of this code snippet?

    new Promise((resolve,reject) => {
        console.log('outer promise')
        resolve()
    })
    .then(() => {
        console.log('outer 1 then')
        new Promise((resolve,reject) => {
            console.log('in promise')
            resolve()
        })
        .then(() => {
            console.log('in 1 then')
            return Promise.resolve()
        })
        .then(() => {
            console.log('in 2 then')
        })
    })
    .then(() => {
        console.log('outer 2 then')
    })
    .then(() => {
        console.log('outer 3 then')
    })
    .then(() => {
        console.log('outer 4 then')
    })

Here are my explanation:
1.Execute the new Promise,output outer promise
2.Execute the first outer then,its callback go to the microtask queue.The second outer then,the third outer then and the fourth outer then execute later,but all of their callback don't go to the queue since each promise returned by each then still in pending state.
3.Execute the callback of the first outer then,and output outer 1 then.After that,new Promise will output in promise
4.Execute the first inner then,its callback go to the microtask queue.The callback of the second inner then don't go to the queue
5.Now,the callback of the first outer then has totally finished,which means the promise returned by  the first outer then has resolved.Thus,the callback of the second outer then go to the queue
6.Execute the first task of the queue,it will output outer  2 then and makes the callback of the third then go to the queue.Next,execute the callback of the second inner then,it will output in  2 then
7.Execute the callback of the third outer then,it will output outer 3 then and makes  the callback of the fourth then go to the queue.
8.At last,execute the callback of the fourth outer then,it will output outer 4 then
Therefore,the output order should be:
outer promise
outer 1 then
in promise
in 1 then
outer 2 then
in 2 then
outer 3 then
outer 4 then

But it actually ouput:
outer promise
outer 1 then
in promise
in 1 then
outer 2 then
outer 3 then
outer 4 then
in 2 then

What I am confused is why in 2 then will output at last? And why outer 2 then,outer 3 then,outer 4 then will output continuously? This is different from what I have thought about event loop.I thought the result is something to do with the statement return Promise.resolve(),but I don't know what the statement exactly do and why it will influenced the output order.

A: Before explaining the output of your code, it is important to note that real-world code should not rely on the timing of promises in unrelated promise chains. If you want one promise to settle after/before another promise, instead of relying on the timing in which both of them will be resolved, create a promise chain that settles the promises in a sequential manner.
Having said that, the key to understanding the output of your code is to understand how the promise returned by the nested then() method
...
.then(() => {
  console.log('in 1 then')
  return Promise.resolve()
})
...

is resolved.
Following steps explain the output:

*

*As the executor function passed to the Promise constructor is called synchronously, first thing that gets logged on the console is 'outer promise'
micro-task queue: [ ]

console output:
---------------
outer promise

*After the above console.log statement, resolve function is called. As a result, the newly created promise is resolved synchronously.
This queues a job in the micro-task queue to execute the fulfilment handler passed to the then() method.
micro-task queue: [ job('outer 1 then') ]

console output:
---------------
outer promise

*After synchronous execution of the script ends, javascript can start processing the micro-task queue.
First job in the micro-task is dequeued and processed. As a result, 'outer 1 then' and 'in promise' are logged on the console.
micro-task queue: [ ]

console output:
---------------
outer promise
outer 1 then
in promise

As the nested promise is resolved as a result of resolve() function call, a job is enqueued in the micro-task queue to execute its fulfilment handler.
...
.then(() => {
  console.log('in 1 then');
  return Promise.resolve();
})
...

micro-task queue: [ job('in 1 then') ]

console output:
---------------
outer promise
outer 1 then
in promise

*As the callback function of the outer 1st then() method ends, implicitly returning undefined leads to the fulfilment of the promise returned by the wrapper then() method. As a result, another job is enqueued in the micro-task queue to execute the outer 2nd then() method's callback function
micro-task queue: [ job('in 1 then'), job('outer 2 then') ]

console output:
---------------
outer promise
outer 1 then
in promise

*Next job in the micro-task queue is dequeued and processed. 'in 1 then' is logged on the console and as the return value of the callback function is a promise, i.e. Promise.resolve(), the promise returned by the wrapper inner then() method is resolved to the promise returned by its callback function.
Following code example demonstrates how the promise returned by the then() method is resolved to the promise returned by its callback function:
const outerPromise = new Promise((resolveOuter, rejectOuter) => {
   const innerPromise = new Promise((resolveInner, rejectInner) => {
      resolveInner();
   });

   // resolve/reject functions of the outer promise are
   // passed to the `then()` method of the inner promise
   // as the fulfilment/rejection handlers respectively
   innerPromise.then(resolveOuter, rejectOuter);
});

This means that the outer promise (returned by the then() method) now depends on the inner promise (return by its callback function). A job is enqueued in the micro-task queue to resolve the outer promise to the inner promise.
micro-task queue: [ job('outer 2 then'), job(resolve(outerPr, innerPr) ]

console output:
---------------
outer promise
outer 1 then
in promise
in 1 then

*Next job in the micro-task queue is dequeued and processed. 'outer 2 then' is logged on the console.
As the return value of the callback function is undefined, the promise returned by the wrapper outer second then() method is resolved. This enqueues a job in the micro-task queue to execute the fulfilment handler passed to the outer 3rd then() method.
micro-task queue: [ job(resolve(outerPr, innerPr), job('outer 3 then') ]

console output:
---------------
outer promise
outer 1 then
in promise
in 1 then
outer 2 then

*Next job in the micro-task queue is dequeued and processed.
As the inner promise is resolved, a job is enqueued in the micro-task queue to resolve the outer promise. (resolve function of the outer promise is registered as a fulfilment handler of the inner promise) (see step 5)
micro-task queue: [ job('outer 3 then'), job(resolve(outerPr) ]

console output:
---------------
outer promise
outer 1 then
in promise
in 1 then
outer 2 then

*Next job in the micro-task queue is dequeued and processed. 'outer 3 then' is logged on the console. A job is enqueued in the micro-task queue to execute the fulfilment handler passed to the 4th outer then() method.
micro-task queue: [ job(resolve(outerPr), job('outer 4 then') ]

console output:
---------------
outer promise
outer 1 then
in promise
in 1 then
outer 2 then
outer 3 then

*Next job in the micro-task queue is dequeued and processed. This resolves the promise returned by the 1st inner then() method. As a result, a job is enqueued in the micro-task queue to execute the fulfilment handler passed to the 2d inner then() method.
micro-task queue: [ job('outer 4 then'), job('in 2 then') ]

console output:
---------------
outer promise
outer 1 then
in promise
in 1 then
outer 2 then
outer 3 then

*Finally, the last two jobs in the micro-task queue are dequeued and processed one after the other, logging 'outer 4 then' and 'in 2 then' on the console respectively.
micro-task queue: [ ]

console output:
---------------
outer promise
outer 1 then
in promise
in 1 then
outer 2 then
outer 3 then
outer 4 then
in 2 then

A: I would shove this in the corner undefined behaviour. You shouldn't rely on the internals of the JavaScript engine to execute then callbacks in a certain order. I can imagine two scenarios that suit the given code.

*

*The inner tasks should be run before the outer tasks. Here you should make sure you return the inner promise. You can then move the inner then calls and add them to the outer promise chain.

new Promise((resolve,reject) => {
  console.log('outer promise');
  resolve();
})
.then(() => {
  console.log('outer 1 then');
  return new Promise((resolve,reject) => { // <- added a return statement
    console.log('in promise');
    resolve();
  });
})
.then(() => {
  console.log('in 1 then');
  return Promise.resolve();
})
.then(() => {
  console.log('in 2 then');
})
.then(() => {
  console.log('outer 2 then');
})
.then(() => {
  console.log('outer 3 then');
})
.then(() => {
  console.log('outer 4 then');
});

*You want to split off a path for the inner promise and don't care that further then callbacks execute before or after this separate path. The execution order between the two different paths should not be assumed. However within a path you can control the order. In the example below in 2 then should always be executed after in 1 then. The order of in 1 then and outer 2 then should not be assumed.

const splitPoint = new Promise((resolve,reject) => {
  console.log('outer promise');
  resolve();
})
.then(() => {
  console.log('outer 1 then');
  return new Promise((resolve,reject) => { // <- added a return statement
    console.log('in promise');
    resolve();
  });
});

const path1 = splitPoint.then(() => {
  console.log('in 1 then');
  return Promise.resolve();
})
.then(() => {
  console.log('in 2 then');
});

const path2 = splitPoint.then(() => {
  console.log('outer 2 then');
})
.then(() => {
  console.log('outer 3 then');
})
.then(() => {
  console.log('outer 4 then');
});

Promise.all([path1, path2]).then(() => {
  console.log('path1 and path2 finished');
});


text:
Q: Speeding up page transitions the right way I would like some tips.
I am experimenting the 300ms delay on
phonegap + JQM + HTML5BoilerPlate + IOS6.
Although I installed and called new FastClick(), I still end up with the same delay!
Is there a way to test that FastClick is actually performing at its best ?
Is there another normal ~300ms delay I am focusing and misleaded on ?
What is the expected time transition between a <a> click and its page load event done ?
Note: the html file contains all pages.
<body ... onload='init()' ...>
function init(){ new FastClick(document.body); }

...
$.mobile.bind('vclick', ...
   $.mobile.changePage('#...', {transition: "none"});

Added later in discussion:

A: try removing transitions if you want to speed it up
     $(document).bind("mobileinit", function() {
     $.mobile.defaultPageTransition = 'none';
     $.mobile.defaultDialogTransition = 'none';
     }

you can also create custom transition
 http://jquerymobile.com/demos/1.0.1/docs/pages/page-transitions.html
Here you can change the .in, .out rule to set custom times
     .in, .out {
     -webkit-animation-timing-function: ease-in-out;
     -webkit-animation-duration: 200ms;
     }

hope this helps.


text:
Q: How to fade in an image gradually with pygame? I work with pygame and I have to fade in an image.
I've tried guides from the internet, but none of them work.
I use +=, but the first frame (fps is set to 120, I identified this using fps 1) is fully transparent and the second frame is quickly fully opaque. I need to have a fade in effect instead of this.
I have this code:
i = 0
for i in range (0, 255):
    i = 0
    i += 1
    dvd.set_alpha(i)
    screen.blit(dvd, dvdrect)
    pygame.display.update()

The line below doesn't work.
pygame.time.delay(30)

A:
i = 0
for i in range (0, 255):
    i = 0
    i += 1
    dvd.set_alpha(i)

This is not how a for loop works. You are calling dvd.set_alpha(1) 255 times.
Maybe you meant to use this instead:
for i in range (0, 255):
    dvd.set_alpha(i)

Which calls dvd.set_alpha(0), then dvd.set_alpha(1), then dvd.set_alpha(2), ..., then dvd.set_alpha(254).
Note that it does not call dvd.set_alpha(255), because the upper end of range is exclusive.

I don't know if set_alpha expects a float between 0 and 1, or an integer between 0 and 255 (or maybe 256?). If the former is the case, you need to call something like dvd.set_alpha(i / 256) when i goes from 0 to approximately 256, to scale it into the range from 0 to 1.

A: Instead of doing i += 1, measure the time between current frame and last frame. That will be your delta.
Now, you just simply multiply your delta value by the fade/second value. In your example, you seem to want a fade value of 255/120, so the resulting line would be:
i += delta * 255/120
Another problem that could be happening here is that alpha value might be a float/double from 0.0 to 1.0, hence making it fully opaque after you add 1 to it.
In your simple example, try adding 1/255 to see if you get your expected result.
Edit: my brain completely skipped over the fact that yes, you are setting alpha to 1 all the time. Instead of doing
for i in range(0,255):
    dvd.set_alpha(i)

I suggest doing
    for i in range(0,256):
dvd.set_alpha(i/256)


text:
Q: ajax firing multiple times after database becomes unlocked I'm having a problem with an ajax call.
I have some code set up to run a function every 2 seconds which looks to see if the content has been updated or not with WordPress ajax, does some work with php, then updates a database:
window.setInterval( "updateContent()", 2000 );

function updateContent(){

    if($('#needcontent').hasClass('yes')){
       CONTENT.updateContent( 'monitor' , ids );
    }

}

$(function() {

    CONTENT= {

        updateContent: function(callback, data){

            data = {
                action: 'myplugin_do_ajax',
                callback: callback,
                data: data
            };

            $.post(ajaxurl, data, function(response){

                switch(data.callback){

                    case 'monitor' :

                        data_returned = eval("(" + response + ")");

                        if(data_returned.completed == 'true'){
                            //Adjust the DOM because there was a content update, and remove the class "yes" from #needcontent to stop the check until next time
                        }
                        else{
                            //Do nothing because no content was found, let the Interval run again
                        }

                    break;

                }

            }

    }

}

The problem I'm finding is that sometimes the content is quite large, and ends up locking the table while php updates the database. The ajax call runs once, runs into a database lock, and doens't return anything until the database is unlocked again. The database could be locked for a 10 second period, resulting in 1 run and 4 not-run calls.
UPDATE:
It's not the database locking, it's the php function taking longer than 2 seconds to return, causing the Interval to loop again and again without a response.
What's happening is those 4 not-run ajax calls then begin to fire one right after the other like they are trying to catch up or something.
I've tried increasing the Interval time to 10 seconds, but that doesn't solve the problem because if the database is locked for 11 seconds it'll still fire twice.
I've tried using global variables in Javascript (yuck) to stop the Interval from calling the function, but that doesn't seem to work either.
UPDATE 2:
I answered my own question below to what worked for me.

A: try this:
window.updateCheck= window.setInterval( "updateContent()", 2000 );

function updateContent(){

    if($('#needcontent').hasClass('yes')){
       CONTENT.updateContent( 'monitor' , ids );
       clearInterval(window.updateCheck);
    }

}

$(function() {

    CONTENT= {

        updateContent: function(callback, data){

            data = {
                action: 'myplugin_do_ajax',
                callback: callback,
                data: data
            };
            if(window.ajaxCall) window.ajaxCall.abort();

            window.ajaxCall= $.post(ajaxurl, data, function(response){
                window.updateCheck= window.setInterval( "updateContent()", 2000 );
                switch(data.callback){

                    case 'monitor' :

                        data_returned = eval("(" + response + ")");

                        if(data_returned.completed == 'true'){
                            //Adjust the DOM because there was a content update, and remove the class "yes" from #needcontent to stop the check until next time
                        }
                        else{
                            //Do nothing because no content was found, let the Interval run again
                        }

                    break;

                }

            }

    }

}

what we did here was to put the interval in a global variable, and also the ajax call ($.post() call actually), then when the conditions of updating is checked, we stop the interval, kill all the other active or queued request and send the ajax request to the server.
while the request is being sent to the server the update checks are stopped, then as soon as the server responds to the request we start the update check again!

A: charlietfl's comment on my OP got me thinking about the difference between setInterval and setTimeout, and I realized that:
a) setInterval would continuously run, regardless if a result is returned or not. In my case, using ajax, the function was being call asynchronously so the setInterval wouldn't care if a result was returned.
b) If I changed the code to use setTimeout, I could control the outcome more.
This is what I did.
Firstly, remove the setInterval function completely, it's not needed.
Then I changed my switch case to this:
case 'monitor' :

    var monitor = false;

    data_returned = eval("(" + response + ")");

    if(data_returned.completed == 'true'){
        //Adjust the DOM because there was a content update, and remove the class "yes" from #needcontent to stop the check until next time
    }
    else{
        //Run the monitor after a 2 second timeout.
        var ids = j('.contentDiv').attr('id');
        window.setTimeout(CONTENT.updateContent( 'monitor' , ids ) , 2000);
    }

break;


text:
Q: VB.Net create functions under categories How can i make custom functions that are in the same category in the editor.
For example My.Computer.FileSystem.
Has a lot of functions inside.
I would like to make something like this.
UsefulFunctions.Weather.GetTemp()
UsefulFunctions.Weather.GetInfo()
UsefulFunctions.Weather.GetLala()
so on...

A: Combining the comment about namespaces and the answer of Hadoko.Chen gives you the most useful answer:
Namespace UsefulFunctions
    Public Module Weather
        Public Function GetTemp()
            ....
        End Function

        Public Function GetInfo()
            ....
        End Function

        Public Function GetLala()
            ....
        End Function
    End Module
End Namespace

Any class or module you put with the Namespace UsefulFunctions will be shown in Intellisense when you type UsefulFunctions.. They don't need to be on the same file.

A: Create a class with shared methods, so you can use them without instancing them first.
Module Module1

    Sub Main()

        Console.WriteLine(UsefulFunctions.Weather.GetTemp())
        Console.WriteLine(UsefulFunctions.Weather.GetInfo())
        Console.WriteLine(UsefulFunctions.OtherClass.GetSomething())

        Console.ReadKey(True)

    End Sub

End Module

Public Class UsefulFunctions

    Class Weather

        Public Shared Function GetTemp() As Double
            Return 123
        End Function

        Public Shared Function GetInfo() As String
            Return "Nice weather"
        End Function

        Public Shared Function GetLala() As Object
            Return New Object
        End Function

    End Class

    Class OtherClass

        Public Shared Function GetSomething() As String
            Return "This is something"
        End Function

    End Class

End Class


text:
Q: Desktop recently started booting significantly more slowly When I got my POWERSPEC G419 system in May, the boot sequence was taking 13 seconds to show anything on the screen (the logo from the BIOS) and then it was just a blazing fast 3 seconds to get to the Windows 10 login screen from there. I regularly shut down the system (daily at least), but usually leave it plugged in and powered.
I went on vacation a couple weeks ago, powered down the system and turned off the power strip. I'm not sure if that has anything to do with this, but the timing seems close to when the problem started, so it could be related. Or it could be a Windows Update. Now after returning from vacation, when I turn on the system, it still takes 13 seconds to show anything on the screen, but it takes an additional 31 seconds to get from the BIOS startup screen to the Windows login screen, with the CMOS entry menu options showing for most of that time.
I've never understood how this system was able to boot so fast, even after all my software was installed, but I'm kind of sad that it doesn't any more. I'm guessing that this doesn't have much to do with installed software because it's only the BIOS boot time that seems to be affected (although the boot time after login may have been reduced). This system has an SSD. I've heard about, but am not entirely familiar with some fast boot technology that restores memory state after a boot instead of initializing it all from scratch, and am wondering if that could be involved. Is it possible a larger memory image got persisted and some of the boot time moved from login to BIOS startup or something? How does fast boot work, and how might it have changed recently?
My primary question is, what could have caused such a drastic difference in the boot timing?

A: The problem was related to my Generic SuperSpeed USB Hub drivers. I noticed also that my front USB 3.0 ports were not functioning, and device manager reported that the device was disabled with error code 43. To resolve this, the support technician from MicroCenter had me:
1. Un-install drivers for all devices named Generic SuperSpeed USB Hub;
2. Shut down Windows;
3. Un-plug the computer from its power source;
4. Hold down the power button for 30 seconds;
5. Plug the system back in and power it on.
This fixed all my problems. Apparently the drivers stored in the hardware got corrupted, and needed to be cleared out, which is what holding down the power button for 30 seconds after unplugging the system does. More information about that process is described at https://superuser.com/a/298817/108993.


text:
Q: Cannot escape double quotes and slashes when initializing an input in html I have an input text field in HTML.
I want to put the value reg query "HKEY_CLASSES_ROOT\mailto\shell\open\command"
into the input field when my page loads.
If I do <input readonly="readonly" type='text' id="john" value="reg query "HKEY_CLASSES_ROOT\mailto\shell\open\command"">
Then the input field dispays

reg query

Then I tried escaping using a backslash for every double quote and slash like so,
<input readonly="readonly" type='text' id="john" value="reg query \"HKEY_CLASSES_ROOT\\mailto\\shell\\open\\command\"">

The result I get is not at all satisfactory

reg query \

I managed to find a workaround which is rather too much I feel . the work-around is
<!doctype html>
<html>
<head>
    <title>Issues with values</title>

 <script>
  function show()
  {
  document.getElementById('john').value = "reg query \"HKEY_CLASSES_ROOT\\mailto\\shell\\open\\command\"";
  }
</script>

<body>
text :  <input readonly="readonly" type='text' id="john" value="reg query \"HKEY_CLASSES_ROOT\\mailto\\shell\\open\\command\"">
    <button id='1' onClick="show()">Start time</button>
</body>
</html>

On clicking the button I get the desired output

reg query "HKEY_CLASSES_ROOT\mailto\shell\open\command"

Question is how to put/parse/escape that value inside the input value as a default???


text:
Q: Why does my TPL program use more ThreadPool resources than its async/await counterpart? I am writing a program that demonstrates the benefits of using asynchronous IO in the context of server scalability.  The program concurrently consumes an asynchronous method, and then reports the IDs of the threads that participated in the asynchronous processing.
To illustrate, consider the following:
static async Task<TimeSpan> AsyncCalling(TimeSpan time)
{
    using (SleepService.SleepServiceClient client = new SleepService.SleepServiceClient())
    {
        TimeSpan response = await client.SleepAsync(time);
        Console.WriteLine(Thread.CurrentThread.ManagedThreadId);

        response += await client.SleepAsync(TimeSpan.FromTicks(time.Ticks / 2));
        Console.WriteLine(Thread.CurrentThread.ManagedThreadId);

        return response;
    }
}

I simulate a server under load by calling the above async method as follows:
int numberOfWorkItems = 50;
for (int i = 0; i < numberOfWorkItems; ++i)
{
    TimeSpan value = TimeSpan.FromSeconds((i % 3) + 1);
    ThreadPool.QueueUserWorkItem(arg => { TimeSpan t = AsyncCalling(value).Result; });

    Thread.Sleep(300);
}

The ThreadPool.QueueUserWorkItem operation simulates the allocation of a request thread, with the AsyncCalling method being the method executed by the request (similar to the operation of WCF).
Execution is as expected, and I only count two or three distinct thread IDs when analyzing the output.  This is typical for my machine as I only have two cores and the thread pool will resist scheduling more threads than cores available.
Now I attempt to do the same analysis, but for a TPL function that doesn't use the await keyword.  The function is as follows:
static Task<TimeSpan> TaskAsyncCalling(TimeSpan time)
{
    SleepService.SleepServiceClient client = new SleepService.SleepServiceClient();

    return client.SleepAsync(time)
                 .ContinueWith(t =>
                 {
                     TimeSpan result = t.Result;
                     Console.WriteLine(Thread.CurrentThread.ManagedThreadId);

                     return client.SleepAsync(TimeSpan.FromTicks(time.Ticks / 2))
                                  .ContinueWith(t1 =>
                                  {
                                      result += t1.Result;
                                      Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
                                      (client as IDisposable).Dispose();

                                      return result;
                                  });
                 })
                 .Unwrap();
}

When TaskAsyncCalling is called in the same context, the output results are completely different.  The tasks generally take much longer to execute, and total number of unique thread IDs is generally on the order of 30 (again, for my 2-core machine).
Why does this disparity exist?  I understand that await is not a trivial wrapper over Task<T>, however the thread pool is the common denominator and I expected the same clever thread reuse to occur in the TPL implementation.
Is there another way to rewrite the TPL method to achieve the same results without blocking?

Edit:
The SleepAsync call is the asynchronous generated WCF client method for the following synchronous operation.  Note that in this case, the client does not block where as the server does.
public TimeSpan Sleep(TimeSpan time)
{
    Thread.Sleep(time);
    return time;
}

A: I am not sure that the two implementations are the same, await stores the current
SyncrhonizationContext and gets the TaskScheduler associated with that. Which is not what the default implementation of ContinueWith does. From reflector:
public Task ContinueWith(Action<Task<TResult>> continuationAction)
{
    StackCrawlMark lookForMyCaller = StackCrawlMark.LookForMyCaller;
    return this.ContinueWith(continuationAction, TaskScheduler.Current, new CancellationToken(), TaskContinuationOptions.None, ref lookForMyCaller);
}

So ContinueWith uses the TaskScheduler.Current whereas await uses the TaskScheduler associated with the current SyncrhonizationContext. If the two are not the same you may get different behavior.
Try specifying a TaskScheduler.FromCurrentSynchronizationContext() for ContinueWith and see if there is any difference.

A: In this case, the classic TPL version uses more threads than the async/await version because each ContinueWith continuation is executed on a separate pool thread.
Fix that with TaskContinuationsOptions.ExecuteSynchronously:
static Task<TimeSpan> TaskAsyncCalling(TimeSpan time)
{
    SleepService.SleepServiceClient client = new SleepService.SleepServiceClient();

    return client.SleepAsync(time)
        .ContinueWith(t =>
        {
            TimeSpan result = t.Result;
            Console.WriteLine(Thread.CurrentThread.ManagedThreadId);

            return client.SleepAsync(TimeSpan.FromTicks(time.Ticks / 2))
                .ContinueWith(t1 =>
                {
                    result += t1.Result;
                    Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
                    (client as IDisposable).Dispose();

                    return result;
                }, TaskContinuationsOptions.ExecuteSynchronously);
         }, TaskContinuationsOptions.ExecuteSynchronously)
         .Unwrap();
 }

OTOH, the await continuations are normally executed synchronously (if the operation completed on the same synchronization context it was started on, or if there was no synchronization at both points of execution). So it's expected to acquire two less threads.
A good related read: "Why is TaskContinuationsOptions.ExecuteSynchronously opt-in?"


text:
Q: how to save the content of an input box on electron locally I would like the contents of what I put in here to save after I click a save button, how would I go about that? Anything I have tried finding online doesn't answer my question.
https://imgur.com/mUXgsKe

A: Search for a CRUD application, there're several good tutorials on CRUD apps, this is my favorite:
https://www.youtube.com/watch?v=D67Liy5C86s
And please, node.js/electronjs and javascript are languages totally different from java.


text:
Q: Word for "selectful" looking for a proper word to say "only a selectful of them", which tries to express that,

*

*only a handful of them, not all of them

*of these a handful, each is carefully selected, not random picked

What would the proper word to use here?
I've found a word "selective", but it doesn't sound right to me as it is normally used as "selective in reading", or "someone is selective".

A: The word you are looking for is not "selective" but "selection":

selection
the action or fact of carefully choosing someone or something as being the best or most suitable.

So you can say:

Only a selection of them.


text:
Q: how to determine the dimension of a vector space given linear transformations I was dealing with the following problem:
Let $V,W,X$ be vector spaces and let $T:V\to W$ and $S:W\to X$ be linear transformations.
(i) Prove Sylvester's Rank Inequality:
$
rank(T) + rank(S) - dim(W) \leq rank(ST) \leq \min\{ rank(T), rank(S) \}.
$
(ii) Let $A,B$ be two $4\times 5$ matrices of rank $3$ and let $C=A^T B$. Find all possible values for the rank of $C$. That is, for each possible value, find an explicit example of such matrices. Then prove that all other values are impossible.
Using part (i), one can find the possible values for the rank of $C=A^T B$. I was told that the dimension of $W$ must be $4$  in order for C to be well-defined, since $A^T$ is $5 \times 4$ and B is $4 \times 5$. While I understand this, I don't see why $W$ couldn't be something like a $4 \times y$ matrix, where $y$ could be anything, since vector spaces can be made up of matrices and not just vectors. Then the dimension would be $4y$ and not just $4$, and the linear maps would still be able to take $B: V \rightarrow W$, and $A^T: W \rightarrow X$ for some $V, X$. The rest of the proof makes sense, but it's just this one small concept that should be obvious that I'm stuck on. What am I missing?

A: This is a really good question because it's a subtle problem. I think the following might help clear it up (this is at least what helps me think about it).
Implicitly these matrices are representing linear functions on the usual $n$-space of vectors. If you wanted to view, for example, left multiplication by $A^T$ as a linear map -- let's call it $R$ -- on the space of $4\times y$ matrices, then you need to be a little more careful. In this case we have $\dim(W)=4y$, as you say. However, the matrix representation of $R$ is not the same as the matrix $A^T$. In particular, the rank of $R$ is not equal to the rank of the matrix $A^T$ (the rank of the matrix as calculated in the usual way through something like row reduction). This increase in the dimension of $W$ from $4$ to $4y$ will be off-set by the change in the rank of $R$. I encourage you to try an example of this!
To make it concrete, here is a small example of my claim about the rank changing. Consider the matrix $A^T$ being the identity matrix $I_4$ (in this case the matrix is square, but whatever). Then $I_4$ as a usual matrix linear transformation from $4$-vectors to $4$-vectors has rank $4$. But if we view this as the linear transformation $R$ above (i.e. as left multiplication by $I_4$ on $4\times y$ matrices), then the rank is $4y$. This is because the rank of $R$ is, by definition, the dimension of the image of $R$. In this case, $R$ is surjective (actually it is an isomorphism). In fact, the matrix representation of $R$ would be the $4y$ identity matrix, $I_{4y}$.

TLDR: if you change $W$ from dimension $4$ to dimension $4y$ (as you say in your question), then you are also changing the rank of the linear operator that $A^T$ represents. These changes should exactly off-set one another.

A:
While I understand this, I don't see why $W$ couldn't be something like a $4 \times y$ matrix, where $y$ could be anything, since vector spaces can be made up of matrices and not just vectors.

Well, you can think so but still in deep you are working in $\mathbb R^4$ as each column vector of a $4\times y$ matrix is a member of $\mathbb R^4$ ;which is obtained as an image of corresponding column vector in $5\times y$ matrix of vector some space V i.e. $M_{5\times y}(\mathbb R)$ specifically (along the lines you are thinking on).

Then the dimension would be $4y$ and not just $4$,

Since the dimension of image is equal to the rank of matrix $B$ and $rank(B)\le 4$ so $dim(Imsp(B))\le 4$ which suggests that no matter how large is the integer $y$ you choose, you are always restricted to get an image under $T$ which is contained in vector space of dimension $4$.


text:
Q: Why defalut value from getDefaultProps func overrides the value passed from parent component? Recently i am attempting to transform a native page to a React-native page for my App. I encountered a puzzled problem with usage of getDefaultProps func. As far as i know, the func will work when no value passed in from parent component and also caches value sometimes. But when i have passed isSuccess with false and defalut value has been set true, i got this property as true. Has anyone tells me why and the specific function of getDefalutProps?
Code likes below.
getDefaultProps: function() {
    return {
            displayData: {},
            bottomStyle: 0,
            isSuccess: true
        };
  },

render: function(){
        // isSuccess is true
        console.log("trade state: ", this.props.isSuccess);

Thx a lot.


text:
Q: regex pattern in angularjs to allow all characters from english,spanish,german,french,italian,Swedish, numbers and dashes Can someone help me with regex that allows only characters from (english,spanish,german,french,italian,Swedish) languages,numbers and dashes. I want to use this regex pattern in angularjs validation.

A: This is a bit tricky!
To match all Unicode Letters with JavaScript regex you can use:
As a first step you would have to filter the languages you want.
[\u0041-\u005a\u0061-\u007a\u00aa-\u00aa\u00b5-\u00b5\u00ba-\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec-\u02ec\u02ee-\u02ee\u0370-\u0374\u0376-\u0377\u037a-\u037d\u037f-\u037f\u0386-\u0386\u0388-\u038a\u038c-\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559-\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e-\u066f\u0671-\u06d3\u06d5-\u06d5\u06e5-\u06e6\u06ee-\u06ef\u06fa-\u06fc\u06ff-\u06ff\u0710-\u0710\u0712-\u072f\u074d-\u07a5\u07b1-\u07b1\u07ca-\u07ea\u07f4-\u07f5\u07fa-\u07fa\u0800-\u0815\u081a-\u081a\u0824-\u0824\u0828-\u0828\u0840-\u0858\u08a0-\u08b4\u0904-\u0939\u093d-\u093d\u0950-\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2-\u09b2\u09b6-\u09b9\u09bd-\u09bd\u09ce-\u09ce\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e-\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd-\u0abd\u0ad0-\u0ad0\u0ae0-\u0ae1\u0af9-\u0af9\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b35-\u0b39\u0b3d-\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b71-\u0b71\u0b83-\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c-\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0-\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d-\u0c3d\u0c58-\u0c5a\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd-\u0cbd\u0cde-\u0cde\u0ce0-\u0ce1\u0cf1-\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d3d\u0d4e-\u0d4e\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd-\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32-\u0e33\u0e40-\u0e46\u0e81-\u0e82\u0e84-\u0e84\u0e87-\u0e88\u0e8a-\u0e8a\u0e8d-\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5-\u0ea5\u0ea7-\u0ea7\u0eaa-\u0eab\u0ead-\u0eb0\u0eb2-\u0eb3\u0ebd-\u0ebd\u0ec0-\u0ec4\u0ec6-\u0ec6\u0edc-\u0edf\u0f00-\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f-\u103f\u1050-\u1055\u105a-\u105d\u1061-\u1061\u1065-\u1066\u106e-\u1070\u1075-\u1081\u108e-\u108e\u10a0-\u10c5\u10c7-\u10c7\u10cd-\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258-\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0-\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16f1-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7-\u17d7\u17dc-\u17dc\u1820-\u1877\u1880-\u18a8\u18aa-\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7-\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae-\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5-\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59-\u1f59\u1f5b-\u1f5b\u1f5d-\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe-\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071-\u2071\u207f-\u207f\u2090-\u209c\u2102-\u2102\u2107-\u2107\u210a-\u2113\u2115-\u2115\u2119-\u211d\u2124-\u2124\u2126-\u2126\u2128-\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e-\u214e\u2183-\u2184\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2-\u2cf3\u2d00-\u2d25\u2d27-\u2d27\u2d2d-\u2d2d\u2d30-\u2d67\u2d6f-\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f-\u2e2f\u3005-\u3006\u3031-\u3035\u303b-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fd5\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a-\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6e5\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ad\ua7b0-\ua7b7\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb-\ua8fb\ua8fd-\ua8fd\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf-\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a-\uaa7a\uaa7e-\uaaaf\uaab1-\uaab1\uaab5-\uaab6\uaab9-\uaabd\uaac0-\uaac0\uaac2-\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab65\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e-\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]


text:
Q: How do I create multiple stores? Below I have posted some code that was edited from an article. I can only show one store location on the map. However, I would like to have multiple location that are present.
Here is the code:

    Your current location
    <input id="manualAddress" type="text" style="width: 500px" />
    <input id="getManualDirections" type="button" value="Get Directions" />

Here is the article:
http://www.dotnetcurry.com/ShowArticle.aspx?ID=783

A: As Nicolas pointed out the code you have will only show one location on the map. What you first need is a data set of your stores. Many Bing Maps customers use the Bing Spatial Data Services to store their store data and have it exposed as a spatial REST service. http://msdn.microsoft.com/en-us/library/gg585132.aspx Once you have a data source file that matches the required schema you can upload it to your account using the Bing Maps portal as documented here: http://msdn.microsoft.com/en-us/library/hh698204.aspx
Once you have a data source you can then easily query the data source and have it display your nearby store locations. Here are some examples:
http://www.bingmapsportal.com/ISDK/AjaxV7#SpatialDataServices1
http://rbrundritt.wordpress.com/2012/01/17/dynamically-updating-data-in-bing-maps-v7/
If you have your data in a database you may prefer to expose this data using a custom web service. If this is the case then take a look at these blog posts:
http://blogs.bing.com/maps/2013/07/31/how-to-create-a-spatial-web-service-that-connects-a-database-to-bing-maps-using-ef5/
http://blogs.bing.com/maps/2013/08/05/advance-spatial-queries-using-entity-framework-5/


text:
Q: Problems with multiples private sites in Liferay 6.2 I need to create 2 private sites in Liferay 6.2. I have already created one of them, that has been built as the private side of the portal (site 1). I have created the another private site (site 2). The problem I am facing is that I cannot log in and go straight to the new site (site 2). Instead of that I always get logged in in the private side (site 1), as well as the new private site (site 2). In other words, when I log in I can see both private sites, and I cannot not remove the first private site (private side of the portal).
This woudl be the site structure:
Liferay Portal
    |- Private site 1 (private side of the portal, strikethrough eye icon)
    |- Private site 2

I guess I am not working properly with private sites. Maybe site 1 needs to be something different from the "private side" of the portal? Do I need to move content from site 1 to another site and leave site 1 empty?
Thanks!!!

A: In Liferay you cant log in only to one site, you are being logged to the portal instance that contains sites. You have to create new instance in control panel in order to achieve two independent sites.


text:
Q: TypeError: req.logIn is not a function I'm making a dashboard for my discord bot, but im getting this error:
TypeError: req.logIn is not a function
    at Strategy.strategy.success (C:\Users\joasb\Desktop\Bot\node_modules\passport\lib\middleware\authenticate.js:247:13)
    at verified (C:\Users\joasb\Desktop\Bot\node_modules\passport-oauth2\lib\strategy.js:189:20)
    at Strategy._verify (C:\Users\joasb\Desktop\Bot\strategies\discord.js:38:24)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

These are my files:
app.js:

require('dotenv').config()
require('./strategies/discord');

const express = require('express');
const passport = require('passport');
const app = express();
const mongoose = require('mongoose');
const PORT = process.env.PORT || 3002;
const routes = require('./routes');

mongoose.connect(`${process.env.DATABASE_URL}`, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
});

app.use('/api', routes);
app.use(passport.initialize());
app.use(passport.session());

app.listen(PORT, () => console.log(`Running on port ${PORT}`));

And discord.js

const passport = require('passport');
const DiscordStrategy = require('passport-discord');
const UserDB = require('../database/Schemas/UserDB');

passport.serializeUser((user, done) => {
    done(null, user.discordId)
});

passport.deserializeUser(async (user, done) => {
    try {
        const user = await UserDB.findOne({ discordId });
        return user ? done(null, user) : done(null, null);
    } catch (err) {
        console.log(err)
        done(err, null);
    }
});

passport.use(

    new DiscordStrategy({
        clientID: process.env.DASHBOARD_CLIENT_ID,
        clientSecret: process.env.DASHBOARD_CLIENT_SECRET,
        callbackURL: process.env.DASHBOARD_CALLBACK_URL,
        scope: ['identify', 'guilds'],
    }, async (accesToken, refreshToken, profile, done) => {
        try {
            const { id, username, discriminator, avatar, guilds } = profile;
            console.log(id, username, discriminator, avatar, guilds);
            const findUser = await UserDB.findOne({ discordId: id }, {
                discordTag: `${username}#${discriminator}`,
                avatar,
                guilds: guilds.length,
            });
            if (findUser) {
                console.log(`User was found!`);
                return done(null, findUser);
            } else {
                const newUser = await UserDB.create({
                    discordId: id,
                    discordTag: `${username}#${discriminator}`,
                    avatar,
                    guilds: guilds.length,
                });
                return done(null, newUser);
            }
        } catch (err) {
            console.log(err);
            return;
        }
    })
);

I also have a couple of strategies, but those are not the problem as they work just fine. I can authorize my client but after that it just gives the error and crashes.
Any ideas on how to fix this?
EDIT:
satvik choudhary asked me to add the package.json so here it is:

{
  "name": "quabot-db",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "dotenv": "^10.0.0",
    "express": "^4.17.1",
    "mongoose": "^6.0.14",
    "passport": "^0.5.0",
    "passport-discord": "^0.1.4"
  }
}

A: The order of your middleware is wrong. You initialize passport after handling any API routes, so when you call req.logIn in your route, it doesn't even exist yet!
It should be the other way round:
app.use(passport.initialize());
app.use(passport.session());

app.use('/api', routes);


text:
Q: How to escape newline in regex scan str = "This\n is a sample text for test"
str.scan(/\S.{0,15}\S(?=\s|$)|\S+/)
# => ["This", "is a sample text", "for test"]

Here, it splits when the newline (\n) is present. I actually want the output as,
 ["This\n is a", "sample text for", "test"]

How can I achieve that?

A: Use the /m modifier which allows the dot to match newlines:
str.scan(/\S.{0,15}\S(?=\s|\z)|\S+/m)

Also, I suggest you use \z instead of $ because $ matches the end of a line; \z is the only way to force Ruby to match the end of the string. It doesn't matter in this example, but it's a good habit to get into. Ruby differs from all other regex flavors in these two points.


text:
Q: Singular Perturbation Theory problem for slightly unstable pde I'm learning about singular perturbation theory for solving an approximate solution to a pde and I'm a little confused on how to apply it. The problem I'm trying to work on is $\frac{\partial u}{\partial t} = k \frac{\partial^2 u}{\partial x^2} - \varepsilon u^3$ where $u(0,t)=u(L,t)=0$. I know I need to look for the different orders of $\varepsilon$ and solve for the non-perturbed equation: $\frac{\partial u}{\partial t} = k \frac{\partial^2 u}{\partial x^2} \rightarrow u_0(x,t)= A(t)\sin\frac{\pi x}{L}.$ I'm not sure what to do after this or the intuition of this method.
Then
$\frac{\partial u_1}{\partial t} = k \frac{\partial^2 u_1}{\partial x^2} -u_0^3 \\
\frac{\partial u_1}{\partial t} = k \frac{\partial^2 u_1}{\partial x^2} -(A(t)\sin\frac{\pi x}{L})^3 \\
\frac{\partial u_1}{\partial t} = k \frac{\partial^2 u_1}{\partial x^2} -(A(t))^3(\frac{3}{4}\sin\frac{\pi x}{L} - \frac{1}{4}\sin\frac{3 \pi x}{L})$
So I know the solution must go with $\sin\frac{\pi x}{L} - \sin\frac{3 \pi x}{L}$, so $u_1 = B_1 \sin\frac{\pi x}{L} + B_3 \sin \frac{3 \pi x}{L}$ meaning the total solution is $u = A(t)\sin\frac{\pi x}{L} - \varepsilon (B_1 \sin\frac{\pi x}{L} + B_3 \sin \frac{3 \pi x}{L})$ This can be further solved for B by applying $u_1$ to the above solution:
$\frac{dB_1}{dt}\sin\frac{\pi x}{L} + \frac{dB_3}{dt}\sin \frac{3\pi x}{L} = k[\frac{-\pi^2}{L^2}B_1\sin \frac{\pi x}{L} - \frac{9 \pi^2}{L^2} B_2 \sin \frac{3\pi x}{L}] - A^3[\frac{3}{4} \sin \frac{\pi x}{L} - \frac{1}{4} \sin \frac{3\pi x}{L}] \\
\sin \frac{\pi x}{L} [ \frac{dB_1}{dt} + \frac{k \pi^2}{L^2}B_1 + \frac{3}{4}A^3] + \sin \frac{3\pi x}{L}[ \frac{dB_3}{dt} + \frac{9k \pi^2}{L^2}B_3 - \frac{1}{4}A^3]=0$ Now I'm not sure how to solve for $B_1$ and $B_3$ from this.

A: A(t) can be solved from the first equation: $\frac{du}{dt} = k \frac{d^2u}{dx^2} \\ A'(t)\sin\frac{\pi x}{L} = -k \frac{\pi^2}{L^2} A(t) \sin\frac{\pi x}{L} \\A'(t)= -k \frac{\pi^2}{L^2} A(t) \\ A(t) = c_1 \exp(-k\frac{\pi^2}{L^2} t)$
and $c$ cannot be solved without an initial condition. This can be substituted into the two equation for solving for the B coefficients now:
$\frac{dB_1}{dt} + k\frac{\pi^2}{L^2} B_1 +\frac{3}{4} A^3 = 0 \\
\frac{dB_3}{dt} + 9k\frac{\pi^2}{L^2} B_3 -\frac{1}{4} A^3 = 0 \\
\frac{dB_1}{dt} + k\frac{\pi^2}{L^2} B_1 +\frac{3}{4} c_1 \exp(-3k\frac{\pi^2}{L^2} t) = 0 \\
\frac{dB_3}{dt} + 9k\frac{\pi^2}{L^2} B_3 -\frac{1}{4} c_1 \exp(-3k\frac{\pi^2}{L^2} t) = 0 \\
B_1 = \frac{3 c_1 \exp(-3k\frac{\pi^2}{L^2} t)}{8 k\frac{\pi^2}{L^2}} + c_2 \exp(-k\frac{\pi^2}{L^2} t) \\
B_3 = \frac{c_1 \exp(-3k\frac{\pi^2}{L^2} t)}{24 k\frac{\pi^2}{L^2}} + c_2 \exp(-9k\frac{\pi^2}{L^2} t)$
Bringing the final solution to be $u(x,t) = A(t) \sin \frac{\pi x}{L} - \varepsilon (B_1 \sin\frac{\pi x}{L} + B_3 \sin\frac{3\pi x}{L})$


text:
Q: Jinja2: HOW-TO render a dict | UndefinedError i have template .html stored in variable "email_html"
also i have a dictionary called "info" defined as
info = {'username': u'snip', 'netlink': [u'> F: IL00091 = AMS/VIE/LE-134621 : None : None | O: at-vie01a- : xe-3/1/3 _ et-2/1/21 : nl-ams05a- | W: None : None _ None : None *'], 'end': [2015, 8, 15, 11], 'notes': u'', 'usms': u'ccc', 'start': [2015, 8, 15, 11], 'netelement': [u'> at-vie01a- * x.x.x.x']}

but when i try to load the info variable to the template :
template = jinja2.Template(open(email_html).read())
html = template.render(**info)

am getting the following error :
In [13]: html = template.render(**info)
---------------------------------------------------------------------------
UndefinedError                            Traceback (most recent call last)
<ipython-input-13-be5c22c9f3c9> in <module>()
----> 1 html = template.render(**info)

/usr/lib/python2.7/site-packages/jinja2/environment.pyc in render(self, *args, **kwargs)
    967         except Exception:
    968             exc_info = sys.exc_info()
--> 969         return self.environment.handle_exception(exc_info, True)
    970
    971     def stream(self, *args, **kwargs):

/usr/lib/python2.7/site-packages/jinja2/environment.pyc in handle_exception(self, exc_info, rendered, source_hint)
    740             self.exception_handler(traceback)
    741         exc_type, exc_value, tb = traceback.standard_exc_info
--> 742         reraise(exc_type, exc_value, tb)
    743
    744     def join_path(self, template, parent):

<template> in top-level template code()

/usr/lib/python2.7/site-packages/jinja2/environment.pyc in getitem(self, obj, argument)
    376         """Get an item or attribute of an object but prefer the item."""
    377         try:
--> 378             return obj[argument]
    379         except (TypeError, LookupError):
    380             if isinstance(argument, string_types):

UndefinedError: 'info' is undefined

this is plain Python (no Django, no Flask).
could you please advise on what am doing wrong ?

A: You are passing in the keys of the info dictionary to the template. The name info itself is not available to the template.
Just use {{ username }} and {{ netlink }}, etc. in the template instead.
Alternatively, pass in info as an actual name when rendering:
html = template.render(info=info)


text:
Q: Using jQuery .append and .html together I am having to add content dynamically to an iFrame that is generated by my CMS in their forum module. I have no control over the HTML. I am adding content dynamically and trying to find the best solution.
Here is the code I am using:
HTML

Forum content is typed here.

More forum content.

    Forum Signature

JS
nestedFrame = myFrame.find('#re_contentIframe').contents().find('body');
nestedFrame.append("Dynamic content" + data); //this is what is inserted dynamically.

Here is the issue I run into. Because I cannot control the code for the iFrame my CMS generates because of this I end up having something like this when I use the above code:
Forum Signature Dynamic content...

I want the dynamic content to be added below the Forum Signature. I then tired this:
nestedFrame.html("Dynamic content" + data); //this is what is inserted dynamically.

When I do this the forum content is wiped by .html
I then tried this:
nestedFrame.append("
 Dynamic content" + data);

When I do that it prints the
.
Here is my question:
Is there a way to append html to the target without wiping the html that is there? I cannot figure a way to do this.

A: jQuery.parseHTML(str) converts the passed string to the actual html contents (including textNodes) whereas just calling $(str) will only return the elements in the string.
So where
$("
 Dynamic content" + data) //=>

$.parseHTML("
 Dynamic content" + data) // textNode +
 + textNode

When you're appending the string, as I mentioned in the comment, you can also just use insertAdjacentHTML
nestedFrame[0].insertAdjacentHTML("
 Dynamic content" + data); which should do the same as nestedFrame.append($.parseHTML("
 Dynamic content" + data));

A: There is a few options

*

*You can create element -> var br = document.createElement('br'); and append them

*Use '
' inside, With + + in between, not 100% sure of that method.

*You can checkout jQuery after, wonderful solution for that issues.

Goodluck.


text:
Q: Rolling delinquiency calculation for a dataframe I am new to R and trying to get a work around to calculate the 3 months delinquicy on a rolling basis.
My dataframe consists of (CID, acquistion_date and delinquient)
i am trying to create a new dataftrame with a 4th column appended (Roll_deliquency) ie count of delinquient in the last 3 months). As soon as we have a new customer id we start again with the first transaction of that customer. Roll_Deliquiency is the total count of  delinquient of last 3 months only.
the expected result is as below
CID AQ_DATE   Delinquient Roll_Deliquiency
103   2007/03/18    1       0
103   2007/04/03    0       1
103   2007/04/17    0       1
103   2007/05/03    0       1
103   2007/05/17    1       1
103   2007/06/02    1       2
103   2007/06/16    1       3
103   2007/07/02    1       3
103   2008/01/03    1       0
103   2008/01/17    1       1
103   2008/02/02    0       2
103   2008/02/16    1       2
105   2007/01/01    1       0
105   2007/01/11    1       1
105   2007/02/10    1       2
105   2007/02/14    0       3
105   2007/02/17    1       3
105   2007/02/17    1       4
105   2007/02/17    1       5
105   2007/04/02    0       5
105   2007/04/10    1       5

Can someone please help me with the R code? I tried using rolling apply but not able to customise the same as per the need.

A: This might not be what you want, but it is the best I can do with my current understanding of the problem.  For each person and each date in the data file I went back in time 90 days and summed the number of delinquencies.  My results are stored in the vector my.count.  My results do not match Roll_Deliquiency.  However, maybe this will get you started.  If you provide additional information on how Roll_Deliquiency is calculated I might be able to modify the code below.  I might also clean up the code a little soon.  It currently includes some variables I did not end up using to obtain my answer.
df.1 <- read.table(text='
CID AQ_DATE   Delinquient Roll_Deliquiency
103   2007/03/18    1       0
103   2007/04/03    0       1
103   2007/04/17    0       1
103   2007/05/03    0       1
103   2007/05/17    1       1
103   2007/06/02    1       2
103   2007/06/16    1       3
103   2007/07/02    1       3
103   2008/01/03    1       0
103   2008/01/17    1       1
103   2008/02/02    0       2
103   2008/02/16    1       2
105   2007/01/01    1       0
105   2007/01/11    1       1
105   2007/02/10    1       2
105   2007/02/14    0       3
105   2007/02/17    1       3
105   2007/02/17    1       4
105   2007/02/17    1       5
105   2007/04/02    0       5
105   2007/04/10    1       5', header=T, colClasses=c('character', 'character', 'integer', 'integer'))

df.1$AQ_DATE2 <- as.Date(df.1$AQ_DATE, "%Y/%m/%d")

df.1$running.count = sequence(rle(df.1$CID)$lengths)
df.1

max.value <- data.frame(id.max = with(df.1, tapply(running.count, CID, function(x) x[length(x)])))
max.value

max.value$CID <- row.names(max.value)
max.value

all.data  <- merge(max.value, df.1, by=c('CID'), all = TRUE)
all.data

my.count <- rep(0, nrow(all.data))

m <- 1

for(i in length(unique(all.data$CID)):1) {

  all.data.i <- subset(all.data, all.data$CID == max.value$CID[i])

    print(all.data.i)

     for(j in nrow(all.data.i):1) {

        for(k in j:1) {

           if(((j-k) >  1) &
             (as.numeric(all.data.i$AQ_DATE2[j] - all.data.i$AQ_DATE2[k+1]) <= 90)  &
             (as.numeric(all.data.i$AQ_DATE2[j] - all.data.i$AQ_DATE2[k  ]) >  90)) my.count[m] = sum(all.data.i$Delinquient[(k+1):j])

           if(((j-k) == 1) &
              as.numeric(all.data.i$AQ_DATE2[j] - all.data.i$AQ_DATE2[k])   >  90)  my.count[m] = all.data.i$Delinquient[j]

           if((k == 1) &
              as.numeric(all.data.i$AQ_DATE2[j] - all.data.i$AQ_DATE2[1])   <= 90)  my.count[m] = sum(all.data.i$Delinquient[1:j])

         }

     m = m + 1

     }

}

my.count

 [1] 6 5 6 5 4 3 3 2 1 3 2 2 1 4 4 3 2 1 1 1 1


text:
Q: How to mask byte in java to get the condition I read byte[] from socket as Param_Code. there is a condition for Param_Code as below:
• Option 1: Sometimes the Param_Code corresponds to the ID
• Option 2: Sometimes the Param_Code corresponds to 0x40000000 + the ID
• Option 3: Sometimes the Param_Code corresponds to 0x80000000 + the ID
This is my code:
byte[] cbuf = new byte[4];

socketReader.read(cbuf, 0, 4);

int Param_Code = byteArrayToIntBI(cbuf, 0);

public static int byteArrayToIntBI(byte[] b, int offset) {
    int value = 0;
    for (int i = 3; i > -1; i--) {
        int shift = (i) * 8;
        value += (b[i + offset] & 0x000000FF) << shift;
    }
    return value;
}

My question is, How can i know (with if statement or something else) when the Param_Code is one of above option?
How can i get ID?
if( ? ){
        it is Option 1 and ID = ?
}else if( ? ){
        it is Option 1 and ID = ?
}else if( ? ){
        it is Option 1 and ID = ?
}

A: this is standard bittwiddling
int mask1 = 0x80000000;
int mask2 = 0x40000000;
int id = paramCode & ~(mask1|mask2);// ~ is NOT,  & is AND and | is OR
if((paramCode&mask1) != 0){
   //option 2
}else if((paramCode&mask2) != 0){
   //option 3
}else{
   //option 1
}

im assumming ID will fit in 0x3fffffff if not you have serious problems

A: You should add some restriction on ID. Because we cannot apply mask in that case.
Imagine, that you got 0x81234123. It can be:

*

*ID 0x81234123

*ID 0x41234123

*ID 0x01234123

Provide additional condition to avoid that ambiguity.
i can only assume that your ID doesn't include first hexadecimal number so, in that case use mask: ID = NUM & 0x0FFFFFFF
NUM is actually your byte[4]


text:
Q: Depth First Directory Traversing resulting in Segmentation Fault in C I am writing a code to traverse through the directory using depth first algorithm. The problem is the program is not displaying anything and gives Segmentation Fault error. I tried to debug it but it was worthless as I am still learning stuff. So now I need the help of experts. Here is the code:
void func(char path[]);

int main(int argc, char *argv) {
    char buf[255];

    scanf("%s",buf);
    func(buf);
    return 0;
}

void func(char path[]) {
    DIR *dirp;
    struct stat states;
    struct dirent *direntp;
    printf("Inside\n");
    dirp=opendir(path);
    stat(path, &states);

    while ((direntp=readdir(dirp)) != NULL) {
        if (S_ISDIR(states.st_mode)) {
            printf("Calling Func\n");
            func(direntp->d_name);
            chdir("..");
        } else if (!S_ISDIR(states.st_mode)) {
            printf("  %s\n", direntp->d_name);
        } else if (!strcmp(direntp->d_name, ".") || !strcmp(direntp->d_name, "..")) {
            continue;
        }
    }
    return ;
}

A: Inside func, in front of the while, put that:
dirp=opendir (path);
if (!dirp)
  return;

and, btw, its int main (int argc, char *argv[])

A: For debugging printing, print to stderr; it is line buffered, so it appears more reliably.
Your function, in outline, is:
void func(char path[])
{
    DIR *dirp;
    struct stat states;
    struct dirent *direntp;
    printf("Inside\n");
    dirp=opendir(path);
    stat(path,&states);

    while ((direntp = readdir(dirp)) != NULL)
    {
        if (S_ISDIR(states.st_mode))
        {
            printf("Calling Func\n");
            func(direntp->d_name);
            chdir("..");
        }
        else if (!S_ISDIR(states.st_mode))
        {
            printf("  %s\n",direntp->d_name);
        }
        else if (!strcmp(direntp->d_name,".") || !strcmp(direntp->d_name,".."))
        {
            continue;
        }
    }
}

The chdir("..") is unwise; you've neither done a chdir() to the relevant directory nor ensured that the directory is a direct sub-directory of the current directory, which means this code is going to go haywire...if it ever gets to that bit.
You do stat(path, &states); but do not check that it worked.
You do dirp = opendir(path); but do not check that it worked.
You don't do stat() on each entry; you continually use the initial stat from path.  This is probably a directory when you test, so you then call the function recursively, which will be reading ., which is a directory, and you would probably just end up running out of stack if you didn't run out of DIR pointers first.
Your tests in the loop are wrongly sequenced, even if you arranged to stat() the file — which is a non-trivial operation because the name you just read has to be appended to the path of the directory to form the correct file name.  Your code is:
if (is a directory)
else if (is not a directory)
else if (name is . or ..)
else ...missing...

First, the if and the following else if covers all options, so the name test and final (non-existent) else would never be executed.  You probably need the name test first (pseudo-code):
if (name is a "." or "..")
    print "Skipping";
else if (name is a directory)
{
    create "path/name" as string;
    recurse with "path/name";
}
else
    print "Skipping non-directory";

Note that this always prints something in every iteration.  That's very important while you're debugging.  You don't want the code to be quiet when it does something you aren't expecting.
Note that you do not call closedir(); this means you will run out of directory descriptors, getting a NULL value in dirp which crashes when you use it.
Note that the pseudo-code does not include any chdir() operations.  Be very, very, very cautious about using them.  Understand the use of fchdir().
Read up on ftw() and nftw(); there are notes about the complications that those functions face.


text:
Q: Oracle AQ - why I don't see processed messages in global view? Does anyone have an idea on why I see PROCESSED messages here:
select 'MFS_MISSION' as queue_name, CONSUMER_NAME, MSG_STATE, count(*) from aq$MFS_MISSION_QTAB  group by consumer_name, MSG_STATE

 QUEUE_NAME     CONSUMER_NAME     MSG_STATE     COUNT(*)
 -------------  ----------------  ------------  -----------
 MFS_MISSION    T1                PROCESSED     143216
 MFS_MISSION    S1                PROCESSED     377208

but not here:
select dq.queue_table, dq.queue_type, dq.name, v$aq.waiting, V$AQ.ready, V$AQ.expired, V$AQ.total_wait, V$AQ.average_wait
from V$AQ, dba_queues dq where dq.qid=v$aq.qid and dq.name like '%MISSION%'

 QUEUE_TABLE       QUEUE_TYPE       NAME                    WAITING     READY     EXPIRED     TOTAL_WAIT     AVERAGE_WAIT
 ----------------  ---------------  ----------------------  ----------  --------  ----------  -------------  ---------------
 MFS_MISSION_QTAB  EXCEPTION_QUEUE  AQ$_MFS_MISSION_QTAB_E  0           0         0           0              0
 MFS_MISSION_QTAB  NORMAL_QUEUE     MFS_MISSION_QUEUE       0           539002    0           0              0
 MFS_MISSION_QTAB  EXCEPTION_QUEUE  AQ$_MFS_MISSION_QTAB_E  0           0         0           0              0
 MFS_MISSION_QTAB  NORMAL_QUEUE     MFS_MISSION_QUEUE       0           480333    0           0              0

The queue has retention of 0, so messages should either be PROCESSED or disappear altogether as soon as they are committed.
The count of messages tells me they have accumulated over course of months.
I'll be glad for any pointers, esperience or insights.
Edit: Oracle Database 10g Release 10.2.0.3.0

A: In a multiple consumer queue, messages remain in the queue until all subscribers have consumed the message.  I would seem like the discrepancy between v$aq and aq$MFS_MISSION_QTAB would indicate that there are messages being shown in v$aq that are still waiting for all of the subscribers to consume so they can be marked as processed.
Also, you have 2 entries in aq$MFS_MISSION_QTAB for you MFS_MISSION_QUEUE.  Do these have different Owners are are you using RAC?


text:
Q: How to share data between two closures, without global exposure? I have two closed scopes set up, in which one has a dependency on the other. Normally, I'd share data (in this case, a function with a prototype) by exposing it into the global scope, like so:
(function(){

    var thing;

    /* ... */

    window.thing = thing;

}());

and:
(function(){

    /* I now have access to 'thing' */

}());

Is there a pattern where data can be shared without exposing it to the entire window?

A: This can only be done by making the two closures themselves child scopes of another closure, and making the shared data a local variable within the parent closure:
(function() {

    var thing = 'foo';

    (function f1() {
        // thing is accessible here
        ...
    })();

    (function f2() {
        // and here!
        ...
    })();
})();

NB: closures are a lexical construct, that means the two functions must all be within the same source unit.

A: @Alnitak has provided a good solution for you problem.
But extending your example only , you can also do like this :
(function (xyz) {
      var thing = "foo";

      xyz.thing = thing;
}(closure1 = {}));

and then you can fetch like :
(function(){

    /* I now have access to 'thing' */
    alert(closure1.thing);
}());


text:
Q: How to set a onclicklistener on Notification android I need to set a onclicklistener on a notification, so that I can call a PHP file, and get data from my database, and then set it into the activity that is intended by my notification, can you please give me some clues?
I looked up in other questions but I didn't really understand how to do that.
Here is my code when I set up the notification:
public class FirebaseMessagingService extends
com.google.firebase.messaging.FirebaseMessagingService {

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {

    showNotification(remoteMessage.getData().get("message"));
}

private void showNotification(String message) {

    Intent i = new Intent(this, ActivityRestaurantHistoryReservations.class);

    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .setAutoCancel(true)
            .setContentTitle("You have a new reservation !")
            .setContentText(message)
            .setSmallIcon(R.drawable.common_google_signin_btn_icon_dark)
            .setContentIntent(pendingIntent);

    NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    manager.notify(0, builder.build());
   }
}

Thank you for your help

A:
i need to set a onclicklistener on a notification

That is not possibly directly.

so that i can call a PHP file, and get data from my database, and then set it into the activity that is intented by my notification

When the user taps on your notification, the user will be taken to the ActivityRestaurantHistoryReservations activity, using your existing code. So, either:

*

*Put your "call a PHP file" and related logic in ActivityRestaurantHistoryReservations, or

*Change the PendingIntent to something else that will perform this work, or

*Add a separate action (addAction()) that puts another button in the notification, and have its PendingIntent go to something else that will perform this work (in which case, this work will only be performed if the user clicks on that action button specifically)

A: I recommend you to check this Add list item in RecyclerView Adapter on receiving Firebase message article out to understand how to send data from FirebaseMessagingService to Activity


text:
Q: What is the importance of properties in MVC Model Binding? I have an Ajax Query that does the following:
var dataToSend = {
    userValueExample: {
        name: 'Rintu', email: 'Rintu@gmialsfdfs.com'
    }
};
$.ajax({
    url: '/Transactions/TestMethod',
    type: "POST",
    contentType: 'application/json; charset=UTF-8',
    data: JSON.stringify(dataToSend),
    success: function (data) {
        alert(data);
    },
    error: function (xhr) {
        alert('error');
    }
})

In the c# classes, I have the following:
public class UserTest {
    public string name { get; set; }
    public string email { get; set; }
}

[HttpPost]
public void TestMethod(UserTest userValueExample) {
    // Do whatever. Used a breakpoint to see values.
}

Now, the above would work perfectly but it took me ages to realize that the {get;set;} is required for MVC model binding to work properly..
Prior to this, I use fields:
public class UserTest {
    public string name;
    public string email;
}

This fails for some unknown reason and when the breakpoint hits, the values for 'userValueExample' in the TestMethod() is of a default property initialization.
Why is a property important in this case and why is it required for the ModelBinding to work properly?

A: In fact it doesn't matter that much, basically it is a design decision from the CLR team to add more value and logic to properties over fields.
As a member of the VB team says:

*A lot of the .NET databinding infrastructure binds to properties but not fields
I've heard arguments on both sides as to whether or not that's a good thing, but the reality is that's the way it works right now.