text:
Q: AWS RDS MYSQL Write Operation Counts Per Second I'm making a mysql table and coding an API to receive and storing data for 1000 plus devices every second. Each device push more than 100 datapoints to this PHP server. I'm testing for 360 devices with 10 datapoints each, it went well with 3600 write counts per second, thats understandable. However, I noticed that the write operation counts per second increase with the number of devices. I'm trying to google the saturated point for number of write count per second but couldnt find any. Is there any maximum of write count per second? How is the system performance when the number of write count is reaching 100 thousand per second. Is anyone expert on mysql database please advice me, thanks.

A: You might be able to find a benchmark to that shows some high number in a very limited test case.  But there are too many factors that impact 'writes per second':

*

*Spinning drive vs SSD, plus brand, etc

*RAID

*Batched insert / LOAD DATA / single-row inserts / MyISAM

*Number of indexes

*BEGIN...COMMIT / autocommit

*Concurrency -- both of multiple writes, and also of simultaneous reads

*Settings: innodb_flush_log_at_trx_commit, sync_binlog, etc

*Version (5.6 made some improvements; 5.7 made more; MariaDB has some of those improvements, plus others)

*Schema

*Client and Server vying for resources

*etc.

I have heard of a benchmark showing a million "transactions" per second in 5.7.
But, to get 100K is quite a challenge.  Here's what I recommend:

*

*SSD (probably exists in AWS; get the max IOPs)

*RAID striping (parity hurts some, but probably worth having)

*MyISAM, because of table locking, may not be a good idea if you use multiple-threaded inserting.  (I am assuming InnoDB in the rest of this discussion.)

*What will you be doing with the data?  If you do not need SQL to look at individual values, store the 100 values in a JSON string and compress it into a BLOB.  Now you are down to a leisurely 1000 writes/second.

*FusionIO SSDs might do the compression for you.  I don't like InnoDB's automatic compression.  Doing it in the Client offloads the Server.

*Indexes:  Once you have a huge amount of data, the random updates of the indexes will kill you.  Design the PRIMARY KEY so that the inserts can be "at the end of the table".

*Insert 100-10K rows per batch -- less than that leads to overhead costs; more than that leads to inefficiencies in overrunning the undo log, etc.

*innodb_flush_log_at_trx_commit=2, sync_binlog may not matter because of the batching.

*5.7, possibly MariaDB 10.1

*If necessary, move the Client(s) to separate servers.

As for how to collect lots of data fast, possibly with multiple threads, read my "High speed ingestion" blog.  It talks about ping-ponging a pair of tables -- one for receiving data, the other for processing (normalizing, compressing, summarizing) and shoveling into the Fact table.
Another issue...  You are trying to push a few MB into a table every second; that adds up to nearly a terabyte per day.  How long will you keep the data?  How much disk space do you have?  If you will be deleting 'old' data, then PARTITION BY RANGE is a must.  My Partitioning blog goes into detail on how to do the DROP PARTITION and REORGANIZE PARTITION to do the deletes very cheaply.
That leads to another suggestion -- process the data, but don't save it.  OK, maybe you need an hour's data to process.  In this case all the above discussion still applies (except for INDEX restrictions).  And my High speed ingestion is probably still worth doing.  And you could ping-pong once an hour.  One hour might be 10GB -- enough to keep in RAM, hence avoiding the I/O bottleneck.

A: Also consider the underlying EC2 instance size of your provisioned RDS.


text:
Q: tabular: caption and align problem What I would like to create are two tables side by side, each with its own caption above the table. This is my attempt
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath,amssymb,amsfonts,systeme}
\usepackage{makecell}
\setcellgapes{5pt}
\usepackage{float}
\floatstyle{plaintop}
\restylefloat{table}

\begin{document}

\begin{table}[H]
\centering
\makegapedcells
\begin{tabular}{| *{7}{>{\centering\arraybackslash}p{1.5cm} |}}
\hline
$\theta $ & $\eta$ & $\nu$ & $\rho$ \\ \hline\hline
20 & 22.727 & 22.272 & 1.0204 \\ \hline
25 & 17.962 & 17.670 & 1.0165 \\ \hline
30 & 14.416 & 14.234 & 1.0127 \\ \hline
35 & 11.631 & 11.528 & 1.0090 \\ \hline
40 & 9.8771 & 9.8264 & 1.0052 \\ \hline
45 & 9.1780 & 9.1658 & 1.0013 \\ \hline
50 & error & error & error \\ \hline
\caption{$x_1 = 0.4$}
\end{tabular}
\end{table}
\quad
\begin{table}[H]
\centering
\makegapedcells
\begin{tabular}{| *{7}{>{\centering\arraybackslash}p{1.5cm} |}}
\hline
$\theta $ & $\eta$ & $\nu$ & $\rho$ \\ \hline\hline
20 & 39.976 & 37.827 & 1.0568 \\ \hline
25 & 30.827 & 29.273 & 1.0531 \\ \hline
30 & 24.157 & 23.027 & 1.0491 \\ \hline
35 & 19.205 & 18.373 & 1.0453 \\ \hline
40 & 15.486 & 14.867 & 1.0417 \\ \hline
45 & 12.577 & 12.115 & 1.0381 \\ \hline
50 & error & error & error \\ \hline
\caption{$x_1 = 0.5$}
\end{tabular}
\end{table}

\end{document}

As you can see, the caption is an unusual position, and the tables are not positioned next to each other
Can you help me?
Thank you in advance

A: Here are two possibilities:
I have moved the \caption command from inside the tabular environment to right before \begin{tabular} so there is no need to use \restylefloat. I have also drastically reduced the margins in order to make the two tables fit into the textwidth. Lastly, I have also changed the column specifiers from 7 to 4 as you only need four columns in your tables. In order to position the tables next to each other, put them in the same table environment and each of the tabulars inside of an own minipage environment.
Since you used the option [H] to place the table exactly where is was defined in the code, I have added the second example. In this I have completely removed the table environment and used \captionof{table} from  the caption package instead.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath,amssymb,amsfonts,systeme}
\usepackage{makecell}
\setcellgapes{5pt}
\usepackage{float}
%\floatstyle{plaintop}
%\restylefloat{table}
\usepackage{caption}
\usepackage[margin=1.5cm]{geometry}

\begin{document}

\begin{table}
\begin{minipage}{0.5\textwidth}
\centering
\makegapedcells
\caption{$x_1 = 0.4$}
\begin{tabular}{| *{4}{>{\centering\arraybackslash}p{1.5cm} |}}
\hline
$\theta $ & $\eta$ & $\nu$ & $\rho$ \\ \hline\hline
20 & 22.727 & 22.272 & 1.0204 \\ \hline
25 & 17.962 & 17.670 & 1.0165 \\ \hline
30 & 14.416 & 14.234 & 1.0127 \\ \hline
35 & 11.631 & 11.528 & 1.0090 \\ \hline
40 & 9.8771 & 9.8264 & 1.0052 \\ \hline
45 & 9.1780 & 9.1658 & 1.0013 \\ \hline
50 & error & error & error \\ \hline
\end{tabular}
\end{minipage}%
\begin{minipage}{0.5\textwidth}
\centering
\makegapedcells
\caption{$x_1 = 0.5$}
\begin{tabular}{| *{4}{>{\centering\arraybackslash}p{1.5cm} |}}
\hline
$\theta $ & $\eta$ & $\nu$ & $\rho$ \\ \hline\hline
20 & 39.976 & 37.827 & 1.0568 \\ \hline
25 & 30.827 & 29.273 & 1.0531 \\ \hline
30 & 24.157 & 23.027 & 1.0491 \\ \hline
35 & 19.205 & 18.373 & 1.0453 \\ \hline
40 & 15.486 & 14.867 & 1.0417 \\ \hline
45 & 12.577 & 12.115 & 1.0381 \\ \hline
50 & error & error & error \\ \hline
\end{tabular}
\end{minipage}
\end{table}

\noindent
\begin{minipage}{0.5\textwidth}
\centering
\makegapedcells
\captionof{table}{$x_1 = 0.4$}
\begin{tabular}{| *{4}{>{\centering\arraybackslash}p{1.5cm} |}}
\hline
$\theta $ & $\eta$ & $\nu$ & $\rho$ \\ \hline\hline
20 & 22.727 & 22.272 & 1.0204 \\ \hline
25 & 17.962 & 17.670 & 1.0165 \\ \hline
30 & 14.416 & 14.234 & 1.0127 \\ \hline
35 & 11.631 & 11.528 & 1.0090 \\ \hline
40 & 9.8771 & 9.8264 & 1.0052 \\ \hline
45 & 9.1780 & 9.1658 & 1.0013 \\ \hline
50 & error & error & error \\ \hline
\end{tabular}
\end{minipage}%
\begin{minipage}{0.5\textwidth}
\centering
\makegapedcells
\captionof{table}{$x_1 = 0.5$}
\begin{tabular}{| *{4}{>{\centering\arraybackslash}p{1.5cm} |}}
\hline
$\theta $ & $\eta$ & $\nu$ & $\rho$ \\ \hline\hline
20 & 39.976 & 37.827 & 1.0568 \\ \hline
25 & 30.827 & 29.273 & 1.0531 \\ \hline
30 & 24.157 & 23.027 & 1.0491 \\ \hline
35 & 19.205 & 18.373 & 1.0453 \\ \hline
40 & 15.486 & 14.867 & 1.0417 \\ \hline
45 & 12.577 & 12.115 & 1.0381 \\ \hline
50 & error & error & error \\ \hline
\end{tabular}
\end{minipage}

\end{document}

If you don't want to decrease the margins, you might want to consider decreasing the column width. You could for example use c tpe columns. With this column type, both tables will easily fit next to each other in the standard text width of  the article documentclass. Personally, I'd prefer tables with less lines, so in the following MWE, I have als included an example on how to achieve that, using the booktabs package. (If you'd also like to align the numbers with respect to the decimal separator, you might want to have a look into the siunitx or the dcolumn package.)
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath,amssymb,amsfonts,systeme}
\usepackage{makecell}
\setcellgapes{5pt}
\usepackage{booktabs}

\begin{document}

\begin{table}
\begin{minipage}{0.5\textwidth}
\centering
\makegapedcells
\caption{$x_1 = 0.4$}
\begin{tabular}{| *{4}{c|}}
\hline
$\theta $ & $\eta$ & $\nu$ & $\rho$ \\ \hline\hline
20 & 22.727 & 22.272 & 1.0204 \\ \hline
25 & 17.962 & 17.670 & 1.0165 \\ \hline
30 & 14.416 & 14.234 & 1.0127 \\ \hline
35 & 11.631 & 11.528 & 1.0090 \\ \hline
40 & 9.8771 & 9.8264 & 1.0052 \\ \hline
45 & 9.1780 & 9.1658 & 1.0013 \\ \hline
50 & error & error & error \\ \hline
\end{tabular}
\end{minipage}%
\begin{minipage}{0.5\textwidth}
\centering
\makegapedcells
\caption{$x_1 = 0.5$}
\begin{tabular}{| *{4}{c|}}
\hline
$\theta $ & $\eta$ & $\nu$ & $\rho$ \\ \hline\hline
20 & 39.976 & 37.827 & 1.0568 \\ \hline
25 & 30.827 & 29.273 & 1.0531 \\ \hline
30 & 24.157 & 23.027 & 1.0491 \\ \hline
35 & 19.205 & 18.373 & 1.0453 \\ \hline
40 & 15.486 & 14.867 & 1.0417 \\ \hline
45 & 12.577 & 12.115 & 1.0381 \\ \hline
50 & error & error & error \\ \hline
\end{tabular}
\end{minipage}
\end{table}

\begin{table}
\begin{minipage}{0.5\textwidth}
\centering
\caption{$x_1 = 0.4$}
\begin{tabular}{cccc}
\toprule
$\theta $ & $\eta$ & $\nu$ & $\rho$ \\ \midrule
20 & 22.727 & 22.272 & 1.0204 \\
25 & 17.962 & 17.670 & 1.0165 \\
30 & 14.416 & 14.234 & 1.0127 \\
35 & 11.631 & 11.528 & 1.0090 \\
40 & 9.8771 & 9.8264 & 1.0052 \\
45 & 9.1780 & 9.1658 & 1.0013 \\
50 & error & error & error \\ \bottomrule
\end{tabular}
\end{minipage}%
\begin{minipage}{0.5\textwidth}
\centering
\caption{$x_1 = 0.5$}
\begin{tabular}{cccc}
\toprule
$\theta $ & $\eta$ & $\nu$ & $\rho$ \\ \midrule
20 & 39.976 & 37.827 & 1.0568 \\
25 & 30.827 & 29.273 & 1.0531 \\
30 & 24.157 & 23.027 & 1.0491 \\
35 & 19.205 & 18.373 & 1.0453 \\
40 & 15.486 & 14.867 & 1.0417 \\
45 & 12.577 & 12.115 & 1.0381 \\
50 & error & error & error \\ \bottomrule
\end{tabular}
\end{minipage}
\end{table}

\end{document}

As your two tables seem to be closely related, you could also combine them into one:

\documentclass{article}
\usepackage{caption}
\usepackage{booktabs}

\begin{document}

\begin{table}
\centering
\caption{The caption text}
\begin{tabular}{ccccccc}
\toprule
& \multicolumn{3}{c}{$x_1 = 0.4$} & \multicolumn{3}{c}{$x_1 = 0.5$} \\
\cmidrule(r){2-4} \cmidrule(l){5-7}
$\theta $ & $\eta$ & $\nu$ & $\rho$ & $\eta$ & $\nu$ & $\rho$ \\ \midrule
20 & 22.727 & 22.272 & 1.0204 & 39.976 & 37.827 & 1.0568\\
25 & 17.962 & 17.670 & 1.0165 & 30.827 & 29.273 & 1.0531\\
30 & 14.416 & 14.234 & 1.0127 & 24.157 & 23.027 & 1.0491\\
35 & 11.631 & 11.528 & 1.0090 & 19.205 & 18.373 & 1.0453\\
40 & 9.8771 & 9.8264 & 1.0052 & 15.486 & 14.867 & 1.0417\\
45 & 9.1780 & 9.1658 & 1.0013 & 12.577 & 12.115 & 1.0381\\
50 & error  & error  & error  & error  & error  & error \\ \bottomrule
\end{tabular}
\end{table}

\end{document}

A: A layout with siunitx and the floatrow package (incompatible with float, but redefines macros from float):
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath,amssymb,systeme}
\usepackage{makecell}
\setcellgapes{5pt}
\usepackage{floatrow}
\usepackage{siunitx}

\begin{document}

Some text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text.

\begin{table}[H]
\floatsetup[table]{floatrowsep=qquad}
\setlength{\tabcolsep}{4pt}
\sisetup{table-format =2.4, table-number-alignment=center}
\begin{floatrow}
\centering
\makegapedcells
\ttabbox{\caption{$x_1 = 0.4$}\label{x1: 4}}{
\begin{tabular}{|>{\centering}p{1cm}|*{3}{S |}}
\hline
{$\theta $} & {$\eta$} & {$\nu$} & {$\rho$} \\ \hline\hline
20 & 22.727 & 22.272 & 1.0204 \\ \hline
25 & 17.962 & 17.670 & 1.0165 \\ \hline
30 & 14.416 & 14.234 & 1.0127 \\ \hline
35 & 11.631 & 11.528 & 1.0090 \\ \hline
40 & 9.8771 & 9.8264 & 1.0052 \\ \hline
45 & 9.1780 & 9.1658 & 1.0013 \\ \hline
50 & {error} & {error} & {error} \\ \hline

\end{tabular}}
\ttabbox{\caption{$x_1 = 0.5$}\label{x1: 5}}
{\begin{tabular}{|>{\centering}p{1cm}|*{3}{S |}}
\hline
{$\theta $} & {$\eta$} & {$\nu$} & {$\rho$} \\ \hline\hline
20 & 39.976 & 37.827 & 1.0568 \\ \hline
25 & 30.827 & 29.273 & 1.0531 \\ \hline
30 & 24.157 & 23.027 & 1.0491 \\ \hline
35 & 19.205 & 18.373 & 1.0453 \\ \hline
40 & 15.486 & 14.867 & 1.0417 \\ \hline
45 & 12.577 & 12.115 & 1.0381 \\ \hline
50 & {error} & {error} & {error} \\ \hline
\end{tabular}}
\end{floatrow}
\end{table}

\end{document}

redpajama_set_name: RedPajamaStackExchange


text:
Q: javascript: Why does obj.constuctor.name give 2 different results if prototype is missing? Why does obj.constuctor.name give 2 different results if prototype is missing? How do i get the constructor name instead of "Object" if it has prototype then?
// Class with prototype
function Foo(a) {
    this.a = a;
}
Foo.prototype = {
    bar: function () {
        console.log(this.a);
    }
};
f=new Foo(1)
f.constructor.name
"Object"

// Class with no prototype
function Fooee(a) {
    this.a = a;
}

f1=new Fooee(1)
f1.constructor.name
"Fooee"

A: You're changing the constructor of Foo() by redefining its prototype to object {}.
You should've instead done this:
Foo.prototype.bar = function () {
   console.log(this.a);
}

A: Functions' prototype properties have initial values that include constructor. You can try it:
function Foo() {
}

assert(Foo.prototype.constructor === Foo);

When you overwrite the entire prototype with an object, you're clobbering that property. ({}.constructor === Object.) Just assign new properties to it instead:
Foo.prototype.bar = function () {
    console.log(this.a);
};


text:
Q: Is .net app.config bindingRedirect dangerous? I see bindingRedirects all the time in different projects! For instance when creating a new MVC5 project.
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>

People uses it to solve all kind of version conflicts, without thinking much about it.

*

*Isn't this dangerous, leading to runtime error?

*Why would Microsoft create redirects between mayor version, when the API probably has changed?

*Could the compiler check that the API hasn't changed?

Also, even when the API is unchanged the logic could have changed.


text:
Q: Celery with dynamic workers I am putting together a Celery based data ingestion pipeline. One thing I do not see anywhere in the documentation is how to build a flow where workers are only running when there is work to be done. (seems like a major flaw in the design of Celery honestly)
I understand Celery itself won't handle autoscaling of actual servers, thats fine, but when I simulate this Flower doesn't see the work that was submitted unless the worker was online when the task was submitted. Why? I'd love a world where I'm not paying for servers unless there is actual work to be done.
Workflow:

*

*Imagine a While loop thats adding new data to be processed using the celery_app.send_task method.

*I have custom code that sees theres N messages in the queue. It spins up a Server, and starts a Celery worker for that task.

*Celery worker comes online, and does the work.
BUT.
Flower has no record of that task, even though I see the broker has a "message", and while watchings the output of the worker, I can see it did its thing.
If I keep the worker online, and then submit a task, it monitors everything just fine and dandy.
Anyone know why?

A: You can use celery autoscaling. For example setting autoscale to 8 will mean it will fire up to 8 processes to process your queue(s). It will have a master process sitting waiting though. You can also set a minimum, for example 2-8 which will have 2 workers waiting but fire up some more (up to 8) if it needs to (and then scale down when the queue is empty).
This is the process based autoscaler. You can use it as a reference if you want to create a cloud based autoscaler for example that fires up new nodes instead of just processes.
As to your flower issue it's hard to say without knowing your broker (redis/rabbit/etc). Flower doesn't capture everything as it relies on the broker doing that and some configuration causes the broker to delete information like what tasks have run.


text:
Q: Girsanov Theorem: Equivalent condition for density I am studying on Girsanov's theorem. Moreover my lecturer states, following:
$$Z>0\text{ is a continuous local martingale }\Leftrightarrow \exists! \text{ N continuous local martingale }:Z=e^{(N-\frac{1}{2}[N])}$$
Is this still true, when $N$ is only a martingale?
$$Z>0\text{ is a continuous martingale }\Leftrightarrow \exists! \text{ N continuous martingale }:Z=e^{(N-\frac{1}{2}[N])}$$
If yes, is it possible to rewrite the condition "If the Doléans-Dade exponential is a continuous martingale" into "If $N$ is a continuous martingale" ? (I am especially interested in $"\Leftarrow"$)
Proof for the statement: Using Ito's lemma we find both directions:
$"\Leftarrow"$
$$
\begin{align}
Z&=\exp(N-\frac{1}{2}[N])\\
&=\exp(N_0)+\exp(N-\frac{1}{2}[N])\cdot (N-\frac{1}{2}[N])+\frac{1}{2}\exp(N-\frac{1}{2}[N])\cdot[N]\\
&=\exp(N_0)+\exp(N-\frac{1}{2}[N])\cdot N
\end{align}
$$
$"\Rightarrow"$
$$
\begin{align}
\log Z=\log Z_0+Z^{-1}\cdot Z-\frac{1}{2}Z^{-2}\cdot[Z]=(\log Z_0+Z^{-1}\cdot Z)-\frac{1}{2}[\log Z_0+Z^{-1}\cdot Z]
\end{align}
$$
is a semi-martingale with unique decomposition, therefore
$Z=e^{(N-\frac{1}{2}[N])}$
with $N:=\log Z_0+Z^{-1}\cdot Z$
Looking at the proof, my question seems to narrow down to the following: When is a stochastic integral with respect to a continuous martingale a continuous martingale again?


text:
Q: Prove that for a dense set $A$ and an open set $U$, $U\subset \overline{A\cap U}$ In a topological space $X$ a subset $A$ is called dense if $\overline{A}=X$. Show that for a dense set $A$ and an open set $U$
$U\subset \overline{A\cap U}$
My solution
$U$ is open $\Rightarrow$ $U \subset \overline{U}$
and also $U \subset X$
$\Rightarrow$ $U \subset \overline{U} \cap X $
Since $A$ is dense in $X$ $(\overline{A}=X)$
$\Rightarrow$ $U \subset \overline{U} \cap \overline{A} $
$\Rightarrow$ $U \subset \overline{U \cap A }$
Does this proof looks good or I missed something.

A: Let $x\in U$
Let $V$ be an open set containing $x$ then $x\in U\cap V$ since $A$ is dense any non empty open set intersects $A$
so $A\cap(U\cap V)\neq $ empty thus $x\in \overline {(A\cap U)}$


text:
Q: Rails: Missing region error AWS heroku paperclip I keep getting this error:
Aws::Errors::MissingRegionError (missing region; use :region option or export region name to ENV['AWS_REGION']):
my paperclip config looks like this:
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV['AWS_BUCKET'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}

tried to add :region ENV['AWS_REGION']
config.paperclip_defaults = {
:storage => :s3,
:region => ENV['AWS_REGION'],
:s3_credentials => {
:bucket => ENV['AWS_BUCKET'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}

region in env is (when running heroku config)
AWS_REGION: us-east-1
tried to default config. created aws.rb in config/initializers
Aws.config.update({
region: 'us-east-1',
})

still doesn't work.

A: You should try :s3_region not :region

A: I got it working by performing the following:

*

*Add to config/environments.production.rb

config.paperclip_defaults = {
      :storage => :s3,
      :s3_region => ENV['AWS_REGION'],
      :s3_credentials => {
        :bucket => ENV['AWS_BUCKET'],
        :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
        :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}

*Set an additional heroku config by using: heroku config:set AWS_REGION=us-east-1

*Ensure your region lines up with the latest regions at: http://docs.aws.amazon.com/general/latest/gr/rande.html#opsworks_region
Hope that helps!


text:
Q: Link_to redirecting wrong I'm having a strange problem with link_to, this is what happens:
When I click in this link_to:

<%= link_to "Sign up", sign_up_path %>

It redirect to sessions/new, but I want to go to users/new
I think my routes.rb is wrong but I don't see anything wrong
This is my route.rb:
get "sessions/new"
get "sign_up" => "users#new", :as => "sign_up"
get "log_in" => "sessions#new", :as => "log_in"
get "log_out" => "sessions#destroy", :as => "log_out"
root :to => "sessions#new"
resources :users

resources :sessions

resources :orchestras

resources :conductors

resources :instruments

resources :integrants

If someone can help, Thanks.
Update
@ChrisPeters said to me see if there is a before_action redirecting me to my sessions/new
I verify and I found a before_filter:
before_filter :verifyUser, :only => [:orchestras, :conductors, :instruments, :integrants, :users]

Because this I'm redirecting to wrong page, I change my users_controller to skip this:
  skip_before_action :verifyUser, only: [:new]

And now it's working.
Thanks @ChrisPeters.

A: See if there is a before_action intercepting the request and redirecting the user to sessions#new.
As you said in your update, it looks like you had missed one:
before_filter :verifyUser, :only => [:orchestras, :conductors, :instruments, :integrants, :users]

And you were able to resolve by calling skip_before_action:
skip_before_action :verifyUser, only: [:new]

One small pointer would be to rename your filter method to verify_user because snake_case is the conventional Ruby way to name your methods.


text:
Q: How to animate an ImageView so that once it reaches the upper end of the screen it starts showing from the bottom end of the screen? Here is what I could achieve:
package game.card.translationproblem;

import androidx.appcompat.app.AppCompatActivity;

import android.animation.AnimatorInflater;
import android.animation.AnimatorSet;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {

    ImageView ball;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_layout);

        ball = findViewById(R.id.coloured_ball);
        ball.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(MainActivity.this, R.animator.move_the_ball);
                set.setTarget(ball);
                set.start();
            }
        });

    }

}

Here is the animation file:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

    <objectAnimator
        android:propertyName="translationY"
        android:valueFrom="0dp"
        android:valueTo="-500dp"
        android:duration="5000"/>

    <objectAnimator
        android:propertyName="translationY"
        android:valueFrom="320dp"
        android:valueTo="0dp"
        android:duration="5000"
        android:startOffset="5000"/>
</set>

And here is the layout file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="700dp"
        android:orientation="vertical"
        android:gravity="center">

        <ImageView
            android:id="@+id/coloured_ball"
            android:layout_width="138dp"
            android:layout_height="141dp"
            android:gravity="center"
            app:srcCompat="@drawable/ball" />
    </LinearLayout>

    </LinearLayout>

I want to perform a translation along the screen so that any portion of the image that goes past the upper edge of the screen immediately shows up from the bottom of the screen.
I thought of using 2 identical images and show one from the bottom at the same time while the other is disappearing from the upper edge but the major objection to this solution is that I can not guarantee the size of the screen and I might just be showing two full images at the same time.

A: could create the animation via the screen size:
void moveBall(){
    // getScreenHeight
    Display display = getDisplay();
    Point outSize = new Point();
    display.getSize(outSize);
    int height = outSize.y;
    //create animator via height
    Animation animator = new TranslateAnimation(0F, 0F, 0F, -(height / 2 + ball.getMeasuredHeight()));
    animator.setDuration(2000);
    animator.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            Animation animator = new TranslateAnimation(0F, 0F, +(height / 2 + ball.getMeasuredHeight()), 0F);
            animator.setDuration(2000);
            ball.startAnimation(animator);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    ball.startAnimation(animator);
}


text:
Q: change color on bootstrap using vue.js wen i run this script with vue.js and bootstrap ( vertical tab )
<vue-tabs class="row" direction="vertical" value="Description" >

    <v-tab :title="siteObject.line_info[index].lineid">

          {{ key }} {{ field }}

    </v-tab>

</vue-tabs>

I have this result

nsn 0102753206
upk 1018.0-1/2
status ACTIVE
lex_id 79VOLGUTD

What can i do that when status is Active then is all text is red?

A: Have you looked at Class & Style bindings?
Add :class="{ 'text-danger': status === 'Active' }" to the element you want to apply your red text to.
Then create your .text-danger in your css.

In this example we are essentially saying:
IF status is equal to Active EXACTLY, Add a class of text-danger

A: <vue-tabs class="row" direction="vertical" value="Description" >

        <v-tab :title="siteObject.line_info[index].lineid">

                    {{ key }} {{ field }}

{{item.status}}

        </v-tab>

  </vue-tabs>

and style


text:
Q: Fortran runtime error while reading a file: "Bad repeat count" I'm trying to read an input file with fortran but I get the following error at runtime:
At line 118 of file prog.f90 (unit = 53, file = 'data.dat')
Fortran runtime error: Bad repeat count in item 1 of list input

The data file is the following
3, 5, 3 %comment
%%%%%%%%%%%%%%
1d0, 0d0, 0d0 % comment
0d0, 0d0, 1d0
%%%%%%%%%%%%%%
1, 1, identity, 1, 1 %comment
1, 2, sigmax, 2, 2
2, 3, sigmax, 2, 2
1, 3, sigmaz, 1, 3
3, 3, identity, 1, 1
%%%%%%%%%%%%%%
0, 0            %comment

and the interesting part of prog.f90 is
COMPLEX(KIND(1D0)), DIMENSION(:), ALLOCATABLE:: H1, H2
INTEGER :: i,A,B,C
CHARACTER(50) :: GHOST

OPEN(UNIT=53,file='data.dat',status='old')
READ(53,*) A,B,C
READ(53,*) GHOST
ALLOCATE (H1(A),H2(A))
READ(53,*) (H1(i), i=1,A)
READ(53,*) (H2(i), i=1,A)

where the 118th line is READ(53,*) (H1(i), i=1,A). I tryed also with an explicit do loop but with the same result.

A: I haven't tested this, but I'd expect
READ(53,*) (H1(i), i=1,A)

to try to read 3 complex numbers.  It gets fed the line
1d0, 0d0, 0d0 % comment

from which it gets 1½ complex numbers and then barfs on the % sign, misinterpreting it as a syntactically invalid repeat count.
I'd suggest providing 3 complex numbers in the file when that read statement is executed.

A: The numbers are dimensioned complex, while in fortran complex numbers should be in the file with parenthesis as:
 ( realpart , imaginarypart )  ( realpart , imaginarypart )
I really don't know what the standards say regarding the input form you have presented, but after some testing gfortran throws that Bad repeat count error regardless of the % comment.  It throws that error even with four or more comma separated reals on the line.
Now ifort on the other hand reads the line just the way you have it -- but watch out -- it reads each of the comma separated values as the real part of your complex variable, setting the imaginary part to zero. ( that is it only uses the first two values on each line and discards the third )
You will really need to study the code to make sure you understand what was intended to sort out how to fix this.  If the later (ifort) behavior is the intention one simple fix would be to declare a couple of reals. Read into the reals, then assign those to your complex variables.


text:
Q: mail.Attachments.Add(path) will lead to error when I used it twice When I used win32com.client to send outlook emails with one than one attachments in Python, I want to add multiple attachments with twice "mail.Attachments.Add()" However, it will intermittently lead to an error that said "This file could not be found. Please verify that the path and file name are correct." How interesting is that sometimes it will run normally, and sometimes will have this error. But when I used "mail.Attachments.Add()" only once it never lead to this error.
I wonder why it is. If this way is not reliable, is there other way to add multiple attachments to send outlook emails.
I have made sure the path is existing.
def send_email(path, detail_path, datestr, name):
    olook = win32.Dispatch("outlook.Application")
    mail = olook.CreateItem(0)
    mail.HTMLBody = body_html
    mail.Subject = datestr + 'summary'

    # summary
    mail.Attachments.Add(path)
    # detail
    mail.Attachments.Add(detail_path)


text:
Q: Having some SQL subquery issues with taking query result from one query and using it to filter the next result Having some SQL subquery issues with taking query result from one query and using it to filter the next result
Table one I took the results from query one  but i want to use the result from fav to  filter from  my teams table where i have many teams and it will display the results
mysql> SELECT fav FROM login WHERE username ='djk';
+-------------+
| fav         |
+-------------+
| Real Madrid |
+-------------+
1 row in set (0.00 sec)

i tried this
(SELECT fav FROM login WHERE username ='djk') as team_name  from team;

and many other have not worked
this is my team table so i want to use the results from the one query to filter from team_name and only show the requested team
mysql> describe team ;
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| team_id     | int(11)      | NO   | PRI | NULL    | auto_increment |
| team_name   | varchar(355) | NO   |     | NULL    |                |
| country     | varchar(255) | YES  |     | NULL    |                |
| stadium     | varchar(255) | YES  |     | NULL    |                |
| city        | varchar(255) | YES  |     | NULL    |                |
| coach       | varchar(255) | YES  |     | NULL    |                |
| league_name | varchar(255) | NO   |     | NULL    |                |
| league_id   | int(11)      | NO   | MUL | NULL    |                |
+-------------+--------------+------+-----+---------+----------------+
8 rows in set (0.00 sec)

If some one could guide me in the right direction i would appropriate it.

A: A simple subquery in the WHERE clause should work just fine:
SELECT * FROM team WHERE team_name = (SELECT fav FROM login WHERE username = 'djk'

A: Your use case is an inner join
select *
from team t
join login l on t.team_name = l.fav
where l.username ='djk';

A: Thanks for the help  i was able to do it with where

<?php
ob_start();
echo $_SESSION['username'] ;
$getname = ob_get_contents();
ob_end_clean();

                            $conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
if (!$conn) {
                                echo "here";
}
                    $sql3 = "SELECT * from team where team_name =(select fav from login where username='${getname}')";


text:
Q: Is it possible to use $logProvider for logging in config block of the module? I'd like to output log messages to console when debugging. Works fine in controllers but can't get it to work in a module config block, e.g.
angular.module('MyApp', [])
  .run(function($state){
    // run stuff here
  });
  .config(function($logProvider){
    $log.debug('Config debug message');
  });

I get an error:
error TypeError: Cannot read property 'debug' of undefined

Is it possible to use the logProvider in the config block of a module?

A: $logProvider accessed during the config phase is used to configure the log service, or you can inject $provide to change/leverage the behavior of logservice using decorators. The log service itself has not been instantiated yet in your module MyApp. You could instead get a logger instance from core ng and use it for debugging.
You could do:-
 .config(function(){
     var $log =  angular.injector(['ng']).get('$log')
     $log.debug('Config debug message');
  });

$logProvider.$get will give you the constructor for logservice, you could yourself create an instance of it by calling $injector.instantiate($logProvider.$get) but the problem is that it has a dependency on window service which has not bee instantiated yet, so ultimately your logger instantiation will fail.
Another hacky way would be force angular to instantate logger by adding a decorator in the config block which you can set up as the first config block before any config logging is required, after that you can execute the ctor from $logProvider getter and get the instance of a logger.
.config(function($provide){
   //Just a dummy decorator
   $provide.decorator('$log', function($delegate){
      return $delegate;
  });

}).config(function($logProvider){
   //get logger instance
   var log = $logProvider.$get();
   log.debug("Got it");
});

Plnkr


text:
Q: Cannot download images from apple website? Generally one can download the images from any website by right clicking and selecting save image as.. but its not possible in apple website https://www.apple.com/iphone/compare/ , also they are using
 tag-
for example-

Gold

A: They're using css to set the image as the background image of the  element with the class .iphone-6-gold-image
See below:
.page-compare .section-color-finish .iphone-6-gold-image {
  background-image: url("https://www.apple.com/v/iphone/compare/c/images/6_gold_large.jpg")
}

A: If an image URL is not explicitly written in the HTML, check the page's CSS. Unless the website uses an  tag, the image URL will be written in the background property of the element containing the image.
In this case:

.page-compare .section-hero .hero-image {
  background-image: url("https://www.apple.com/v/iphone/compare/c/images/hero_large_2x.png");
}


text:
Q: Microsoft word call C# Clipboard change event after closing In my winform application in C#, I'm using this code to do something when windows Clipboard contents changes.
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool AddClipboardFormatListener(IntPtr hwnd);

private const int WmClipboardupdate = 0x031D;

protected override void WndProc(ref Message m)
{
  base.WndProc(ref m);
  if (m.Msg != WmClipboardupdate) return;
  richText.Paste();
}

Now when I copy some text from Microsoft Word, it works fine. But the problem is when I close Word application, it still calls the change event 3 times and the text in the clipboard pastes in to my RichTextBox or wherever I use the Clipboard content.
Does anyone has any idea how to prevent that?

A: Remove your listener to stop receiving events.
RemoveClipboardFormatListener(hwnd);

how do you know when an unrelated application is open?
    private bool IsWordFileOpened()
    {
       bool isExist = false;
       System.Diagnostics.Process[] prs = System.Diagnostics.Process.GetProcesses();
       foreach (Process pr in prs)
       {
          if (pr.ProcessName == "WINWORD")
          {
            isExist = true;
            break;
          }
       }
       return isExist;
    }

or subscribe to closing even using SetWindowsHookEx, CBTProc callback function, HCBT_DESTROYWND.
But this is a hack. I would suggest you probably are doing something wrong. I'm not sure I understand your requirements, but you should have your winforms application do it's thing during the lifetime of the winforms application.


text:
Q: front 'however' vs. end 'however' The sentence I focus on is this:

As we will see below, there are some cognitivists who do not take a Gricean approach, offering a semantic explanation instead. This is not the most common approach, however.

I do not understand why however is used as the end of this sentence. Could I front however to the head of this sentence in the context above like this:

However, this is not the most common approach.

Why does this author like to end a sentence with 'however', or even 'instead'?

A:
I do not understand why however is used as the end of this sentence.

Ending with "however" like that would usually be "setting up" for a sentence to follow.  That sentence would provide a contrast, saying what the most common approach would be:

*

*"As we will see below, there are some cognitivists who do not take a Gricean approach, offering a semantic explanation instead. This is not the most common approach, however. Much more common would be to copy and paste explanations from StackExchange."
Since you stopped your example after the "however", we don't know if there's such a next section or not.  But I'd feel it would be weird without it, sort of dangling.  "however... what?"

Could I front however to the head of this sentence

Yes.
(Sidenote: using front as a verb like this is not "correct", though it can be understood as a casual and expedient way of "verbing" a noun--people might do it, consciously knowing it's not correct English.  When people use "front" as a verb it usually means something else... as short for "confront".  So here you probably want to say something like "Could I move 'however' to the front of this sentence?")

Why does this author like to end a sentence with 'however', or even 'instead'?

Mechanical questions are easier to answer than "why".  Why don't they give their example first, and then say "as we have seen" instead of giving us a preview with "as we will see below"?  (Why write something that sounds so boring in the first place?  :-P)
The positioning of these words has to do with guiding people along a train of thought.  You're being told something first...but then being asked to "change gears" to realize the thing you've been told might not be the most important.  Good placement of these pauses and turning points helps keep readers on track with the points in the order you want to make them.
The reason for choosing any given ordering and those contrasts may be fully reasoned--or it could just be the order that the author happened to think of them in.  Where you put the howevers has more to do with how the setups sound "in your head" than anything.


text:
Q: Strategy Pattern Implementation I have to generate a code that will send through SMS or Email to implement the One Time Password (OTP) requirement of our client.
I just finished creating the design using strategy pattern, .
.
This it the first time I've used strategy pattern in real life projects so I would like to ask if I'm doing it right.
Below is just a sample code that will be used by client.
 //OTPGeneratorStrategy generatorStrategy = new EmailGeneratorStrategy("test@gmail.com"); for sending to Email for example
OTPGeneratorStrategy generatorStrategy = new SmsGeneratorStrategy(993454454545);
OTPGeneratorContextgeneratorContext = new OTPGeneratorContext(generatorStrategy);
context.generate("1-12345-0");

OTPValidatorStrategy validatorStrategy = new SmsValidatorStrategy();
OTPValidatorContext validatorContext = new OTPValidatorContext (validatorStrategy );
try {
validatorContext.validate("1-12345-0","e7241f");
} catch (InvalidVerificationKeyException ivk) {
System.out.println("Verification key is invalid!");
} catch(VerificationKeyExpiredException vke) {
System.out.println("Verification key is already expired, Please regenerate");
}

Updated:
Thank you for the feedback, actually I was not able to update my latest UML design and already separated the generation and validation.
And the reason why I've used Exception rather than enums because the project was built in java 1.4.

A: First thing that strikes me as a problem is using exceptions for validation result. Don't use exceptions for application logic. Just return an enum value. I would assume there are not many ways validation can end up.
Next thing I would question is using of two strategies. What would happen if you used SMS generator with Email validator? To me, it seems there should be just one strategy with both generate and validate methods. As for "merging the two violates SRP", I would actually say having them separate violates SRP. SRP is about cohesion. And cohesion works both ways. It separates non-cohesive code and joins cohesive code that was split. Ask yourself "If I changed how Email one-time-password policy worked, would I change only generator or validator or would I have to change both?". I'm quite sure you would need to change both, meaning generation and validation are cohesive parts. If you are worried about putting email sending into the strategy implementation, then that should be strategy's concern. OTPContext doesn't need to be bothered by that. It doesn't need to know generation uses some special logic, that is not relevant to validation.
Last nitpick is that I would prefer if strategy was set to OTPContext in a constructor instead of getters/setters. What would happen if you changed the validator strategy after code was generated? You should keep things read-only unless there is explicit requirement for things to change.

A: As a former, but now somewhat reformed object-oriented programming enthusiast I have to say - be careful with design patterns. This feels like classic "kingdom of nouns" OOP overdesign (check out Steve Yegge's classic blog post on the subject: http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html ).
I'd highly recommend trying a simple, procedural implementation of this, in addition to what you're considering - e.g. a simple static method that takes boolean or enum flag for SMS/email, in addition to the other inputs, and follows a simple linear flow of logic, using plain ol' if statements for steps that differ between SMS/email etc.
You may find that the strategy pattern leads to the simplest, most compact, easiest to maintain code in the end, but it definitely pays to try a few design approaches. The more code I've written and read over the years the more I've seen how OOP "best practices" can needlessly overcomplicate things.


text:
Q: Intuition behind the solutions of the Schrodinger equations I am learning the basic and easy first examples of the most common problems in Quantum Mechanics,and while trying to find solution to the Schrodinger equation,i find myself struggling with the intuition behind finding the general solution of the equation.
The lecturer sometimes writes that the solution is of form $A\sin x+B\cos x$ and sometimes he writes $Ae^{ip/h}+Be^{-ip/h}$ and sometimes he writes $Ae^{p/h}+Be^{-p/h}$.
Now i know that the first two general solutions are connected via Euler's formulas so i suspect that whichever i write down i will get the right solution.
But,the question is about all three general solutions(i know that afterwards there might be more general solutions as these are for simple cases-or not),so i want to know if there is something that intuitively tells you which one you have to choose in order to start solving the equation.
Thank you


text:
Q: How should operators be understood in second quantization? So I am trying to understand in which sense first and second quantization is equivalent. I am following Richard Martin's book on interacting electrons. In the appendix (A.2) he has a piece on second quantization. My understanding of it is that:
First quantization:
A state is a square-integrable function.
Second quantization:
A state is an infinite-dimensional tuple that simply holds the tally of how many particles are in each energy level of the hamiltonian. Moreover, it seems that second quantization it is assumed that the hamiltonian is for non-interacting harmonic oscillators(?).
In his book on page 680, Richard Martin states that if the matrix elements of an operator $\widehat O(x)$ is going to be the same in first and second quantization, we assume that $\{\psi_n\}$ is a basis of orthonormal functions (are these arbitrary or Harmonic oscilltor?) and that
$$
\langle \phi, \widehat O \phi \rangle = \int \phi^* \widehat O \phi\, dx, \quad \text{and} \quad \phi = \sum_n \alpha_n \psi_n, \quad \text{and} \quad |\phi \rangle = \sum_n \alpha_n c_n^\dagger |0 \rangle
$$
Martin states that a natural definition is therefore
$$
\widehat O = \sum_{k_1,k_2} c_{k_1}^\dagger O_{k_1 k_2} c_{k_2}, \quad O_{k_1 k_2} = \int \psi^*_{k_1} \widehat O \psi_{k_2} dx.
$$
What is going on here? Why is this natural?
What is the definition of a summation and scalar multiplication in second quantization? For example, what is the meaning of
$$
5\cdot | 101 \rangle + 42 \cdot |0101 \rangle = ?
$$
Without telling the reader what scalar cultiplication and addition means in this hilbert space, how could I tell what $\sum_n \alpha_n c_n^\dagger |0 \rangle$ is?
Finally, Martin states that if there is an operator of two arguments $V(x,x')$, then
$$
\widehat V = \frac{1}{2} \sum_{k_1k_2k_3k_4} V_{k_1k_2k_3k_4} c_{k_1}^\dagger c_{k_2}^\dagger c_{k_3} c_{k_4}, \qquad V_{k_1k_2k_3k_4} = \int \psi^*_{k_1}\psi^*_{k_2} V \psi_{k_3} \psi_{k_4} dx dx'
$$
Why is this the right definition?

A:
Without telling the reader what scalar cultiplication and addition means in this hilbert space

If you're asking about the mathematical meaning, then it is the same as in any other Hilbert space. In fact, mathematicians say that all Hilbert spaces are isomorphic to each other and there's just one Hilbert space.
If you're asking about the physical meaning, then it is still the same as in any other Hilbert space. The interpretation of a state you wrote down is "the system is in a superposition of states $\left| 101 \right>$ and $\left| 0101 \right>$ with real coefficients $5$ and $42$ respectively". You can apply the Born rule to the same extent it can be applied in any other quantum theory and say that the probability of observing $\left| 101 \right>$ is $5^2 / \left( 5^2 + 42^2 \right)$.
Finally, w.r.t. the relationship between a first-quantized operator and the corresponding second-quantized operator. In the Fock space (the second-quantized Hilbert space), a notable subspace is the space of "one-particle states", that is, states with a single occupation number $1$ in some mode and zeroes in all other modes. It is trivial to see that this is the same as the first quantized Hilbert space. Let's denote the mapping from $\mathcal{H}_1$ (first-quantized Hilbert space) to $\mathcal{H}_2$ (second-quantized Hilbert space) by $S$. It is defined by acting on a basis vector in $\mathcal{H}_1$ by
$$
S \left| \psi_a \right> = c_a^{\dagger} \left| 0 \right>.
$$
The idea is to define the second-quantized opertor corresponding to the first-quantized operator such that it acts in the same way the original operator does, on this subspace. The expression
$$
\Omega = \sum_{a,b} c^{\dagger}_a O_{ab} c_b
$$
achieves just that (I denote by $O$ the first-quantized operator and by $\Omega$ the second-quantized corresponding operator). It is easy to see: the first-quantized state $\left| \psi_a \right>$ gets mapped into $c_a^{\dagger} \left| 0 \right>$ by the ebmedding of the one-particle subspace in the Fock space. We need to check, the result of applying $O$ gets mapped to the result of applying $\Omega$ to the original operator, that is, we need to check that $S O = \Omega S$.
$$
O \left| \psi_a \right> = \sum_b O_{a b} \left| \psi_b \right>,
$$ $$
\Omega S \left| \psi_a \right> =
\Omega \, c_a^{\dagger} \left| 0 \right> = \sum_{b,c} c_b^{\dagger} O_{bc} c_c c_a^{\dagger} \left| 0 \right> = \sum_{b,c} \delta_{a c} O_{b c} c_b^{\dagger} \left| 0 \right> = \sum_b O_{ab} c_b^{\dagger} \left| 0 \right> = S O \left| \psi_a \right>,
$$
which is exactly what we expected to see. Therefore, $\Omega$ acts on the 1-particle subspace of the Fock space exactly like $O$ does on the first-quantized Hilbert space (isomorphic to the 1-particle subspace).


text:
Q: It is possible to replay CAN bus messages for building intercom system? I would like to automate my apartment's intercom unit to unlock the building door remotely. I am able to press the door unlock button at any time and this unlocks the door in the lobby. I scoured the internet and was able to find the unit as a wholesale in China and the documentation mentions the communication protocol is CANbus.
I took the cover off my video intercom unit and found that there is a single DATA pin which I presume is transmit or maybe a single wire implementation of CAN? Impossible to tell.
I measured the voltage by connecting a multimeter to ground and to the DATA pin. It was 14.5v which seems rather strange. When I press a button I can see the voltage drop slightly.
Are there any tools I could use to see the messages being generated by the intercom unit? Ideally I would like to reverse engineer the CAN messages and then replay them from a WiFi enabled micro controller so I can remotely operate.

A: Canbus is not normally single wire, equally the voltage makes it seem more like K-line / L-line, if that is the case you should be able to hook it up to a PC serial port and log it at 10400 baud, (CANbus is usually too fast for reliable single wire transfer over the kind of distances a home intercom would work at)
It is 100% possible to replay messages, just in this case depends a little on the implementation, e.g. if it uses some kind of rolling code (unlikely) to prevent replay messages from being valid.
Have a look at where that data pin connects to inside the device, usually there will be a little 8 pin IC that acts as a tranciver for the data bus, this should give you a very solid tell tale of exactly what physical layer it is using (could alternatively just be a transistor),
And finally, if it is K-line, you will need to offset the voltage of any logic analyser you may hook up to it at a later stage, low is below 33% of VCC, and high is above 66%, so for your 14.5V bus you want to offset near the middle for reliable capture from some of the weirder devices.
Edit: Adding image of suggested transceiver schematic.


text:
Q: How do I connect to a bluetooth device from the Linux Kernel? I am just starting to delve into the Linux kernel. As a starting point I am attempting to write a driver for an independent device (Mindstorms NXT. Yes, I know there are userspace alternatives, but that is not what I am looking for.) that may be connected to the host either by USB or Bluetooth. The aim is to expose a common interface as a character device, independent of the underlying connection.
The USB portion is up and running, but I am having a hard time figuring out how to scan and connect to a Bluetooth device from my module.
I am familiar with how to do this from user code, but I want to know how it may be done from the kernel.
Thus, my questions are as follows.

*

*How do I scan for and connect to a remote Bluetooth device inside a kernel module?

*Can I register a callback to be called whenever a Bluetooth device matching a given PID:HID/BTADDR/Serial Number similar to the probe callback in an USB-driver?

*Is this a silly thing to try do, if so why?

Thank you.

A: *

*If you can say how bluetooth scanning process is organized(sorry about this word, cannot select synonym) in user space, so why wouldn't you try to investigate what is going on during that moment in kernel space? What system-calls were called when you scan the air? What ioctl, what parameters? And so on.

*Well, actually everything is possible. But as I think it's not good idea to add this functional on USB driver, since it was developed for more common things. As an advice I would try to implement any kernel thread with TRACE EVENTS.


text:
Q: How can I use MultipleoutputFormai in Hadoop 0.20? I am working with Hadoop 0.20 and I want to have two reduce output files instead of one output. I know that MultipleOutputFormat doesn't work in Hadoop 0.20. I added the hadoop1.1.1-core jar file in the build path of my project in Eclipse. But it still shows the last error.
Here is my code:
public static class ReduceStage extends Reducer<IntWritable, BitSetWritable, IntWritable, Text>
{
    private MultipleOutputs mos;
    public ReduceStage() {
        System.out.println("ReduceStage");
    }

    public void setup(Context context) {
        mos = new MultipleOutputs(context);
    }

    public void reduce(final IntWritable key, final Iterable<BitSetWritable> values, Context output ) throws IOException, InterruptedException
    {
        mos.write("text1", key, new Text("Hello"));
    }

    public void cleanup(Context context) throws IOException {
        try {
            mos.close();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

And in the run():
FileOutputFormat.setOutputPath(job, ConnectedComponents_Nodes);
job.setOutputKeyClass(MultipleTextOutputFormat.class);
MultipleOutputs.addNamedOutput(job, "text1", TextOutputFormat.class,
                IntWritable.class, Text.class);

The error is:
java.lang.NoSuchMethodError: org.apache.hadoop.mapreduce.lib.output.FileOutputFormat.setOutputName(Lorg/apache/hadoop/mapreduce/JobContext;Ljava/lang/String;)V
at org.apache.hadoop.mapreduce.lib.output.MultipleOutputs.getRecordWriter(MultipleOutputs.java:409)
at org.apache.hadoop.mapreduce.lib.output.MultipleOutputs.write(MultipleOutputs.java:370)
at org.apache.hadoop.mapreduce.lib.output.MultipleOutputs.write(MultipleOutputs.java:348)
at bitsetmr$ReduceStage.reduce(bitsetmr.java:179)
at bitsetmr$ReduceStage.reduce(bitsetmr.java:1)
at org.apache.hadoop.mapreduce.Reducer.run(Reducer.java:176)
at org.apache.hadoop.mapred.ReduceTask.runNewReducer(ReduceTask.java:566)
at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:408)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:216)

What can I do to have MultipleOutputFormat? Did I use the code right?

A: You may go for an overridden extension of MultipleTextOutputFormat and then make all the contents of the record to be the part of 'value', while make the file-name or path to be the key.
There is an oddjob library. They have a range of outputformat implementations. The one which you want is MultipleLeafValueOutputFormat : Writes to the file specified by the key, and only writes the value.
Now,say you have to write the following  pairs and your separator is say the tab character ('\t'):
<"key1","value1"> (you want this to be written in filename1)
<"key2","value2"> (you want this to be written in filename2)
So, now the output from reducer would transform into follows:
<"filename1","key1\tvalue1">
<"filename2","key2\tvalue2">
Also, don't forget that the above defined class should be added as the outformat class to the job:
conf.setOutputFormat(MultipleLeafValueOutputFormat.class);

One thing to note here is that you will need to work with the old mapred package rather than the mapreduce package. But that shouldn't be a problem.

A: Firstly, you should make sure FileOutputFormat.setOutputName has the same code between versions 0.20 and 1.1.1. If not, you must have compatible version to compile your code. If the same, there must be some parameter error in your command.
I encountered the same issue and I removed -Dmapreduce.user.classpath.first=true from run command and it works. hope that helps!


text:
Q: Ajax only works once when form submitted I am attempting to create a login widget that utilizes ajax on the user side of Wordpress.  I have created a form, ajax and response. The form only works once during testing (as it stands right now I am just testing for responses to the ajax request).
Here is my code:
Form:
<form class="fs-login" autocomplete="off" novalidate method="post">

                <input class="uk-input uk-form-small" name="username" type="text">

                <input class="uk-input uk-form-small" name="password" type="password">

            <button id="fs-login-button" type="submit" class="uk-button uk-button-small uk-width-1-1">Login</button>

            Not registered?
Create an account

Jquery:
jQuery(document).ready(function($){
'use strict';

$('.fs-login').on('click', '#fs-login-button', function (){

    var username = $("input[name=username]").val();
    var password = $("input[name=password]").val();

    // if(username.length > 0) {

        $.ajax({

            method: "POST",

            url: ajaxurl,

            data: {

                'action'        : 'ajaxlogin',

                'username'      : username,

                'password'      : password

            },

            success: function(data){

                if (data.success == true){

                    alert('pass');

                } else {

                    alert('fail');

                }

            }

        });

    // } else {

    //  alert('You have to enter your username');

    // }

});

});
Here is my function:
public function ajax_login(){

    $data = array( 'success'=>true );

    wp_send_json( $data );

    wp_die();

}

Yes I have the following codes added to my files:
wp_localize_script( $this->plugin_name, 'ajaxurl', admin_url( 'admin-ajax.php' ) );

In addition to :
$this->loader->add_action( 'wp_ajax_ajaxlogin', $plugin_public, 'ajax_login' );
$this->loader->add_action( 'wp_ajax_nopriv_ajaxlogin', $plugin_public, 'ajax_login' );

As I stated, the ajax functions fine the first time I run it. I get the jQuery alert popup.  The second time that I run the program, there is no popup and the script appears to post and load the a new page with no functions being parsed.
Any help is always appreciated.
Mike

A: By just looking at it I guess you can do two things:

*

*return false on submit handler for example:

<form onsubmit="return false;" ...

*Maybe you also have to extend your clickhandler like:

... '#fs-login-button', function (e){ e.preventDefault()
To achieve prevent submitting the form non-ajax, google it you have to do it


text:
Q: Evaluation order of Operator * I have the following piece of code :
int f(int &x, int c){
    c = c - 1;
    if (c == 0) return 1;
    x = x + 1;
    return f(x, c)*x;
}

Now, suppose I call the above function like this :
int p = 5;
std::cout << f(p, p) << std::endl;

The output is 9^4, since x is passed by reference, hence the final value of x should be 9, but when the return statement of the above function is changed to :
return x*f(x, c);

the output is 3024 (6*7*8*9). Why is there a difference in output ? Has it anything to do with the order of evaluation of Operator* ? If we are asked to predict the output of the above piece of code, is it fixed, compiler-dependent or unspecified ?

A: When you write:
f(x,c)*x

the compiler may choose to retrieve the stored value in x (for the second operand) either before or after calling f.  So there are many possible ways that execution could proceed.  The compiler does not have to use any consistency in this choice.
To avoid the problem you could write:
auto x_temp = x;
return f(x, c) * x_temp;

Note: It is unspecified behaviour; not undefined behaviour because there is a sequence point before and after any function call (or in C++11 terminology, statements within a function are indeterminately-sequenced with respect to the calling code, not unsequenced).

A: The cause is that f() function has side effect on its x parameter. The variable passed to this parameter is incremented by the value of the second parameter c when the function returns.
Therefore when you swap the order of the operand, you get different results as x contains different values before and after the function is called.
However, note that behaviour of the code written in such way is undefined as compiler is free to swap evaluation of operand in any order. So it can behave differently on different platforms, compilers or even with different optimization settings. Because of that it's generally necessary to avoid such side effects. For details see http://en.cppreference.com/w/c/language/eval_order


text:
Q: Debain jessie Empty PHP session variables I am using Debian jessie
I installed apache 2.4 and php 7.0 but the problem that I have is that the variables are always while I put the instruction session_start () in all the pages Thank you for help me please

A: I'm no php guru but I think you could try to save the session vars into a static variable, and then check the output of that var to see if it's empty or not. There are probably ways of debugging php scripts and see what's wrong but I can't help you with that.
If I were you I would also check the permissions for /var/lib/php/session. That folder is used to save temporary session vars used/generated by php. If let's say your apache is running as nobody or www-data or apache, set the proper ownership for that folder according to your apache user.
ps aufx | grep httpd

First entry on the left would be the user. Remember that user and issue a:
chown apacheuser:apacheuser /var/lib/php/session

Restart apache (systemctl restart httpd) and try again and see if that works!


text:
Q: How can I increase the value of a variable in an expression? I have the following code:
$b = 1
Import-Csv c:\Awsaf\powershell\Beforenew.csv | select name, CustomAttribute1, CustomAttribute2, @{n='Counter';e={$b}} | Export-Csv -NoTypeInformation c:\Awsaf\PowerShell\afternew.csv

I want to increment the value of $b by 1. I have tried $b++, $b+=, for loop, do-while, nothing seems to be working. How can I do it?
I have also tried the following additional code, but I cannot figure out how to increase the value of $b.
$b = 0
Import-CSV c:\Awsaf\powershell\afternew.csv -Delimiter ',' | `
ForEach-Object { $_.Counter = "$b"; return $_ } | `
Export-CSV c:\awsaf\powershell\afterX.csv -Delimiter ',' -NoTypeInformation

A: Use explicit script scope for the variable 'b'. After increment (++) do not forget to output the value.
Here is the code that works fine for me (it is a slightly changed version of yours):
# Prepare some data for the test
Get-ChildItem | Select-Object Name | Export-Csv test1.csv -NoTypeInformation

# 1) Use explicit script scope for the variable 'b'
# 2) After increment (++) do not forget to output it
$script:b = 0
Import-Csv test1.csv |
select Name, @{n='Counter'; e={$script:b++; $script:b}} |
Export-Csv -NoTypeInformation test2.csv

A: This is a slight variation as I needed this in a string. Roman's curly brackets don't take a string. You need to use parentheses:
`"$($script:b++; $script:b)"`

A: Ohter option (although not so beautiful) is to use Add-Member. You tried it in your ForEach-Object:
gci |
  select Name |
  % -beg {$counter=0} {$counter++; Add-Member -in $_ -name Test NoteProperty $counter -pass }


text:
Q: I need to add Javascript to Wordpress theme called Juridica I did slider for photos on my site but I don't know where to put this into  Juridica theme. This is slider code
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>

        <script type="text/javascript">

            var numer = Math.floor(Math.random()*5)+1;

            var timer1 = 0;
            var timer2 = 0;

            function ustawslajd(nrslajdu)
            {
                clearTimeout(timer1);
                clearTimeout(timer2);
                numer = nrslajdu - 1;

                schowaj();
                setTimeout("zmienslajd()", 500);

            }

            function schowaj()
            {
                $("#slider").fadeOut(500);
            }

            function zmienslajd()
            {
                numer++; if (numer>5) numer=1;

                var plik = "<img src=\"slajdy/slajd" + numer + ".png\" />";

                document.getElementById("slider").innerHTML = plik;
                $("#slider").fadeIn(500);

                timer1 = setTimeout("zmienslajd()", 5000);
                timer2 = setTimeout("schowaj()", 4500);

            }

</script>

And question where is this theme's html?

A: You can find the Theme directory under the wp-content/themes/your theme name/
Also please refer the wp_enqueue_script function to add a script in the WordPress theme.


text:
Q: How to know whether the mousedown event is occured on where we want in canvas? Here I have a code sample related to moving an element on canvas.
To move a circle to an other position on canvas, the below code is checking whether the mousedown event got triggered on the circle element itself or not so that further dragging can be initiated using mousemove. But I dont understand the logic that's been used to know whether or not the mouse is doubleclicked on the correct circle to drag it.
// start dragging
function DragStart(e) {

    //coordinates of mouse from mousedown event e{x,y}
    e = MousePos(e);
    var dx, dy;

    //initialCirclePosition is the centre (x,y) of the circle
    dx = initialCiclePosition.x - e.x;
    dy = initialCiclePosition.y - e.y;

    if ((dx * dx) + (dy * dy) < circleRadius * circleRadius)   {

        //Yes, user is trying to move the circle only
        ........
    }
}

When user holds the mouse control on any element(by clicking on it), mousedown event occurs, Then, when he tries to drag the element, mousemove event occurs. But, before letting mousemove gets triggered, we should find whether or not the user is trying to drag the right element (circle here). If you see the code above, the logic in if() statement was used to check that. I am unable to understand that logic and that's the question is about. Thanks.

A: An explanation of what your code is testing.
This part of your code...
((dx * dx) + (dy * dy) < circleRadius * circleRadius)

...uses the Pythagorean Theorem to mathematically test if the mouse is inside the circumference of a circle.
(dx * dx) + (dy * dy) measures the distance between the circle centerpoint and the mouse. It actually measures the centerpoint-to-mouse distance squared, but since Math.sqrt is an expensive operation, we just compare the mouse distance squared to the circle radius squared. We get the same result but avoid the expensive Math.sqrt.
Here's a tutorial on determining distances using the Pythagorean Theorem:
https://www.youtube.com/watch?v=We3LG8pK-LU

We can't tell why the test is being done without seeing more of your code.
But, but presumably if the mouse is inside the circle you are deciding that the user intends to drag the circle.
And conversely if the mouse is outside the circle you are deciding that the user intends to execute a click.

An alternative click vs drag test:
This alternative test is nice because you can let the use either click in the circle or drag the circle. This alternative tries to "read the intent" of the user.

*

*In mousedown, save the starting mouseX & mouseY position.
var isDown,startX,startY,itIsADrag;

function handleMouseDown(e){

  // save the mouse position at mousedown
  startX=parseInt(e.clientX-offsetX);
  startY=parseInt(e.clientY-offsetY);

  // initially set the "itIsADrag" flag to false
  itIsADrag=false;

  // set the "isDown" flag to true
  isDown=true;

  ... any other code ...
}

*In mousemove, test if the mouse has moved less than about 5 total pixels (or 10px or whatever).

*

*If moved <5 pixels do nothing in anticipation of this being a click.

*If moved >=5 pixels start a drag operation.
function handleMouseMove(e){

    // return if the mouse is not down
    if(!isDown){return;}

    // get the current mouse position
    mouseX=parseInt(e.clientX-offsetX);
    mouseY=parseInt(e.clientY-offsetY);

    // do nothing if the mouse has moved less than 5 total pixels since mousedown
    if(!itIsADrag && Math.abs(mouseX-startX)+Math.abs(mouseY-startY)<5){return;}

    // Set the dragging flag to true
    // This flag prevents the Math.abs test above if we know we're dragging
    itIsADrag=true;

    // start a drag operation
    ... do drag stuff ...
}

*By the time mouseup occurs, we can just read our itIsADrag flag to determine if the user clicked or dragged.
function handleMouseUp(e){

  if(itIsADrag){
      console.log("You have been dragging");
  }else{
      console.log("You've did a click");
  }

  // clean up by clearing the isDown flag
  isDown=false;
}

Example code and a Demo:

var canvas=document.getElementById("canvas");
var ctx=canvas.getContext("2d");
function reOffset(){
  var BB=canvas.getBoundingClientRect();
  offsetX=BB.left;
  offsetY=BB.top;
}
var offsetX,offsetY;
reOffset();
window.onscroll=function(e){ reOffset(); }

var isDown=false;
var isDown,startX,startY,itIsADrag;

$("#canvas").mousedown(function(e){handleMouseDown(e);});
$("#canvas").mousemove(function(e){handleMouseMove(e);});
$("#canvas").mouseup(function(e){handleMouseUp(e);});
$("#canvas").mouseout(function(e){handleMouseOut(e);});

function handleMouseDown(e){
  // tell the browser we're handling this event
  e.preventDefault();
  e.stopPropagation();

  // save the mouse position at mousedown
  startX=parseInt(e.clientX-offsetX);
  startY=parseInt(e.clientY-offsetY);

  // initially set the "itIsADrag" flag to false
  itIsADrag=false;

  // set the "isDown" flag to true
  isDown=true;
}

function handleMouseUp(e){
  // tell the browser we're handling this event
  e.preventDefault();
  e.stopPropagation();

  // report if this was a click or a drag
  if(itIsADrag){
    alert("You have been dragging");
  }else{
    alert("You've did a click");
  }

  // clean up by clearing the isDown flag
  isDown=false;
}

function handleMouseOut(e){
  // clean up by clearing the isDown flag
  isDown=false;
}

function handleMouseMove(e){
  // return if the mouse is not down
  if(!isDown){return;}

  // tell the browser we're handling this event
  e.preventDefault();
  e.stopPropagation();

  // get the current mouse position
  mouseX=parseInt(e.clientX-offsetX);
  mouseY=parseInt(e.clientY-offsetY);

  // do nothing if the mouse has moved less than 5 total pixels since mousedown
  if(!itIsADrag && Math.abs(mouseX-startX)+Math.abs(mouseY-startY)<5){return;}

  // Set the dragging flag to true
  // This flag prevents the Math.abs test above if we know we're dragging
  itIsADrag=true;
}
body{ background-color: ivory; }
#canvas{border:1px solid red;}

Click or drag in the canvas.

<canvas id="canvas" width=300 height=300></canvas>


text:
Q: I have tried to make a code that on getting input of 2 numbers from the user, generates a random number This is the code I have. The main.js file is currently empty I keep it there just for show. The styles.css is currently only making the font cursive, so again, I didn't mention it. I hope it can be fixed without major changes. I need it to generate a random number between the two input numbers from a user on the webpage. I expect it to give me a random number between for example 1 and 10. It should give me something like 3 or maybe 7. I ran the snippet and it didn't give me any clear error. It said that there is a code error in line 0 file "".

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="styles.css" rel="stylesheet">

    <input type="text" placeholder="First Value" id="firstNum">

    <input type="text" placeholder="Second Value" id="secondNum">

    <input type="text" placeholder="Generated Number" id="genNum">

    <button onclick="genRand();">Generate</button>

A: Here are some of the issues I have found in your code:

*

*genRand accepts two arguments, but it is called (in the button onclick) with zero arguments. You have to move the code that grabs the values of the two inputs inside the function.

*The line Math.floor(Math.random() * (num2 - num1 + 0) + num1) = numGen is invalid, because when you are doing a variable assignment, the variable has to be on the left side: i = 0 is valid, but 0 = i is not.

*I'm not sure what the purpose of the zero in (num2 - num1 + 0) is. Why did you put that there?
Below is a runnable snippet that remedies these issues. Please try to do it yourself first before looking at the code I have written.

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="styles.css" rel="stylesheet">

    <input type="text" placeholder="First Value" id="firstNum">

    <input type="text" placeholder="Second Value" id="secondNum">

    <input type="text" placeholder="Generated Number" id="genNum">

    <button onclick="genRand();">Generate</button>

A:

    Generate


text:
Q: connect with vpnclient.exe from scheduled task I have a set of scheduled tasks I've inherited, which require a vpn connection. Right now they only work when a user is logged in interactively.
When I launch the connection from a script (.bat/.ps1), the GUI login prompt displays (which it shouldn't) and requires the user to click 'Connect'. If the bat is run from a scheduled job, the job just hangs forever, presumably waiting on input to a form that isn't being displayed. Here is my launch command:
"%ProgramFiles%\Cisco Systems\VPN Client\vpnclient.exe" connect <profile> user <username> pwd <password>

The parameters for the connection have been tested interactively and work fine.
I've confirmed the command syntax with this page, and I have tried the cliauth parameter, but without luck. I've also confirmed that there is not an old password saved in the profile (.pcf) file.
So, how can I make the client connect without any interaction from a user?
Additional info:
the batch file we schedule looks like this:
CALL "F:\VPN\Start_VPN_Connection.bat"
CALL "F:\Scripts\FTPSync.bat"
CALL "F:\VPN\End_VPN_Connection.bat"

and the Start_VPN_Connection.bat is exactly as shown above, but with the security credentials.
The FTPSynch.bat runs a winscp synch, but the script only gets that far if we connect interactively.


text:
Q: Notice: Undefined index: Page in C:\xampp\htdocs\admin\achive\nur.php on line 16 First page showing:

Notice: Undefined index: Page in C:\xampp\htdocs\admin\achive\nur.php on line 16
Notice: Undefined index: Page in C:\xampp\htdocs\admin\achive\nur.php on line 17.....

<?php

if($_GET["txtKeyword"] != "")
    {
    $objConnect = mysql_connect("localhost","root","") or die(mysql_error());
    $objDB = mysql_select_db("gnnursury");
    // Search By Name or Email

    $strSQL = "select @rownum:=@rownum+1 rank,stid,roll,tmark,name from mark, (SELECT @rownum:=0) r WHERE (year LIKE '%".$_GET["txtKeyword"]."%')";
    $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
    $Num_Rows = mysql_num_rows($objQuery);

    $Per_Page = 6;   // Per Page

    $Page = $_GET["Page"];
    if(!$_GET["Page"])
    {
        $Page=1;
    }

    $Prev_Page = $Page-1;
    $Next_Page = $Page+1;

    $Page_Start = (($Per_Page*$Page)-$Per_Page);
    if($Num_Rows<=$Per_Page)
    {
        $Num_Pages =1;
    }
    else if(($Num_Rows % $Per_Page)==0)
    {
        $Num_Pages =($Num_Rows/$Per_Page) ;
    }
    else
    {
        $Num_Pages =($Num_Rows/$Per_Page)+1;
        $Num_Pages = (int)$Num_Pages;
    }

    $strSQL .="order  by tmark ASC LIMIT $Page_Start , $Per_Page";
    $objQuery  = mysql_query($strSQL);

    ?>

A: You are not passing a

GET parameter Page

and you are directly referencing it in line 17 $Page = $_GET["Page"];
Ideally for this easy fix will be
    if(!$_GET["Page"])
    {
        $Page=1;
    }
   else{
       $Page = $_GET["Page"];
   }

Hope it helps
Happy Coding !!!

A: You can use php function isset to check a argument "Page" is set.
if (isset($_GET['Page'])) {
 $Page = $_GET['Page'];
} else {
 $Page = 1
}

A: Update these lines
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
    $Page=1;
}

With
if(isset($_GET["Page"] && !empty($_GET['Page'])))
{
    $Page=$_GET["Page"];;
}else{
    $Page=1;
}

A: You did not pass any "Page" parameter. You can change the code to.
if(!isset($_GET["Page"]))
{
    $Page=1;
}


text:
Q: Wicket Strange behaviour of URL with ajax I have issue that have strange steps. I have ajax behave rendered on Head render stage
    final AbstractDefaultAjaxBehavior behave = new AbstractDefaultAjaxBehavior() {
       protected void respond(final AjaxRequestTarget target) {
             boolean undoEn = getRequest().getQueryParameters().getParameterValue("undoEn").toBoolean();
             if (undoEn) {
                mSaveButton.setEnabled(true);
                target.add(mSaveButton);
             }
        }
    };

    public String getCallbackName() {
        return "saveButtonVisibilityToggle";
    }

    @Override
    public void renderHead(IHeaderResponse response) {
        String script = getCallbackName() + " = function (e) {  Wicket.Ajax.ajax({\"u\": \"" + behave.getCallbackUrl() + " + &undoEn=\"+e+\"\" });}";
        response.render(OnDomReadyHeaderItem.forScript(script));
    }

Everything works well this behave called every time node changed in tinyMCE editor
     settings.addCustomSetting(" setup: function(editor) {" +
            "        editor.on('NodeChange', function(e) {" +
            " editor.save();" +
            getCallbackName() + "(editor.undoManager.hasUndo())" +
            "        });" +
            "    }");

But sometimes when i leave browser tab, change few tabs (chrome) then use other app for few minutes, and turn back to our tab, ajax url have accidently appeared in browser url.
http://localhost:8080/wicket/bookmarkable/com.tac.kulik.pages.SomePage?3-1.IBehaviorListener.0-contentPanel&entityId=2+++&undoEn=true

this is also quite strange that instead normap parameter pass it's ++++ signs added
by the way this sighns recognized as "2    " so for some reason '+' changed to whitespace
UPDATE 1
 Using  @svenmeier answer i've page start's infinite loop refreshing. with logs
org.apache.wicket.core.request.mapper.StalePageException: A request to
page '[Page class = x.x.x.CardPage, id = 25, render count = 1]' has been
 made with stale 'renderCount'. The page will be re-rendered.

and really for some reason behave link has renderCount 1, but form has 0.
the request from browser
    jquery-1.12.4-ver-1476216952000.js:10254 XHR finished loading: GET "http://localhost:8080/wicket/bookmarkable/com.tac.pages.ca…?4-0.IBehaviorListener.0-contentPanel&cardId=1&_=1476873175645&undoEn=true"

I ve add some set of JS to prevent cicling refreshing, But i'we still has Stale exception
     "if (editor.undoManager.hasUndo()) { " +
            "                  console.debug('Behave called ');" +
            behave.getCallbackScript() +
            "        }" +

this is my behave
   final AbstractDefaultAjaxBehavior behave = new AbstractDefaultAjaxBehavior() {
        protected void respond(final AjaxRequestTarget target) {
            log.info("Behave called");
            boolean undoEn = getRequest().getQueryParameters().getParameterValue("undoEn").toBoolean();
            if (undoEn) {
                mSaveButton.setEnabled(true);
                target.add(mSaveButton);
            }
        }
        //
        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            String undoEn = "return {'undoEn': editor.undoManager.hasUndo()};";
            attributes.getDynamicExtraParameters().add(undoEn);
        }
    };

And there is no difference, it could be behave without any realization, page behaviour the same((
    final AbstractDefaultAjaxBehavior behave = new AbstractDefaultAjaxBehavior() {
        @Override
        protected void respond(AjaxRequestTarget target) {

        }
    };

A: You should rework your behavior to use dynamic extra parameters instead.
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
{
    super.updateAjaxAttributes(attributes);

    String undoEn = "return {'undoEn': editor.undoManager.hasUndo()}";
    attributes.getDynamicExtraParameters().add(undoEn);
}

And:
settings.addCustomSetting(
        "setup: function(editor) {" +
        "  editor.on('NodeChange', function(e) {" +
        "    editor.save();" +
        "    " + getCallbackScript() + ";" +
        "  });" +
        "}");


text:
Q: Regression column in pandas Let's say I have a pandas dataframe df with some trivial indexing, e.g. 0,1,2,... and just one column 'Values' which contains numerical data. I would like to add a new column 'Trend' such that df['Trend'][n] is a coefficient of linear regression based on 5 consecutive values from the original values column: 'df['Values'][n-5] ... 'df['Values'][n-1]. The first 5 values are of course undefined, so let's say we put them to be NaN. Is there an easy way to do that?

A: Have you tried checking the index and doing different things, depending on where you are in the DataFrame?
for index, row in df.iterrows():
    if index<5:
        df['Trend'][index] = 'NaN'
    else:
        df['Trend'][index] = df['Values'][index-5]...


text:
Q: Parsing php requires This could be easy but I just can't seem to be able to figure it out for now. Lets assume we have two sets of .php files:
Set 1, that contains files named page1.php, page2.php, ... pageN.php.
Set 2, that contains files named module1, module2.php, ... moduleN.php.
Files from "Set 1" contain non-php code that should be treated as TEXT, and are using
<?php require("SomeFileFromSet2.php");?>

to include the respective contents from the files on Set 2. Files from set 1 are never php "required" by any other file.
Also, the files from "Set 2" can be required by one or more files from "Set 1", but can also "require" other files, from "Set 2" only. If SomeFileFromSet2.php is getting "required" from AnotherSet2File.php, then the first cannot also require the file it 's been required from (the latter), I mean there are not circular issues. (I could explain this (better?) using more sets of files, but tried to stick to two for simplicity). Files from Set 2 also contain non-php code to be treated as text again.
There is no other PHP code in none of the files of either set, except the
<?php require("SomeFileFromSet2.php");?>

calls.
What I want to achieve is to find a way and perform some kind of building process, so that when I run it for each file from "Set 1", I can parse php requires on it and on the modules that it includes, and get a new output file like "page1-with-modules.whatever" that would be php require "free" and contain all the code from the module files.
EDIT: Adding a basic sample so that I make more clear what I would like to achieve.
Contents of filefromset1.php (ie page1.php) could be:
<some no-php code #1>
<?php require("SomeFileFromSet2.php");?>
<some no-php code #2>

Contents of SomeFileFromSet2.php could be:
<some no-php code #3>
<?php require("SomeOTHERFileFromSet2.php");?>
<some no-php code #4>

And SomeOTHERFileFromSet2.php could have:
<some no-php code #5>

What I want to achieve is to parse all these requires in the files related to "filefromset1.php" and output a new "php-free" file containing:
<some no-php code #1>
<some no-php code #3>
<some no-php code #5>
<some no-php code #4>
<some no-php code #2>

A: I actually solved it and it was pretty simple! Since I am currently on windows 10
I changed powershell's encoding to utf-8 by running 'chcp65001', and then I run the php.exe command like this:
path-to\php.exe ./page1.php >> page1-with-modules.html

The contents of page1-with-modules.html was exactly what I wanted to achieve for "page1".

A: For what you are trying to do you cannot use include or require. Since you are wanting to generate new files you should be using fopen, fread, and fwrite.

A: If you want to do it in PHP, you can also parse the AST using PHP-Parser.
If I recall correctly, it is also used in some well-known frameworks too (like Laravel).


text:
Q: LibGDX - Application crashes when call TiledMapRenderer.render() @Override
public void render(float delta) {
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    camera.update();
    sprite.setProjectionMatrix(camera.combined);

    mLevel.getTiledMapRenderer().getProjectionMatrix().set(camera.combined);
    Vector3 tmp = new Vector3();
    tmp.set(0, 0, 0);
    camera.unproject(tmp);
    mLevel.getTiledMapRenderer().render(tmp.x, tmp.y, camera.viewportWidth, camera.viewportHeight);

    sprite.begin();
    ...
    sprite.end();
}

Here is what I get when launching the desktop version :
Exception in thread "LWJGL Application" java.lang.IllegalArgumentException: Number of remaining buffer elements is 0, must be at least 1. Because at most 1 elements can be returned, a buffer with at least 1 elements is required, regardless of actual returned element count
    at org.lwjgl.BufferChecks.throwBufferSizeException(BufferChecks.java:162)
    at org.lwjgl.BufferChecks.checkBufferSize(BufferChecks.java:189)
    at org.lwjgl.BufferChecks.checkBuffer(BufferChecks.java:230)
    at org.lwjgl.opengl.GL15.glBufferData(GL15.java:141)
    at com.badlogic.gdx.backends.lwjgl.LwjglGL20.glBufferData(LwjglGL20.java:93)
    at com.badlogic.gdx.graphics.glutils.VertexBufferObject.bind(VertexBufferObject.java:208)
    at com.badlogic.gdx.graphics.Mesh.bind(Mesh.java:268)
    at com.badlogic.gdx.graphics.g2d.SpriteCache.begin(SpriteCache.java:868)
    at com.badlogic.gdx.graphics.g2d.tiled.TileMapRenderer.render(TileMapRenderer.java:336)
    at com.badlogic.gdx.graphics.g2d.tiled.TileMapRenderer.render(TileMapRenderer.java:286)
    at com.crunsh.libgdx.screens.GameScreen.render(GameScreen.java:102)
    at com.badlogic.gdx.Game.render(Game.java:46)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:202)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:131)

I've tried both this tuto and this one, and I get the same error at the same line mLevel.getTiledMapRenderer().render(tmp.x, tmp.y, camera.viewportWidth, camera.viewportHeight);.
EDIT : I just noticed that the data of my .tmx file was automatically encoded by Tiled Map Editor, so I just desactivated it, but still get the same error.
If I copy/paste this project (I mean the whole project, not only the render() method) it works but when I try to load my own map in my own project it just crashes ...
So after that I decided to simplify my render() method by just doing like the link I gave before and by using the TiledMapHelper class the author provide, so there is my render() method now:
mHelper.getCamera().update();
mHelper.render();

Still crashiiiiiiiiiiiiiingg.....
If someone can please provide some help it would be greatly appreciated because atm i'm really going mad !

A: I found what caused the error :

*

*all the tiles in my "packfile" had -1 as their index

*all the tiles in my "packfile" had the same name as their original tile file name, but not the same name as the .png file containing all the tiles packed.
Currently my screen is black so I think no tile is draw (probably because I gave random indexes to the tiles in the packfile - fixed, see the end of the post) but no exceptions are thrown and that's the point.
Those mistakes are due to the program I used to pack the tiles that was supposed to make me win time lol. So I will try different options or use something else.
If you want to know the program was "TexturePacker GUI" v3.1.0.
If you know what options I should/not use to avoid errors please let me know.
EDIT : Found a usefull and working tool for packing tiles, here it is : http://freigabe.philweb.de/bubblr/texturepacker_edited.jar
(link is dead ; use this one instead. or another packing tool)
To use it open cmd and go to the directory where your downloaded the .jar file and then :
//You should create, in the same directory of the .jar file, two additionnal folders
//Call the first folder 'input' and put in all your tiles (rename them "level_1.png", "level_..")
//Call the 2nd folder 'output' and leave it empty
//Then just type in the command prompt : java -jar nameOfDownloadedJarFile.jar input output level
//Then rename the "input1.png" into "level.png", and "level.pack" into "level packfile"
//Open "level packfile" with notepad and change "input1.png" into "level.png"
//Then draw your map using "level.png" in TiledMapEditor
//Then just follow dpk' tutorial for rendering the map and it should work

Here is dpk's tutorial I mentioned, just follow from here : http://dpk.net/2011/05/01/libgdx-box2d-tiled-maps-full-working-example-part-1/#p4
If application doesn't crashes but the screen is black, just increase camera's viewport's width & height.
Happy mapping :) !


text:
Q: How to attack "if true, prove it; if not true, give a counterexample" question? I am taking a basic analysis course. This is a general question that I often encounter in weekly homework. How should we start to attack this type of question: if the statement is true, prove it; if not true, give a counterexample? Yesterday evening I spent four hours looking for a counterexample, and finally figured that the statement was indeed true. I tried so hard to find a counterexample because I was not able to prove the statement at first. Are there any steps to follow in terms of this type of questions? In particular, sometimes a statement does not look like it is true. In this case, how can I quickly figure out whether I should try counterexamples or keep the efforts on proving the statement is true? The core problem is that this type of question is very time-consuming according to my homework experience. I desperately doubt I could figure out a correct answer during a timed exam next week.

A: To the solutions elsewhere, I'd add some rules of thumb in the nature of pursuing a math degree on the under graduate level.
I found that when given such a problem, a counter example was usually apparent within a few minutes contemplation. If you couldn't find one by then, you probably had something you needed to prove.
Review your earlier work. Such questions are usually just a mild extension of something previously addressed in examples or homework.
Perhaps the prof went easy on us, so such problems seemed among the easiest. I think it more likely I had exceptionally good study partners and we were careful to share info instead of copy for the sake of having homework to turn in.
I recommend making it a group activity and make sure you do your homework. Seems like you are doing the latter very well, spending four hours on a problem on your own. Shows a lot of dedication. But I stress that you do not have to struggle alone.

A: I disagree with the approach of proving by contradiction as a start.
In most cases, and which ones are the exception simply requires experience, you should just start by trying to prove the statement as if it were true. There's no point in starting with a proof by contradiction. Just try to prove it.1
If you are careful, and again experience is needed here, then your derivation will either be successful, or you will get stuck.
Now ask yourself. Why did you get stuck? Maybe you need to assume that $x+1=y$, or maybe you need to assume that the function is continuous at $0$. Who knows? It depends on the problem and on your attempt to prove it. The next step, then, is to try and engineer a counterexample using the failure of this assumption. If you need to assume $x+1=y$ in order for it to work, take an example where $x=0$ and $y=3$. And so on. If that works, well done, you found a counterexample, and you even got a free bonus information: you found a condition that will let you complete the proof.
Of course, it might be that your attempt at a proof was bad. Maybe you tried to do something wrong. Who knows. But if your attempted counterexample failed, that gives you new information, it tells you that the information you thought was crucial for the proof is in fact not crucial for the proof.
So you have to start over again, and try a different method and a different approach. And repeat this until the result is satisfactory.
Unfortunately, it will not be the case that this will always work. Sometimes you are missing a crucial piece of knowledge that would simplify the work. Or sometimes you just made a series of mistakes in your proof, and you thought you proved it, whereas you haven't actually proved the right statement. This is why it is a good idea to work with a friend, where you can check each other and discuss these kind of things.
One last thing, which might be worth discussing, is how to approach a proof to begin with. Well, if you want to prove that things fall down to the earth, you start by letting a few things fall down and see how that works out. Similarly in mathematics, experimenting is not a bad idea. If you need to prove some equation holds, try plugging in some small numbers, $0$ and $1$ are perhaps $\sqrt2$, if the equation makes it convenient. If you have to prove something about functions, try a constant function, or $e^x$, or whatever.
Toy examples are very important towards understanding why something is true, and if you get some general idea as to why something might be true, it will also give you an idea as to how it should be proved.

*

*Of course, if the natural angle of attack is by contradiction, there's no point in not doing that either.

A: *

*Ask yourself what must necessarily be true about the counterexample.

*If those conditions seem at odds with each other, try to prove they are inconsistent. Maybe it's clear that only trivial examples exist. If they seem compatible, try to find some object that satisfies them.

*If you find an object, see if it's a counterexample. If it's not, then figure out what condition it's missing to be a true counterexample. Add that to your list of conditions, and repeat.

A: One strategy is to first try to prove by contradiction that the statement is true. Such an effort will identify necessary conditions for a counterexample. If through such an analysis you realise you can also give sufficient conditions for a counterexample, and you can work out how to satisfy them, you'll have a counterexample. With any luck, in the event the statement is true you'll find a valid proof soon enough. (Once you do, it's worth checking whether it can be rewritten to not use contradiction; students new to proof-writing sometimes unnecessarily add a contradiction "wrapper" around a direct proof.)
Note that if a counterexample exists in a textbook exercise, there will be a simple one that slightly complicates a situation that illustrates a weaker true claim. For example, if I asked you to prove or refute-by-counterexample the claim that all finite groups are Abelian, the hope is you'd quickly find this counterexample. It's slightly more complicated, though only slightly, than the case of a finite group with a single generator, which of course would be Abelian. So the hope is you'd think, "let's try to make a group with two generators; that might do it".

A: All of the other answers are great. I would second everything they've said, plus the following:

*

*For every "if then" statement in a Theorem, find an example that aligns with the proof. This should be an example that isn't super easy, but illustrates what's going on in the proof.

*For the theorems listed above, find several examples that match the conclusion, but don't match the criteria in the hypothesis.

*For the same Theorem, find several examples that don't match the criteria, and don't find the conclusion.

To work the problems well, one must have a strong understanding of the theorems complete with examples and counter-examples. Doing this has helped me find counterexamples/proofs faster by finding when the theorems apply/don't apply.

A: As @lhf comments, this is exactly what you encounter doing mathematical research.
You suspect something is true. You try to prove it. If you keep running into dead ends you change your guess and suspect it's false. Then you look for counterexamples. If you keep running into dead ends you change your guess again - and so on until you understand the situation, or decide to work on another problem.
That strategy is good for this kind of homework question too. You learn a lot in the back and forth. Since it's homework and not a research question, you will probably reach the correct solution in a reasonable length of time.
On an exam this kind of question is reasonable only if the answer is clear to someone who has mastered the material - you know a theorem that applies, or you recognize that some important hypothesis is missing.

A: It is a good habit to try to prove and to try to get a counterexample simultaneously. That type of mentality is necessary to be a successful mathematician. You also need to have a feeling about when to leave a problem; you will get that from solving lots of problems. Follow the book How to Solve It by Pólya for more detailed explanation.