Which elementary particles does light interact with?

Question: Other than electrons, does light interact with the other subatomic particles? Also, do different elementary particles behave differently when interacting with light (X-rays or gammas)? Can you say, for example, that this is an up quark and this is charm?
Answer: Light, at the level of particles which you are asking, is composed out of a confluence of photons. Photons are elementary particles in the standard model of particle physics. These particles are at the underlying level of all matter as we presently know it.

To first order, photons interact with the electromagnetic interaction with all charged particles in the table, and thus with all complex particles , atomic  and molecular entities that contain them. For example the neutron is neutral, but the quarks contain in it are charged thus there is a first order interaction.
Neutral elementary particles, other than the photon,  are the neutrino and the Higgs. There is no first order interaction for these neutral elementary particles.
But interactions of elementary particles go through higher order terms in the expansion for calculating the crossections. There exists photon-photon scattering whose crossection grows with energy. There also exists neutrino photon scattering through Z and W exchanges in higher order diagrams, this reaction is important for cosmological models.
Equivalently there exists a higgs boson  to two photon decay, so in cosmological studies the higher order diagrams would be again important.
So the answer to your question is:
Light interacts to first order ( higher crossections) with all charged elementary particles and through higher order diagrams with the neutral elementary particles.
Comment: Anna, if a photon hits a neutron, this will be a clear interaction with momentum transfer and perhaps a re-emission of a photon. Why not call it a first order interaction?
Comment: @HolgerFiedler  I have called it a first order interaction.
Comment: "For example the neutron is neutral, but the quarks contain in it are charged thus there is a first order interaction." My question was, why one need to say that neutron as a neutral particle interacts through its quarks. Do we really need this complication?
Comment: @HolgerFiedler if we want to write down a crossection calculation, yes.
Comment: @HolgerFiedler - if you don't, you get a contradiction: the "neutron" itself is neutral indeed, but it is not elementary. So the interaction has to be between a photon and a (now charged) quark.
Comment: @Frank Does the car hits the walker? No, never a car will hit a human, it was the bumper only. ;-)
Answer: All elementary particles with an electric charge interact with light. Uncharged particles don't interact with light.
Answer: Light, including everything from radio to gamma rays, only interacts with particles that have an electric charge. This is because light is the fluctuation of the electromagnetic field.
The most common result of interacting with a photon of light is a change of momentum (Compton scattering), so, all else being equal, there's little difference to what happens when a single particle is struck by a photon. The mass of the struck particle would affect the energy of the scattered photon, with larger mass particles taking less energy from the photon.
What determines more complex behavior (absorption, pair production, etc.) is the larger system to which the struck particle is bound--quarks in a hadron, electrons in an atom, etc.


Gravitational time delay and contraction of matter

Question: How can any matter contract to its Schwarzschild radius if gravitational time dilation clearly states that all clocks stop at that point. So any contraction any movement would stop. If that is so why all this talk about objects which can never form in the first place?
Comment: You must distinguish between the clocks of a distant observer and the clocks of observers falling in with the contracting matter. The former sees the gravitational redshift, the latter sees nothing unusual at all.
Comment: Related question http://physics.stackexchange.com/q/21319/
Comment: Also related: http://physics.stackexchange.com/q/48086/
Comment: That is of course true. Only I don't care much about others clocks but my own one. So it still stands as the question. From my and (hopefully) your frame of reference that contraction never reaches Rs. So why bother?
Comment: Apart from that it holds even true from any! distance to Rs because time delay is INFINITE at Rs and for any other R>Rs it is finite.
Answer: "Clocks stop" or "time stops" at the Schwarzschild radius only as seen by a far away observer.  Where the matter is falling in, if it were wearing a wristwatch, it'd still see one second go by every second.  Time continues as normal, and matter squeezes into the BH.
True, as seen by a far away observer, the matter will appear to shrink down to the Schwarzschild radius but slower and slower, all manner of light or other particles decreasing in energy (longer wavelengths, redshift)  but this appearance may be remedied easily: just go dive into that BH and see for yourself that time doesn't stop!
Comment: Of course time doesn't stop in relation to itself. I never told so. It stops for anyone who has any distance from Rs if matter has contracted to its Rs.
Comment: Whatever the point of view from a co-moving observer of the contracting matter. From our frame of reference and any other position away from the contracting matter that object will never reach its Rs. No singularity has ever formed in our Universe and none will ever do so. What is happening from the perspective of some body which clocks freeze is a quite philosophical question. He is in "suspended animation" like some cartoon character only he will never find out if the object doesn't evaporate.
Comment: Time doesn't stop neither at no point because no object ever reaches its Rs so there is no point where time dilation gets infinite. It is mathematically possible to move towards a point without ever reaching it. like for any second which passes you move 1/2 of the distance to the point. You will never reach it but always stay in motion!
Comment: OK LET MAKE IT SIMPLER. Lets say a star had a gravitational collapse 10years ago at lets say 2ly distance. coordinate systems can be freely translated from one frame of reference to another (I hope we agree on this one). Now you say for the in-falling matter would reach Rs from that point T(10years ago)+Tm right? Now translate me Tm into Te (where Te would be some time coordinate in our earthly time).


Cross-platform unicode support for Python command line tool

Question: I am working on a large command line tool, written for Python 2.6+ and supported for Windows, OS X and Linux. The target users are developers but it is also being auto-invoked by CI-systems etc. In the Windows environment, our tool runs in cmd.exe, but in the other OS's we allow whatever terminal the users have.
I would really like to add general unicode support to this tool, in particular to print non-ascii characters to the terminal. Python is in general pretty nice with unicode, but cmd.exe does not play well with my small tests due to some issue with the encoding. I can probably "get it to work" on Windows in some way, but can other encoding issues occur in other terminals? Do "most modern terminals" use utf-8 on GNU/Linux and OS X (or is it locale dependent?). Also, if an encoding mismatch occurs, will "most terminals" just output garbled chars, or will they actually crash? Is it in general possible to reliably determine the encoding used by the terminal?
Looking mainly for people who have attempted at implementing cross platform command line tools with unicode support. My goal with this question is to determine whether I can implement unicode support with little to moderate effort which works for the vast majority of our users.
Answer: We're using the code from https://stackoverflow.com/questions/878972/windows-cmd-encoding-change-causes-python-crash/3259271#3259271 whenever we run into problems on cmd.exe and windows. Linux seems to be utf-8, and the only problem we've seen there is when windows users' putty settings have been off. I don't know about OS X.
Can you implement unicode support with little to moderate effort? Yes and no. Plugging in the above code is very little effort and will work for most users, but users can change their terminal encoding and other tools aren't always Unicode Safe...


How to recreate this gradient in Illustrator?

Question:
Need to recreate this gradient in Illustrator. I tried the various gold/metallic gradients, but nothing close to this, and not as random.
Is it achiveable in any other software? Any ideas?
Thank you.
Answer: That's not a gradient It's a series of solid filled circles. You may be able to get close, but you won't be able to match the way color is dispersed.
I'd blur the image....

This way color shows more than the divisive circles.
Then sample the colors and build a gradient....
Comment: Thanks Scott. The attached is a vector and I tried picking the colours from each circle, but each solid fill shows as the gradient and not a solid colour. That is why I thought maybe there's some way of applying the gradient to a series of circles.
Comment: @Mdd7725 Oh there may be then. It looks like solid filled circles here. Especially because of how colors are dispersed. It *can't* be one gradient applied to all the circles. Maybe each circle is too subtle. If they all have the same gradient, can't you drag the gradient swatch from the **Gradient Panel** to the **Swatch Panel** to save it?
Answer: In Illustrator you can:
Make new swatches of the colours in your reference image.
Select your circles and make it a live paint object.
With the live paint group selected, use the bucket tool and your left right arrow keys to cycle through your swatches and fill your circles.
You can hold down your mouse button/stylus and draw across multiple circles to fill them with the same colour/swatch.
Answer: Since you say that you can pick up the gradient using Illustrator's eyedropper tool, I would draw a rectangle the size of your artboard and fill the rectangle with the gradient.
Then draw a second rectangle of the same size and fill it with white.
Now draw a circle on top of the white rectangle at the location of one of the circles in your sample image.  Select the white rectangle and the new circle, and use the pathfinder tool to "Exclude" or "Minus Front."
This creates a compound path, which causes Illustrator to treat the circles as if they were holes cut through the white rectangle, allowing the gradient-filled rectangle at the bottom of the stack to show through.
If you use the "Exclude" command, you can create all of the circles first, and use the Exclude tool on all of them at once. Make sure that all of the circles are on layers above the white rectangle, and that you select all of the circles AND the white rectangle before using the Exclude command.


Using a friend class vs. adding accessors for unit testing in C++?

Question: Is it better to add functions that return the internal state of an object for unit testing, as opposed to making the testing class a friend? - especially, when there is no use for the functions except for the case of unit testing.
Comment: Possible duplicate of [How do I test a class that has private methods, fields or inner classes?](https://stackoverflow.com/questions/34571/how-do-i-test-a-class-that-has-private-methods-fields-or-inner-classes)
Answer: Unit tests should 95% of the time only test the publicly exposed surface of a class.  If you're testing something under the covers, that's testing implementation details, which is inherently fragile, because you should be able to easily change implementation and still have the tests work.  Not only is it fragile, but you could also be tempted into testing things that aren't actually possible in planned usage scenarios, which is a waste of time.
If the point of the accessors you want to add is just to test whether the function had the desired effect, your class design may violate another principle, which is that a state-machine-like class should always make it clear what state its in, if that affects what happens when people interact with the class.  In that case, it'd be right to provide those read-only accessors.  If it doesn't affect the class's behavior, refer back to my previous bit about implementation details.
And as you rightly said, cluttering up the public surface of a class with unused stuff is also undesirable for its own reasons.
If I had to pick between accessors and friending in your case, I would choose friending, simply because you own your test and can change it in a pinch.  You may not own the code by the clown who finds a way to use your extra accessors, and then you'll be stuck.
Answer: I'll disagree with the accepted answer and instead recommend the use of a friend class.
Part of the state you are testing is probably specific to the implementation of your class; you're testing details that other code normally doesn't know about or care about and shouldn't rely on.  Public accessor functions make these implementation details part of the class's interface.  If the internal state you are testing is not part of the intended interface, it shouldn't be visible through public functions.  From a purist point of view you're stuck between two wrong answers, as friend classes are also technically part of the public interface.  In my mind the question becomes, which option is less likely to lead to poor coding choices down the road?  Going with a set of implementation-dependent public accessor functions will inadvertantly encourage an implementation-dependent conceptual model of the the class, leading to implementation-dependent use of the class.  A single friend class, appropriately named and documented, is less likely to be abused.
While in general I strongly agree with the recommendation to prefer accessor functions over direct access to member variables, I don't agree that this best practice applies to unit testing of implementation-dependent internal state.  A reasonable middle ground is to use private accessor functions to those pieces of state your unit test will care about, and be disciplined enough to use the accessor functions in your unit tests.  Just my opinion.
Answer: Using friend classes for unit testing is a perfectly legitimate and allows you to maintain encapsulation. You should not modify your classes public interface simply to make the class more testable. Think about it this way. What if you purchased a third party FTP library and you are trying to use it and it's public interface is cluttered with a bunch of methods you don't even need to know about simply because of unit tests! Even modifying a protected interface to compensate for unit tests is BAD. If I am inheriting from some class, I don't want to have to worry about what methods are useful to me and which ones are only there because of unit tests!!! Using friends classes for unit tests helps you maintain a simple, easier to use class interface; it helps to preserve encapsulation and abstraction!!!
I have heard the argument that using friend classes for unit testing is bad because the class under test should not be "tightly coupled" with its test class and it should not "know" anything about its test class. I do not buy this. It's a single line added to the top of the class:
friend class MyClassTest;
and now you can test your class any way you want!
Now I do agree that you should not use a friend class unless it is necessary. If you can test what needs testing without making it a friend, by all means do.  But if life gets difficult and using a friend class makes life easy again, use it!
Answer: I recommend using accessors rather than allowing access via public members or friend classes.
I don't think that using friend class actually gets you any benefits, and it has the potential to make your life a lot worse down the road. If your code is going to stay around for a long time there's a good chance that it might be used in ways that you don't anticipate. The access functions might be only used for testing now, but who knows what will happen in the future? Using accessors rather than providing direct access to variables gives you a lot more flexibility, and it has a very low cost.
The other argument is that using accessors rather than public members is a good habit. Developing good habits is an important skill as a programmer.
Comment: Yes, for two reasons: 1, it tells other programmers what you want them to be able to do with the data, and 2: the compiler can often optimize const functions that it could not without the const identifier.
Comment: Oh, yes, note that having a variable time and a function time() won't compile; most people have the actual variable with a trailing underscore like time_, and the accessor like time() { return time_; }
Comment: To  make sure I understand you, an accessor for the variable
double time;
I create would create:
double time() const;
Answer: How about making internal state "protected"?
And then do unittest using derived class.
Comment: protected has a worst encapsulation protection than friend. **Anyone** inheriting from your class would have legitimate access. And because you put them protected, you say this is indeed supported. At least, a friend class with a specific name `friend class MyObjectOnlyForTestingPurpose` will limit the access to ONE class with ONE specific name. . . All in all, it's like give the keys of your appartment to ONE friend, against giving the keys to everyone in your familiy (including the half brother of the husband of your daughter)
Answer: I think there needs to be a distinction between future-proofing the class by providing accessors to its users if it makes sense to do so, and improving testability. I'm also not a big fan of befriending classes for the sole purpose of testing as this introduces a tight coupling in a place where I prefer not to have it.
If the sole use of the accessors is to provide a way for the test cases to check internal state of the class, it normally doesn't make sense to expose them publicly. It also can tie down implementation details that you might wish to change later on but then find you can't because someone else is using said accessors.
My preferred solution for this would be to provide protected accessor functions to communicate clearly to the class's users that these are not part of the public interface. Your tests would then create a minimal derived class of the original which contains call-through stubs for the parent's functions but also makes the accessors public so you can make use of them in the test cases.
Comment: Wouldn't derived classes be considered clients/users of the class, just as much as clients/users of the public interface are?  Unless the only derived class is the unit testing stub, you've got the same problem as if you had made the accessors public - writers of derived classes can't tell which protected functions are OK to call and which should be used only for testing purposes.  If you change the test-related functions, you may break derived classes that didn't know not to use an accessor.


Where should I store a list of objects?

Question: I have a base class and two derived classes. I want to write and read objects of these classes to / from a file. I was thinking about virtual functions to write/read data, but I don't know where should I place these functions. In the base class? When I will be reading data from the file I will store pointers to objects in a vector, but I suppose I cannot have a vector of pointers to objects of a class in which this vector is declared. Could someone help me solve this problem? Thanks in advance for any advice.
Answer: When you write the objects to the file, you also have to store some information such that you know the type/class of the object when reading it in again later; Otherwise you will not know which of the derived classes to instantiate.
Once you have solved this, you can decide to store the objects where ever and in which way you want.
Answer: As far as I understand your problem, you have a base class and two derived classes. All of them you want to write and read from a file and you want to read more than one instance from this object at a time.
In my opinion you need a container class, which takes care of the reading and writing. This means you implement a class, which stores your instances in a vector and then can save them to the disk and read them again.
Saving different types of classes, which are inherited from the same base class, requires additionally that you add a type, which you have to check during the writing and the reading, to process the stored information correctly.

Where should I store a list of objects?


Shore caught crabs

Question: I caught 4 small shore crabs (green crabs) yesterday and took them home to eat. They were alive in the bag until I got home and I out them straight into the freezer (no cleaning or boiling etc). They are now frozen. I have read some articles about if you don't clean them etc and they die before you cook them, they become very poisonous. Can I still cook and eat them or are they now not edible?
Answer: From what I have found so far, Green Crabs (as found on the coasts of the US) are not usually considered good eating, although they are edible. The same species is considered an important food source in parts of Europe. I'm still trying to get reliable info to sort that out.
According to The Washington Department of Fish and Wildlife "Although most crabs are either alive or have been killed just prior to cooking, they certainly are safe to use if you know they are fresh, i.e., dead for only a few hours." But that source does not address freezing of live crabs. The Louisiana Seafood Bible - Crabs says that it's safe to freeze live Blue Crabs if you are sure that the were in fact alive when first put in the freezer. I can't find anything that specifically addresses the safety of frozen, uncleaned Green Crabs, but I also can't find anything that suggests that Green Crabs would be any different than Blue Crabs in that regard. At any rate, cooking and cleaning live or just killed crabs is definitely preferred for quality, regardless of the species.
If you're in the US (or anyplace other than the shores of the North-east Atlantic Ocean or Baltic Sea, for that matter), don't lose any sleep if it turns out that you harvested them for no good reason:

Carcinus maenas is a common littoral crab, and an important invasive species, listed among the 100 "world's worst alien invasive species". It is native to the north-east Atlantic Ocean and Baltic Sea, but has colonized similar habitats in Australia, South Africa, South America and both Atlantic and Pacific coasts of North America. It grows to a carapace width of 90 millimeters (3.5 in), and feeds on a variety of molluscs, worms and small crustaceans, potentially impacting a number of fisheries. Its successful dispersion has occurred via a variety of mechanisms, such as on ships' hulls, packing materials, bivalves moved for aquaculture, and rafting.

-Wiki
They're so invasive and detrimental where they don't belong that Massachusetts has paid for crab bounty hunters, and Washington and Oregon ask that any Green Crabs found be brought to Fish and Game authorities, so their invasion can be monitored and hopefully stemmed.

Shore caught crabs


How do I Dual-Enchant weapons effectively?

Question: I enchanted my sword with Absorb Health and Fire Damage, with relatively high charges and a Grand Soul Gem. But after a few swings, it has already lost it's charge. I've read that dual enchanting a weapon makes it have a smaller charge, so I'm wondering if it's really worth it to dual enchant a weapon, or, if there's a way around it.
Answer: When you dual enchant a weapon, each swing will trigger both its enchantments and both will drain its power. This is why your weapon lasts half as long.  Overall, you get the same amount of effect out of it- it's just focussed into fewer swings. It's the same tradeoff you make when you choose how much extra damage you add per swing.
To stop your weapon from burning out twice as fast, make each enchantment half as powerful per swing and you'll get the same number of total swings.
Alternatively, accept that you have a very powerful weapon that needs a lot of souls and make sure you have plenty of souls for it. Making Soul Trap one of your enchantments and carrying Azura's Star is an effective way of doing this.
Answer: You can reduce how much charge is used by using the correct Fortify spell school.  It is determined by the color of the weapon.
In your case, since both effects are destruction, you will want to get some fortify destruction to lower the charge use.
At fortify 100%, your weapon will not use any charges.


Hydrogen Emission vs Absorption Wavenumbers

Question: I am used to using the formula $ R_H (\frac{1}{n^2_{final}}-\frac{1}{n^2_{initial}}) $ to calculate the transition wavenumbers when an electron in a  Hydrogen atom emits a photon. Can you use the same formula to calculate the wavenumber when a electron absorbs a photon?
Comment: Do you mean emit/absorb an *electron*? If so, your question is easily answered: take $$1/n_{initial) = 0 and n_{final}$$ to be whatever PQN the electron was absorbed into.
Comment: @AravindSuresh no sorry I made a mistake, I mean when the electron absorbs/emits a photon, I suppose it doesn't matter if it's in Hydrogen apart from I've used the Rydberg constant for hydrogen.
Answer: Yes, the energy (and therefore the photon wavelength) required for the transition between two energy levels is independent of the "direction". One way to see this is observing absorption and emmision spectra of the hydrogen, where the position of the lines for both types is the same.
Comment: Thank you, so does this mean you would have a negative wavenumber? Or do you rearrange to make it positive?
Comment: You'd have to rearrange it, Maybe it's easier to visualize if you think of this equations in terms of energy rather than wavelengths: if you multiply both sides of the Rydberg equations by $hc$ you obtain $\Delta E = hcR_H (1/n_1^2-1/n_2^2)$. $\Delta E$ is the difference in energy between both levels, and its sign indicates if the transition requires or releases energy.


Bypassing proxy for loopback/locahost

Question: I am developing a web application where in I am running a webserver at localhost:3000 and my app is deployed on the same.
Access to this URL through a web browser works fine because there is an option in the browser to say that I want to bypass the proxy for localhost/127.0.0.1. If I don't use this , the request when routed through the proxy is blocked by the campus firewall(I am a student).
When I programmatically try to make requests to localhost/127.0.0.1, the firewall like above kicks in and I am served an error message. The same happens when I use
$ curl http://localhost:3000

Could you let me know how I can configure my system such that bypassing the proxy for localhost/127.0.0.1 works on a system wide scale rather than being an application specific setting(my web browser as mentioned above).
Answer: My module I was using to make this http request(https://github.com/intridea/oauth2) was picking up the proxy setting from the current shell environment. Setting the shell environment variables, http_proxy and HTTP_PROXY, to an empty string helped

Bypassing proxy for loopback/locahost


Why does the government have the burden of proof in equal protection cases?

Question: In US law strict scrutiny requires the government to prove there is a legitimate reason for any law which discriminates. Why is the burden of proof on the government and not the other way round?
Comment: Do you have a reference supporting the assertion that the burden of proof lies with the government?
Comment: Hi yes, from https://legal-dictionary.thefreedictionary.com/Strict+Scrutiny+Test
Answer: The premise of the question is unsound. See, e.g.,
Alexander v. Bozeman Motors, Inc., 2010 MT 135 (Montana Supreme Court 2010) which held (in support of the overwhelming majority rule) that statutes are presumed constitutional, and the party challenging a statute bears the burden of proving the statute unconstitutional beyond a reasonable doubt. The claimants in that case failed to meet their burden of proving § 39-71-413, Montana Code Annotated, was unconstitutional.
The burden of proof is generally on the ultimate merits and the burden of coming forth with evidence to establish a prima facie case are always on a party seeking relief.
Arguably, strict scrutiny could be seen as an affirmative defense to a constitutional violation, to which a different burden of proof applies and is placed on the state, but I do not have confidence that that question has a uniform resolution that follows that logic in all U.S. jurisdictions.
The strict scrutiny analysis generally comes into play only once the party challenging the statute has already established that the statute is subject to strict scrutiny because it violates a constitutional right beyond a reasonable doubt.
Then, the question is whether a state can overcome that showing, by providing some evidence and argument to show that it meets the strict scrutiny test, with the ultimate burden of proof usually still on the party seeking to invalidate the law. This is usually so even though the state must present some evidence that it met the strict scrutiny test in the first place in order to impose the obligation on the party seeking to invalidate the law to show beyond a reasonable doubt that the strict scrutiny test has not been met.
The statement at legal-dictionary.thefreedictionary.com/Strict+Scrutiny+Test about the state bearing the burden of proof in these cases is sloppy writing on the part of the legal dictionary definition writer from a legal dictionary not widely accepted as authoritative, that oversimplifies the analysis. It wouldn't be unusual for a full treatment of this issue that doesn't take shortcuts to take a dozen pages, rather than a sentence or two.
Comment: Thanks very much!


Unable to load Ubuntu after installing Windows

Question: I had Ubuntu 11.10 installed, I installed Windows 7 on another partition but now on booting I cant see dual boot options and Windows 7 is loaded.
How can I run Ubuntu now?
Comment: did you try `sudo update-grub`? May be after that try posting the contents of your `/boot/grub/grub.cfg` file so that we can know what is going on.
Answer: Your grub2 installation was removed from the MBR by the Windows installation.
Please follow the instructions in the Recovering Ubuntu After Installing Windows wiki page, the graphical method should restore your grub2 install that was over written by the Windows installation.

Insert your Ubuntu CD, reboot your computer and set it to boot from CD in the BIOS and boot into a live session. You can also use a LiveUSB if you have created one in the past.
Install and run Boot-Repair
After this, click "Recommended repair" and apply. If you are willing to use the advanced options, make sure you leave the "Reinstall GRUB" checkbox ticked.
  Now reboot your system. The usual GRUB boot menu should appear. If it does not, hold Left Shift while booting. You will be able to choose between Ubuntu and Windows.

The recovery method should detect both your new Windows and the Ubuntu install.
Answer: Is seems you have to reinstall grub as it was wiped after installing Windows 7. If I'm correct you will be looking for reinstalling grub 2. There seems to be some options for restoring grub 2 given on the ubuntu community help site: https://help.ubuntu.com/community/Grub2#Reinstalling_GRUB2
Answer: Re install GRUB. If you have a Ubuntu Live CD and you know the partition where Ubuntu is installed, then this blog post will help you for sure :-)
Restore Ubuntu after installing Windows
Answer: Windows 7 has its own boot manager which boots Windows, so when you install Windows 7 grub isn't avaible to load both operative systems, to solve this i'd use http://www.supergrubdisk.org/ , then you'll be able to get in ubuntu, upgrade your grub: sudo update-grub and this should fix your problem-


A hypothetical scenario for the formation of a black hole

Question: According to the definition of the concept of barycenter, the question arose for me as a mental experiment that if there were an ultra-heavy binary system such as two neutron stars so that the center of mass was outside the surface of two stars (such as the Sun and Jupiter). Given the definition of a black hole, and assuming that the total mass of the two neutron stars has passed a critical value, can we say that a black hole is formed at the point where the center of mass of this system is located?
Answer: No. The black hole will form in the volume with the greatest average density.
$r_s \propto M$ where $M$ is the mass inside $r_s$. Barycenter is irrelevant. What matters is density, which is a local quantity. Mass is only indirectly relevant, in that the more mass you have, the less density you need.
Since
$r_s = k_1 M$
and $M = |\rho| V$, where $|\rho|$ is average density within spherical volume $V$
and
$V = k_2 r^3$
we have
$|\rho| k_2 k_1^3 M^3 =  M$
$|\rho| = 1/(k_2k_1^3M^2) = k_3/M^2$
The black hole forms when the density inside a given spherical volume V becomes equal to a proportionality constant divided by the square of the mass inside the volume.
Dimensional analysis for a sanity check:
$k_2 = 4\pi/3$
$k_1 = 2G/c^2$
$k_3 = 3c^6/(32 \pi G^3)$
$c^6$ units: $m^6/s^6$
$G^3$ units: $m^9/kg^3s^6$
$c^6/(G^3M^2)$ units: $kg/m^3$
Those are density units, so I'm reasonably confident I haven't messed up.
Comment: Calculations for a flat space are not applicable to black holes. The volume $V$ inside the Schwarzschild radius $r_s$ is not $\dfrac{4}{3}\pi r_s^3$, but zero. The Schwarzschild radius is not a spatial radial distance to the origin (which is also zero), but a reduced circumference of the horizon. Geometry of a curved space is very different from the Euclidean.


Does a ball have a normal force exerted on it if the ball is thrown?

Question: I was working on a lab in class drawing Free Body Diagrams. The problem required we drew an FBD of a ball that is in the motion of being thrown. I drew a slightly diagonal line labelled Applied Force, a vertical line straight down labelled Gravity, and a line opposite of Gravity labelled Normal Force. I was told that there is no normal force at all in this situation, and that the only two forces are gravity and applied force. I was confused because I thought that the ball was being held up by the hand (acting as a surface) which provided a normal force while still being pushed by the hand in the positive direction resulting in an applied force. So in this situation, would the ball have any normal force at all acting on it?
Answer: Let's review what a normal force is.
Solid objects are characterized by an inability to occupy the same volume of space as other matter. The microscopic reasons for this behavior are very complicated, but the macroscopic result are simple to describe.
A normal force is the force that enforces the "no occupying the same volume" rule for solids and as such it always acts perpendicularly to the surface of contact and points pushes the two objects away from each other (this is a Newton's 3rd Law pair).
Somethings that are not characteristics of normal forces

They do not always point upward.
The do not always balance the weight of the object. Or even the vertical component of the weight. You get "balancing" for objects that are in equilibrium.

Now, on to your situation.

There is a contact force in the problem. It exists between the hand (or throwing mechanism whatever it is) and the ball. When you drew it on your FBD you labeled that (quite reasonably, BTW) as "applied force".
The ball is not in contact with a horizontal surface so there is no upward pointing contact force. The "normal force" that you drew was erroneous.
Comment: If I were to throw the ball underhand meaning that the palm of my hand is under the ball, would that qualify as a horizontal surface allowing me to draw the upward pointing contact force?
Comment: The "applied force" is the effect of the hand on the ball. It may include an upward component (it usually does), but there is no reason to break this into more than one force in your FBD.
Comment: So whether you classify the palm as a horizontal surface or not, if I did break the applied force into more than one force, which you said was pointless, would it still be erroneous, or rather correct and just overly-complicated?
Comment: @dsowders Free body diagrams are tools intended to help you apply Newton's Laws correctly and to communicate your understanding to others. Toward those ends the manner of drawing them is closely defined. I would have marked your drawing as incorrect to, because the point isn't to have an argument that "this drawing is defensible", but to learn to draw them in the usual form. There should be one vector associated with the hand because you were told what it was.
Answer: Don't forget that normal is a mathematical synonym for perpendicular.  There is a normal force in your problem; it is perpendicular to the palm of your hand.  That is, the applied force of throwing is the normal force due to your hand.
Calling the force "Applied" doesn't identify the agent of the source, or what kind of force it is (in this case, a compressive contact force).   Something similar can be said about centripetal force.
In my opinion, it is better to identify the agent  ("rope", "table", "earth", ...) or type of force  ("normal", "tension", "compression" ...), perhaps with a notation, something like "the applied force" near the label of the force.  Just my opinion for keeping things straight and clear.


Vortex Panel Method implementation

Question: I'm trying to understand and implement panel methods for a two-dimensional airfoil.
I haven't found yet a very detailed explanation on how to implement it, and there are  some things I don't' still understand.
Here it is how I would implement it, I know it is only one of many possible implementations, please let me know if it's correct and if it would work.
I need just to compute the velocity field data of an airfoil in a flow, so I think I can use only vortices, without the need of sources, sinks and doublets.
I describe the airfoil as a set of panels; then I place a vortex of unknown strength in the center of each panel. Then I create a system of equations to obtain the unknown strengths. I have to impose that the velocity field created by every vortex plus the flow has a zero component perpendicular to every panel, calculated at the center of the panel. Now I still need an extra condition, the Kutta condition, that states that the velocities above and below the trailing edge must be the same. So i obtain the unknown strengths by solving the system. But I have some doubts on the Kutta condition. Can I implement this condition just by imposing that the velocities are the same in the two control points that are the closest to the trailing edge?
And is it necessary to impose that the vortices in the lower airfoil edge rotate counterclockwise and those on the upper edge rotate clockwise, or it just results automatically from the solution of the system? Thank you.
Answer: I had worked on this problem and prepared a short report which might answer some of your questions. In chapter 1, both lifting and non-lifting configurations are described in the context of cylinder and an airfoil.
Here is the link to the report:
https://www.dropbox.com/s/zqiawtqrfapgbmf/report.pdf .
Eq. (1.26) needs to be implemented to ensure the boundary condition for no-penetration condition and for the Kutta condition, based on Eq. (1.27), you need to add another equation to enforce it. Hope you find it useful.
For implementing the Kutta condition, you may also refer slide 25-29 from this presentation: http://www.ltas-aea.ulg.ac.be/cms/uploads/Aerodynamics04.pdf.
Answer: A very good start is the book:
Low-Speed Aerodynamics by Joseph Katz and Allen Plotkin.
It describes a variety of panel methods for airfoils and wings,
and, best of all, it includes source code.

Vortex Panel Method implementation


Installing Ubuntu Linux over Windows XP

Question: My machine has Windows XP SP2 installed. I want to install Ubuntu Home Edition on it. Please let me know how should I proceed without disturbing Windows XP.
Answer: You can have both XP and Linux on the same disk, by using Linux as an application within Windows. This way, you don't disturb XP at all.
I suggest the Wubi linux distribution, since it's a variant of the very popular and easy to use Ubuntu Linux:
Wubi -- an officially supported Ubuntu installer for Windows
Comment: Simple great tool. I just installed and my Linux is up and running. I never used Linux in my 10 years of programming life and now realise how great it is.
Answer: The simplest way to check (and even use) Ubuntu installation on a USB Bootable system,
without disturbing the installed XP on it is to get a 4GB USB flash drive and install on it.

for minimum disruption use the bios boot menu (F8 or F12 at boot time) and select the USB to be booted.

when installing choose the 'Advanced' option to install on the USB instead of the hard-disk mbr (this will leave your hard-disk untouched).

I think a USB Harddisk will also do -- all you need is your platform (PC+BIOS) should be able to boot through it (else, things get a bit more complicated).
When you boot with the Ubuntu LiveCD, the first menu will allow you to install right from the LiveCD.
You can take this option to install to the pre-connected USB Harddisk.
As a safety measure (about the 'Advanced' part above) you could just unplug your XP harddisk cabling and leave the CD Drive wired along with the external USB harddisk to boot and install.
This will eliminate jeopardizing your XP installation.
If you are taking this last step too, you do not need to backup your XP (assuming you do not break the disk in the cable work involved) and, you can throwaway the Ubuntu installation without any impact to the XP later (just unplug the drive, format it, etc).
You can also easily boot with the drive connected using the BIOS boot menu.
Further, you can also boot this Ubuntu installation on any other PC that will allow you to boot through that USB drive!
I carry such an installed USB flash in my pocket as my default Ubuntu system.
USB Drive based Ubuntu installation is my preferred way of suggesting an Ubuntu try-out on any system.
Ubuntu LiveCD does not give the correct feel of an installed Ubuntu system.
And, other schemes of installing besides existing systems (like XP) tend to disrupt those installations (or, at least need space or new hard-disk setups).
Comment: Will a USB Hard Disk do? When I have downloaded Ubuntu installar, how to execute the setup?
Answer: As stated: install another hard drive and put Ubuntu on that.
If you're willing to disturb XP a little, you can use the Ubuntu installer to shrink the XP partition and install Ubuntu on the same hard disk.  It's actually very easy, just follow the prompts in the installer.
Note: ALWAYS back up before doing any kind of OS install!
Answer: Wubi (as mentioned by UK) is a very simple way. The downside is that it is inside the Windows partition so that if the Windows partition breaks and is inaccessible, then Ubuntu may fail too.
If you want Ubuntu as a dual boot, mainly as insurance- to know that you can get to your Windows files if Windows will not boot- then it is usually fairly easy. Lifehacker- dual boot has a guide for Windows 7 and Ubuntu, most of the information will apply to XP. Note that XP does not have a partitioning faciliity so you will need to use the GParted tool explained.
If you are looking to experiment and learn, then go with Wubu, or a Portable Ubuntu Lifehacker- Portable Ubuntu tutorial
Hope all this helps, if you need more info, shout up and let us know how far you get, what needs more explaining...

Installing Ubuntu Linux over Windows XP


how to solve #error : Must define a target architecture in wince mfc application?

Question: how to solve #error : Must define a target architecture in wince mfc application?i got to know that we need to use device header and libraries but how can i use that?
Answer: I think you need to globally define some macro like <code>_X86_</code> in the project options, but I'm not sure.
Comment: You'll also need to define `_M_IX86` to get past that warning, but there will be other problems after that.
Answer: Presumably, the error is because you're trying to build the application against the (desktop) Windows SDK. The easiest thing to do is to create a new "Win32 Smart Device" project and add your code to it.
Alternatively, check the "Compile for architecture" setting under project properties -> C/C++ and ensure that it is set for the appropriate architecture.
Comment: There Cody, I did it for him :)
Comment: Amazing, another accepted answer that isn't "useful". @Suri: I notice you've asked 63 questions but only given 20 upvotes. Seems like an odd ratio to me. Especially since you've accepted nearly 30 answers. I'm glad I was able to help solve your problem, but please take advantage of the mechanisms that are in place on this site.


Kohana 3.14 fails at unit testing with message class 'Kohana' not found

Question: I have a kohana website that works okay, and I started unit testing (retrospectively, I know it is not the best practice)
The first error I get and I cannot get rid of is quite puzzling:

Fatal error: Uncaught exception 'LogicException' with message 'Passed
  array does not specify an existing static method (class 'Kohana' not
  found)' in /Users/dananicula/Sites/mnib1/application/bootstrap.php:44

in bootstrap, line 44 is:
<code> spl_autoload_register(array('Kohana', 'auto_load'));
</code>
and class Kohana actualy exists in system/classes/kohana.php
Any hints? Opinions? Suggestions?
Thank you!
Answer: Seems like you have your own unittests without loading Kohana core class. Use native Unittest module as described here.


Learning Graph Algorithms

Question: In algorithms, I've mostly been self-taught and that's largely been fine. However, I'm having trouble grasping graph algorithns. I'm looking for some kind of reference that has concepts and actual code so I can not only learn the theory (which I usually do ok with) but also get a feel for how graphs are represented and manipulated in practice (what I usually have a harder time grasping). Can SO deliver? Anything from books, to links, to existing projects would be great as long as they have both concept and implementation.
This is language agnostic, but I'm most familiar with python and don't have much experience with FP.
Answer: Both of these are very good:

The Algorithm Design Manual
Algorithms in C++ Part 5: Graph Algorithms (Don't worry about the C++ bit, has pseudocode as well)

Free Stuff:

Chapter 5. Graphs and graph algorithms
Answer: Steve Yegge says this is a terrific book on algorithms that uses graphs extensively.
Answer: I learned a lot about graphs from the book linked below... it's one of my favorite books:

A Course in Combinatorics
by J. H. van Lint, R. M. Wilson
  Cambridge University Press ISBN 0
  521 00601 5
Comment: The following site also has some really cool animations which might help you understand graph algorithms: http://www.cs.sunysb.edu/~skiena/combinatorica/animations/
Answer: I would suggest that when you study any algorithms then don't think of coding it. Algorithms are totally mathematical and you must have the same attitude towards them. When you study something like Graph Spanner algorithm then don't think how to code it how to represent them. First appreciate why the algorithm is important and non-trivial. Then try some very trivial solutions and compare their complexity. Next see how optimal solutions look like and try to derive their properties. Use a paper and pen and not IDE, try to derive and prove lemmas and so on. Then finally see how you can write a pseudocode to solve the problem. If you do these things then you will develop an intimate relation with the algorithms and then you will find it is much easier to solve them since then you don't think while coding that why I am doing this.
Unfortunately due to tremendous demands for programmer the programmer of now days are not mathematician and they face problems in solving new problems. Programmer of earlier days such as Don Knuth, Mcarthy were mathematicians and good researchers. Hence programmer is now a days relatively cheap word compared to computer scientists.
Answer: Bellman–Ford algorithm:
Shortest path from Source to all other nodes in weighted directed graph even with -eve edge weight (not cycle). slower but versatile than Dijsktra.
Complexity: O(|V|.|E|)
BFS: Find path from one given vertex to other nodes in un-weighted un-directed graph.
Complexity: O(|V|+|E|). it is faster when you know vertices ahead and use appropriate data structure i.e FIFO Que for figuring out which vertex already processed than complexity can be reduced to O(|V|)
DFS: Find Shortest path from source to other nodes. in Tree and also in Graph. Graph may contain cycle which means a node could be visited again and again. so we can use boolean array to keep track of visited nodes. otherwise algorithm won't stop.
more over it look deeper and deeper and go as far to the end of branch in tree.
Complexity: O(|V|+|E|). and Complexity: O(|V|) space to store vertices.
Floyed Warshal Algorithm:
Find All pair shortest path in Directed unweighted graph with +eve, -eve (not cycle) edge weight. but it doesn't return details of the paths themselves.
it can be used to detect -eve weight cycle in graph. when it find one it terminates. it compare all possible path through graph between each pair of vertices . so it uses Dynamic approach not greedy approach.
Complexity: O(|V^3|)
Johnson's Algorithm: find all pair shortest path in directed weighted sparse graph when edge weight is +eve, -eve but not -eve cycle.
it first uses belman-ford algorithm to compute transformed graph from original graph. it removes -eve weight edges. then Dijkstra is applied to find paths.
Complexity: O(V^2 Log V + VE)
Dijkstra Algorithm:
the original version of this algorithm not uses Priority Que so Complexity is O(|V^2|) but a newer version uses this data structure so complexity becomes O(E+ V log V). and it is faster single source shortest path algorithm. it works by assigning a tentative weight to visited node and infinity to un-visited nodes for visited node look for its all not visited edges and select with minimum weight. and add it to path set.
Krushkal's Algorithm: to find MST where it finds an edge of least possible weight that connects any two tree in forest on un-directed, weighted graph.
this is greedy algorithm.
it also find Minimum Spanning Forest.
Complexity: O(E log V)
Prim's Algorithm: it finds subset of edges that form a tree on un-directed, weighted graph. but can't find MS Forest like Krushkal's Algorithm does.
Brouvka's Algorithm: Problem with this algorithm is that weights should be unique in graph. it find MST by examining each vertex then putting with smaller weight. this algorithm is parallel in nature but not faster than Prim's Algorithm.
Same Complexity as Krushkal's Algorithm.

Learning Graph Algorithms


Looking for most performant way to execute several similar WP queries within shortcodes

Question: I have a very data-driven website where each page contains several (5-10) shortcodes, each of which execute WP queries and display the results.
The queries are usually quite similar - I've added 3 examples of a var_dump of the WP query $args to this codeshare: https://codeshare.io/3AvRgv
I'm looking for a way to improve performance, and wonder if there's a better way of doing this than having a new WP_query every time.
For example could I set some query parameters in a custom field, run the query when the page loads, save the array of post_ids to a variable, and then modify them to suit? Would that help?
Any ideas welcome!
Comment: Maybe use the Query Monitor plugin to figure out whether your performance problems are DBMS-based?  And, if you can, try to add a persistent object cache to your tech stack.
Answer: I think, it would be hard to achieve this, on the PHP-side as there is not much to gain in how you execute the WP_Query, because it will still result in the same WP_Queries executing the same logic under the hood.
There is however "easy" performance to gain by either; not using WP_Query and for instance writing a more specific SQL query by using (e.g.) $wpdb (which in my experience still doesn't do a whole lot, depending of course on how many meta_queries are adding JOINS and using extra tables etc.), but the biggest gain would be to execute the query's themselves less, by e.g. caching their results.
But this is only a good idea depending on how quickly your data changes.
Since days of php7 versions and especially now with php8, the execution of php itself wouldn't be the bottleneck as much as in the past.
Although, WordPress in itself is not built on "modern" ideas or php, the biggest performance is lost in it's simple, but not very performance-friendly database structure.
Finally if you can't cache your data, or use $wpdb, the key would be in making your queries as simple as the wanted response allows them to be, and try to avoid meta_queries as much as possible.
Oh, and also, avoid ordering your posts by random.
I will add a little snippet below, I once wrote to explain why not, to some colleagues, it could be useful:
Further, if you really can only try and speed up the php code itself, try to use as many type-hinting, and strict type comparisons (=== instead of ==) as you can in your functions, this is often overlooked, because it is generally not promoted in the WordPress docs (because they want to be backwards-compatible as far as possible), but this makes the compiler have to do less work.
Another thing you could try is be as direct as possible. What I mean by this, is WordPress gives you a lot of wrapper functions which just wrap around other code, which might be harder to understand, or performing extra checks. If you look at the get_posts() function it checks a lot of conditions, which eventually lead to the creation of a new WP_Query instance, where if you would create that yourself you could skip a bunch of checks (If you are using wp functions, try to take a look at what they do, and if you can replicate that in a simpler manner).
But once again, I don't think the performance gains, in writing faster code would be consistent and substantial enough.
If you want to make a function to "generate" your similar WP_Queries faster, do consider that your code for creating the WP_Query is probably for php 10% of the work opposed to the 90% of work that is triggered by the WP_Query class itself, so I think the key would be in caching and re-using retrieved data where you can and also to keep your queries as simple as possible.
The snippet (do note that these results where not really consistent or substantial):
   /**
     * Get a random post ID from wpdb or, when passed, a random ID of a post which meets the requirements.
     *
     */
    function sb_get_random_post_id(string $post_type = null, string $post_status = 'publish'): int
    {
        global $wpdb;

        $query           = "SELECT ID FROM {$wpdb->prefix}posts WHERE post_status = '%s' ";
        $query_arguments = [$post_status];

        if ($post_type) {
            $query             .= "AND post_type = '%s' ";
            $query_arguments[] = $post_type;
        }

        $prepared_statement = $wpdb->prepare($query, ...$query_arguments);
        $postID             = $wpdb->get_var($prepared_statement);

        return (int) $postID;
    }

    /**
     * Get a random post or, a random post within the defined parameters.
     */
    function sb_get_random_post(string $post_type = null, string $post_status = 'publish'): ?\WP_Post
    {
        $random_id = sb_get_random_post_id($post_type, $post_status);

        return \get_post($random_id);
    }

    /**
     * Random post
     */
    $random_post = sb_get_random_post();

    /**
     * Random Woocommerce Order, shop_order uses defferent statusses so one with status 'publish' wouldn't exist.
     */
    $random_completed_wc_order = sb_get_random_post('shop_order', 'wc-completed');

    /**
     * Why would you go this length?
     * Here's a function using WP_Query
     *
     * When timing sb_get_random_post() vs get_random_query_post() the results are:
     * sb_get_random_post:    0.004508972167968
     * get_random_query_post: 0.011613130569458

     * random_query_post executes one db query and takes almost three times as long as our function which executes two
     * queries because it first queries our ID and effectively has to run a second query when get_post($random_id) is called.
     * Just imagine that a wordpress page load does up till 100+ queries on average, which will cause every page load to
     * take seconds.
     */
    function get_random_query_post(string $post_type = null, string $post_status = 'publish')
    {
        $args = [
            'post_status'    => $post_status,
            'posts_per_page' => 1,
            'order'          => 'rand',
            'orderby'        => 'ID',
        ];

        $query = new \WP_Query($args);
        return $query->get_posts();
    }


How do I backup a windows azure virtual machine?

Question: How do I backup a windows azure virtual machine? I would like to schedule daily backups of system state that could be restored if needed. Data can be backed via Azure Backup, but not system it seems.
Answer: If you're talking about backing up the vhd of the virtual machine, you can:

Create periodic blob snapshots (since the vhd is stored in a Windows Azure Storage blob). Initially snapshots don't really take up any space since they're effectively an index of storage pages. Over time, if these pages change, then the snapshot(s) grow in size. You can create as many snapshots as you want, but you'll need to purge them over time to avoid storage growth as your vhd changes.
Create blob copies. This is a complete copy of the vhd, unlike the snapshot. And you can make copies across storage accounts (or even across data centers).

Regarding the snapshots: You can create a brand new blob from a snapshot, which you may find convenient at times.
Regarding the blob-copies: The one challenge you might run into, when making a blob copy: If the source changes during the copy, the copy will fail. So for an OS vhd, this operation should only be done if the Virtual Machine is in a stopped state. You may find snapshots to be the better mechanism in this case.
There's really no Azure-specific mechanism for things like system restore points, as that's within the OS itself.
Answer: There is a service in preview, called Azure Recovery services. With it, you can take backup of your Azure VMs as well as your local VMs, to the cloud. It looks pretty similar to the built-in Windows Backup
http://www.windowsazure.com/en-us/documentation/services/recovery-services/
Answer: This is a nice tutorial complementing David's answer: Create Backups of Virtual Machines in Windows Azure by using PowerShell
You can backup AzureOSDisk and AzureDataDisk in four steps:

Select virtual machine to back up
Identify virtual hard disks
Create cloud storage container for storing backups
Back up virtual machines in Windows Azure to cloud storage
Answer: There are recent new features around using Azure for backup, including the ability to directly back up an existing VM in Azure - https://azure.microsoft.com/en-us/documentation/articles/backup-azure-vms/
Answer: As of March 2016, the ability to protect ARM VMs with Azure Backup is now in public preview. You can find more information at  https://azure.microsoft.com/en-us/documentation/articles/backup-azure-vms-first-look-arm/


How is the proof of work actually proved in the mining pool?

Question: When mining Bitcoin in a mining pool, we share the coin for percentage of the work we have contributed.  But how is the work "proved".  For example, if the mining software reported "it has done 1G hashes", how is it proved that the 1G hashes are actually done?
Answer: When a pool issues work to a miner, it is typically for a lower difficulty than the network difficulty. This allows the miner to solve a block header for the lower difficulty and submit it to the pool. These submitted headers are known as shares.
Even though most shares will not be valid for the network, having miners submit shares allows the pool to track how the individual miners are performing. Pools will pay their miners proportionally to the number of shares submitted, with some caveats (usually it isn't exactly proportional, there are various caps and other things calculations done, but in the end, the proportion of shares submitted is the major factor in the payout calculation).
Comment: by what if the miner reported he has done all those hashes, but in reality he did not?
Comment: @deeper-understanding Since the hashes must be valid (they must satisfy the PoW requirements), that is not possible without doing the work. Miners are not just submitting hashes, they are also submitting the data that they hashed.


Two checkers on a 3x3 board

Question: Imagine this  Now, the first case describes how you can connect the two points. You are only allowed to connect them vertically or horizontally, not diagonally. Is this possible for the second scenario? Please explain your answer.
Comment: isn't it just up right right? pretty sure it's not but i'm not understanding the question
Comment: I am not sure, whether I get the intent of the qeustion, but it is not possible to visit all the squares exactly once in the second case.
Comment: if what peter said was correct, you can't because once you go to the squares to the top or the bottom of the destination you are trapped.
Answer: McLinux: Please edit your question to explain that the path has to visit all the squares, and each exactly once.
Not possible in Case 2. With the exception of the dotted squares, every other square must be entered once and exited once. In particular, the path must use both "walls" of every corner square. Now look at the corners on the right side: both walls that separate them from the dotted square must be used. Which means the path to the right-side dot must come from BOTH corners on the right side. Contradiction.
Answer: Color the squares in a checkerboard pattern - black, white. Two squares that share a common edge are colored differently. Now, if there is a path that visits all squares, moving from square to square only through the edges, starting from on point and ending at the other, then a necessary condition for such path to exist is that both points are on squares that are colored the same way.
Now a path that goes through all squares should go from black to white to black... (order the sequence in a linear order). Then the path should have the number of black and white squares equal to the number of black and white squares from the board. So if one starts from black, it cannot end at white. If you add the numbers, you'll see they do not add up. If you start from black and end up at white, then the total number of squares should be even (because next to each black there is a white square forward). But the number of the squares on the board is odd.
Now if one corner square is black, then all corner squares are black. If one starts from a white square the end should be white too by the above argument. But then the number of white squares in a path is more than the number of black squares. But these are the same squares from the board, on which the number of black squares is larger than the white. So there is no path between white-white. Basically, we cannot start or end at a white vertex. It has to be black
Comment: That is a necessary condition, but not a sufficient one. Suppose for definiteness that the corner squares are black. Then there exists such a path for all choices of black start- and end-points, but not for any choice of white start- and end-points.
Comment: @TonyK Man, I really didn't feel like going too much into detail for this question. But I edited my answer to accommodate your correct observation.
Answer: The only way you can visit all the squares is to roll the checkerboard and make a cylinder then follow the path in this drawing below:

Two checkers on a 3x3 board


If the Pope were to commit suicide would he go to hell?

Question: This question may sound rude but, if someone as holy as the pope were to commit suicide would he go to hell? Considering his devotion to god wouldn't he get some sort of pass? I think someone who gives up on life's desires and focuses on spreading faith shouldn't be sent to hell. And again if this is insulting then I apologize. I used the Pope for my question because I believe that one who holds the    position of Pope would be extremely devoted and most likely the most devoted.
Comment: Suicides are not an automatic ticket to Hell in the Catholic Church. Mental health or any number of issues come into play. This is true even for a pope. God's mercy extends to all mankind.
Comment: I think the questioner would be satisfied with an answer stating that "The pope would suffer the same fate as any other person in the same circumstances", which I believe to be true but I'm not certain enough to make it an answer.
Comment: An hypothetical question can only be answered with an opinion-based response, which is off-topic on this site.
Comment: Not, I believe, a hypothetical any more than "if a person commits a mortal sin do they go to hell".
Comment: @NigelJ   CCC 2279-2282, and 2325 have some coverage of the topic.
Comment: @NigelJ Short attention span answer is at 2325 *Suicide is seriously contrary to justice, hope, and charity. It is forbidden by the fifth commandment*  CCC 2279-2282 provide a bit more depth.
Answer: The Pope does not get special treatment in spiritual matters such as Heaven, Hell and Judgement.
In other words, if you ask "Would the Pope go to hell if he did this?" the answer will always be the same as "Would a person go to Hell if he/she did this?", assuming other circumstances are the same.
As Ken Graham points out, suicide does not automatically send one to Hell, so there are other factors to consider. Those factors would be exactly the same as for someone who was not the Pope.
Comment: Would James 3:1 not come into play here?
Comment: @Kris No because they are separate matters.


Downloading programs from Microcontrollers?

Question: So I'm trying to reverse-engineer a small PCB which has an ATMEGA48-15AT1 microcontroller on it. My question is, can a program, on said microcontroller, be downloaded and read as the C# code that its programmed in (e.g. through AtmelStudio) ?
Answer: An AtMega is likely to be programmed in C or C++, not C#.
In most cases the vendor of a product will enable 'read-protection' on such a chip, exactly to prevent what you are trying to do. If he forgot to do so, you can read out the chip with a small hardware device called a programmer.
If you could read out the chip (download the firmware) you would get what is stored in the (flash program and eeprom data) memory. That is equivalent to the machine code, or call it assembler code, without any hints to the structure or meaning of it.
A clever programmer could re-engineer something that resembles the original source code from the machine code, but the effort will be comparable to or even larger than the original effort of writing the code.
Comment: Ahh, okay. Yeah I thought it would be silly to expect the program not to be in machine code when downloaded from the memory. Thanks for the info.


When monsters are generated, is Monster Level affected by current XL or max XL acheived?

Question: My character is currently at XL17 (max so far), and I'm letting a wraith drain me prior to buying protection. I've completed my Quest, so no longer need to be at any particular level. Knowing that XL affects ML, I'm wondering if there's any benefit from lowering my level permanently, or if the previously achieved level dictates? Also, will DL eventually over-rule all of this? I'm wondering this because I haven't foud a genocide scroll and have terrible luck with the nasties.
Answer:
On the way down, a Monster is selected with a difficulty that ranges from (Dungeon Level / 6) to ( (Dungeon Level + Player Level)/2 ).  Once you've hit the sanctum, just assume that you're Dungeon level is pegged there.
When a monster of appropriate difficulty is selected it's Level (base Hit Die) is then modified based on Dungeon Level (-1 or +1/5 the level difference) and your Level (+1/4 the level difference).

For example, let's say you've found the castle on DL27.

Minimum Difficulty is 5:  Killer Bees, Gnomish Wizards and the like.
Maximum Difficulty for a L1 Character is 14:  Lich, Vampire Lord, Disenchanter...
Maximum Difficulty for a L17 Character is 22:  Krackon, Mastadon, Iron Golem...
For the L17 Character any Killer Bees or Gnomish Wizards will get a boost of 3HD more than the L1 Character.

Personally I'd rather have the extra 16 Levels worth of Hit points, +16 to-Hit, Skill points enough to max out my favorite Melee & Ranged weapons with enough left over for "Skilled" in a couple of other abilities.  At Level 17, "Skilled" in a school gives "easy" casting of spell level 5.
This means that by artificially limiting your own experience level you can have some effect on Monster Difficulty and Hit Dice.  Unfortunately, taken to extremes, this also allows you to be regularly outclassed by the Monsters you encounter.  You'll also notice that the highest difficulty baddies in the game are not randomly generated, but standing around waiting for you, and showing up at Experience Level 1 won't rob them of a single Hit Die.
Comment: So, you're saying....it's using CURRENT level?  This character as HP(dnurses, potions too), AC and accuracy/strength, tryin a novel tack to let my pets levelup, and maybe ascend  XL1 from 1st entry to Valley.
Comment: @slowball16 Yes, I'm saying the calculations use your current level.  I'm also saying that being under leveled your current game stage will not keep you from seeing the most "difficult" monsters, and that Monsters will not have their default Hit Dice reduced to compensate for wimps.  Just look at the difficulty table I've linked to, and you'll see that, by the sanctum, you'll be generating everything but newts, gnomes and the like anyway.
Answer: From the source code (makemon.c):
<code>zlevel = level_difficulty();
/* determine the level of the weakest monster to make. */
minmlev = zlevel / 6;
/* determine the level of the strongest monster to make. */
maxmlev = (zlevel + u.ulevel) / 2;
</code>
In plain English, monsters are generated with a difficulty between one-sixth the "zlevel", and the average of the "zlevel" and your current experience level.
"Zlevel" is a bit difficult to define.  It's essentially:

If you're in the elemental planes, it's the full depth of the main dungeon plus Gehennom, plus one-half your current experience level.
If you've got the amulet, it's the depth of the deepest dungeon level you've reached.
If you're in a branch of the dungeon that grows upwards, it's the depth of the branch entrance, plus the number of levels you've gone in the branch.
Otherwise, it's the depth of the current level.

Yes, reducing your experience level will make the monsters easier.  However, it doesn't make them much easier: the minimum monster difficulty is unaffected, and past dungeon level 30 (the shallow part of Gehennom), depth is the dominant factor even for someone who's been power-leveling.
In the endgame, it would seem like keeping your experience level low would be a good idea: since your experience is factored in twice, the formulas give a difficulty range of 11 to 49 for a level 30 player, versus 8 to 26 for a level 1 player.  However, apart from arch-liches (29) and archons (26), the most difficult randomly-generated monsters in the game are level 22.


Can a USB drive be tracked?

Question: If I had a specific USB and I plugged it into one computer to download something and then plugged it into another computer to download more files/view the files/etc., would there be some kind of record that it was that specific USB plugged into both computers? If someone really wanted to know where that USB has gone, could they somehow find a way to figure out every device that USB has been plugged into?
Answer: There is no "default" tracking in most computers, however it is perfectly possible for the host filesystem/OS to write some form of metadata for tracking. If a drive is plugged into the same system multiple times, there is a record of it being plugged in (in kernel/udev logs for Linux and in the registry for Windows, however that's not cross-system.

Can a USB drive be tracked?


Learning programs for Kids

Question: I am installing Ubuntu in 2 schools that hold at least 1000 kids and wanted to know what programs are available in Ubuntu to teach this Kids. This kids range from ages 4 to 13. Programs that help in math, science, drawing and chemistry would be very good.
Comment: I wish to make this a community question since all answers here a perfect.
Comment: Great to see community outreach with Ubuntu! :-)
Answer: Go to the Ubuntu Software Center, Click on Education on the left side, and browse a list of educational programs.  I have most of which installed ( specially the ones listed below)on my kids machine, and they love it.

Educational suite GCompris
Childsplay
Primary Bundle
Answer: Edubuntu is the educational distribution of Ubuntu.
Answer: I would recommend using Edubuntu. You may do this by either downloading and installing the full distro, or getting any or all of the following packages(and recommends/dependencies thereof) and installing upon existing, well-customized (for stability, security, drivers, etc) Ubuntu installations, and removing previous desktop environment choices:
<code>edubuntu-desktop
ubuntu-edu-preschool
ubuntu-edu-primary
ubuntu-edu-secondary
ubuntu-edu-tertiary
</code>
Or any other packages listed here.
Answer: You should Try Tux4Kids
This is a big hit with my children and it has 3 main elements. These are all available from the Ubuntu Software Centre.  The interesting thing is that as the children grow so does the level of difficuly.
**

Tux Maths
Tux Typing
Tux Paint

**
Quote below from their website which you can access here  You will be able to see screen shots etc

Tux4Kids develops high-quality software for kids, with the goal of
  combining fun and learning into an irresistable package. Our software
  is free: you can download it for use at home or onto hundreds of
  computers in a school. We support all major platforms, including
  Windows, Macintosh, and Linux/Unix. Our programs are used by people
  around the globe, and they have been translated into dozens of
  different languages. As open-source software, these programs can be
  freely extended or customized, and they are supported by active
  communities of volunteer developers.
Answer: KDEdu
is another project worth looking at for the size of your Project. It covers all your bases and a lot more besides.  Floss based on the KDE technologies: students, parents, children, teachers, adults, can freely use it, copy it, and modify.  I have used many of the applications (not all) with great success.
You can access their website here
Most of the applications are available all Linux distros in their respective Software centres, including Ubuntu that I am aware of and rather than list them here is a screen shot of all the titles

Learning programs for Kids


Apple.ca accepts answer, Apple ID app/ iCloud doesn't?

Question: how can Apple.ca accept my answers for security questions but when I type them into the set up for iCloud their wrong?? They are each 3 letter words, so spelling & capatlization wouldn't be a. Problem :( I forgot.ca doesn't help either
Answer: If one web app works and another doesn't you would probably need to contact support to determine if the problem is with your account or with Apple's infrastructure.
Also, you will want to be sure you are really connecting to Apple sites (some computers and networks are compromised by malicious software). If you are connecting to a site that is imitating / designed to look like Apple's, that could explain the acceptance of your answers as it would actually be collecting your account details.

https://support.apple.com/en-us/HT204759 - phishing / verified Apple websites
https://support.apple.com/en-us/HT201487 - change back your actual password

In that case the "fake" approves your transaction to get you to keep trying all passwords you might reuse and then when you try a legitimate Apple site you are either locked out or the malicious people/software may have changed your password.


Does Enduring Agony increases the damage of bleeding and poison?

Question: I know that Enduring Agony (finesse ability) increases the duration of poison and bleeding but does it increase their damage as well?
Comment: Increasing the duration *results* in an increase in damage, just not an increase in damage per second.
Comment: @RavenDreamer Ok wait there is something i don't get here,when you lets say have a weapon with 10 poison damage over 5 seconds,would that mean that it deals 10 poison damage every second for 5 seconds,or does it means it deals only 10 damage through those 5 seconds?Because the game does say "10 poison damage over 5 seconds" which made me think it takes 5 seconds to deal that 10 damage,which would then mean that if you extend the duration of the poison you would actually make it weaker by increasing the time it takes to reach that damage of 10.
Comment: The games has to store damage and time separately, because they're two different stats on the random gear. Divide the damage by the time to get the damage per *tick*.  When you later increase the duration via Enduring Agony, you're effectively adding "ticks" to the DoT, not altering the underlying mechanic.
Comment: @RavenDreamer Which means that by extending the duration of poison it takes longer to deal the full damage,which actually makes it weaker,unless i missed something again in your explanation.
Comment: @RavenDreamer Nevermind i get it now,at least i think i do.Put up everything you said in your comments and post it as answer and i'll mark it as accepted.
Answer: It only increases the duration, but it does increase the damage of Shadow Flare (Reference). It basically buffs two different attacks in one skill.

+20% Bleeding and Poison duration, +10% Shadow Flare Damage
+30% Bleeding and Poison duration, +20% Shadow Flare Damage
+40% Bleeding and Poison duration, +30% Shadow Flare Damage
+55% Bleeding and Poison duration, +40% Shadow Flare Damage
+70% Bleeding and Poison duration, +50% Shadow Flare Damage
Comment: I was wondering if it was a debuff that increases the duration of bleeds and poisons applied in the future or if it strictly extends the duration of currently active (previously applied) bleeds and poisons. ?
Answer: I think it increases the status effect of poison and bleeding. Poison weakens your opponents damage and bleeding weakens their defense. So this would increase HOW LONG their stats are weakened. Its the only thing that really makes any sense.
Answer: I'm sure you've figured it out by now, but I'll answer if only to provide one clear answer, combining all the information.
Enduring Agony does not increase the damage per second of bleeding and poison abilities, but it does increase their duration which effectively increases their damage by extending the duration of the DPS effect. For example, an effect of 10 poison damage over 5 seconds is a DPS of 2 damage/second for a total of 10 damage over 5 seconds, but with 1 level in Enduring Agony, the effect lasts 6 seconds (5 * 1.2 = 6), thus dealing 12 damage over 6 seconds. An additional 2 points in this example would yield 14 damage over 7 seconds, etc. It's not going to make or break the amount of damage you deal as the numbers are usually so small.
The more useful aspect is that by increasing the poison and bleeding effect duration, the weakening of the opponent's damage dealt caused by the poison effect and the weakening of the opponent's defense by bleeding are also extended. By extending the bleeding effect, you also extend the window to do more damage with other attacks, leading to a further improvement in damage.
Additionally Enduring Agony also increase the damage of Shadow Flare which, while not devastating towards the end of the game, it also causes a bleed effect and can still be marginally useful against big enemies if all 5 blades hit and can be good if you need to stun some enemies quickly.


How can I know what kind of App I am in?

Question: Is there a way for a user to find out what kind of app she/he is using once already inside? Say a SharePoint 2013 user is inside of a Custom List.
How would this user know if she was using a Custom List instead of a Task List?
Thanks
Answer: If you open an ítem with Display Form you can find the section "Content Type: Task" just above created and modifided data.
Comment: I don't think that's really reliable.  What if you create a custom list and add the Task content type to it, then create an item of type Task?
Comment: Good point ....
Comment: What do you mean by the word legend?
Answer: There is way to find programtically, you can get list object and use below method to get base template id...
oListItem.get_baseTemplate()

Refer below link for your detailed reference...
Get List Template ID JavaScript
Answer: To answer your question, no this is only displayed from what sort of tile an app gets before you are go into it.
I would inform the users that they can review this on the site contents page to learn about what sort of app was used to create the list/library they are using. The ribbon options can also be a clue to users if there in a list or library but they type isn't easy to figure out without looking at the tile.
App Tile Examples:
From left to right: Custom list, Document Library, Calendar, Links list, Task List, Discussion board. (etc.)
Answer: You can find it from ctx. I believe you are familiar with ctx. If you are not familiar with ctx, then have a look over here. Now write few lines of code and it to you master page.
(function () {

    // Al list templates
    var listTemplates = [{
        "name": "Document Library",
        "listTemplate": 101
    }, {
        "name": "Form Library",
        "listTemplate": 115
    }, {
        "name": "Wiki Page Library",
        "listTemplate": 119
    }, {
        "name": "Picture Library",
        "listTemplate": 109
    }, {
        "name": "Links",
        "listTemplate": 103
    }, {
        "name": "Announcements",
        "listTemplate": 104
    }, {
        "name": "Contacts",
        "listTemplate": 105
    }, {
        "name": "Calendar",
        "listTemplate": 106
    }, {
        "name": "Promoted Links",
        "listTemplate": 170
    }, {
        "name": "Discussion Board",
        "listTemplate": 108
    }, {
        "name": "Tasks",
        "listTemplate": 171
    }, {
        "name": "Issue Tracking",
        "listTemplate": 1100
    }, {
        "name": "Custom List",
        "listTemplate": 100
    }, {
        "name": "Custom List in Datasheet View",
        "listTemplate": 120
    }, {
        "name": "External List",
        "listTemplate": 600
    }, {
        "name": "Survey",
        "listTemplate": 102
    }, {
        "name": "Asset Library",
        "listTemplate": 851
    }, {
        "name": "Data Connection Library",
        "listTemplate": 130
    }, {
        "name": "Report Library",
        "listTemplate": 433
    }, {
        "name": "Access App",
        "listTemplate": 3100
    }];

    // find current list

    var currentList = listTemplates.find(function (item) {
        return item.listTemplate == ctx.listTemplate;
    });

    if (currentList) {
        alert(currentList.name);
    } else {
        alert("Unable to find.");
    }
})();

ctx.listTemplate returns the current list's template. listTemplates has all lists name & template information. So I am just finding current list's information based on ctx.listTemplate.
Find all list templates in MSDN.


Do SVM's find the minimal number of support vectors in the case of redundancy?

Question: Consider the case where more than the minimal number of vectors lie on the lines (or hyperplanes in higher dimensions) defined by the margin found by the SVM algorithm. For example, see the image below where a third redundant vector lies on the margin. Do we have any guarantees on the selection of support vectors in this case? For example, will all three points be stored as support vectors or just the minimal number necessary? If it's the former, is there any structure in their associated dual coefficients?
Answer: No, quite often you end up with redundant support vectors that lie on the margin, but the decision surface can be constructed with only a subset of the identified support vectors.  The example you give with three co-linear support vectors is a good example of that.  Vapnik gave a name to the support vectors without which you can't construct the decision surface, but I can't remember what it is off hand.
Whether the training algorithm will identify all of the support vectors or just those necessary to represent the decision surface is likely to vary from one algorithm to another.  In this example, an algorithm that is based on identifying the closest points between convex hulls of the examples belonging to each class may well only identify two of the three support vectors.  One based on Sequential Minimal Optimisation would probably depend on the way it identifies the next dual parameter to optimise, and something like interior point may identify all three?
Comment: Please do add to the answer if you remember the name for such support vectors, it would be interesting to know their name. So from my reading of your answer there does exist a method by which you could keep only the minimal number of support vectors without much additional overhead?


How to calculate the projected area at different angles/vectors?

Question: Please help me with the following. I want to know if there is an equation/set of equations to find out the projected area of a (3-D) cube when it is oriented at different angles of attack to the fluid flow, rendering the velocity vector of the impinging fluid on the cube surface to change with each angle of attack. In particular, what is the projected  area when the cube is oriented at such an angle that the flow velocity vector passes through one of the vertex and the geometric centre of the cube? Thanks.
Comment: Which hydrodynamic problem are You going to calculate? There are few which can be solved with such a precision to need exact projected area. In practice one regularly just takes the diameter of "equivalent sphere".
Answer: The projected area is $\sqrt{3} \ l^2$
Imagine the long diagonal of a  cube.  This diagonal is the same direction as the velocity vector you're interested in.
The length of the diagonal is $\sqrt{3}l$, with $l$ the side length of the cube.  This come from the Pythagorean Theorem.
If we project this diagonal onto a side, we get simply $l$.  Therefore, the projection operation at this angle divides by $\sqrt 3$.
The cube has three faces exposed to a fluid flowing coming in from the direction of the long diagonal, each with area $l^2$.  Each of these is projected onto the plane perpendicular to the fluid flow, so the projected area is $(3/\sqrt{3})\ l^2 = \sqrt{3} \ l^2$.
Comment: General Case

$$l^2 (|\hat{n_1} \cdot \hat{u}|+|\hat{n_2} \cdot \hat{u}|+|\hat{n_3} \cdot \hat{u}|)$$

where $\hat{u}$ is the unit vector of the fluid flow and $\hat{n_i}$ is the normal vector to one of the cubes three orthogonal sides.
Comment: @David: you might want to make that an answer. (If you also explain where it comes from, it'll be an even better answer.)


Sentence structure of "At what age"

Question: I came across the sentence "At what age were you able to start reading successfully to a baby?". My question is why the word " at " can be placed at the beginning of the sentence? Is the sentence the same as "how old were you able to start reading successfully to a baby?"
I often see questions begin with "what", "how", "when", "why", and "what". It's the first time I notice the sentence which begins with "At what age".
Can anyone explain why it is like this? What is the grammar rule that the sentence follows?
Thanks in advance.
Comment: 'At what time did the thunderstorm begin?' // 'At what point did you decide to leave?' // 'For what reason did she take the French subsidiary?' // 'To which countries do they fly?' // 'Among which tribes is this still a custom?' // 'Beneath which stone did the crab hide?' // 'Concerning which regulations is there a problem?' // 'On top of which box was the spider?' ...
Comment: "At what age" is an adverbial phrase comprised of {preposition *at* + noun phrase *what age*}. We can replace it with the adverb "When". Adverbs and adverbial phrases are commonly used to start sentences.
Comment: "How old were you able..." is ungrammatical. "At what age" is correct.
Comment: Thank you. I do need to improve my grammar.
Answer: Leaving aside the problem of whose age (the addressee's or the baby's) is being questioned,

At what age were you able to start reading successfully to a baby?

is an example of a grammatical phenomenon known as Pied-Piping. This sentence is a question, formed from a statement something like

You were able to start reading successfully to a baby at ___ age

where the blank represents the missing information the questioner is seeking; in this case it gets transformed into the interrogative what in the prepositional phrase at what age.

You were able to start reading successfully to a baby at what age

The next step in question formation is to invert (exchange) the subject (you) and the first auxiliary verb (were)

Were you able to start reading successfully to a baby at what age

If it weren't for the Wh-word at the end, this would be an OK yes/no question

Were you able to start reading successfully to a baby at that age?

But it's a Wh-question, not a yes/no question, so after inverting, the next step is to move the Wh-word (in this case, the phrase what age) to the front of the question, producing

What age were you able to start reading successfully to a baby at?

Which is grammatical, but is also a great example of stranding a preposition at the end of the sentence. What good is it doing there? It doesn't mean anything; it's just something required by the idiom be at X age, and it's silly to require the speaker to add it at the end, or for the listener to have to wait for it. But you can't leave it out. Because grammar.
So, the optional rule of Pied-Piping allows the speaker to move the whole prepositional phrase at what age, as a unit interrogative constituent.
Not only that, but any other higher constituent that the interrogative word is part of -- like a noun phrase containing the prepositional phrase, or another noun phrase containing that one -- can also be pied-piped, at the will of the speaker, producing prose of massive turgidity, like

printed volumes the lettering on the covers of which is specified by law

Sentence structure of "At what age"


Can a country choose to only partially ratify a treaty?

Question: Let's say that Country A wants to enter into UNCLOS. However, it doesn't like certain provisions of UNCLOS. Is it legally possible de jure (not de facto, since countries clearly can just establish the stuff they like in UNCLOS as their own laws) to only ratify parts of the treaty (not abiding by the opt-out clause)? Or is this against international norms/is not regarded as legal? (I also do not mean countries who are in the process of adopting all parts of a treaty since their intent is still to adopt the entire treaty.)
Now, let's say that the country was abiding by the opt-out clause and did not exclude any other parts of the treaty. Did they technically/semantically speaking still ratify the entire treaty?
Comment: It depends on the provisions of the particular treaty.  For UNCLOS, articles 309 and 310 are relevant. You can read some of the declarations made on signature or ratification at https://treaties.un.org/Pages/ViewDetailsIII.aspx?src=TREATY&mtdsg_no=XXI-6&chapter=21&Temp=mtdsg3&clang=_en
Answer: Broadly speaking: "yes, but..."
Such declarations are called 'reservations'.

A reservation is a declaration by a state made upon signing or ratifying a treaty that the state reserves the right not to abide by certain provisions of the treaty.
Reservations are formally defined in Article 2.1(d) of the 1969 Vienna Convention on the Law of Treaties. Articles 19-23 govern the process of making and withdrawing reservations. Generally, it outlines, among other things, that:

Reservations cannot be incompatible with the object and purpose of the treaty.
A treaty may also prohibit reservations for some or all of the treaty's provisions.
Other states may object to a reservation.
A reservation may also be withdrawn at a later date.
Reservations and objections must be in writing.

In comments here, Henry linked to the UNCLOS page where you can see its signatories and their declarations and reservations, and pointed to UNCLOS articles 309 and 310.

Article 309
Reservations and exceptions
No reservations or exceptions may be made to this Convention unless expressly permitted by other articles of this Convention.
Article 310
Declarations and statements
Article 309 does not preclude a State, when signing, ratifying or acceding to this Convention, from making declarations or statements, however phrased or named, with a view, inter alia, to the harmonization of its laws and regulations with the provisions of this Convention, provided that such declarations or statements do not purport to exclude or to modify the legal effect of the provisions of this Convention in their application to that State.