Einstein gravity versus Newton's gravity

Question: What's the basic difference between the gravity as seen by Einstein, and that by Newton?
Comment: http://www.youtube.com/watch?v=DdC0QN6f3G4
Comment: Related: http://physics.stackexchange.com/q/37926/2451 and links therein.
Comment: I'm glad you left cosmology out of your tags, because I sure don't have the rep to burn on downvotes.  The citation in my comment on Michael Brown's answer will show you how, re Newtonian physics vs. GR, there's--literally--nothing left to compare.
Answer: Often people get confused by the additional complication that Newtonian and Einsteinian gravity are often discussed in different mathematical formalisms. This can tend to obscure the physical differences. If you are game for the mathematics then Misner, Thorne and Wheeler (check it out of a library or get it second hand unless you are really serious about this business) has a wonderful chapter which puts both theories side by side in the same language (differential geometry). The key difference is that Newtonian gravity has a privileged separation of spacetime into space and time, whereas Einsteinian gravity just has spacetime.

Edit: to be absolutely clear, Newtonian gravity can be written as spacetime curvature! This is counter to the common statements about the novel thing in GR. The key difference is that Newtonian gravity has extra absolute structures that GR does not have: absolute time and space, a preferred separation of spacetime into time and spatial parts, absolute simultaneity, and a curved connection that is not the special one derived from a spacetime metric (Christoffel).
In mathematical form:
$$ \begin{array}{ll}
R_{00} = 4\pi\rho;\text{all others vanish},& \ \text{Newtonian} \\
R_{\mu\nu}-\frac{1}{2} g_{\mu\nu} R = 8\pi G T_{\mu\nu}, & \ \text{Einsteinian}
\end{array}$$
with a few other relations I've not written (see MTW chapter 12 for details).
A consequence of the formalism is that the Newtonian equation is a constraint equation - it does not describe a propagating degree of freedom. No gravitational waves, gravitons etc. No speed of light limit for gravity. All matter has an instantaneous gravitational effect on all other matter. This is different in GR since the field equation is a wave equation which describes the propagation of gravitational disturbances from one point to another at the speed of light.
What GR has that Newton does not is a spacetime metric of Lorentzian signature. This metric has a privileged role in that all other structures (connections, curvatures, etc.) are derived from it. There is essentially nothing else to Einstein gravity. That is why it is so elegant in the geometrical formalism. This metric actually comes from special relativity. But the metric was a fixed structure in SR, almost similar to the absolute time and space of Newton (don't tell anyone I said this). The new thing in general relativity is that Einstein lets the metric "flap around" so to speak - to change from place to place and time to time in response to what matter is doing.
Comment: +1 For being right about a subtle concept, though I was tempted to -1 for the sole reason that you recommended MTW to a 16-year-old ;)
Comment: @AlfredCentauri I'm not sure that's what the OP meant by "see." Anyway, I really doubt Newton saw gravity in this way since the concepts of curved geometries weren't around at the time. I'm not an expert on the history of Einstein's thought process, and even less so on Newton's. But I can say a thing or two about what their theories mean *physically*, and I think it's relevant that what is commonly stated to be the difference between them really *isn't*, even if maybe Einstein saw it that way (I doubt he did for long if ever he did - he obviously understood his own theory pretty well!).
Comment: @ChrisWhite Lol, I didn't realize she was 16. Well, some people are precocious. :) And if she is 16 and asking about this then maybe she can't understand MTW yet, but she's well on her way. Samama Fahim, if you're reading this comment and didn't understand my answer don't be discouraged. It takes most people years to understand this stuff. You're asking good questions. And if you did understand it... wow. Just wow! :)
Comment: Re your edit:  Yes, but isn't it the case that the OP asks specifically of the difference *as seen by* Einstein and Newton?  Yes, Newton's theory can be written in geometric language (and I don't mean to take away from this illuminating exercise), but is it the case that Newton "saw" gravity this way?
Comment: @MichaelBrown -Although, at my own level of ignorance, I'd much prefer having a single theory (either GR or ECT) to deal with (in my attempts to get a better handle on reality), I'm surprised that you'd feel Newton to have been uninvolved in "curved geometries":  Guth's discussions of Newtonian physics, in his book "The Inflationary Universe", assume spherical configurations for a universe floating in Newton's absolute space, and point out existential deficiencies in his cosmology that can be grasped thru the simplest algebra (cf. p.296 in his 1997 ed.).  GR/ECT comparisons might be preferred.
Answer:
What's the basic difference between the gravity as seen by Einstein,
  and that by Newton?

Newtonian gravity is an instantaneous force, i.e., action at a distance, coupled to gravitational mass (conceptually different from inertial mass).
General Relativity is a local theory (no action at a distance).  Einsteinian gravity is the curvature of spacetime and the coupling is between mass-energy and geometry; "matter tells spacetime how to curve, spacetime tells matter how to move".
Answer: In at least one basic respect, both general relativity (gravity according to Einstein) and Newtonian gravity are similar; both describe gravity as a gravitational field on a space.  In other words, they are both classical field theories.
In the case of general relativity, that field is a pseudo-Riemannian metric $g_{\mu\nu}$ on the space, and the space is a 4-dimensional topological space called spacetime, while in the case of Newtonian gravity, the field is a vector field (if you are describing it by the gravitational acceleration $\mathbf g$) or a scalar field (if you are describing it by the gravitational potential $\Phi$) on three-dimensional Euclidean space.
In the case of general relativity, the gravitational field tells you the geometry of spacetime, and it's the curvature of this geometry that particles "ineract with" in when they move around.  The gravitational field is determined by the energy-momentum content of spacetime through Einstein's Equations.
In the case of Newtonian gravity, the gravitational field tells you the acceleration that a particle would feel at any given point in space, but in contrast to general relativity, the geometry of the space itself is not altered by the sources of gravity (masses in this case).
In a highly simplified nutshell:
General relativity describes gravity as spacetime curvature while Newtonian gravity describes it as something living on top of a static space with no curvature.
Comment: Have you read chapter 12 of Misner, Thorne and Wheeler? You'd probably like it. Newtonian gravity can be put in the same formalism as general relativity. The difference between the two is rather interesting and non-obvious once it is a fair contest with them side by side in the same language. :)
Answer: One more aspect. Roughly speaking, in General Relativity "energy" is attracted $(E/c^2)$, while in  Newtonian gravity - only mass. And there is no time dilation in  Newtonian gravity.
Answer: In Newtonian Gravity, space is like 3-dimensional graph paper, and objects are moving through space at an absolute time.  The objects path curves because a force is present. Without that force (gravity) objects will continue in a straight line.
Where Newton's idea of Gravity is 3D space with Time a constant, Einstein conceived of 4D space -- called space-time. In this structure, time is not absolute but a dimension or variable in the structure such that (x,y,z,t) exist for a given event.  Objects moving through space-time curve not because they are "pulled" by the force of gravity, but because they are taking the shortest distance through curved space-time.
Amazingly, for Einstein, you can have curved space-time without matter so an object might start moving in curves even if nothing is present.
Answer: Newton saw the universe, as a 17th century man would, as having a fixed time speed everywhere and lengths that appeared the same to all observers.  Within this model, he created a really excellent set of rules for motion under the influence of gravity.
Einstein allowed for the speed of time and length measurements to vary based on the observer's reference frame.  The resulting complications can be addressed using 19th century mathematics (Einstein famously said to a mathematician friend, "Grossman, you must help me or I will go mad!").  However, I think people go too far when they turn around and "see" the mathematics as defining a sort of higher reality. I think it is just a model; a very wonderful model that works, but still just a model to address the differences in viewpoints of time and length measurements.
If one takes a more prosaic view, and simply says "Newton was pretty much right other than adjusting for different times speeds and measured lengths," then one can develop a parallel model for motion under the influence of gravity, that works every bit as well at matching observations including gravitational lensing, the Shapiro time delay, planetary precession, satellite precession, relativistic rocket travel, photon sphere, gravitational waves, and the dynamics of falling into a non-roating black holes. The key is to retain all of Newton's laws, include conservation of energy, but allow the local traveler to experience motion according to his reference frame (he feels he is closer to the gravitational source, and that path lengths are shorter, and that the distant viewer has a clock that runs slower due to velocity and faster due to less gravity). For example, remove Mercury and put a spaceship in its place with a physicist and perfect measuring equipment - at no point in the orbit would he ever measure an error in Newton's laws nor see a day's motion that was inconsistent with Newton's laws, but sure enough, after 1 Mercury year, he'd find that he ended up with a precessed perihelion.
Conversely, there are things that the geometric curved spacetime models struggle to explain.  For example, as people note, it is vital that there not be an absolute maximum time speed (which would imply an absolute zero velocity).  Yet I can populate the universe with clocks created at the big bang and set in a no-dipole-in-the-cosmic-microwave-background-radiation reference frame, allowing them to separate with universal expansion.  It is impossible to create a clock in any other reference frame that could be beside one of my clocks and record more time having passed since creation.  Hence it appears that I have defined a maximum time rate and an absolute zero velocity.  (In fact, it is necessary for us to define an absolute zero velocity in order to define an age of the universe.)
There are other problems with the geometric mathematical solution, in that the complexity leads to false conclusions or the reliance on adages that may not be true in all cases.  For example, one response says that "Objects moving through space-time curve not because they are "pulled" by the force of gravity, but because they are taking the shortest distance through curved space-time."  But consider the path of two clocks starting at a point on the moon and returning to the origin.  One clock is thrown vertically upward, while the other is thrown very fast to circle the whole moon at a very low altitude and return.  The clock thrown vertically will record more time than a clock that sits at the origin, while the clock that flew all around the moon will record less time than the clock at the origin.  The vertically thrown clock followed a "shorter distance" through spacetime than the still clock, but the low angle throw followed a longer distance through space time than the still clock, yet both paths are geodesics.
And there are more problems, like the conclusion that the astronaut twin ages less because she accelerated and later reversed direction while her brother stayed still.  But have the astronaut accelerate to leave Earth on January 1 at noon, and have her stay in position fixed relative to the stars, and her brother will come around next January 1st to find that his sister has aged more than him by a fraction of a second (this is true even if the circling the sun twin is on board a spaceship with no gravity rather than on the planet Earth).
That is - Newton is not so bad.  We can adjust Newton to account for changing time speeds and lengths, and do a fine job at dealing with motion through the universe under the impact of gravity using his laws.  The conventional curved space model is useful, but it is not proven to have any more "truth" than Newton's model with adjustments, and it can lead to incorrect conclusions.
To anyone who feels angry at this response, please don't down vote unless you can address the three specifics I mention - an apparent universal maximum time speed, the tossed clocks whose paths can be either shorter or longer distances through spacetime than a still clock, and the twin paradox problem's resolution having nothing to do with who accelerated or who changed direction. And if you can explain those things, I will be very pleased to learn from you.
Comment: None of your "specifics" are particularly challenging. They seem to be nothing more than a few simple misunderstandings of how GR is supposed to work. You should ask those as individual questions of your own instead of incorrectly answering other people's questions


Perfectly centered break of a perfectly aligned pool ball rack

Question: Imagine the beginning of a game of pool, you have 16 balls, 15 of them in a triangle <| and 1 of them being the cue ball off to the left of that triangle. Imagine that the rack (the 15 balls in a triangle) has every ball equally spaced apart and all balls touching all other appropriate balls. All balls are perfectly round. Now, imagine that the cue ball was hit along a friction less surface at the center axis for this triangle O-------<| and hits the far left ball of the rack dead center on this axis. How would the  rack react? I would imagine this would be an extension of newtons cradle and only the 5 balls on the far end would be the candidates to move at all. But in what way would they move? Which ball, for instance, would move the furthest? Thanks
Comment: Congrats- you've just dived into chaos theory.
Comment: I am looking for a qualitative answer. Which balls would move, would those balls mover further or a shorter distance than another ball. I am writing a pool simulation program and I'm curious what this kind of break would look like.
Comment: thanks for the advice, I'll post my question at Math SE and we'll see
Edit: I see that it's already been posted there for me, thanks!
Answer: Note: This question was cross posted by the OP on the Mathematics Stack Exchange.  Here is a copy of my answer for it there.

This is it.   The perfectly centered billiards break.   Behold.

Setup
This break was computed in Mathematica using a numerical differential equations model.  Here are a few details of the model:

All balls are assumed to be perfectly elastic and almost perfectly rigid.
Each ball has a mass of 1 unit and a radius of 1 unit.
The cue ball has a initial speed of 10 units/sec.
The force between two balls is given by the formula
$$
F \;=\; \begin{cases}0 & \text{if }d \geq 2, \\ 10^{11}(2-d)^{3/2} & \text{if }d<2,\end{cases}
$$
where $d$ is the distance between the centers of the balls.  Note that the balls overlap if and only if $d < 2$.  The power of $3/2$ was suggested by Yoav Kallus on Math Overflow, because it follows Hertz's theory of non-adhesive elastic contact.

The initial speed of the cue ball is immaterial -- slowing down the cue ball is the same as slowing down time. The force constant $10^{11}$ has no real effect as long as it's large enough, although it does change the speed at which the initial collision takes place.
The Collision
For this model, the entire collision takes place in the first 0.2 milliseconds, and none of the balls overlap by more than 0.025% of their radius during the collision.  (These figures are model dependent -- real billiard balls may collide faster or slower than this.)
The following animation shows the forces between the balls during the collision, with the force proportional to the area of each yellow circle.  Note that the balls themselves hardly move at all during the collision, although they do accelerate quite a bit.

The Trajectories
The following picture shows the trajectories of the billiard balls after the collision.

After the collision, some of the balls are travelling considerably faster than others.  The following table shows the magnitude and direction of the velocity of each ball, where $0^\circ$ indicates straight up.
$$
\begin{array}{|c|c|c|c|c|c|c|c|c|c|c|}
\hline
\text{ball} & \text{cue} & 1 & 2,3 & 4,6 & 5 & 7,10 & 8,9 & 11,15 & 12,14 & 13 \\
\hline
\text{angle} & 0^\circ & 0^\circ & 40.1^\circ & 43.9^\circ & 0^\circ & 82.1^\circ & 161.8^\circ & 150^\circ & 178.2^\circ & 180^\circ \\
\hline
\text{speed} & 1.79 & 1.20 & 1.57 & 1.42 & 0.12 & 1.31 & 0.25 & 5.60 & 2.57 & 2.63 \\
\hline
\end{array}
$$
For comparison, remember that the initial speed of the cue ball was 10 units/sec.  Thus, balls 11 and 15 (the back corner balls) shoot out at more than half the speed of the original cue ball, whereas ball 5 slowly rolls upwards at less than 2% of the speed of the original cue ball.
By the way, if you add up the sum of the squares of the speeds of the balls, you get 100, since kinetic energy is conserved.
Linear and Quadratic Responses
The results of this model are dependent on the power of $3/2$ in the force law -- other force laws give other breaks.  For example, we could try making the force a linear function of the overlap distance (in analogy with springs and Hooke's law), or we could try making the force proportional to the  square of the overlap distance.  The results are noticeably different

Stiff Response
Glenn the Udderboat points out that "stiff" balls might be best approximated by a force response involving a higher power of the distance (although this isn't the usual definition of "stiffness").  Unfortunately, the calculation time in Mathematica becomes longer when the power is increased, presumably because it needs to use a smaller time step to be sufficiently accurate.
Here is a simulation involving a reasonably "stiff" force law
$$
F \;=\; \begin{cases}0 & \text{if }d \geq 2, \\ 10^{54}(2-d)^{10} & \text{if }d<2.\end{cases}
$$

As you can see, the result is very similar to my initial answer on Math Stack Exchange.  This seems like good evidence that the behavior discussed in my initial answer is indeed the limiting behavior in the case where this notion of "stiffness" goes to infinity.
As you might expect, most of the energy in this case is transferred very quickly at the beginning of the collision.  Almost all of the energy has moves to the back corner balls in the first 0.02 milliseconds.  Here is an animation of the forces:

After that, the corner balls and the cue ball shoot out, and the remaining balls continue to collide gently for the next millisecond or so.
While the simplicity of this behavior is appealing, I would guess that "real" billard balls do not have such a force response.  Of the models listed here, the intial Hertz-based model is probably the most accurate.  Qualitatively, it certainly seems the closest to an "actual" break.
Note: I have now posted the Mathematica code on my web page.
Comment: +1 Actually, the OP cross-posted on [_MathOverflow_](http://mathoverflow.net/q/156263/36526). When it comes to the cross-post on _Math SE_, well... I'm guilty. :) I absolutely love your answer.
Comment: As a novice programmer who wanted to check that his pool break simulation that he'd programmed had the correct end result, I have been absolutely blown away by this answer. My simulation currently represents the incredibly stiff result, though I feel spurred on now to attempt to incorporate the maths of the linear answer into my design. I'm going to be spending the next week just trying to wrap my head around the maths that went into this. Thanks @JimBelk for an incredibly extensive answer!
Comment: @GlenTheUdderboat Thanks for copying my answer here.  I have copied it to MathOverflow as well.
Answer: If you are actually writing a sim, then you just need to analyze each ball's position and applied force vectors (similar to Newton's Cradle).  Since you stated you're ignoring friction, the balls won't spin or slow down, so you can do it as a 2-dimensional model of discs.  All discs are incompressible and have 100% elasticity (i.e. no loss of kinetic energy on collision).  Then "all you have to do" is set up a time cycle, and on each click of the clock, check for collisions, calculate the impact vectors, use momentum conservation to calculate the rebound angles and speeds, and you're done!
Comment: Using your method I will simulate different results based upon the the order that I process the collisions. As far as I know there is not a method for calculating multiple collisions simultaneously, therefore they are broken down into pairs. For instance, if we number the balls in the columns with the left most ball <| being one, then the next column at the top is 2, then that same column next one down is 3, etc. If ball one hits ball 2 first (order processed) then ball 2 gets most of the momentum. Ball 3 gets almost nothing. However, if ball 3 was processed first ball 2 would get nothing.


Hit a deer and piece to headlight snapped

Question: Okay so I hit a deer. There's actually not too much damage except for some dents and this plastic part that snapped. The headlight moves Around now so I know I have to replace it but I don't know what part it is. It's a Mitsubishi Mirage 2017. The deer ran into my passenger side.
Answer: You will almost certainly find that that broken piece is an integral molded part of the headlamp body.
Which sadly means you will need to purchase the complete unit.
You might attempt a repair but it will need to be strong.
Comment: I've had some success fixing plastic parts using fiberglass repair tape and epoxy, the fiberglass tape bridges gaps and adds rigidity once the epoxy cures. However, in this case even I'd just replace the part, there's just too much damage. Plus you it may no longer be watertight.
Comment: Loctite 406 seems to be a good candidate
Comment: @GdD correct, just gluing the broken piece never works.
Comment: True @Moab, there's not a glue in existence which can hold snapped plastic together edge to edge with any strength. There are heat welding techniques, not something I've ever tried


matching a border of one polygon to another

Question: I have a polygon (A) that I drew the eastern border of in QGIS. I have another polygon(B) whose western border I want to nest against the eastern border of polygon a so they are touching but not overlapping each other. Is there away I can do this other than reshaping polygon B's western border by hand as I had to do with polygon A's eastern border?
Answer: Go Settings -> Snapping options and enable "Avoid intersection" For your layer. Then just overlap borders of the second polygon over the first polygon and the second polygon will be cropped. See pictures.


Solving simple diophantine equation with modulos

Question: I need to solve this diophantine equation using a positive integer $x$: $$x^2 + 42x + 21 \equiv 0 \mod 105$$
I think it will be easier if I could use the prime factors of $105$ to get a system of congruences and then use the Chinese Remainder Theorem. Can I do that? If so, why exactly?
If it's possible, then I would get the factors $3$, $5$ and $7$. But I'm getting stuck in this one: $$x^2 + 42x + 21 \equiv 0 \mod 5 $$
Can anyone show me how to do it properly?
Answer: Hint:
$x^2+42x+21\equiv x^2+2x+1\pmod 5$
and
$x^2+42x+21\equiv x^2\pmod{3,7}$


Coderush - Shortcut for Generic ICollection

Question: Is there a shortcut in Coderush to generate code for an ICollection?
Answer: CodeRush can certainly help with all sorts of code generation.
If you could be a little more specific with your question, I will refine this answer and show you what you need.
Which version of Studio (and hence .Net) are you using?
What sort of code ywould you like to see generated?
I ask because ICollection implies an interface but not what processes should back it. there are many ways in which you might choose to do this.
CodeRush cannot guess but if you have some more clues I might be able to help


CA-signed certificate for localhost / production app

Question: I have developed an application that consists of various parts, each part communicating either via http and / or gRPC to one another.
All communication has been switched over to TLS using a self-signed cert (CN=localhost) for development.
However, this application will go into production and it will ONLY EVER run on localhost (Windows machines).
Self-signed certificates are not really an option then, so I'd request an "official" certificate (signed with the org's CA or subordinate CA) which I could then install in the operating sys's certificate store.
Now my question: Is this something that can be done? I know it is awkward to use an officially CA-signed cert for localhost, but that's just what I need. Or is there something else I could do instead?
Comment: *Stop. Using. Loopback. Sockets. For. IPC!* They are far and away the _least_ secure common form of IPC, they aren't even very performant, they're way more hassle to configure securely, and these days they aren't even meaningfully more portable than local (a.k.a. Unix) domain sockets as those work on Windows as well as *nix. Or if you're Windows-only, you can use named pipes (far more powerful than the *nix feature of the same name). Network sockets should only be used when there's nothing else that will work, almost never true for connecting to "localhost" (which might not even be loopback!)
Comment: Thanks, I get it ;-) This project is in preparation of another one and it is therefore very over-engineered to have an experimental playground (my v1 is just a console app). In fact, the application can switch over to using IPC (AF_UNIX). In the future the "server" part might get put somewhere else (linux container). However, none of the machines will ever get proper internal DNS names, ip addresses only. Named pipes are an additional option that I might implement for the Windows-only environment.
Answer: One can only get a publicly signed certificate for a domain which one controls. The domain localhost is not controlled by somebody, it is on every computer, i.e. controlled by everybody. Therefore it is not possible to get a publicly signed certificate for it.

Self-signed certificates are not really an option

Why? The local browser will ask once if the certificate should be accepted and then remember the choice.

Or is there something else I could do instead?

One hack in the past was to get a domain and get a certificate for it, then map the DNS for this domain to 127.0.0.1 (localhost). But this way you rely on internet connectivity to get the DNS mapping or the domain must be resolved by some internal DNS. And you'll face the problem that you need to regularly install an updated certificate since it will expire after a while. And the certificate might also be revoked because it might be considered compromised - see When are public applications embedding certificates pointing to 127.0.0.1 OK?. Thus, bad idea.
Another option is to not get a publicly issued certificate but to get a company issued one, in case there is already a PKI established in the specific production environment. But also don't use localhost as name here, but the actual DNS name of the machine in this specific environment.
Comment: OK thank you, this confirms my research. I will stick with self-signed certificates then since no one can guarantee any DNS resolving infrastructure whereever the actual deployment will happen (we have some installations w/o any network connections due to security reasons). However, as mentioned above, it is mainly an experimental app testing out gRPC on http/2 vs IPC performance. Thank you for the input.


Select a table's current identity from another database

Question: How can I get the current identity of a table using OPENQUERY in SQL Server?
How to select the current identity on the table from another database?
Answer: If the Database is on the same Instance, then you don't need to use OPENQUERY. But even if the Database is on another Instance, then you still shouldn't need OPENQUERY (as @AndriyM reminded me of in a comment on this Answer): since the query uses JOINs to system Views instead of using the built-in meta-data functions (e.g. OBJECT_ID), fully qualifying the object names with the 4-part name (beginning with the Linked Server name) should work just fine. And in fact, using the 4-part names is probably better anyway as it would allow you to parameterize the query, whereas OPENQUERY requires a string literal for the Query (which then requires Dynamic SQL to generate the query that calls OPENQUERY).
Hence, in either case, the following query should work:
SELECT ISNULL(sic.last_value, 0) AS [LastValueReserved],
       ISNULL(sic.last_value, 0) + sic.increment_value AS [NextValue]
FROM   [ [ {linked_server_name}. ] {database_name}. ][sys].[identity_columns] sic
INNER JOIN [ [ {linked_server_name}. ] {database_name}. ][sys].[objects] so
        ON so.[object_id] = sic.[object_id]
INNER JOIN [ [ {linked_server_name}. ] {database_name}. ][sys].[schemas] ss
        ON ss.[schema_id] = so.[schema_id]
WHERE  ss.[name] = N'{schema_name}'
AND    so.[name] = N'{table_name}';

Of course, if you are getting this info for the current database, then you don't need to fully qualify those system view names with {database_name}..
Please note:

I labeled the first field with the qualifier of "Reserved" because there are reasons that Identity values can be reserved but never used (i.e. not found in the table). Examples being: if an INSERT statement fails, or if the INSERT is done within a Transaction that gets rolled-back, or if the server restarts (in which case you sometimes see a jump of approximately 1000; this behavior has been asked and documented on here and other sites).
ISNULL(sic.last_value, 0) is used because prior to the first INSERT operation, the value in the last_value column is NULL.


Route certain domains through different interfaces

Question: Is there a simple way to route certain domains (i.e. debian.org) through a different network interface. Here is the situation.  I have a server with two interfaces eth0 going to the local network and tun0 going to an openvpn network.  I would like to have all requests going to *.debian.org go out tun0 and the rest go through eth0.  Is there a simple way to do this using names as opposed to ip addresses?
Answer: Not so much. The routing system is definitely IP based and names have no meaning. By the time traffic gets to the level of routing it has been turned from a name into a number. Any system that claims to do this is just dereferencing domain names to their IP components.
Comment: That sucks... :).  Any pointers on what to look next?
Comment: @rmarimon Pretty much what you already know. Set up static routes to the debian subnets you want tunneled.
Answer: What kind of traffic are you routing?
If it's HTTP, you could configure vhosts and proxy *.debian.org to IP addresses or domain names that resolve to IP's on the tun0 subnet.  You can use modproxy or modrewrite for this. If your routes are setup correctly and it's just HTTP traffic, this should work.


'Run As' box popping up when program runs on Windows XP

Question: I have a program that was written in house years ago by someone who has now left. The program should run (minimized in the task bar) when I login which it does but before it can run I see the 'Run As' window below. The program isn't signed which may be the problem. I'm logged on as an administrator. Can anyone tell me why I see the 'Run As' box? It runs fine on Windows 7 but I need to add it to a Windows XP PC.
The program is set to run from the registry via HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.
Many thanks
James
Answer: If you don't have any other need for the RunAs feature then you could first try stopping the service. open the run command and type services.msc then scroll down to "Secondary Logon" and disable this service.


In SQL Server the backup file is around 190 gb, but when restore the log needs around 2 TB space

Question: From the production the database is backed up automatically every day full backup and every 1 hour for transactional backup.
A test server was prepared and I want to restore the latest full backup to the new test server; the full backup size (<code>*.bak</code> file) is around 190 GB, but it keeps showing an error that the log needs around 2 TB for restore - what can be a solution for this?
Answer: Please verify the log file size on the production server. It is probably 2TB. Maybe at some point it grew. So, even if it is empty bow because of log backup, it's still a 2TB file on disk, and you will need to have that space available for the physical file on the new server.
If your test server is VM, you could add large disk and restore the log file there and shrink it after restore. Then move the log to a smaller disk and remove the large disk.
Other option is to shrink log file before full backup, if you're sure that it does not need to be 2TB.
Answer:
backup size (*.bak file) is around 190 GB, but it keeps showing an error that the log needs around 2 TB for restore

A backup file contains only the allocated pages in the database files plus the log records that were created during the backup process, and may be compressed.
Restoring a backup, however, recreates the target database will all its files the same size they were on the source system.


LoRaWAN collision and demodulation

Question: In what scenario is it possible that collision happens between two packets.
And if a collision happens, is it possible to demodulate? How?
Regarding here it says there are two types of interference. Intra and internetwork for unlicensed networks. I suspect when a node from outside network interferes with signals inside network, it is recoverable. But how?
Thanks.
Comment: In LoRaWAN any device can talk at any time, so if two devices send on the same frequency you may end up with a collision. There's no carrier sense/listen before talk, no collision avoidance, no collision detection, no collision recovery. Whether two devices sending on the same frequency but using different data rates end up colliding or not is unclear to me, though.
Comment: @jcaron Does data rate even matter? In unlicensed networks there could be intra-network and inter-network interference. I want to know which is recoverable?
Why did you say that all sort of interference is not recoverable?
I suspect if collision comes from out of network node signal, the message ould be recovered? But how
Answer: Lora's spreading and frequency chirps provide some level of de-confliction, but it's not perfect. Lora devices transmit randomly on their own schedule, so there's always the possibility of collision. If the Lora gateway cannot de-conflict both packets, then they're dropped. The transmitting device won't know that the packet was dropped, unless the device was requesting information or acknowledgement. You can implement a retry feature where the gateway requests packets that were missed based on sequence numbers. If the gateway receives packets 1, 2, 3, and 5, it can request packet 4 from the device. It's up to your device to implement that feature.
Comment: I also found this paper useful : Understanding collisions in a LoRaWAN (google it)
Answer: I am trying to answer all your questions one after the other below.

In what scenario is it possible that collision happens between two packets.

If at the location of the receiver the signal of two or more LoRaWAN radio packets interfere so that the receiving device is not able to demodulate that packet that was addressed to it, we say that the packet was lost due to collision.

And if a collision happens, is it possible to demodulate?

If the signal of two LoRaWAN radio packets interfere at the location of the receiver, it may still demodulate the one that was addressed to it.

How?

A radio packet that is facing collision with another radio packet at the receiver can be demodulated with high likelihood under the following conditions:

The two radio packets are sent on different LoRaWAN channels.
(LoRa is using several channels with 125 or 500 kHz channel bandwidth.)
The two radio packets are sent on the same LoRaWAN channel but they are modulated with a different spreading factor.
(LoRa applies 6 possible spreading factors for modulation. These are referred as SF7..SF12 where SF7 corresponds to the highest, SF12 to the lowest data rate)

There is only a little interference between neighbouring radio channels and LoRaWAN modulations of different spreading factors are orthogonal.

Regarding here it says there are two types of interference. Intra and internetwork for unlicensed networks. I suspect when a node from outside network interferes with signals inside network, it is recoverable. But how? Thanks.

Your referred link (here) is talking about inter-system/intra-system interferences and not inter-network/intra-network interferences that you mentioned in your question. It is important to make a difference between the two scenarios.

In case of LoRaWAN technology, inter-network interference means collisions with LoRaWAN radio packets that are sent by such devices that belong to other,  (foreign) LoRaWAN networks. In these cases the conditions of successful demodulation of a radio packet are the same as listed above (different channel, different spreading factor).

Inter-system interference means interference with radio signals produced by non-LoRa devices (e.g.: a garage opener) that operate in the same ISM band. In these cases the signal of foreign systems is considered as noise of the LoRa signal to be demodulated. Whether or not demodulation will be successful depends on the SNR threshold of the actual spreading factor and receiver.
Answer: LoRa modulation can demodulate packets transmitted on same center frequency, given their spreading factors are different.
But, packets [simultaneously] sent on same center-freq and SF will collide and will not be demodulated.
However, some regions such as KR920 offer LBT (Listen-Before-Talk) that takes a reading on given center-freq for N samples to measure against a preset THRESHOLD in order to avoid possible collision.

LoRaWAN collision and demodulation


Taking over Ethernet data in Linux

Question: I have been given the assignment of finding an appropriate take-over point in the Linux ethernet data chain.
I have looked at it from various angles. I have successfully written NetFilters. But what I'm really looking for is the best location to insert my code such that I receive directly from the driver -- without having to modify the driver, and hopefully staying "Linux-friendly". (I'm not opposed to a hostile take-over, but I'm trying to avoid it.)
I want to be able to have the options to: completely take over all IP, or pick off TCP (perhaps a proprietary connection that I don't want traversing the Linux stack), or pick off other protocols or connections. (I don't mean mid-connection.)
For example: a TCP SYN comes in from an IP address I recognize. I want to respond and communicate without the Linux stack ever knowing the message ever came in. I want to TX messages without netfilters getting a copy of it.
I don't want to take on the burden of all the great things the Linux stack provides but I don't want any filters to see my proprietary messages either.
After looking through tons of kernel code, I'm coming to the conclusion it might just be easier to alter the driver (in this case r8169.c). But I would prefer to find that "sweet spot" where I can peek/poke/prod/coerce via my Kernel Module and create a chain with me always being first.
Does anyone know where that "sweet spot" might be?
Answer: If you open a standard socket with the RAW protocol, I believe this prevents the data being passed up to TCP/IP layers.  This would allow you to examine ethernet packets and respond, but I don't think it will allow you to put the packet back in the stack for it to go further up.
Comment: Thanks for your input. I looked at this, but unfortunately it also doesn't prevent filters from having a look as well.

Taking over Ethernet data in Linux


Can RNN work with just one input?

Question: We have a time series data.Is it possible to create a RNN such that there is only dimenson(or feature) in data(as shown in fig1).If yes,will it identify the pattern in time series data correctly? The confusion arises because only neuron (yellow to blue in figure 2) information is passed to the output.Is it sufficient to predict a pattern in time series data?
Comment: Yes. Your input vector can have an arbitraty number of dimensions.
Comment: Yes It can have...but will it predict time series perfectly?
Comment: Sometimes to properly predict time-series it will need feedback input too, so it makes prediction based about previous values of time-serie and current input-values. It is especially important when handling with dynamic systems for example.
Comment: Actually my question is ,suppose we have dataframe containing just one column of values (that is there is only one input neuron). Is it sufficient to predict a time series problem?Or we require more than one column of values arranged in time series fashion?
Comment: Based on your comments this is more of a conceptual problem about time series prediction than about RNN's in general. You are asking if it is possible to predict $X_{t+1}$ based on $X_t$ for your time series. If the sequence you are trying to predict show dependence across time steps, then it will be possible to predict it to some extent using an RNN, or many other time series models. If the dependence across time is highly non-linear then an RNN could be a good model choice. I suggest you do some exploration on your time series, to get a sense for the dependence structure across different lag
Answer: Yes, in this case train_x and train_y both have just 1 column.  RNN learns patterns in just that variable and tries to predict next instance based on the patterns.

Usually, this is just a theoretical exercise. In real world, you will have multiple features.
Some examples :
https://machinelearningmastery.com/time-series-prediction-lstm-recurrent-neural-networks-python-keras/
https://machinelearningmastery.com/time-series-forecasting-long-short-term-memory-network-python/
Comment: I would recommend reading on them first and then trying to code it up and then your queries will be solved :)
Comment: Ok so how does it really work.Suppose we give a batch size of one...it will take the first feature vector and find the output value.Now coming to second feature vector..will it pass the value found out in the first feature vector to find the output for second?
Comment: Batch size is not 1. You will provide a set of values. Like last 300 values of X and next Value of X will be the output.

Can RNN work with just one input?


Under what conditions does SQL Server encrypt tempdb?

Question: When does tempdb get encrypted with Transparent Data Encryption?  What configuration, etc, causes tempdb to be encrypted this way?
Comment: I believe if you turn on TDE on *any* database in the instance, `tempdb` gets encrypted, too. Is that what you're getting at? The question is a bit unclear.
Comment: Yes, Jon, that's what I'm getting at.  I'd love to find a better way to word/frame the question.
Answer: When you encrypt the first database in the instance, tempdb will also be encrypted.  As per this reference on TDE:

Transparent Data Encryption and the tempdb System Database
The tempdb system database will be encrypted if any other database on
  the instance of SQL Server is encrypted by using TDE.

This will be the case when you set ENCRYPTION ON on a database.
Comment: Microsoft doesn't seem to include information about *which* certificate is used for tempdb. (E.g. if you use a separate certificate to encrypt different database catalogs.)
Comment: @Granger: While I don't know I have reason to believe the answer is "none of them".


Installing Elementary OS on an 2009 MacMini running El Capitan

Question: I tried installing Zorin OS 15 on a 2009 MacMini running El Capitan so that it would dual boot. It crashed out at the last moment :(
The good news was that it didn't brick my MacMini
So does anyone have any experience of installing Elementary OS on this vintage of Macs?
Answer: Hi I have a macmini 2009 and the os is broken tried to repair it and fsck-ed it under single user mode but nothing worked. Bought a new mac air this could read the old hard drive in an external enclosure and could move the data from the old 500gb hard drive. Now I want to install elementary OS on the old mac mini. But how to do this when the mac OS is broke. I don't want to mess up the new mac. So i use a windows computer. Anyway I wil try to install elementary os and let you know.
Answer: I just recently installed eOS 5.1 on 2009 iMac elCapitan and the install went fine.  Beautiful looking UI and I hope that I can get my bugs worked out so that I can stick with it.  I'm very new to Linux and first installed Linux Mint about a month ago so I'm just learning how to move around in Linux. I found eOS a week or so ago and have been using it since.  Here is the bugs I have so far so if you know how to fix it I'd love the help:
--Once the computer goes to suspend and turns the display off, coming back (mouse,spacebar, etc..) doesn't turn it back on.  The computer is awake since anticipating this if I instead enter the user password (with the screen black) and enter, I login and the display turns back on.  Mint didn't have this issue. This annoys my wife fiercely.
--The bluetooth "Magic Mouse" loses connection so often that it's better to use the usb mouse.  Mint didn't have this issue. This annoys my wife fiercely.
--I can't get the superdrive to play a dvd-- Tried different programs (VLC, etc..) I have Linux Mint installed on a similarly old macbook and plays dvd's fine.  I don't play many dvd's so it's not a real issue, but annoys me not-fiercely.


What's the difference between std::advance and std::next?

Question: Is there more beyond advance takes negative numbers?
Answer: std::advance

modifies its argument
returns nothing
works on input iterators or better (or bi-directional iterators if a negative distance is given)

std::next

leaves its argument unmodified
returns a copy of the argument, advanced by the specified amount
works on forward iterators or better (or bi-directional iterators if a negative distance is given))
Comment: If I had a time machine I would take away InputIterator's copy constructor and make it move-only.  I think that would make them much safer and easier to reason about.
Comment: The extra constraint on `std::next` was backed out by http://cplusplus.github.io/LWG/lwg-defects.html#2353
Comment: I don't suppose you happen to know why they made it UB to use `next` on an input iterator that's not a forward iterator, even though the defined effect of `next` is guaranteed to work on an input iterator?
Comment: @HowardHinnant: gah, thanks. So basically if you're working with an InputIterator then you should just use `++` (or `advance`, to protect yourself from the devastating convenience of one-liners involving `next`), or write your own `my_next` that quite possibly is identical to your implementation's `std::next`, maybe with a traits assertion removed. It occurs to me that on the same argument, InputIterator shouldn't require `operator++(int)`. Way too late to fix that now, I suppose.
Answer: Perhaps the biggest practical difference is that std::next() is only available from C++11.
std::next() will advance by one by default, whereas std::advance() requires a distance.
And then there are the return values:

std::advance(): (none) (the iterator passed in is modified)
std::next(): The n th successor.

std::next() takes negative numbers just like std::advance, and in that case requires that the iterator must be bidirectional. std::prev() would be more readable when the intent is specifically to move backwards.
Comment: `next` doesn't only move forwards, it's like `advance` in that respect. Given the existence of `prev` it might be strange to write `next(it, -1)`, with a negated literal. But for iterators of the right categories it's fine for example to write `next(it, distance(it2, it3))` even if `it2 > it3`.
Comment: @SteveJessop: Thanks for the edit and for preserving the emphasis on readability.
Comment: @Johnsyweb `std::next()` is available after C++11, not  only in C++11.
Comment: Thanks @John. The answer was correct when I wrote it nine years ago.
Answer: std::advance
The function advance() increments the position of an iterator passed as the argument. Thus, the function lets the iterator step forward (or backward) more than one element:
#include <iterator>
void advance (InputIterator& pos, Dist n)

Lets the input iterator pos step n elements forward (or backward).
For bidirectional and random-access iterators, n may be negative to step backward.
Dist is a template type. Normally, it must be an integral type because operations such as <, ++, --, and comparisons with 0 are
  called.
Note that advance() does not check whether it crosses the end() of a sequence (it can't check because iterators in general do not know the
  containers on which they operate). Thus, calling this function might
  result in undefined behavior because calling operator ++ for the end
  of a sequence is not defined.

std::next(and std::prev new in C++11)
#include <iterator>
ForwardIterator next (ForwardIterator pos)
ForwardIterator next (ForwardIterator pos, Dist n)

Yields the position the forward iterator pos would have if moved forward 1 or n positions.
For bidirectional and random-access iterators, n may be negative to yield previous  ositions.
Dist is type std::iterator_traits::difference_type.
Calls advance(pos,n) for an internal temporary object.
Note that next() does not check whether it crosses the end() of a sequence. Thus, it is up to the caller to ensure that the result is
  valid.

cite from The C++ Standard Library Second Edition
Answer: They're pretty much the same, except that std::next returns a copy and std::advance modifies its argument. Note that the standard requires std::next to behave like std::advance:

24.4.4 Iterator operations [iterator.operations]
template <class InputIterator, class Distance>
void advance(InputIterator& i [remark: reference], Distance n);

2. Requires: n shall be negative only for bidirectional and random access iterators
  3. Effects: Increments (or decrements for negative n) iterator reference i by n.
  [...]
template <class ForwardIterator>
ForwardIterator next(ForwardIterator x, [remark: copy]
     typename std::iterator_traits<ForwardIterator>::difference_type n = 1);

6. Effects: Equivalent to advance(x, n); return x;

Note that both actually support negative values if the iterator is an input iterator. Also note that std::next requires the iterator to meet the conditions of an ForwardIterator, while std::advance only needs an Input Iterator (if you don't use negative distances).


AquaticPrime "Regular" License?

Question: I am looking at using AquaticPrime for my key generator for a Cocoa shareware app.  For those of you who don't know about it, you can check it out here: http://aquaticmac.com/.  However, I am running into a problem when I attempt to implement it.  I don't want my users to have to copy and paste a whole dictionary into my app (or select it from a file browser), I just want them to have some code like: 1111-1111-1111-1111-1111 that will unlock the app for them.  Is there some way to do this in AquaticPrime?  But assuming that it can't, is there some other framework that does do this or would I just have to hard code it?
Answer: The reason it uses license files is to make it cryptographically hard to make up licenses—you can't just write a keygen like you can with license numbers.
You can make this easy by making a custom file type for license files in your application's Info.plist. (This must be app-specific. When you begin your second product, you'll need to make a new type.) This type will have a custom, app-specific filename extension with it.
Then, when the user double-clicks on the license file (possibly in Mail), the OS will open it with your app. You'll handle this, probably in your app delegate, by feeding the license file to AquaticPrime to validate.
This way, the user does not even have to summon a dialog box, copy the license number, and paste it. All they have to do is double-click on the license file.
Thus, the license file makes it easier to register your application, not harder.
Comment: Hey Peter:

Thanks for your reply.  That makes sense - It's just that I don't normally do register applications this way.  But it doesn't mean that it doesn't work better!
Answer: If you have a trial version of your application that is unlocked then you can do the following.

1) Create a custom url scheme.
Follow the instructions on this posting but instead of http and https make your application respond to something like activate-com-mycompany-myproduct.
Once the user has run your application once any link in a browser like activate-com-mycompany-myproduct://somedata will automatically open your application.

2) Provide a product activation link in your final buy page of your web store and your email receipt.  To make it simple for the user and not for you, append a unique id to the URL.  Map the ID in a database, generate a license plist on the fly and push it to the user seamlessly.
Answer: In case someone else stumbles on this question: you might also want to take a look at CocoaFob. The keys it generates are rather long, but closer to the format you were after and still easy enough to cut and paste.

AquaticPrime "Regular" License?


Tor auto-exits when opened - Mac

Question: When ever I open Tor on my mac, 10.9.5 version, and when ever I open Tor it crashes when establishing network contact. This happens on what ever network I use. I've tried to reinstall it but the problem's still there.
Comment: Can you "Copy Tor Log to Clipboard" and insert the output into your question?
Answer: (I don't have enough rep to comment but hopefully this is helpful.)
Make sure you check your Tor config as a setting you recently changed might cause the Tor Engine to not start. I had the same problem when I forgot the file in the Log notice file tor.log line in my config. If you are not sure what happened you can always re-download the latest Tor (Browser) and reinstall it.

Tor auto-exits when opened - Mac


Can a ERC-1155 contract tokenized by ERC20 tokens be indivisible?

Question: Example: Using a ERC-1155 contract for real estate, Say I have a 100 acres of real estate i want to lock into a ERC-1155 vault to then fractionalize with 100 ERC20 tokens. I want those ERC20 tokens to be indivisible so users can't own a half of a token, only 1 token. Is this possible?
Answer: The thing is that ERC20 tokens are fungible and normally they are divisible. This is the idea of fungible tokens. But you can always have your own implementation of the ERC20 token which will behave the way you want.
On the other hand, you are talking about something that is non-fungible. And in the case of 100 acres of real estate you want to fractionalize, it's better to use the ERC721 token, which is non-fungible. With the ERC721 token, you will not have the problem that the user can own just a portion of a token.
I think this article could be helpful for https://101blockchains.com/erc-1155-vs-erc-721/


Trying to measure point density along a line

Question: I have a dataset that consists of animal sightings along a road and I want to calculate the density of points (sightings) along that road.  My primary goal is to measure sighting hot spots, but I also want to subsequently look at the habitat characteristics associated with these hotspots.  Kernel and point density do not seem appropriate b/c I only have measurements along this road (a line) I have no measurements of occurrences at locations away from this line. I'm using ArcGIS 10.3  Suggestions?
Comment: I don't have arcgis but I suspect you might get more help if you could share your dataset or a small portion of it for someone to analyze and reproduce to provide an answer.
Answer:
First use Generate Network Spatial Weights in ArcGIS. This tool will generate a matrix file from network that you will use it in other tools
Use the matrix file in Hotspot Analysis tool . with this method you use the hotspot analysis alonge the path.
You can use the Matrix file for other analysis.
Answer: I just found this. Maybe other people still are as well.
A different option, that might work better (better for me) is discussed here:
https://www.esri.com/arcgis-blog/products/product/mapping/using-graduated-lines-to-show-the-number-of-accidents-along-road-segments/
Your run the Spatial Join Tool to basically count how many points are near each segment of your line set. In the questioner's case you would need to break your road up into a number of linked segments.
You can set the search radius. It was able to handle a large dataset quite well, where an attempt at a density/heat map of my points just crashed each time.


How can I embed a YouTube video in OneNote?

Question: How can I embed a YouTube video in OneNote?
Comment: why would you want to?
Answer: 6 Years later and it is possible for ONENOTE 2016!
Insert online videos into OneNote 2016 for Windows

To add a video in OneNote, do the following:
Copy the video link from your video source.
On the page where you'd like to add the video, click Insert > Online
Video.

Paste the link into the Video address field, and click OK.
Comment: Does this embed and store the video content offline or references it and has to stream from the net when online?
Answer: If you want to embed video for playback in the note itself, I don't believe that is possible, or I haven't figured out a way to do it.
I know if you add Windows media type files, OneNote will use an internal player for playback, but it opens the video in its own window. (It would be nice if you could add notes to the video at specific times/frames.)
The best I've done for YouTube is downloading the video and then dropping the .flv file in as a link. OneNote will use an external player when you click for the video. There are browser extensions that allow you to grab the video from a specific YouTube page. This does have the advantage of keeping the video for as long as you keep the note files.


Regex nginx location with named location

Question: I have the following set up - a production version of some software;
location @myradio {
    rewrite ^/myradio/([^/]+)/([^/]+)/?  /myradio/index.php?module=$1&action=$2 last;
    rewrite ^/myradio/([^/]+)/?          /myradio/index.php?module=$1 last;
}

location /myradio {
    alias /usr/local/www/myradio/src/Public;
    try_files $uri $uri/ @myradio;

    location ~ \.php {
        fastcgi_index   index.php;
        include         fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME    $request_filename;
        fastcgi_pass    php5-fpm;
    }
}

and several development versions - there's also myradio-lordaro, among others.
location @myradiodev {
    rewrite ^/myradio-([^/]+)/([^/]+)/([^/]+)/?  /myradio-$1/index.php?module=$2&action=$3 last;
    rewrite ^/myradio-([^/]+)/([^/]+)/?          /myradio-$1/index.php?module=$2 last;
}

location /myradio-dev {
    alias /usr/local/www/myradio-dev/src/Public;
    try_files $uri $uri/ @myradiodev;

    location ~ \.php {
        fastcgi_index   index.php;
        include         fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME    $request_filename;
        fastcgi_pass    php5-fpm;
    }
}

Both of these work perfectly fine, but copying out the same /myradio-* config several times seems inefficient and I feel like I can do better.
Is it possible to generalise the development configs into one that uses regex to redirect nginx to the correct location? The @myradiodev is used successfully for all dev versions, so I don't believe that's the issue, but my own attempts to do it have just resulted in various 403 or 404 errors, with no clear idea where nginx is trying to access.
[Other recommendations as to how to clean this up appreciated (was originally converted from an apache config)]
Answer: You can use a regular expression in the location block. (you already did that in the nested location block for php). It's announced by the tilde "~".
location ~ ^/myradio-([^/]+)

You could then use the match variable like:
alias /usr/local/www/myradio-$1/src/Public;

Or cleaner without match variable:
alias /usr/local/$request_uri/src/Public

Did not try it, but it should work.


In what way production of language is optimal or most economical?

Question: I have been listening to Linguistics & Philosophy lecture by Noam Chomsky and he mentions around 1h:08m that it is posited that language productions are actually the most economical way to convey information. I guess this is some more widely known language theory but I am relatively new to the field. I am wondering, in what way exactly these productions are deemed optimal?
Comment: Note (as we would in Stack Exchange) that claiming anything to be _optimal_ is merely an opinion, unless it be backed up by very strong statistical evidence demonstrating that all other possibilities score lower on some commonly-agreed-upon scale of optimality. To say that Chomsky's claims about optimality do not meet this standard is perhaps unnecessary, but one never knows. While many linguists revere Chomsky, not all agree with him, and many find no evidence to support his theories.
Answer: There is a whole strain of research (represented, e.g., by Florian Jaeger) that regards the communication channel as a Noisy Channel in the sense of Shannon. The uniform information density hypothesis postulates that this Noisy Channel is always optimally used with respect to information, and that speakers adjust their utterances to the channel capacity.
Comment: Almost every layer of linguistics is affected by this: Starting from phonetics (how careful are some syllables articulated?) over word choice, word order, ellipses, fillers, coreference chains ... there are really a lot of means to modulate information density, and we use them all.
Comment: Thank you for the hint. I am aware of the Shannon's theory. In more detail, I was wondering about choice of particular features of the language: e.g. phrases, words, etc. that are synonymous yet used much more seldom (or not at all, but allowed by the language rules)  that could be rationalized by such a theory. Is that the case with works of Florian Jaeger?


What stats test should I use?

Question: If BMI data is broken into two groups, those with low BMI and those with high BMI, what statistical test would I use to see if there is a gender difference (male and female) between the two categories of low and high BMI?
Comment: Why not compare BMI for males with BMI for females?
Comment: You can perform a chi squared test of independence. You null hypothesis would be: There is no association between gender and BMI level. Where the alternative hypothesis would be: There is an association. [Here is an example of how to perform a chi squared test of independence using python](https://stats.stackexchange.com/a/461111/276652)
Answer: If all you have is the data that has already been binned for you, then the appropriate test is a Chi squared test, on the two-by-two cross tab. This will test against the null hypothesis of no relationship between the rows and columns (in this case, sex and BMI category - it doesn't matter which is row or column).
Any stats package, and even Excel, can calculate the Chi squared test for you.
If you have the actual BMI values then you should avoid doing this categorisation, and instead make use of the much greater information in the continuous variable. So this answer presumes that you don't, you just have "low" or "high", so you have no alternative.
Answer: If you have large enough samples, you can go with z-test for comparing two proportions (e.g. proportions for male in the two groups).
Alternatively you can use the $\chi^2$-test of independence for a $2 \times 2$ contingency table.

What stats test should I use?


Using wet saw for cutting tile

Question: How long does the tile have to dry before I can put it on the wall ?
Should I dry it with a heat gun or is drying it with a towel good .
Comment: Hello, and welcome to Stack Exchange. How are you adhering the tile to the wall? (Edit the answer into your question.)
Answer: If you are using thin-set, then damp is fine (as in, dry with a towel).  It is usually a good idea to damp the tile and substrate with a sponge anyway, (especially if tiling to wood/gypsum(drywall) etc.) so that the substrate doesn't soak up all the moisture from the thin-set.
If using mastic, you want the tiles to be dry.

Using wet saw for cutting tile


Pokemon Go logged out of my account

Question: I got logged out on Pokemon Go, but my mom sighned me up so I don't know the username password or email. I don't know if it is a pokemon trainer club account or google. All I know is the Nickname which is JewelsPanda. Is it possible to get my accout back?
Answer: Why don't you ask to your Mom? She probably knows if she created a trainer club account or not.
For my part, I log in with my main Gmail adress, never with the Username.
BTW, there's only 1 username (account) for an email adress.

Pokemon Go logged out of my account


Install on premise SharePoint 2010 Site template, on SharePoint Office365 (SP 2013 based)

Question: Is there a setting that'll enable me to install a SharePoint 2010 site template (wsp) on SP 2013?
Answer: You can install a site template on a SharePoint online 2013 if you subscribed to Office 365 before March 1st. Thus you should be able to import your template in a 2010 site then to upgrade the site to 2013.


Using flail expertise with powers that push/pull/slide

Question: I am playing a battlemind with flail expertise.  This allows me to knock prone an opponent instead of sliding them.  Is sliding specific to just powers that say slide or is push and pull included as a slide?
Comment: Welcome to the site!
Related: http://rpg.stackexchange.com/q/13221/4089
Answer: No, push and pull do not count as slide.
From the RC, p211:

Forced Movement
  Certain powers and effects allow a creature to move a target forcibly, whether the target is willing or unwilling. ... The three kinds of forced movement are pull, push, and slide.

Push & pull are not special types of slide; push, pull, and slide are all types of forced movement.
However, here are 2 feats you may want to look at:

Dragging Flail (heroic tier feat from Martial Power 1 page 133)
Prerequisites: Dex 15, fighter
Benefit: Whenever you use a flail to knock an enemy prone, you can also slide that enemy 1 square.

and

Lashing Flail (paragon tier feat from Martial Power 2 page 14)
Prerequisite: 11th level, any martial class
Benefit: Whenever you use a flail to hit an enemy with a melee basic attack, you can slide that enemy 1 square.


Why do we need 3 phase power supply?

Question: Why do we need 3 phase?
For the reason that voltage will never be zero in 3 phase? OR we need high voltage?
Comment: No one **needs** any power. Three-phase power is convenient for a number of reason, but it's not a *necessity*.
Comment: @ConnorWolf Is power/current/voltage coming to house single phase? Is it delta configuration? what happens when voltage drops to zero in single phase? Is [this](http://www.head-fi.org/g/i/458593/avatars/) single phase?
Comment: The power coming to your hose is whatever you pay for and/or the utility is willing to provide.
Answer: Comparing 3-phase with single phase transmission, 3 phase has a couple of significant advantages:
1) More efficient use of conductors : given the same peak voltage between conductors and same current in each conductor, 3-phase delivers 3x the power with 1.5x the copper (3 wires instead of 2). This doubles the usefulness of each pound of copper (aluminium etc) Over long distances, this is a significant cost saving.
2) Three phase motors run smoothly with no additional complexity to define their running direction. Power delivery is approximately constant as the rotor follows the rotating field (with some slip, in an induction motor) with no torque variation or vibration. Reversing can be as simple as interchanging any two phases.
The advantage of smoothness also applies to the 3 phase generators : they absorb power from e.g. the turbine smoothly : a large single phase generator would probably be shaken apart from the torque variations.
Answer: There are several reasons 3-phase is desirable over 1-phase power. One advantage of 3-ph over 1-ph has to do with instantaneous power (i.e. power generated or consumed at any instant in time within the power cycle).
For example, consider a heating element (power resistor) in a 1-phase circuit. Voltage and current are in phase. Both cross zero twice during a cycle as they go positive and then negative.
Their product is power which is a sinusoid at 2x the fundamental frequency (multiply two sine waves and you get a new sine wave with twice the frequency). The power dissipated by the heating element has a sinusoidal waveshape that sits above the zero line (because the two V & I sinusoids, when multiplied together, always give a positive value).
The power sinusoid also reaches zero twice during the fundamental cycle at the same time V or I cross zero. The resistor doesn't produce heat (consume power) at these zero-crossing instants in time (resistor remains hot due to its thermal mass). Now replace the resistor with a 1-ph induction motor.
For similar reasons, despite V & I being out of phase, there are times in its power cycle when the motor doesn't produce mechanical power (it remains spinning due to its own and its load's inertia). In a 3-ph system, the phases are staggered by 120 electrical degrees. If a 3-ph heating element is connected (Y or delta; doesn't matter for the purpose of this discussion), each individual resistor "sees" a zero crossing but collectively the three are producing heat at all times. There is no instant in time when heat is not being produced.
Similarly, with a running 3-ph motor, there is no instant in time when it isn't producing mechanical power. The result is a simplified motor (no starting winding needed as is the case with a 1-phase motor), smaller frame for same horse-power because instantaneous power is never zero. Unlike the 1-ph motor, the 3-ph motor doesn't need the larger bulk to "coast through" a zero crossing.
Answer: Total power in three phase system is almost constant and so creates less vibration.

Total power in single phase system is pulsating and so creates more vibrations.
Answer: 3-phase is easy to generate, easy to transmit, and easy to manipulate in many different ways.
In a delta configuration it makes for very easy long distance transmission, since there is no "ground" needed - the ground equivalent functionality for one phase is provided by the other two phases.
In a star configuration it provides three individual single-phase power circuits for feeding to consumers.
Switching between delta and star arrangements is as simple as using a transformer with the primary and secondary windings in the right arrangement.
It's has to be by far the most flexible of all the arrangements you can come up with.

Why do we need 3 phase power supply?


Continued Fraction Counting Problem

Question: The house of my friend is in a long street, numbered on this side one, two, three, and so on.  All the numbers on one side of him added up exactly the same as all the numbers on the other side of him.
There is more than fifty houses on that side of the street, but not so many as five hundred. If we find the number of the house where my friend lives, the problem had one solution — house no. 204 in a street of 288 houses, i.e.
1+2+ ... 203 = 205 + 206+ . . . 288.
But without the 50-to-500 house constraint, there are other solutions. For example, on an eight-house street, no. 6 would be the answer:
1 + 2 + 3 + 4 + 5 =  7 + 8.
Ramanujan is reported to have discovered a continued fraction comprising of a single expression with all such correct answers.  What is the continued fraction, and how can it be found?
Comment: I think it may be the continued fraction for $\sqrt{8}$ or something related. For sure it is the Pellian $x^2-8y^2=1$.
Answer: If it is house number $x$ in a street of $y$ houses, we have
$$\frac{x(x-1)}{2}+x+\frac{x(x-1)}{2}=\frac{y(y+1)}{2}$$
which simplifes to
$$(2y+1)^2-8x^2=1\ .$$
This can be solved by computing the continued fraction
$$\sqrt8=2+\frac{1}{1+{}}\frac{1}{4+}\frac{1}{1+{}}\frac{1}{4+\cdots}\ .$$
The table of convergents is
$$\matrix{&&2&1&4&1&4&1&4&1&4&\cdots\cr
  0&1&2&\color{red}{3}&14&\color{red}{17}&82&\color{red}{99}&478&\color{red}{577}&2786&\cdots\cr
  1&0&1&\color{red}{1}&5&\color{red}{6}&29&\color{red}{35}&169&\color{red}{204}&985&\cdots\cr}$$
The pairs beneath the second-last entry in each period (that is, in this case, beneath the $1$s) are marked in red.  They give the integer values of $2y+1$ and $x$ satisfying the equation.  For example we have firstly $y=1$, $x=1$ (the trivial solution - house numbers on both sides of $1$ add up to $0$).  Then $y=8$, $x=6$ as you observed.  The fourth solution is Ramanujan's.
Answer: Also, if we take the house numbers $$ x_0 = 0,  $$
$$ x_1 = 1,  $$
$$ x_2 = 6,  $$
$$ x_3 = 35,  $$
$$ x_4 = 204, $$
$$ x_5 = 1189,  $$
we have a simple recurrence
$$ \color{magenta}{ x_{n+2} = 6 x_{n+1} - x_n }$$
which follows by Cayley-Hamilton from the generator of the oriented automorphism group of $u^2 - 8 v^2.$
If $y_n$ is the number of houses on the street, so $y_n \in \{1,8,49,288,1681, \ldots \}$ then
$$ \color{magenta}{ y_{n+2} = 6 y_{n+1} - y_n + 2 }$$
The part about the automorphism group comes down to this single identity involving a linear map,
$$ (3u+8v)^2 - 8(u+3v)^2 = u^2 - 8 v^2  $$

Continued Fraction Counting Problem


What is the meaning of the toy eye that Walter keeps?

Question: There are a few episodes on Breaking Bad where a toy eye that Walter removes from his pool appears. It seems to be having some sort of judgmental meaning as if it sees everything that Walter does. What is the true meaning of it? Especially, interesting to understand what does it signify when Skyler spots the eye but in the end doesn't seem overly confused over finding something of that sort at Walter's apartment.
Comment: Related: [What does the pink teddy bear represent in Breaking Bad?](http://movies.stackexchange.com/q/14560/49). (Though, it seems you might not even be aware that it's the eye of that teddy that fell out of the crashing plane.)
Comment: Sure, I was just confused that you didn't mention the teddy at all.
Comment: I remember the eye coming from a pink teddy bear half burnt from the plane crash. But seems like producers possibly had a few deeper meanings to it once it got separated from the bear.
Answer: Vince Gilligan:

The teddy bear eyeball that Walt found in his swimming pool is symbolic. It's very, very symbolic. However, I'm not sure I can tell you with 100% certainty of what the symbolism is, what it represents...On the face of it, when we were coming up with that eye as an image, it probably, represented some form of the eye of the universe, the eye of god, the eye of morality, I suppose judging Walter White...And so symbolism like the eyeball, I'm not sure what it means to me completely but I'm always interested in hearing what it means to viewers of the show. I guess if you're going to hold my feet to the fire, what it means to me is the eye of God on Walt. If not necessarily judging him, nonetheless watching him, keeping tabs on him. And then the question: If that is what the symbolism stands for, then why does Walt keep that eye? Why does he keep it in his drawer versus discarding it?

More...
Comment: What was the source of that quote? (link is not working)
Comment: http://breakingbad.wikia.com/wiki/Pink_Teddy_Bear
Comment: Yes, that's the same link... which incidentally works again now. But I've been unable to track down where the actual source of the quote. No citation is given in the wiki.
Comment: Possible meanings in the link you can find the source.
Comment: What I'm saying is that they didn't state  where / when VG uttered it, unfortunately.
Answer: I always believed it to symbolise the innocence Walter had destroyed staring back at him. If you'll realize, every time he sees it, or it sees him, he is in a pathetic state, ignorant, or just guilty.
Answer: The teddy bear and the missing eyeball symbolizes Gus. When Walt kills Gus at the end of season 4, one of Gus's eyes was missing.
Answer: I have frequently noticed that an artist, an author, a sculptor or anyone in the creative field may be able to analyze and/or explain their art, but frequently overlooks what another, an unknown third party viewer may be able to see.  (No pun intended.)  Yes, the eye of the once perfect pink teddy bear, the eye that is forever lost to the teddy bear and the teddy bear itself, forever lost to one child or another, may symbolize what one character IS able to see and what another character may not notice at all.
The son has MS, the Mother commits illegal acts at the accounting firm, the DEA brother-in-law steps outside of his legal boundaries, purposefully with no remorse.  Every character on the series has a flaw, but it seems as if Walt may be the only one to recognize his own flaw and yet continue to act in a manner in which he knows is wrong.
He keeps the eye for a few reasons. He wants to remind himself that what he is doing IS wrong, and to never take it for granted that it is in anyway OK; he recognizes his own flaws and does not want to forget.
He is fearful, in hiding, that more than the teddy bear's eye will see him, so he even tries to hide that eye from time to time. Walt understands that no-one and nothing is perfect Curiously, it is only one eye and not two that are lost from the stuffed animal so the animal is never rendered fully (and symbolically) blind. So too is true of the character Walt.
Even the bear, in its burnt (out) and seemingly no longer worthwhile position (now debris and seemingly worthless  when at one time the bear was a treasured possession), part of this pink broken bear still has worth.  Walt does not want the entire bear to "go away" just to be replaced by another toy.  He keeps the eye, without realizing, that he is attempting to keep some value unto himself knowing that even the flawed are worthwhile.  With the eye as his superego as well as his reminder of the fact that all will be lost to him one day,Walt "holds on" to what is real and what is perception.
Comment: Also, just heard (Season 4) that pale pink, the color pale pink, is the most stable color of the rocks aka minerals that the Brother in Law has in his possession.  So, perhaps, in part at least, the missing eye of the pink teddy bear, in the possession of Walt, symbolizes  the beginning of the loss of stability as well as a feeble attempt to hold on to the same.
Comment: Moving toward the end of the series, I see (ha!) how limited my explanation was, though still competent.  Look at the eye also as the "I" and in me, myself and I, and connect that to Whitman's work "Song of Myself"...some of the same lines, or at least close to the lines in the poem, appear within the script of this series as I have now re-read the poem from having shelved it so many years back.  Even the black hat connects the poem to the character named Walt So, I am adding yet another possible of symbolism may be that the ever present eye may very well be the ever changing "I.."


Can I be arrested if I'm not home and there are drugs in my room?

Question: If I am out somewhere, and say my door is open and there are drugs in plain view, if a cop was in the house could I be arrested even though I'm not there?
Answer: In the US, there is a co-occupant consent rule (United States v. Matlock, 415 U.S. 164 (1974)). If a co-occupant of your house consented to a search, anything in plain view from the common areas is useable as justification for probable cause (for arrest) and admissible as evidence at trial.
Comment: "Common areas" implies *not* a co-occupant's room, right? Unless you sleep on the couch.
Comment: the answer says "visible from a common area" and the question said "door open".


Is it considered a bad thing to choose a book character's name as yours in Chinese? Picking a name from a book etc?

Question: So, I am in a process of finding a good name for myself in Chinese.
I wanted it to be somehow connected to space, maybe astrophysics, maths etc. The thing that actually inspired me to sign up for a Chinese course was 三体 book, and I was just wondering if taking a name from it would be considered stupid?
Answer:
I was just wondering if taking a name from it would be considered stupid?

Depend on how common the name is. Names like 國強 or 家明 are like John or David in English. Even the main character in a famous novel is named John, no one would think it is stupid to name yourself John. Only you know this name was inspired by that John in that famous novel.
If we know which character you are talking about just by the name, it is probably not a good idea. For example, a name that appeared only in one particular book.
Family name matter too. No Chinese whose last name is 周 would name his child 周恩來 (蔡恩來 would be ok). ; No English speaker would name a child Harry Potter, but Harry with any other last name would be fine because Harry is such a common name
Comment: Agree. Having the exactly same name as some very famous people or characters does sound weird.
Comment: Weird? Well,it depends on who the famous people are or were. Not sure if there were any Adolf Hitler(s) around, but "According to the Social Security Administration's baby name data, 19 new Baracks were born in 2016. This represented an increase from previous years: In 2015, eight boys were named after the former president, and both in 2014 and 2013, 11 kids got his name" And in Islam, Prophet Mohammad is the epitome of a perfect person, so "Mohammad" becomes the default name for 1600 years & counting. But "Donald" is too common to be associated with "him" But is there a Mao Tse-tung around?
Answer: Although 《三体》 is a famous sci-fi series, not everyone have read it, and many people actually don't remember names of people except some main characters or those with distinct characteristics (e.g. some that I remember: 叶文洁,罗辑,章北海,丁仪).
So in your case, my suggestion is that it will be fine to choose a name from the book, as long as it is not of famous characters. Most likely other people will not find where you take that name from.
Answer: Yes you are right it is not good.
please do not find a name which is known to others.
a very simple way to find a name is the name you can speak loudly.
consider you are in a big class room and a teacher call your name.
he can loudly speak your name.
Comment: Quote:- "consider you are in a big class room and a teacher call your name" This reminds me of an incident that happened to my sister some years ago. She has a name that sounds like a famous Hong Kong actress. She was at a medical clinic in HK and when the nurse called her name the whole room turned to catch a look, and it was pretty disconcerting when they all turned away with disappointment on their faces.
Comment: what is your sister's name
Comment: Sorry, I wouldn't put her name here without her permission. But the actress name is 裕玲, and here she is in the middle -- https://youtu.be/b2KZ7ywaXOU
Comment: I am sorry I do not know 裕玲
Answer: It's OK from 三体, since names from it are generally 'normal', however in many literature works the names are very unusual and awkward if they were used in real world, since they are carefully picked to make the possibility that there are people with the same names in the real world. (since which may cause problem) I haven't read much western literature but I guess things are probably the same.


Installation of fonts in ubuntu 14.04

Question: I usually preferred some fonts which are not available in Ubuntu 14.04 viz. Times New Roman, Arial etc. How these fonts can be installed in Ubuntu 14.04 environment ?
Comment: Not a duplicate: this question is specifically about Microsoft fonts.
Comment: fonts are fonts @AndreaCorbellini if that dupe does not give a method to install MS fonts it should have. Whatever the font tossing them in .font is the easiest method :D
Comment: @AndreaCorbellini The issue of MS fonts has also been dealt with in the question about [Libreoffice is missing Microsoft fonts](http://askubuntu.com/questions/34077/libreoffice-missing-certain-microsoft-fonts)
Answer: Method 1) Open Ubuntu Software Center and search for "ttf-mscorefonts-installer". This will install Microsoft's core fonts.
(Note: downloading ttf-mscorefonts-installer from ubuntu download centre,does not properly install the fonts because Microsoft's license is not accepted) so it can be install only from the terminal)
sudo apt-get install ttf-mscorefonts-installer

then accept the Microsoft's license using tab key in a graphical interface during install.
After installing the font package you will need to update the shared font directories with the following command in a terminal shell.
sudo fc-cache -f -v

[ttf-mscorefonts-installer  is included in Ubuntu-restricted-extras and the common practice is to install them together with video codecs, flash,etc. sudo apt-get install ubuntu-restricted-extras]
Method 2) Create a directory into your home folder, and name it ".fonts". In this folder you can copy all fonts from Windows (C:\WINDOWS\Fonts).
Answer: Navigate to the location of the downloaded fonts, then make sure they're unzipped (if they were in a compressed folder). After that, double click one and a window with a preview of the font will appear. There should be an "Install" button in the upper right corner. Click it to install the font.

Installation of fonts in ubuntu 14.04


DNA result suggests my nephew is my great-nephew

Question: I had my DNA tested several years ago and was pleased with the results.  Recently I saw where my sister's son (my nephew) had apparently had his DNA tested by the same company.  While his DNA was closely the same as mine, he was identified as my "great-nephew. I am curious as to why this was the case.  I remember his mom giving birth and know of no reason for this designation.
Answer: You may have inadvertently uncovered a family secret.
You haven't provided us with the cM for the match between you and your sister's son, but according to DNA Painter, the ranges for great-nephew (330-1467) and half nephew (492-1315) are quite similar, so he could be your half nephew instead of your great-nephew.
For him to be your great-nephew, the woman you know as your sister would be your niece. For him to be your half nephew, the woman you know as your sister would be your half sister.
Of these two situations, I think the latter is more likely. You would probably know if your sister had been born to one of your siblings instead of to your parents.
It's not uncommon for people to receive unexpected results from DNA matching.

On this site, the answer to Confusing DNA Ancestry has an excellent explanation and some guidance on next steps.
Multiple answers to Can Ancestry.com DNA matches be wrong contain useful information and advice.
Ancestry has a helpful page "Unexpected DNA Matches" that walks you through some possibilities.
The International Society of Genetic Genealogy has an excellent list of resources for explanation and support.


How to enable the image classification tool in ArcGIS

Question: I intend to perform a supervised classification on a TIFF image in ArcGIS 10.8. The image is an imagery of an area which I downloaded from my ArcGIS Online account. The goal is to automatically extract footpaths from this imagery as it is a rural settlement. I've not performed any edits on the image whether on symbology or bands after importation. I've enabled the Spatial Analyst tool but every option in the drop-down menu of the image classification tool is still disabled. How can I resolve this?
Answer: Hope you have enabled the Spatial Analyst Extension from the Customize Options, and have selected the imagery layer in table of content.
https://youtu.be/aFTif12Ipf4


Top to random shuffling stationary distribution

Question: Top to random shuffling is a method of shuffling a deck of N cards whereby the top card of the deck is removed and placed at random in the deck, and the procedure is repeated. I want to know the stationary distribution of the Markov chain where a state is a permutation of
the deck. I saw a proof using random walks on groups that the stationary distribution is the uniform distribution. Is there a intuitive way to see this?
Comment: It is a finite state space irreducible and aperiodic DTMC and the uniform distribution is invariant, meaning it solves the stationary equation $\pi = \pi P$. So it is the unique stationary distribution, and all initial distributions converge to it.
Comment: If we are in the uniform distribution, then taking one step by the top card method maintains this distribution. If $J\in\{1,...,52\}$ is the random card we place behind, you can condition on the event $\{J=j\}$ for $j \in \{1, ..., 52\}$, and the corresponding switch in positions $1\rightarrow j\rightarrow (j-1)\rightarrow (j-2)\rightarrow ...\rightarrow 2\rightarrow 1$. For each $j$, the conditional new distribution, given $J=j$, is still uniform. If $p$ is a permutation and $p'_j$ the unique permuatation that this shifts from (given $J=j$) then $P[New=p|J=j]=P[Old=p'_j]=1/52!$.
Comment: I added to my previous comment with some more detail. If you know $\{J=j\}$, there is a one-to-one correspondence between permutations $p\leftrightarrow p_j'$, meaning for every new permutation $p$ we shift into, there is only one unique previous permutation $p_j'$ that could have been the case (it is the one created by the inverse shift from $p$).
Comment: How do we know $\pi=\pi P$?
Comment: Maybe its obvious but I am struggling to see why the new distribution must be still uniform
Answer: There are $52!$ states in this discrete time Markov chain (DTMC),  one state for each permutation $p$. Let $X(t)$ be the permutation at time $t \in \{0, 1, 2, ...\}$. The DTMC can be shown to be irreducible (you can get from any state to any other state using the top card method). The DTMC is aperiodic because the top card method can take from the top and put back on the top (so it has a self-transition where $X(t+1)=X(t)$).
So this is an irreducible, aperiodic, finite-state DTMC.
So there is a unique probability mass vector that solves the stationary equation $\pi = \pi P$, and the limiting probability distribution is equal to this stationary distribution (regardless of the initial distribution).  It remains to show that the uniform distribution solves the stationary equation (so it must be the unique probability mass vector solution that is also the limiting steady state distribution).
Suppose we start in the uniform distribution, so
$$P[X(0)=q]=1/52! \quad \mbox{for all permutations $q$} \quad \mbox{ (Eq. 1)}$$ Let $p$ be a permutation. We have
$$P[X(1)=p] = \sum_{j=1}^{52}P[X(1)=p|J=j]P[J=j]$$
where $J$ is the random card we put the top card behind. It suffices to show $P[X(1)=p|J=j]=1/52!$ for all $j \in \{1, ..., 52\}$.
Note that the event $\{J=j\}$ creates the permutation shift:
$$ 1\rightarrow j \rightarrow (j-1) \rightarrow (j-2) \rightarrow ... \rightarrow 2 \rightarrow 1$$
Given $J=j$ and $X(1)=p$, we know $X(0)=p_j'$ for some unique permutation $p_j'$ that is obtained from the inverse shift. So
$$P[X(1)=p|J=j]=P[X(0)=p_j'|J=j] \overset{(a)}{=} P[X(0)=p_j'] \overset{(b)}{=} 1/52!$$
where step (a) holds because the random choice $J$ is made independently of the permutation at time $0$, that is, event $\{J=j\}$ is independent of the event $\{X(0)=p_j'\}$; step (b) holds by (Eq. 1).
Comment: I consider $n=52$ but the same holds for any positive integer $n$.


Work calculation in a thermodynamics cycle process

Question: To calculate work in a cyclic process (say Carnot cycle) we find area under p-v curve,or use net heat transfer= net work done.
Why won't we simply add work calculated in each process of a cycle,like in Carnot: W1 +W2 +w3 + w4
Comment: Q-W=change in U
Comment: Work is the the area *enclosed* by the P-V diagram. You can divide the closed path into segments any way you like. The sum of the segment integrals will equal the cyclic integral. That is the definition of a cyclic integral.
Answer:
Why won't we simply add work calculated in each process of a
cycle,like in Carnot: W1 + W2 + W3 + W4

We can (But you need to be careful in calling energy of each process as work, $W_1$ & $W_3$ as you call them are heats added and taken from the system not mechanical work).
You already answered your question, the net work of the Carnot cycle is the area enclosed under the $p-v$ curve.
$$ W_{net} = \oint_{\text{cycle}} P\ dV = \oint_{\text{cycle}} T\ dS$$
You can calculate the area under each process in $p-v$ diagram (some will be negative) and the sum will be the net work $W_{net} = Q_{in} - Q_{out}$ (enclosed in white in the following figure, but the axis are temperature and entropy, but you get the idea).


Why are SMD Diodes different Packages than Resistors and Capacitors?

Question: I was looking for SMD Schottky Diodes on Digikey, and they all come in weird packages like SOD-123. There were some that were 1206 or 0805, but they seem fairly rare. Why is this? The only difference is that diodes are polarized, but the diode packages are the same both ways except for the little mark on one end. It doesn't make any sense, and Kicad's module library, being woefully inadequate, doesn't seem to have the diode specific packages.
Comment: I suspect that some of these differences are historical, and they comes from differences in manufacturing processes.  Some dimensions were easier for screen printing, while others were easier for encapsulation in epoxy.
Answer: Diodes in resistor/capacitor style packages are relatively rare and usually far more expensive, which means they are going to stay rare.
Probably mostly historic and partly economic and partly technical. You can buy LEDs in 0603 and 1206 packages, so there is not a serious technical issue, but you probably want a good leadframe in place to allow the heat to be removed through the leads.
You'll find the same thing with tantalum electrolytic capacitors- some of them are available in 1206, 0805 etc. but they are very expensive and have low availability compared to the usual packages.
The usual advice given here is to learn to make your own footprints, usually the canned footprints are not 100% coverage of what you need and also not exactly what you would like them to be (such as the thickness of silk screen lines and such like).
Comment: What are relatively rare? Did OP change the question to make your first line not make sense?
Comment: Hopefully clarified.


Arduino pin 10 for PWM whilst SPI slave

Question: I need to use my Arduino Uno (ATmega328) as an SPI slave and have still have access to at least 5 PWM pins. The only issue is that this means I will have to use pin 10 (Slave select / PB2) as the fifth PWM pin because pin 11 (MOSI / PB3) is definitely not an option and it appears that the moment I initiate SPI in slave mode it stops PWMing pin 10 and simply turns it off. Would it be possible to somehow restore PWM access to this pin? I do not need this pin for slave select, I can rather use a plain IO and just attach and detach SPI upon interrupts from it thereby emulating slave select.
Comment: Or you could use programmed SPI instead of hardware SPI.
Comment: Programmed SPI and/or programmed PWM would both mess up the working of my specific application which cannot afford to stand of as many cycles.
Comment: Depends on what rates you need, but could use the standard digital pins for PWM https://code.google.com/p/rogue-code/wiki/SoftPWMLibraryDocumentation
Comment: You could still use OCR and OVF to trigger the ISRs for PWM.
Answer: The ATmega328p datasheet section 18.3.1 states

the Slave Select (SS) pin is always input.

where using the SPI in slave with out a SS would likely have issues with sync'ing the first bit of the data. Where if that is not a problem then I would suggest that perhaps a Leonardo would solve your problem. It has 8 PWM's, none on the SPI. Whereas its SPI SS is wired to the RXLED and not to a header. Otherwise the Mega would have all what you want.
Answer: The Hardware SPI module forces the use of the Assigned SS pin on slave mode.

The pin schematic shows that it is automatic, and cannot be overwritten, as long as the SPI module is in use.
See the ATMega328p data sheet, section 18.2 and 18.3.
You need a software SPI implementation.

Arduino pin 10 for PWM whilst SPI slave