How to auto execute a macro when opening a Powerpoint presentation?

Question: I have a pretty basic question, but could not find the answer on internet.In Powerpoint 2010, I have a macro that I would like to be executed everytime the Powerpoint document is opened. How to achieve this ?Thanks !
Comment: When reading add-ins, I thought that this was a workaround for something that obviously MUST have existed. But you are right, add-ins seem to be the only way for me. Thanks !
Comment: You couldn't find an answer? C'mon! Doing a search with "powerpoint auto start macro" on google gives you: http://www.pptfaq.com/FAQ00741_How_can_I_get_my_code_to_run_automatically_when_a_presentation_opens-.htm
Answer: While Auto_Open doesn't run in a PowerPoint presentation, you can fake it. Add a CustomUI part to the presentation, then use the CustomUI OnLoad callback to run code when the presentation opens. The CustomUI part needs no more than just the CustomUI tags.
Get the Custom UI Editor from here: http://openxmldeveloper.org/articles/customuieditor.aspx
Open the presentation in the Custom UI Editor. Insert a CustomUI part from the Insert menu:

Now enter some simple RibbonX code, like this:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="MyOnloadProcedure" >
</customUI>

Now write your on-open procedure:
Sub MyOnloadProcedure()
    MsgBox "Hello"
End Sub

If you have both this and the Auto_Open procedure in an add-in, Auto_Open runs first.
Full disclosure: while I thought of using this approach and have used it in Excel, I waited until I first encountered it on the PPT Alchemy web site: Run Code When PowerPoint Opens.
Answer: I am using PowerPoint 2016 so I can't speak for earlier versions although the documentation indicates this works for PowerPoint versions 2016, 2013, 2010, 2007.  This method DOES NOT require any add-ins or application hooks to handle events.
Reference link:
https://support.office.com/en-us/article/command-line-switches-for-microsoft-office-products-079164cd-4ef5-4178-b235-441737deb3a6?ocmsassetID=HA010153889&CTT=1&CorrelationId=ea39d200-aa81-4d6e-8302-afff4c65859e&ui=en-US&rs=en-US&ad=US#ID0EAABAAA=PowerPoint,_PowerPoint_Viewer)
Start PowerPoint from command line and use the /M switch to have PowerPoint run a specified macro when it starts a named presentation file.
The easiest way to do this is to create a shortcut to the PowerPoint application.  Then go to the Properties window for the shortcut and select the Shortcut tab. Next, add the /M switch, your presentation file name (including path), and the name of the macro to run (case sensitive and must be part of the presentation) to the end of the Target field.  Double-click the shortcut and voila!
Example:
My presentation is C:\myPPTpres.pptm and the macro is Run_Slide_Show so I will need to add
/M "C:\myPPTpres.pptm" "Run_Slide_Show" to the end of the existing text in the Target field.

"C:\Program Files (x86)\Microsoft Office\root\Office16\POWERPNT.EXE"
  /M "C:\myPPTpres.pptm" "Run_Slide_Show"

Make sure you are running a macro-enabled version of the presentation (in 2016 it has the .pptm extension.)
Important note if you are trying to start a slide show automatically using the macro.  Add a delay of one or more seconds at the very beginning of your macro to allow the application to finish its startup sequence.  If you do not the slideshow will start but the application will steal focus as it completes its startup, pushing your slideshow to the background.
Comment: Just in addition, to add a delay I first used the windows sleep function. This froze the app completely and didn't work. To add a delay, check out this article: https://www.myonlinetraininghub.com/pausing-or-delaying-vba-using-wait-sleep-or-a-loop Worked for me with the last solution described.
Answer: Assuming the type of macro to be Auto Events related such as Auto_open(), Auto_close(), Auto_print() etc., for powerpoint to execute macros on opening powerpoint file we require Powerpoint Add-Ins to be included or other option could be to save the file as .ppa or .ppam.
For more details and to download the AutoEvents zip file refer the link: http://skp.mvps.org/autoevents.htm


Since marshmallow update Bluetooth discovery using BluetoothAdapter.getDefaultAdapter().startDiscovery(); is broken

Question: I have an app using bluetooth and connecting to devices, can'f find any devices using BluetoothAdapter.getDefaultAdapter().startDiscovery(); It worked fine just before discovery. Tried also other apps, it doesn't work in other apps as well. But the device I try to pair (Arduino bt-module) can be found in Android settings. Any idea what could I try? I implemented everything like described on http://developer.android.com/guide/topics/connectivity/bluetooth.html and it worked before the update.
Answer: Bluetooth Adapter has been change in Android 6.0
You need to set the permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permission and need to use
 BluetoothLeScanner.startScan() method to start the scan.
Below is the description from change logs:
To provide users with greater data protection, in Android 6.0, Android removes programmatic access to the device's local hardware identifier for apps using the Wi-Fi and Bluetooth APIs. The WifiInfo.getMacAddress() and the BluetoothAdapter.getAddress() methods now return a constant value of 02:00:00:00:00:00.
To access the hardware identifiers of nearby external devices via Bluetooth and Wi-Fi scans, your app must now have the ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permissions:
WifiManager.getScanResults()
BluetoothDevice.ACTION_FOUND
BluetoothLeScanner.startScan()

Note: When a device running Android 6.0 (API level 23) initiates a background Wi-Fi or Bluetooth scan, the operation is visible to external devices as originating from a randomized MAC address.
You can get more details from this link  :
http://developer.android.com/about/versions/marshmallow/android-6.0-changes.html
Comment: Thanks for the hint, the solution for me was to add the ACCESS_FINE_LOCATION permission and to request the permission at runtime.
Comment: @mikugo Are you still using `BluetoothAdapter.getDefaultAdapter().startDiscovery();` for initiating the discovery? The changes mentions using the LEScanner instead for Marshmallow and wondering if you made the change to even scan for classic bluetooth devices.
Comment: @jschlepp Yes I'm using `BluetoothAdapter.getDefaultAdapter().startDiscovery();` it was only a small university project. But maybe the LEScanner can also discover classic devices because they use the same frequency. And it uses less power.
Comment: I have those permissions set on the app, and I can discover devices, however, I can't connect with any of them. I think is something about permissions, cause it works on older versions (4.X and 5.X)
Answer: Just enable Location in Settings and it works well !!
Answer: From API level 23, location access permission (ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION ) is also needed for bluetooth discovery.

https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-hardware-id

And just adding permission into manifest file is not sufficient as the permission belongs to "dangerous" protection level.
User consent is needed to request the permission at runtime.
Added permission into AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />

Request for ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION at run time:
private void accessLocationPermission() {
    int accessCoarseLocation = checkSelfPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION);
    int accessFineLocation   = checkSelfPermission(android.Manifest.permission.ACCESS_FINE_LOCATION);

    List<String> listRequestPermission = new ArrayList<String>();

    if (accessCoarseLocation != PackageManager.PERMISSION_GRANTED) {
        listRequestPermission.add(android.Manifest.permission.ACCESS_COARSE_LOCATION);
    }
    if (accessFineLocation != PackageManager.PERMISSION_GRANTED) {
        listRequestPermission.add(android.Manifest.permission.ACCESS_FINE_LOCATION);
    }

    if (!listRequestPermission.isEmpty()) {
        String[] strRequestPermission = listRequestPermission.toArray(new String[listRequestPermission.size()]);
        requestPermissions(strRequestPermission, REQUEST_CODE_LOC);
    }
}

@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
    switch (requestCode) {
        case REQUEST_CODE_LOC:
            if (grantResults.length > 0) {
                for (int gr : grantResults) {
                    // Check if request is granted or not
                    if (gr != PackageManager.PERMISSION_GRANTED) {
                        return;
                    }
                }

                //TODO - Add your code here to start Discovery

            }
            break;
        default:
            return;
    }
}

More details about permission:
https://inthecheesefactory.com/blog/things-you-need-to-know-about-android-m-permission-developer-edition/en


I don't have a phone and I want to start a new Whatsapp account on my PC

Question: I do not have a phone and I wanted to open a new whatsapp account.
is this possible?
I have never made an account before and my friend suggests me to use whatsapp,
as I do not have a phone or any previous account this is a problem.
Answer: You can't use WhatsApp without a smartphone. From the WhatsApp FAQ:

Minimum requirements to enjoy WhatsApp Web

You need to have an active WhatsApp account on your phone.
You need to have a stable internet connection on both your phone and your computer.
You need to use the latest version of Chrome, Firefox, Opera, Safari or Edge as your web browser on your computer.

The account is tied to your phone number, so you can't borrow a friend's phone to set up the account either.
Answer: Yes, this is possible.
There is a way to use WhatsApp or any other Android app, on a PC using BlueStacks.
All you have to do is download the BlueStacks app onto your computer, sign in to your Google account, go to the play store, and download WhatsApp.
After downloading WhatsApp, go thru the regular registration process. If you don't have a phone number of your own, you can register for a free number with Google voice and use it for your WhatsApp account.
I have seen this work perfectly for others, let us know how it goes for you.
Comment: Are you sure this will work? Only real numbers can be registered with Whatsapp!
Comment: @esqmo_ Yes I'm running a Google voice number on WhatsApp. And i know others who are doing the same. I know that they will block 'online' numbers. But not Google voice
Comment: Okay, never tried that. But this works only for people living in the US not outside right?
Comment: @esQmo_ it works internationally. But it would give you an American number, which is not a problem for WhatsApp
Answer: I believe it is possible, you need to install Bluestacks. It is an android emulator for pc, where you can install Whatsapp as well as other apps.
After installation, just follow instructions.
Note: You need an active mobile number.


Replacing egg whites with whole eggs when baking cookies

Question: I want to make the recipe here: http://www.shutterbean.com/2012/flourless-coconut-chocolate-drops/
This recipe states that you should just use four egg whites. I really, really don't want to waste 4 egg yolks (I know you can make scrambled eggs out of them. I always try to remember but often they do go to waste.)
What would happen if I used whole eggs to replace the egg whites in the recipe? I assume I would need fewer eggs, but what else would happen?
Comment: If you don't want to waste the yolks (which at the end of the day might have cost you 50 cents), do something else with them. Homemade mayonnaise is delicious and only takes a couple minutes to make in a food processor.
Comment: Egg yolks can also be frozen (to use for decadent scrambled eggs later)
Answer: Egg yolks and egg whites have very different roles in baking. You can almost never replace them. And in the cases in which you can, you will end up with a different texture.
In this case, it won't be sure disaster to replace, but I would be very reluctant to do it. Flourless recipes are finicky. Flour holds stuff together. Nut flours don't hold anything together, they need a binding agent. Egg whites are a good binding agent. Egg yolks are not only not good as a binding agent (except in certain circumstances, for example in custards - but you don't have this here), they are even a lubricant and as such will interfere with the binding done by the egg whites.
If you substitute here, you will not only change the taste, you risk your cookies crumbling apart in your hands.
In general, don't replace stuff in baking recipes. They are hard to design right. Even if you have some issues (e.g. allergies), it is easier to find an existing recipe without the offending ingredient than to try to tweak an existing one to work with different ingredients. Eggs are especially hard to substitute. Such a reason like "not wanting to waste" loses its sense if what you end up with is bad cookies, which are a much worse waste of products. And besides, you can do many more interesting things with a yolk than just scrambled eggs. In fact, I am frequently throwing out whites because I have found no use for them after doing something with the yolks.
If you still want to go ahead and try if the cookies work for you, try using 3 whole eggs. 2 eggs are nowhere near enough to substitute for 4 egg whites. Not only are the yolks smaller than the whites volume-wise, they will also not deliver you the binding proteins you need so badly.
Comment: I am not replacing the egg whites in the recipe with the egg yolks only, but replacing the egg whites with whole eggs! Would what you have said still stand in that case?
Comment: @alice yes, it holds. You have much less egg white, and you need all your whites. Also, the yolk inhibits the binding of the white. It is a bit like diluting glue with grease - it will probably still bind, but will be weaker.
Comment: Ok rumstscho, i'm going with your advice and will not substitute the whole eggs for the egg whites! Then I will dine on the most decadent scrambled eggs ever known!
Answer: Whenever you consider using whole eggs instead of just whites, first consider the reason it's an egg white-only recipe: is it purely for nutritional (fat/calories) reasons? Or, is it for volume?  In this case, it seems to me that it is the latter, therefore, I would separate the eggs, mix in the yolks with the other ingredients and then whip the eggs separately, to a soft meringue stage and then fold them into the chocolate mixture (after the yolks are mixed in).
Answer: Egg yolks are about 30% of the egg, so if you added whole eggs you'd need to add 3 instead of 4 to get the same approximate weight of egg. As for what the results would be I doubt you'd be able to taste much difference. Egg yolks are much richer than white, however that richness of flavor would be overshadowed by the coconut, chocolate, and sugar.
As the eggs are the main binding agent changing the consistency of the eggs will change the consistency of the result, but again I don't think you'll see much difference. The egg whites are not whipped, so I wouldn't see why this wouldn't work.
Comment: The coconut macaroon recipe I used to use called for 3 egg whites. I switched to 2 whole eggs years ago. The macaroons are still just as yummy, they just have a slightly yellowish cast, and I don't have egg yolks staring at me accusingly from a bowl in the refrigerator anymore.
Answer: In a nutrition class, I was taught to use two eggwhites instead of a whole egg, to avoid cholesterol. You should not have to modify the recipe any further.
Comment: This is a cooking site, nutrition and health is off topic here. I decided to leave the part (originally from a comment) which claims that you can make the replacement with no problems and provides a ratio. But I still disagree that it is a good substitution from the taste perspective, no matter what health merits it might or might not have.


Given a list of (filepath line column), how to make this open as an xref buffer?

Question: If I have a list of file locations in elisp, how would I create an xref window, showing these locations?
Answer: You will need to convert that list to "xref item" values.
See xref--collect-matches-1 for how this is done. Since your locations are not "xref matches", though, you will call xref-make instead of xref-make-match, and won't need the length argument.
Note that you will also need the string contents on that line (it will be shown in the xref buffer as "summary").
To show the list, you call xref--show-xrefs. The first argument, fetcher, must be a function that returns that list we computed above. Depending on how you retrieve that list, the fetcher could call the retrieval logic as well and then create the xref items from the result. Then xref-revert-buffer will work as expected in such buffers.
Alternatively, if the list is static, fetcher can just process that list (by either looking up a lexical var up the scope, or some global var defined in the package). Also, for now, fetcher can be a simple list (of xref items). But that's an obsolete convention.
Note that xref--show-xrefs is ostensibly a "private" function. But it should be stable enough in the near future.
Answer: This function creates an xref buffer from a list of references (thanks to @Dmitry's answer).
(defun my-xref-from-file-references (file-references)
  "Create an xref buffer from FILE-REFERENCES ((file line column display-text) ...)."
  ;; Needed for xref API.
  (require 'xref)
  (let ((xrefs (list)))
    (dolist (item file-references)
      (pcase-let ((`(,file ,line ,col ,display-text) item))
        (push (xref-make display-text (xref-make-file-location file line col)) xrefs))
      (xref--show-xrefs (lambda () xrefs) nil))))

Note that (filepath line column) isn't quite enough information for xref, so a display-text has been included which would typically be the line of text - but can be anything.
Answer: Not an answer, but too much code for a comment.
May be you can reuse and adapt this code:
   (save-excursion
     (and ;;; try finding file from make buffer javac error
      (re-search-forward "(\\(\\([A-Za-z]:\\)?\\.?\\.?/?[a-zA-Z0-9._/+-]+\\.[a-zA-Z0-9_/,+-]+\\):\\([0-9]+\\))" nil t)
      (or
       (and
        (file-readable-p (match-string 1))
        (let ((file (match-string 1)) (line (string-to-int (match-string 3))))
          (find-file file) (goto-line line) (recenter) t
          ))
       (and
        (get-buffer (file-name-nondirectory (match-string 1)))
        (let ((file (get-buffer (file-name-nondirectory (match-string 1)))) (line (string-to-int (match-string 3))))
          (switch-to-buffer file) (goto-line line) (recenter) t
          ))
       )))

Comment: This seems more like a way to step over lines of text (as xref does), not xref. If this is all thats needed compilation-mode can already do this.

The reason I ask about xref is it gives some extra functionality for stepping over references, which are nice to have. I rather not have to re-implement xref.
Comment: @ideasman42 Yes, definitely not xref, and as I said, not an answer but too much text for a comment. This snippet jumps from an error line of javac to the corresponding source line in a (possibly new) buffer. Please copy the code, if it is any help to you and leave me a comment so that I can delete this.
Comment: I have a function where many such snippets are encased by (or ...) so that the function opens a buffer to the first match. I use this quite a lot and would be lost without it.


electric gate motor

Question: I have a question about an electric gate motor I am installing. I purchased a motor rated for up to 650kg(for a level area), but it will operate on a slope which drops by 400mm over the 5 metre opening which the gate will span.  The gate weighs approx. 250kg but I am concerned that the motor will lose traction or the clutch will fail and crush a child as it rolls down the slope, is this a possibility?Any advice would be appreciated
Comment: A picture or diagram would be helpful.
Comment: Can you install the gate so that if the clutch fails the gate will roll open?
Comment: The type or model of the gate would be helpful.
Answer: This is why garage door openers have pass transmitters that stop and reverse the door to prevent such an accident.
Does your gate opener have any safety features to prevent this? If not then maybe you should look for one that has these safety features.
Good luck!

electric gate motor


IntelliJ: configure several Tomcat configurations with different server.xml

Question: In IntelliJ, I would like to have different configurations to start several Tomcat instances, but with different server.xml config files. Is there a way to do this?
Answer: I found a way: create a directory, and put inside a copy of the conf dir from Tomcat, then use this new directory as the Tomcat base. This way, the tomcat binaries are shared, but the configurations are distinct.
Answer: As far as I know there isn't. In the case I want to do that, I simply create 2 copies of Tomcat on my disk and create a configuration for both of them.
Answer: If the configurations are different because of your application's needs, I'd say that editing server.xml is the wrong way to go about it.
A better solution is to have a context.xml for your app in META-INF.  Keep the things that are specific to your app isolated from the server.  You won't affect other apps that way, and you can't always count on being able to modify the server configuration if you're in a shared environment.
Comment: It is the same webapp for several Tomcat instances, I only want to launch several instances for testing purposes.


Visual Studio: Simultaneously develop WCF client and server

Question: I need to develop a WCF server (basically a web service which will eventually run in IIS) and a client application that accesses the service. I have both the client and the server project in the same Visual Studio (2008) solution.
What's the recommended way to connect the client to the server during development?
Two possible solutions immediately come to my mind: One is to deploy the server project to some IIS after every change, and the other one is to start two instances of Visual Studio and use a fixed TCP port for the (Visual-Studio-integrated) web server of the server project.
Since none of these options seems particularly elegant to me, I was wondering if I have maybe overlooked the obvious "right way" to do this...
Answer: The way I do is like this:
- Right-click on your solution file, and choose Set Startup Projects...
- Choose Multiple startup projects and choose Start for your client and server project, leave the other ones set to none.
Now both projects will run at startup, and you will be able to debug them both.
Answer: Because i have a lot of WCF services used by my project and i do not want to have to run too many instances of VS for debugging, this is what i do:-
If you are ok with having a local IIS, you could consider this.

For each WCF Service, i have created a Web Site project.
This website projects are also shared as Web Folders in local IIS. eg http:\mylocalmachine\WCFService1\servicefile.svc
In my WCF clients web.config, the URL for the service is specified as above.
eg (http:\mylocalmachine\WCFService1\servicefile.svc)
Since i dont want to deploy manually every time i change the service, in the post build of each  WCF Service project, i have a postbuild task that copies the contents of the bin directory to the bin directory of the website for that corresponding WCF service (one time setup for the postbuild)
My folder structure is such that for every service project, there is a service host (website) project at the same level so the postbuild is very straightforward as well.
When i run my WCF client (F5), the service projects are compiled, their contents are copied to the websites bin (i.e. automatically deployed to IIS) and i can debug any service just by stepping into the code as my services are in the same solution as my WCF client

An added advantage of this approach is that my debugging (atleast of the services) is also using IIS similar to what my production setup will be like.
Edit : I dont put the service host projects (websites) in my solution as otherwise when running my WCF client, VS opens up a cassini instance for each of them, which is irritating and i anyways dont need or use


Why does a prism refract light into a rainbow?

Question: Why does a prism refract light such that the different frequencies of light "spread out"? The same goes for rainbows, why do the raindrops "spread out" the different frequencies of light?
Comment: The prism refract light, but does not scatter it, ideally.
Comment: look here , it is due to the different dispersion of different frequencies http://hyperphysics.phy-astr.gsu.edu/hbase/vision/specol.html   http://hyperphysics.phy-astr.gsu.edu/hbase/geoopt/dispersion.html#c1
Comment: @my2cts sorry should change that, I forgot what the correct word was for a while
Comment: @Melvin why the deselection?
Comment: @ÁrpádSzendrei not my intention sorry
Answer: This phenomenon is due to the simple concept of refraction. Due to the difference in the wavelengths of each component of white light, this dispersion of white light occurs in denser/viscous media.
Snell's law states that, $$sin(i)/sin(r) = n2/n1 = v1/v2$$ where i is the angle of incidence and r is the angle of refraction, n1 and n2 are the refractive indices of media 1 and 2 respectively.
We also know that $v = f*y$, where f is the frequency of light and y is the wavelength. Hence, the angle of deviation depends on wavelength.
This is also the reason for the "spreading out" of light by a raindrop thus leading to the formation of rainbow.

In the image given above, the red and violet components of white light have different wavelengths and hence the angle of refraction differs significantly in the viscous media.
Comment: You haven't explained why red & violet get refracted by different amounts.
Answer: As the other answer gives you the formula, and the reasoning, the real reason is that different wavelength photons diffract at different angles at the edge of two different medium.
Now the question remains, why do different wavelength photons change angle differently at the edge of a new medium?
I am going to use lattice structure here, but for air and water it is hard to talk about a lattice structure, so in this case what I mean is the molecular structure.
First of all, lets clarify that the change in angle not only happens at the edge of a medium, but:

the angle of the photons will change even in the same medium, at the edge of different lattice structures, or different densities
even if you cut that triangular glass prism into two pieces, and put them exactly back together as they were before, there will be diffraction, as the lattice structure is irreversibly broken at the edge of the two pieces

So, shooting back the question as a boomerang, why do photons travel parallel in white light (inside a single medium, with no density and lattice structure changes):

because the medium has a continuous, unbroken lattice structure, no density changes
this lattice structure is uniform (same structure, same atoms, same molecules, same covalent bonds) throughout the whole path of the photons

So, everytime the lattice structure changes in any way (like density or broken or the structure itself, or different covalent bonds), the photons will diffract (change angle), and the different wavelength photons will change angle in different amounts.
Now you see that the answer to your question, why do the photons change angle in different amounts still remains, and the answer is the lattice structure. To be more precise, in air, or water, there is no lattice (like a solid), but the structure of the molecules, and densities, can still be different. Still, water can act as a prism in air, and you get the same rainbow effect. Why? Because the edge of the water and air has a different molecular structure. Now the question is why do different wavelength photons bend differently at the edge of different structural media?
So shooting back the question again as a boomerang, why does a group of certain (same) wavelength photons bend parallel (the same way) at the edge of a new medium? Why does the wavelength decide the angle? First of all, there is no two photons with the same exact wavelength, as the wavelength is continuous. But, with our eyes, we cannot tell the difference at a certain level, so let's say there are two photons that seem to have the same wavelength (for our viewing purposes). Why do these photons bend at the same angle at the edge? Why do you see a static image of the colors at the prism, and why doesn't the absolute angles of the different color photons randomly change? And why doesn't the relative angle randomly change?
The answer could be classical or QM:

classical answer is that the different wavelength photons travel at different speeds inside a denser medium.
the QM answer is that the photons building up the EM wave interact with the lattice structure, and this elastic scattering decides the angle.

Let me elaborate on the QM answer. When a photon interacts with an atom, three things can happen:

elastic scattering, the photon keeps its phase, energy, and changes angle
inelastic scattering, the photon keeps part of its energy and changes angle
absorption, the photon gives all its energy to the atom

Now in the case of the prism, it is elastic scattering. This is the only way, that the energy of the photons is kept, phase is kept, and relative energy is kept, and relative phase is kept.
Now with elastic scattering, as the photons in the white light, combined of all the different wavelengths from the Sun traveling parallel reach the edge of the glass prism from the air, what happens is:

the different wavelength photons start interacting with the lattice structure of the glass prism. The different wavelength photons elastic scattering will produce a certain angle change for the photons
photons with the same wavelength will interact similarly with the lattice structure, and create the same angle, these photons (same wavelength) will continue in one separate beam separated from the other beams (other wavelengths)

Now this is not the complete reality. Imagine the double slit experiment. The photon (shot one at a time) will have its partial waves pass through both slits and interfere with each other, sometimes constructively and sometime destructively. The destructive interference will not be visible (just its void, missing dot), creating a dark area. The constructive interference will create a visible bright area.
In reality with the prism, the photons interact with the lattice structure of the glass, and the partial waves create interference. Some of the interference will be destructive, basically, in all directions where you do not see the certain beam (certain wavelength photons). In only one angle, direction, will be the constructive interference, where you will see the certain wavelength photons in one beam.
So the answer to your question why different angles for different wavelength is that the elastic scattering as an interaction between the photons and the lattice atoms will create an angle that is:

mostly similar for similar wavelength photons
different for different wavelength photons

It is all about probabilities at the QM level, but if you use a lot of photons, that build up the white light, most of the similar wavelengths will change angle in the same amount, and they will be visibly separated from the other wavelengths.


Reasons behind de Broglie hypothesis

Question: What reasons does de Broglie had when he proposed the idea that electrons behave like waves?
Comment: I can't help feeling this is a question about history rather than physics, and it would be better on the [History of Science Stack Exchange](https://hsm.stackexchange.com/).
Comment: One of the sources of this guess was that electromagnetic radiation already displayed both wavelike (interference) and particle-like (photoelectric/Compton effect) properties. The guess was that this could be extended to other particles.
Comment: @Avantgarde, yes but there is a fundamental difference between light (photons) and matter (eg. electrons). My question is: why should (we think that) matter also display this dual behaviour? Usually the idea that you are left with is: why not? Let's see if that is ideed the case... And it was, it was verified experimentally. But it seems that it was not even an educated guess. It happened to be that way.
Comment: @JohnRennie, Yes, I also think that this question could have been posted to [History of Science and Mathematics](https://hsm.stackexchange.com) as well. This question is about (at least this is my intention) how a physicist thinks, how breakthroughs in physics are being made, but it could also reveal a deeper understanding that perhaps I and others do not have about quantum mechanics.
Comment: @AWanderingMind It was a good guess, but that's all that matters. There are all kinds of particles in nature. If you observe some general property (wave-particle duality) in one of particles (photons), you can't help but think of this property as a unifying aspect in all other particles. I suppose this idea of 'unification' of different particles under one property was motivating.
Answer: The answer to this question can be found in de Broglie's Nobel Lecture. The pdf file is available here. I quote the relevant part.

The necessity of assuming for light two contradictory theories -that of
  waves and that of corpuscles- and the inability to understand why, among
  the infinity of motions which an electron ought to be able to have in the
  atom according to classical concepts, only certain ones were possible: such
  were the enigmas confronting physicists at the time I resumed my studies of
  theoretical physics.
When I started to ponder these difficulties two things struck me in the main.
  Firstly the light-quantum theory cannot be regarded as satisfactory since it
  defines the energy of a light corpuscle by the relation $W=h\nu$ which contains
  a frequency $\nu$. Now a purely corpuscular theory does not contain any
  element permitting the definition of a frequency. This reason alone renders
  it necessary in the case of light to introduce simultaneously the corpuscle
  concept and the concept of periodicity.
On the other hand the determination of the stable motions of the electrons
  in the atom involves whole numbers, and so far the only phenomena in
  which whole numbers were involved in physics were those of interference
  and of eigenvibrations. That suggested the idea to me that electrons themselves
  could not be represented as simple corpuscles either, but that a periodicity
  had also to be assigned to them too.
I thus arrived at the following overall concept which guided my studies:
  for both matter and radiations, light in particular, it is necessary to introduce
  the corpuscle concept and the wave concept at the same time. In other words
  the existence of corpuscles accompanied by waves has to be assumed in all
  cases. However, since corpuscles and waves cannot be independent because,
  according to Bohr's expression, they constitute two complementary forces
  of reality, it must be possible to establish a certain parallelism between the
  motion of a corpuscle and the propagation of the associated wave. The first
  objective to achieve had, therefore, to be to establish this correspondence.
Comment: Ok, so that fact that electrons can only be in some particular "quantized orbits", lead de Broglie to think that they must also exibit some wave-like behaviour.
Comment: Yes, I think so. In addition to that I think he was encouraged by the "fact" that light was already behaving in this (wave-particle) way.

Reasons behind de Broglie hypothesis


How does pronation and supination affect triceps?

Question: I've always done overhand and underhand grips with tricep exercises e.g. Push downs or skull crushers. I just don't know the technical differences between them. Does the supernated vs pronated forearm position change which heads are targeted. Is one better than the other?
Answer: It doesn't change anything. All heads of the triceps have the same insertion point on the elbow, the olecranon of the ulna, and that insertion point does not actually move with forearm rotation, which is a movement of the radius rather than the ulna.
You can test this yourself my feeling the bone at the point of your elbow while you rotate your hand. It doesn't move.
It's standard to use a pronated or neutral grip with triceps exercises just because it's easier to hold the bar or cable that way. Doing tricep pressdowns with a supinated grip would potentially make your grip the limiting factor instead of the target muscles.
Comment: So is there a way to focus the exercise on a different tricep head? Whenever I do any triceps really I almost always only really feel it on the inner triceps head i.e. the one that touches you lats. So is there a way to focus more on the outer tricep head(s)?
Comment: You're probably describing the long head, but just feeling it on the inner part of the tricep is not a reliable indicator that you're only working that part of the muscle. The long head is probably worked more by overhead work like skull crushers and less when the arms are by the sides, like in pressdowns, but it's really not something you need to obsess over.
Comment: See I train more for strength and powerlifting goals so hitting all the heads for better aesthetics isn't really my priority but thanks for the info.


How to see the breakdown of purchases vs. profits for a Vanguard Brokerage account?

Question: I can see the purchases vs. returns on the Performance tab in Vanguard but that is for my retirement and brokerage accounts. I'd like to see that breakdown for just my brokerage account. Does anyone know how to do that?
Answer: You can use the 'My Accounts'->'Cost Basis' link to see the total cost and profit/loss on a per investment, per account basis.
Answer: If you click through to the "Personal Performance" tab (this url or a similar one), you see that same chart as before; but you now have a section that can either select accounts, or holdings, and allows you to click checkboxes for whichever you want to see on the chart, then 'update chart' to get the chart for just that account/holding.
Comment: Thanks for the answer. This is what I thought I wanted, but Andy's answer actually showed the breakdown between short and long-term capital gains, which is really useful.


difference between passing a value vs passing a function as a parameter in scala

Question: I often hear that scala has a ability to pass function as a parameter to another function. I would like to know the difference between passing a value as a parameter vs passing function itself as the parameter. How the latter approach brings advantage to the programming. If functions are passed as the parameter
how the object references are being created since functions are not tied to any objects.
Answer: Lazy Evaluation
The advantage is the ability to perform Lazy Evaluation of the expression that is being passed in.  Instead of having to calculate the real value of x at the time the expression is passed in.  It can create a thunk which defers execution until its absolutely needed.

http://en.wikipedia.org/wiki/Lazy_evaluation

Why is this useful?  One instance is that you can define an infinite list of numbers given an expression.
An example (Haskell)
let fibs = map fst $ iterate(\(a,b) -> (b,a+b)) (1,2)

In this case the value fibs is given an expression which is composed of multiple functions, in this case map fst iterate (and an anonymous expression or lambda).
If fibs was to evaluate immediately it would cause a stack overflow as it would instantly try to calculate an infinite fibonacci sequence.  If i were to call
let fibSum = sum fibs

Then that's what would actually happen as sum will immediately try to attempt to evaluate fibs and cause a stack overflow.
However if I were to use fibs with another expression
let fibsEvenSum = sum(takeWhile(< 4000000) (filter even fibs))

This sum will still cause fibs to evaluate, however takewhile will cause the evaluation to end when the list reaches 4 million.
Answer: Have you ever used the visitor or strategy patterns, factories or dependency injections? Have you ever passed or asked for an object of type Runnable or Comparator? All these things are ad hoc hacks around missing ability to pass functions.
In the visitor pattern, instead of having accept receive an interface for a visitor, you take a function Element => Unit instead (for the void-returning case). The general concept of visitor is known as catamorphism, of which all sorts of mappings and folds are special cases of.
In the strategy pattern, the strategy interface is just a function. In the wiki example, replace the interface with (Int, Int) => Int.
In the factory method pattern, the whole factory class is a function. In the wiki encapsulation example, ImageReaderFactory is just a (InputStream) => ImageReader function.
A Runnable is just a function () => Unit. A Comparator is just a function (A, A) => Int. I could go on and on and on with this, but suffice to say this: you have been passing functions as arguments all this time, just the hard way.
As to your last question, I do not understand very well what you mean. A function, in Scala, is an object implementing the FunctionN interface, where N represents the arity. Of course, non-object oriented languages are not bound to represent functions as objects. In fact, even object oriented languages are not bound to that -- an int in Java is not an object, so why should a function?
Answer: Functions as parameters are useful in many many many ways.
Consider Java's Listener/Adapter pattern and general situations where callbacks are needed (event-based APIs). In Java, to have the GUI do something on mouse click or key press you will need to implement whole appropriate Listener interface (or extend Adapter class). Contrast this with just passing a function object to be executed on mouse click (you can see this in C# with its event system). It is much simpler.
There are also many situations where you would want to have a certain algorithm, where a part of it is customizable by using a passed-in function. E.g.

A family of functions "notAny", "every", "any", "notEvery" which all take a function parameter and a collection parameter and return true if [function returns false for all coll. elem.][function returns true for all coll. elem.][function returns true for any coll. elem.][function return false for any coll. elem]respectively
A comparator which compares results of a function upon collection elements, e.g.
new FuncComparator(Person.getName) would enable you to sort a collection of persons by their name property
functions like "map", "filter", "groupBy", which take a function parameter and a collection(s) and produce a new collection. Transformation of old into new collection uses the parameter function somehow. E.g:
groupBy could take a function and a collection and return a map of lists where lists contain elements of the original collection for which the parameter function returns the same value and this value is the map key.

These are just a few cases where a general algorithm of "go over collection and do X" is greatly improved by functions as first-class objects, because it allows the X to be user-specified through the function parameter.
This is not all however... there are more complex uses of functions as parameters (first-class functions), many involving functions which generate functions.
You should look at Clojure programming language for examples of these uses.
Edit: I don't know the exact implementation details but generally the implementation uses a class or and interface instance to represent the function in JVM. This class has a priviledged method that gets called when function object is invoked. This plumbing is made by Scala compiler.


How to Fix 500 Internal Server Error in Magento 2?

Question: 500 error in Magento 2 I faced at the time installation or up gradation of Magento, or while I backup the system on the product page or login admin page.
Comment: What do the server logs say? Can you run through the steps of what it is you've done so far as its unclear whether its a fresh install or an update?
Answer: give the pemission on root folder of magento 2
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;

Answer: Where your folder is installed at the root, you will find the file index.php then you need to add these lines to view those  500 internal errors, then you can be able to fix them because you will be able to see the exact error.
Steps:- Edit your index.php file(present at the root folder of your installation)
add these lines in the begining then check..
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
// Report runtime errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Report all errors
error_reporting(E_ALL);

// Same as error_reporting(E_ALL);
ini_set("error_reporting", E_ALL);

// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);

After then in the bootstrap.php also you need to add in the begining this code :   app>bootstrap.php  (inside your app folder)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);


Solutions to $ab+1=cde+c$

Question: I'm trying to find a method to find the set of solutions in non zero integers for this diophantine equation. I thought of using a generalized formula of the solutions of $ax +by = c$ but i don't know what is the best way to approach it.
Any help is appreciated. Thanks in advance!
EDIT: the solutions should be in terms of a,b,d regarding them as constants
Comment: If $a$ and $b$ are both constants, why not replace $ab$ by a single constant?
Comment: I have not solved a diophantine equation in a looong time, but you can rewrite it $ab +1 = c(de +1)$ now $de +1$ is on the same form as $ab+1$, hmm.
Answer: With $A=ab, C=c$ and $D=de$ we have the solutions $A=C(D+1)-1$ for arbitrary non-zero integers $C$ and $D$. For any $A$, we can find all ways to write it as a product $A=ab$, e.g., by computing the prime factorisation of $A$. For, say, $C=D=5$ we obtain $A=29$, which we can only write as $1\cdot 29$, or $29\cdot 1$ up to sign.

Solutions to $ab+1=cde+c$


Can a character read a short excerpt from published literature?

Question: I have this character. I am still debating whether I should allow him to read the first line of the King James Version of the Bible, "In the beginning God created the heaven and the earth..." and cut off right there or just summarize what goes on by narration.
Comment: That's awfully skimpy info you give there. Legally you're in the clear as KJV is public domain, but whether you should cut off, summarize or quote verbatim depends on quite a few factors involving *what* you write actually.
Comment: @SF. [The KJV is under perpetual copyright in the UK](http://en.wikipedia.org/wiki/King_James_Version#Copyright_status).
Comment: Are you asking "can" or "should"?  Your characters certainly "can" (i.e., it is not illegal) if you are using public domain material.  Whether or not they "should", and how much they "should", depends on many factors (as Anonymous pointed out).  But, if the quoted material is under copyright, you open up a can of worms known as "fair use" (in the U.S.; most countries have similar but not identical cans of worms).  There are lots of articles online about fair use.
Answer: Generally speaking, you cannot include in your own fiction an excerpt from published literature without permission.  The US copyright office's Fair Use FAQ recommends always getting permission if there is any doubt.
If the work is in public domain, as the text of many classics are, you could insert the whole thing without permission or even attribution.
Note that, as @evilsoup noted in the comments, the King James Bible is protected by a royal copyright within the United Kingdom until 2039, and if you were to publish there you would need to obtain permission from the Cambrige University Press.  (The New King James Version, btw, is a far more recent edition and you'd want to contact Thomas Nelson Publishers for permission.)

BTW, unless you're self-publishing, you shouldn't worry about the excerpts you use aside from noting them and being prepared to substitute something else.  If you're writing, WRITE, and worry about permission to use your quotations latter.
When you finally find a publisher, their legal department may very well already have permission to use various quotations in their works, and will certainly be far more aware of the precedent and standards for your market than random strangers on the internet ever could be.
Answer: The Bible itself is public domain, but particular versions might not be. So the only thing is not to mention the particular version ie. "Scofield KJV".
If you start using the editor's footnotes or personal inserts, then you may run into an issue.
Comment: A copy of the Bible or the Bible?
Comment: I've folded your comment into the answer, making it clearer and more complete (IMHO).


Simple way to prevent one user seeing one contact

Question: My user would like a particular case worker to be prevented from accessing one specific client.  At present we're not using ACLs but I implemented one scheme that I could get to work on my test system but not on their system - I have almost given up trying to figure out why. I created a smart group with all clients except the excluded one, and a group with the case worker who could see only this group. Can anyone suggest another way this can be achieved?
Comment: My suggestion would be something similair to solve it technically. But my gutfeeling is that there are some organizational issues at your client. Why is one particilair case worker not allowed to see one particilair client? What is the reasons behind that and how else could that be solved? My first gutfeeling is that you are trying to solve conflict avoidance behaviour if it is that behaviour that needs to be addressed first before providing a technical solution.
Comment: Above is my gutfeeling and I could be completly wrong. But at least it is worth trying to figure what reasoning behind the request is.
Comment: The 2 people are related, and I agree that a technical solution is possibly not the best. But I'm still trying to work out a good way to solve this
Answer: You could do that with hook_civicrm_aclWhereClause:

remove 'view all contacts', 'edit all contacts' for the case worker
create an extension implementing hook_civicrm_aclWhereClause eg:

function everyoneexcept_civicrm_aclWhereClause($type, &$tables, $whereTables, &$contactID, &$where) {
      if ($contactID == 'your_case_worker_id') {
        $where .= ($where ? ' AND ' : '') . " contact_a.id != 'your_case_worker_relative_id'";
      }
    }

For a one-off case, just hardcode the contact id's for your case worker and their relative.
Caveat - not extensively tested!
Comment: This is a lifesaver @aidan!  I didn't realize that in "vanilla" ACLs, you're controlling both access to the groups AND the contacts in the groups.  This technique is perfect if you want to hide contacts in a group, but let users see all the groups.


Disable all the fields in an InfoPath 2010 form after it has been submitted?

Question: Is it possible to disable all the fields in an InfoPath 2010 form after it has been submitted to a SharePoint list? Any help will be greatly appreciated.
Answer: You can can add a field to your infopath form's data set that basically says "Form has been submitted" as a boolean. When you publish the form, promote that field.
Once promoted, the form status can look and update that field.
Then, your infopath form hides and shows information as needed based on the value of that field.
Answer: From your post I'm assuming you want to disable the fields in the actual form. In the submit rules, you can switch the form to a different view that contains some or all of the fields of the original view. In this view you can have some or all of the controls set to Read-Only. Or you can go into the properties of the view and set the entire view to Read-Only.
In our office we often automate common processes such as requests etc. An example is a request for telephone access. What happens here is the initial user opens the form and fills in all his details (actually pulled from a web service) and the details of the access he is requesting.
This form is the changed to a manager view and submitted. The manager the gets an email with a link to the form that opens in his view. All the details filled in by the user is in a Read-Only state in this view and the manager has his own specific fields to complete regarding approving or rejecting the request.
Needless to say the form opened in the browser and the ribbon is disabled and all means of switching of views by the user. The form goes through some more processing, including steps at the service desk and tele-communications. After the last step the form switches to a completed view where the whole view is set to Read-Only.
Comment: Sorry to beat a dead horse, but I'm trying to do this as well and I am not sure how to accomplish the part "contains some or all of the fields of the original view". This is not explained in any of the blog posts or forums I've read so far, so what I tried is just a copy paste of the form controls into the secondary view, but after I do this I get all kinds of errors and the form doesn't publish as a web form to my SharePoint site.


How can I set up gVim as my editor on Git for Windows?

Question: I'd like to use gVim as my editor for Git commit messages. I realize Git has its own version of vim, but it's not quite the same as gVim (along with my _vimrc settings) which I use all day anyhow.
Answer: You can use gVim with Git by configuring your core.editor to contain the path where you have gVim installed. You'll also want to run it in the foreground and not load your _viminfo file, which would position your cursor in the place where you finished your previous commit message.
Taking note of the single and double quotes, you might do something like this:
git config --global core.editor "'C:\Program Files (x86)\Vim\vim74\gvim.exe' -f -i NONE"

Comment: If you installed vim with the "create batch files" option, you can also do: `git config --global core.editor "'C:\Windows\gvim.bat' -f -i NONE"`.  This way you'll survive a vim update and things will still work.
Comment: I can confirm `gvim.bat` works on Windows 10 under Git for Windows (MinGW).  I like this solution because there's no need to reconfigure Git when you upgrade Vim; it should just continue to work because the batch files are not version-specific.


(Why) did Sarah allow herself to be put in a compromising situation

Question: Starting in Genesis 12:13 Avraham and Sarah deceive Pharaoh into thinking that Sarah was not married. It seems from the verses that Avraham and Sarah understood that if Pharaoh thought Sarah was unmarried he would take her as a consort. My question is, given that adultery is one of the seven Noahide laws and one of the 3 transgressions for which one must give up one's life rather than violate, for what reason or by what right did Avraham and Sarah perpetrate this ruse? Shouldn't Sarah, under fear of rape/adultry have disclosed her relationship? And, shouldn't Avraham allowed himself to be killed, or perhaps at least wait until his life was threatened, before putting Sarah in that predicament?
Comment: Rape does not fall under adultery because the woman is thought to be passive, see Ester's story. Now, is Avraham allowed to put his wife to rape in the first place - I don't think it is Halachic. But keep in mind that half the things that our forefathers did were עת לעשות לה' הפרו תורתך - overriding Torah for G-d's sake.
Answer: The Zohar (part 1, 81b-82a) says that Avraham saw the Shechinah with Sarah, and therefore knew that she'd be safe:

רַבִּי יֵיסָא אָמַר יָדַע הֲוָה אַבְרָהָם דְּכֻלְהוּ מִצְרָאֵי שְׁטִיפִין אִנּוּן בְּזִמָּה, וְכֵיוָן דְּכָל הַאי
  יָדַע אַמַּאי לָא דָחִיל עַל אִתְּתֵיהּ דְּלָא אַהֲדַר מֵאָרְחָא וְלָא יֵיעוּל לְתַמָּן. אֶלָּא בְּגִין דְּחָמָא שְׁכִינְתָּא עִמָּהּ:

And the Midrash (Vayikra Rabbah 32:5) adds that her experience there enabled the Jewish women during the Egyptian exile to be protected from arayos:

רַבִּי הוּנָא בְּשֵׁם רַבִּי חִיָּא בַּר אַבָּא אָמַר שָׂרָה אִמֵּנוּ יָרְדָה לְמִצְרַיִם וְגָדְרָה עַצְמָהּ מִן הָעֶרְוָה, וְנִגְדְּרוּ כָּל הַנָּשִׁים בִּזְכוּתָהּ.
Comment: לא סומכים על הנס - one is not allowed to count on a miracle, this invalidates the whole point of learning something useful from the Torah. 2. The second Midrash - how did Sarah stay away from Arayos exactly? What did she actively do?
Comment: @AlBerko The definition of נס vs. טבע varies depending on one's level. Is it סומכין על הנס to go out when it's -20° F, where the cold can kill? Not if you're wearing a warm coat, because the natural laws with which we're familiar tell us that this will prevent you from freezing. Same way, for those on a level to perceive that the Shechinah is with them, it is just as "natural" that this will protect them from harm, whereas for those who can't perceive that, it would indeed be סומכין על הנס. The more so given the Midrash's statement that there was a constructive purpose in doing this.
Comment: As for (2) - Etz Yosef there says that she stayed away from Pharaoh, and ordered the angel to hit him (פירשה ממנו והיתה אומרת למלאך שיכה בו).
Comment: I understand, but if so he would go full way - saying the truth. It's not serious using it half way - Now I trust in G-d, no I don't.
Comment: @AlBerko First of all, that would put Avraham himself in danger (והרגו אותי ואותך יחיו); he didn't see the Shechinah with himself, after all. Second, elsewhere (https://www.sefaria.org/Zohar.1.111a?lang=he, in connection with the episode with Avimelech) the Zohar in fact says that אחותי היא refers to the Shechinah accompanying her (אמור לחכמה אחותי את).
Answer: Rav Hirsch explains on Lech Lecha 12:13 that they were actually in less danger this way than if they had admitted that they were married.

After all that occurred in Egypt and in the land of the Philistines we
  can conclude that - to which European countries in our modern times
  may not be without analogy - virgins, unmarried women were more
  protected against the prevailing immorality than married women. And
  add to that, a stranger! In both cases, married or unmarried, Sarah's
  honour was in danger. But, as a married woman the danger would be
  imminently threatening. One simply kills the objecting husband and
  rapes the wife. In the case of an unmarried girl accompanied by her
  brother one hopes to get her through the favor of that brother. In any
  case this way takes longer, postpones the matter, and in the meantime
  Hashem can help.

The Egyptians (even the nobles) would have thus, restrained themselves while they tried to get Avraham to agree. Once Par'o expressed an interest, they would have withdrawn and been careful not to offend someone that Par'o wanted to favor. Avraham was successful until Par'o decided to stop playing around and kidnap Sarah.
If Avraham had not taken this tack from the beginning, he would have been unable to make the claim later.
The point Rav Hirsch is making is that one is allowed to take steps in order to avoid being forced into a position of יהרג ואל יעבר. In the way the culture of the time behaved, what he did was to prevent them from being faced with rape/adultery in the first place. Even after she was kidnapped and taken to the palace, Par'o first tried to appease Avraham. Then Hashem intervened so that Sarah was never placed in the יהרג ואל יעבר situation.
Comment: You say "less danger" but it falls under יהרג ואל יעבר as the OP suggested!
Comment: Actually no. It is a way of preventing being put in that position in the first place. @AlBerko.
Comment: @AlBerko The point Rav Hirsch is making is that one is allowed to take steps in order to avoid being forced into a position of יהרג ואל יעבר. In the way the culture of the time behaved, what he did was to prevent them from being faced with rape/adultery in the first place. Even after she was kidnapped and taken to the palace, Par'o first tried to appease Avraham. Then Hashem intervened so that Sarah was never placed in the יהרג ואל יעבר situation.
Comment: If Avraham knew it, why didn't he go to his homeland instead? Oh, that's a good question to ask!
Comment: @AlBerko Avraham had been commanded to go to Canaan. He had to stay close until the famine was over. Also he would have been subject to a second attempt to kill him. Also, there Sara was known to be his wife so he would have been subject even more to being killed so Sara could be raped.
Comment: But he wasn't commanded to go down to Egypt. Why didn't he go elsewhere, but Egypt if he knew he'd be killed and his wife taken?
Comment: First, Egypt was fertile and did not have the famine. Second, other places would have been just as bad. @AlBerko
Answer: This is addressed by Ralbag in his commentary there:

התועלת השלישי הוא ג"כ במידות והוא שכשיביא ההכרח שיגיע הרע לאדם מהראוי שיסתכל האדם באי זה אופן יתכן שיגיע לו יותר מעט מהרע ויבחר בו ולא יתרשל מזה מפני הרע שיקרה לו כי ראוי שיהיה נבחר הרע היותר מעט לברוח מהרע הגדול ממנו הלא תראה שאברם בחר לרדת לארך  מצרים לברוח מהרעב שהיה בארץ כנען ואע"פ שהיה נכון המקום ההוא אל שיקרה לו מהגנות שתתגאל אשתו בזימת הארץ וראוי שתדע שלא היה בזה חטא לאברם כי שרה תעשה באונס מה שתעשה מזה ולזה לא תאסר לבעלה אפילו אחר נתינת התורה כמו שאמרו ז"ל באסתר קרקע עולם היתה  ואם היה אברם בוחר סבל הרעב אשר היה אפשר שימות בו על סבל מה שאפשר שיקרה לשרה מהגנות היה זה חסידות של שטות כאמרם בשלישי מסוטה היכי דמי חסיד שוטה כגון דחזי דטבעה אתתא בנהרא ואמר לאו אורח ארעא לאצולה ולאיסתכולי בה
The third lesson is also in character traits. And it is that when circumstances force that evil will reach man, it is proper for the man to look which way has the possibility of less evil and choose that one. And he should not give up on this on account of the evil that will happen to him, because it is proper to choose the lesser evil to escape from the greater evil. Do you not see that Abram chose to descend to the land of Egypt to escape from the famine that was in the land of Canaan, even though that place was predisposed to the occurrence of the degradation that his wife be sexual in the promiscuity of the land.
And it is proper that you should know that there was not a sin for Abram in this, because Sarah did what she did under coercion and would therefore not be forbidden to her husband even after the giving of the Torah – as the Sages say about Esther that she was like mere ground. And if Abram had chosen to bear the famine, in which it was possible for him to die, over bearing the possible degradation that could happen to Sarah, it would be piety of foolishness. As [the Sages] say in [Chapter] Three of Sotah: "What is a pious fool? For example, he sees a woman drowning in the river and he says 'it is not the way of the land to save her and look at her'."


Objects referenced in multiple locations

Question: I am trying to figure out how to manage items in my program. I want to have a unified inventory system that knows where every item is. Then have container objects that actually hold the inventoried items, and have everything locate-able by container id.
My thought was to have items held inside the containers inside boost::ptr_vetors, and then hold a pointer (probably the same one) inside a hash table inside the inventory object, now shifting things around in terms of the inventory is easy that just changing a single value, and moving things from containerX to containerY is just a matter of removing from one pointer vector, and passing it to the other container, or doing all the work in one container, or another.
The problem that I am having trouble considering is when it comes time to get all the stuff out. I have only really ever dealt with having a pointer/object held in one place at a time not multiple, and I know that if I try to delete something that has already been deleted it will cause a crash at the least. The first thing that comes to mind is to remove all the references from the containers, and still have it reside in the inventory, and then step through, and delete the inventory. Is this feasible, or am I not considering this right, and need to reconsider this? then what if I only need to remove a single thing (keep the rest)?
I am concerned about de-validating the pointers in either case.
Comment: Why not use a vector of smart pointers (in C++11 or with Boost)? you won't have to care about whether or not you have to delete your pointer anymore. But I'm not sure to have understood your problem...
Answer: There are a few ways to do this.

Use boost::shared_ptr or std::shared_ptr with the standard vector. That way you do not
have to worry about deleting and memory is freed incrementally
whenever no pointer references the object. This can be useful if you need to destroy specific objects frequently and requires the least amount of code. The downside is storage
overhead if most objects are never destroyed apart from the rest and you have a lot of objects. And, depending on where you remove the object, it can still reside in the inventory without a container or vice versa.
Give the containers responsibility for destruction and deindexing from the inventories by deriving them or wrapping them in another class. Since each object's pointer only appears in one container as described by you, only inventories may hold extra pointers. Hence whenever an object is to be removed, the container will have to look up the inventories to remove the pointer to the object it is about to destroy. The overhead is the bookkeeping of the inventories.
Use a memory pool that is a container that stores pointers to all objects and is responsible for their destruction when itself is destroyed. The memory pool can be a boost::ptr_vector while the other containers are standard vectors. This effective for frequent adding and querying objects in the system. The downside is that the memory pool must outlive your containers and inventories. Otherwise it has to do bookkeeping like in (2) if individual objects need to be destroyed apart from the rest.
Answer: Boost::ptr_vector assumes ownership of the object when you pass it in. When you remove an object from that vector it will be automatically deleted. You can remove items without deleting them however by using the built in auto_type (see the farm yard example for usage).
This means that you should really only have an item in one ptr_vector at a time. However your idea of having items in a ptr_vector and then having the ptr_vector be owned by your inventory object (which is another ptr_vector) should work. I have never done that but it should be fine.
In order to delete a single object you just look it up using a container_id and an item_id, and then remove it from the item-level ptr_vector. In order to delete a container, just remove it from the inventory. It will destruct anything that it contains at that point.
If you want to remove them without deletion use the auto_type to remove them safely. You can release them from the auto_type and do as you please if you want to using raw pointers to objects.


What are the side effects of blood doping?

Question: It has been in the news that endurance athletes such as cyclists sometimes increase their red blood cell count by blood doping. I don't understand how you can just pump more blood into yourself, there must be some bad side effects to doing this, right?
Answer: Basically, the intended effect is to increase the number of red blood cells in your system, which in turn gives you increased oxygen carrying capacity to the working muscles. This extra oxygen allows your muscles to work longer and harder.
In the early days of "blood packing", circa the 70's and 80's, it was basically taking a couple of pints of blood out of the body, storing it and letting the body naturally replace it, then transfusing it back into the athlete before their events.
Erythropoietin has actually been around since the early 1900's, and in the 60's, they found that it stimulated blood marrow to produce extra red blood cells. In the late 80's, a synthetic EPO agent was created, and this is what led to the EPO use as an athletic enhancing agent, other than its legitimate medical uses (Anemia, and other diseases).
The biggest effect from extra blood cells (Other than the risk factors of homologous blood {Blood from an outside donor}) is that the blood becomes thicker and more viscous. This can lead to blood clots, strokes, heart attacks and pulmonary embolism. This becomes more likely at rest/sleep, as the heart rate slows quite a bit.
Answer: Here is an excellent article from Outside Magazine written by a journalist who rode brevets and decided to explore performance enhancing drugs (EPO & HGH) and write about it.
The really sad thing about these drugs is that they appeal to really talented and dedicated athletes who've reached the pinnacle of their abilities and who have only a very limited amount of time before age or injury degrades their physical performance. I am sure that you'll be able to find plenty of references on the physical side effects of these substances (yes, they're dangerous and potentially fatal). But the psychological "side-effect" is significant as well.
People who take these drugs become acutely aware that they are not themselves and that their performance is not entirely their own. That, by itself, let-alone health consequences is a huge burden that must be carried in secret by athletes who've spend a decade or more developing their abilities using only their own talent and hard-work.
Answer: Blood doping isn't only pumping more blood into your body. Your body increases hemoglobin (red blood cells) when you are in great altitude. This is caused by lower air presure which doesn't allow the lungs to transport enough oxygen into the bloodstream. Therefore the body can increase the ratio of red blood cells in your blood to compensate for the lower oxygen intake. If you train hard in big height this compensation mechanism really kicks in, raising your hemoglobin  level. After doing the traing the high hemoglobin rate only lasts a few days(?)/weeks, therefore you can remove this blood from your body and freeze it for competition.
Before the competition starts you reinject the froozen blood (maybe remove some current blood?). This gives you an higher oxygen binding rate and gives you more power on the bike. You don't need EPO or anything. EPO also increases hemoglobin but without the need of high altitude. I wouldn't really concider that blood doping, but the link from the previous answer differs. I think your question referens to "doping with your own blood"  (not a native speaker, don't know the technical term)
If it harms you? People in high altitude maybe live shorter, but that might be caused by missing health care system, poverty and missing education in countries with high mountains. I think other factors such as increased radiation in heights might account for more deaths than some cardio-vascular stuff. Therefore saying more hemogobin equals higher mortality might be a long shot and empirically wrong. Are there any studies? (not that I know of, but might be worth a search). Injecting large amounts of blood may well be a hazzard if the blood starts to clot, or was contaminated during storage, but I guess that's a small risk. Taking other peoples blood may well mess you up, if some unexspected immune reaction kicks in. I don't think enough cyclists died from injecting their own blood to make some profound statement.
Comment: Mostly correct, but one salient point...the benefit from altitude does not require actually training in it. You only need to be at altitude for 8-10 hours a day to get the benefit. In fact, training at altitude can cause more muscle damage than at sea level and the lower oxygen pressure lengthens the recovery time. Most elite athletes that utilize high altitude sleep (spend their evening and night) at altitude but come down to sea level for their daily training.
Comment: High altitude is easily simulated by lowing the air pressure in the room the person sleeps in. No need to climb to the top of a 20000ft mountain to go to sleep any more.
Answer: From the World Anti-Doping Agency:
http://www.wada-ama.org/en/Resources/Q-and-A/Blood-Doping/
While proper use of EPO has an enormous therapeutic benefit in the treatment of anaemia related to kidney disease, its misuse can lead to serious health risks for athletes who use this substance simply to gain a competitive edge. It is well known that EPO, by thickening the blood, leads to an increased risk of several deadly diseases, such as heart disease, stroke, and cerebral or pulmonary embolism. The misuse of recombinant human EPO may also lead to autoimmune diseases with serious health consequences.
Answer: If the blood is from other individuals then there are a number of hazards, from AIDS and hepatitis to malaria and Lyme disease.  Plus there's always a chance of a sort of allergic reaction to the blood due to mismatched antigens.
If the blood is "autologous" -- from your own body -- then the above risks are avoided (so long as someone doesn't mix up the blood).  But there are non-trivial risks of infection, blood clots, and iron overload.  On the "donating" side, since you're probably stressing your body in several ways, there are additional risks.
Answer: infection with hepatitis or aids. Allergica reaction if incorrect blood type is use. Blood clots. Kidney damage.Strain circulatory system
Comment: Welcome to [bicycles.se] @annalisa. Blood doping is storing some of your own blood and reintroducing it just before competition. How does this lead to *infection with hepatitis or aids*, and what would cause *kidney damage*? Can you expand your answer to explain please?
Comment: @andy256 I would interpret "doping" to be a much broader term that covers pretty much any form of performance-enhancing drug or medical treatment. Autotransfusions are just one of many techniques. Wikipedia seems to agree.
Comment: @Carey I always did think I should edit Wikipedia :-)


Modeling tail data using Generalized Pareto distribution

Question: I just estimated a ARMA(1,1)+GARCH(1,1)+Threshold order(1) equation for time series of stock prices.
Now I'm going to estimate the residuals' marginal distributions using the kernel density estimator in the interior of the distribution and the POT method in the tails using 10% of the data points for each tail.
I calculated cdf for all tail points using estimated parameters $(\mu=-5.98,\sigma=36.342 ,\varepsilon=-7.04)$ but the function doesn't support all of data points in tails. $(\mu < x < \mu-\frac{\sigma}{\varepsilon})$
Am I supposed to fit GPD to all data not just tails?
what are the other distributions appropriate for modeling tail data?
Comment: Meixner Distribution, http://reference.wolfram.com/language/ref/MeixnerDistribution.html
Answer: You might be interested in this ARTICLE (published in Quantitative Finance 2016) and citations therein. The authors consider different distributions to model tails in financial time series and in particular focus on EVT/GPDs.
GPDs are used to specifically model tails and hence are fitted after some threshold that separates the tail from the central region of the distribution. Threshold choice is a separate discussion, the literature provides
several methods (e.g. see article above).
Comment: I'm familiar with the way GPD works but I don't know why the cumulative distribution function gives values less zero or it is unable to calculate cdf for some points. I'm wondering what kind of probability distribution is fitted on data but cannot support all of them!!!
Comment: Meixner Distribution, http://reference.wolfram.com/language/ref/MeixnerDistribution.html


How to Properly Unwrap Metaball, Metaball animation

Question: I have a Metaball animation running with animation node. I want to project the UVs from the surrounding sphere to the metaballs so I can have the textures applied without artifacts (you can se in the gif). The only problem is that I don't really know hot to do it. If it was a normal mesh I would go for the uv projection modifier, but since is a metaball I can't apply modifiers.
Does anyone know how to solve this problem?
Thanks a lot
Comment: Use the generated or object coordinates with the image texture projection mode set to Box, and the blend to a value > 0
Answer: You can use equirectangular type of texture image.
Trick to apply this texture is used Environment texture node (instead of Image node) in material node tree.

If you don't have yet this type of texture, its very easy to let blender render one from sphere.
Let me know if you need more info.
Answer:
I did it this way and it worked fine for me (but i am using a cube instead of a sphere).
Under - Texture Coordinates - Object - Try to plug in your outer sphere.
Comment: What I tried it still produce visible seams to me (even with blend). Unmissable even more in animation, because projected box edges moves but texture doesnt for its projection. And I dont speak about wire texture, I tried it with crazy bark texture.


Recover media after factory reset (One Plus One)

Question: I've recently done a factory reset on my OPO. I though I didn't need anything on it anymore but now I do actually need some pictures who were on it before the reset.
I'm trying to get those pictures back. However, recovery programs do not work because the OPO does not get recognized as a USB mass storage device, since it only has internal storage and there isn't any SD card to find.
Is there anyone with similar problems or does anyone know how to solve this?
Android version 4.4.4
CyanogenMod version 11.0-XNPH38R
Answer: You can try DiskDigger undelete (root) or Undeleter Recover Files & Data app.
I had more success with DiskDigger though.


Exporting Mozilla Firefox Bookmarks Into Excel

Question: I want to export all the bookmarks from my Firefox browser into CSV or Excel file. How can I do this?
Comment: Just an opinion: I wouldn't export into Excel. I've seen too many users using Excel as a DB. Excel is not a DB, it's a sheet, please keep this in mind. If you want to backup your bookmarks, look for something like XMarks.
Answer: I just tried the HTML export/excel import option, rather messy but using " as a delimeter on excels text import wizard did get the urls in a useable format - you could then manually zap most of the rest quite easily; rather depends on what you wanted excel to do with the information.
Answer: Firefox can export bookmarks as an HTML file, and Excel can open HTML files.
Whether Excel will know what to do with an HTML file with bookmarks is another question. I'll do some puttering around and see if I can get more info.
Comment: Did Excel actually handle this conversion well? I'm actually rather interested. I don't have FF on my work machine to test how well it would work.
Comment: Two downvotes? I appreciate constructive criticism more than hidden stabs.
Answer: I did a macro for it, that does 99% of what can be automated.  It's very easy.
. . . maybe you know what Visual Basic command I need to get that extra 1%:
http://www.excelforum.com/excel-programming-vba-macros/996189-macro-to-convert-my-firefox-27-0-1-bookmarks-to-excel-2010-a.html
[This is the main idea, below. The macro is shown in html at the link above, and two .bas files are there also for download, the one I'm using, and the one that almost does as much as is possible to automate.]
I export my Firefox bookmarks . . . and did this macro to automate it, which I have been doing manually (these are my source notes) . . . I have a question in here, at the pertinent point:
File \ Open \ Desktop \ bookmarks.html Yes . . . Delimited . . . No Tab / Other " . . . Finish View / Arrange All / Horizontal / Ok Zoom to 80% . . . Microsoft Sans Serif . . . 10 point
Highlight columns in yellow ... B - G - I - K - M . . . M is the last column Clear Col A for a sort number index . . . Center the text Delete all of the other non-yellow columns through M Column Width of ... B - C - D - E - F ... to 25
Ctrl+Home . . . Ctrl+F for: "Unsorted" It's always on row 123, unless I add bookmarks that stay there (then I'll have to re-do this macro) There will be a long number in the URL column, right aligned, above these new URLs Highlight Row 123 . . . Shift+Ctrl+Arrow Up . . . Right-click / Delete
Ctrl+Home . . . In Cells A1 and A2, put 1 and 2 Put a sort number index in Col A, drag bottom right corner all the way to 500
Ctrl+End . . . Shift+Home+Ctrl+Home Sort on Col B, the URL, to get rid of spaces
Ctrl+End . . . Home . . Arrow Right . . . Ctrl+Up . . . Arrow down Delete everything that was a space, all the way to the bottom: Shift+Ctrl+Arrow Down+Arrow Down . . . Right-click / Delete This is where the problem lies. The row it finds here will probably be different every time, but the macro keeps the row that was determined, when making the macro. Is there a command, like "last active cell" ? If I leave this part out of the macro, I get the data I want, it's just messy, because I have numbers in Col A, and my URLs are not in the original order done. The example here is for 25 bookmarks. If I try to process a bookmarks.html file of 23 bookmarks, it leaves an extra 2 random lines. If I try to process a bookmarks.html file of 11 bookmarks, it leaves an extra 14 random lines. Ctrl+End . . . Shift+Home+Ctrl+Home Sort on Col A, the index, to put URLs back in the original order
Ctrl+Home Put URLs of Col B to the right of the web page names
Ctrl+Home Ctrl+H . . . replace . . . ">" . . . and . . . "
. . . with nothing
Unhighlight B - C - D Ctrl+Home
<code>            Manual editing part (when I leave out the above issue)
</code>
Run the Macro: Process_Bookmarks Sort on Col A, the index, to put URLs back in the order done Move some Titles from B - C - D . . . to E Sorting on B - C - D can make it easier to get them Un-highlight all
Copy and Paste links to bottom of Favorites / Take a look at them to verify / SAVE Close / Dont' Save the Import Edit the bookmark Titles for special characters, or go back to web page to get the Title of the page / then categorize Delete bookmarks.html on Desktop, and the Unsorted URLs in Firefox bookmarks.html will remain in the Recycle Bin for a day or so, in case there are any problems
Comment: Please answer the question on this site instead of linking to another site.
Comment: I can't get my info into this area, and really want to share this, it works great . . . I would like to kindly refer you to check out #5 on this page:

http://www.excelforum.com/excel-programming-vba-macros/996189-macro-to-convert-my-firefox-27-0-1-bookmarks-to-excel-2010-a.html

This is my updated version of the steps for the Macro, it works a little better.  TY.


Which one is the 4G sim slot in Redmi 3s prime?

Question: I have acquired an Jio sim and I am using a Redmi 3s prime. But I don't know which one is the primary 4G sim slot in the phone. Is it the nano one or the micro one? Or can i choose any one of them? Please help. Thanks
Answer: The Redmi 3S Prime uses a hybrid SIM slot which means it accepts one Micro-SIM and another Nano-SIM or microSD card for storage.
Unfortunately, this means that users will have to choose between a second SIM and a microSD card.
Coming to your question : Use any slot for 4G. It is recommended from my side, use the micro-sim slot for the primary sim.
Answer: The Redmi 3S Prime supports hybrid dual-SIM (Micro-SIM + Nano-SIM) slot with the second SIM slot also capable of functioning as a microSD slot. However either slot can be used for 4G.


VMware Player - Running as a Service

Question: Is it possible to run VMware player as a Windows Service so that a user does not have to be logged in to have the player running?
Answer: Vmware Server is the correct tool for running a VM in the background, not Vmware Player.
Comment: vmware server is deprecated and has a low "vm hw version"
Comment: @JamesBarnett people do lots of things that aren't "ideal" - go for a drive and watch how others behave on the roads if you don't believe me. The fact that you can 'bodge' VMWare player into running as a service doesn't alter the fact that VMWare server is the intended tool for that job.
Comment: Not strictly true. People all over the net are running VMWare Player as a service.
Comment: (and is also free)
Comment: Maybe depends on the use case.

If you want to run a VM unattended because you want a cheap VMWare Server then I agree with you.  However the statement "the correct tool for running a VM in the background" is overly broad.

In my case, I wanted to run linux side-by-side with Windows using Unity mode and not have to worry with seeing the VMWare Player UI. Also Windows is overly found closely binding GUIs with background processes.

A central part of computer history is being able to hack a something to do what you want.  The tool isn't wrong, you just need to know it's limitations.
Comment: OTOH, keep in mind that this site is about professional sysadmining.
Comment: @Zoreache LOL. Runnung a VM in the background is a built-in feature to VMWare Workstation since atleast version 6.
Comment: -1 Technically, the question is whether VMware Player can be run in the background, not which alternatives are available that may or may not be more ideal.
Answer: Sorry for the late responce with this. I was trying to figure this out today.  I came across this answer, figured I let SF know.
You can actually ...

Add this to your VMX config file to set VMWare Player not show the UI:
msg.noOk = "TRUE"
Get instsrv.exe from a Windows Server Resource Kit to create your own service
On Startup have a batch file call the service you just made

Step-by-step instructions can be found here:
http://research.stowers-institute.org/dct/docs/admin/VMwarePlayerService.htm
Comment: last link is broken
Answer: I know this is an old question, but I searched all over the internet for a solution to this and I couldn't find anything quite as comprehensive as what I'd like to share.
Yes, it's possible to use vmware player as a service for Linux (there's a separate answer for Windows); it's easy and there's no reason I can think of not to do it. It's especially great for hosting a headless server from a headless server.
The other VMware-oriented choice, VMware Server, is deprecated and the only other $0 choice I know of is VirtualBox. If you like that better than VMWare Player, more power to you, but I know VMWare Player and I don't see a reason not to use a well-supported path to get what I want.
Presumably you'll want it to run under a non-root account and start up and shut down at the standard service startup/shutdown times.  If that's the case, then here's how to configure it:

Get the daemon package (usually not installed by default):
apt-get install daemon

Download VMware Player and VMware VIX from vmware.com and install them to get the VM engine and VIX's vmrun (command-line control of vm execution) binary.
Add the service to the startup by creating /etc/init.d/<vm_server_name>. It could look something like this:
#! /bin/bash
### BEGIN INIT INFO
# Provides:          vm_server_name
# Required-Start:    $named $remote_fs $syslog
# Required-Stop:     $named $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: My Server VM
# Description:       Virtual Machine instance of My Server
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin
VM="/path/to/vmx_file.vmx"
USER_TO_RUN_UNDER="username"

if [[ "$USER" == "$USER_TO_RUN_UNDER" ]]; then
  USER_FLAG=""
else
  USER_FLAG="--user=$USER_TO_RUN_UNDER"
fi

case "$1" in
    start)
        daemon $USER_FLAG -- vmrun -T player start "$VM" nogui &>/dev/null &
        ;;
    stop)
        vmrun -T player suspend "$VM" &>/dev/null
        while [[ "$(vmrun -T player list | grep -o "$VM")" == "$VM" ]]; do
          sleep 1
        done
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac

Make the script runnable:
chmod a+x /etc/init.d/vm_server_name

Add the script to the standard linux service startup/shutdown runlevels. The numbers ensure that it is one of the last things started and the first to be shut down:
update-rc.d vm_server_name defaults 99 01

Notes:

You'll probably need to 'sudo' all the commands as you're modifying root-owned files.
I put a loop in so that on shutdown the script doesn't return to the OS until it has completely suspended the guest OS. I don't know if that's needed or not, but it seemed like a good idea. It will definitely slow down shutdown of the host OS, but it is worth it in my opinion.
If you need to interact with the local GUI of the guest OS, suspend the server by running /etc/init.d/vm_server_name stop and then start it locally using the VMware player GUI. After finishing, suspend it and run /etc/init.d/vm_server_name start to start the headless instance again.
Comment: A good answer for Linux users, but the question was specifically asking about running VMWare Player as a ***Windows Service*** -- Perhaps you should [ask and answer a separate question about doing this on Linux](http://serverfault.com/questions/ask) :-)
Comment: If Vmware player, and Virtual box are the only thing you came up with on Linux, then you aren't searching very hard.  KVM and Xen are the preferred tools these days.
Comment: Thanks for the pointers to other solutions. Try searching for 'vm as a service' in google and you'll see what I saw. I think what you are really saying is that you believe hypervisors are the new hotness. I think there are valid reasons for hobbyists to choose a linux host with other vm's as services, but for scalability I'm sure you're correct.
Comment: Oops, I didn't see the word 'Windows' in the question.
Comment: hmm, on second thought I think windows wasn't mentioned in the question when I answered it. Could be wrong...
Answer: From SuperUser
It is possible using this very old free microsoft wrapper (google for explanations about srvany): ftp://ftp.microsoft.com/bussys/winnt/winnt-public/reskit/nt40/i386/srvany_x86.exe
Or there are also commercial tools: http://www.coretechnologies.com/products/AlwaysUp/Apps/RunVMwarePlayerAsAService.html

VMware Player - Running as a Service


Spearman's rank correlation max number of respondents?

Question: So apparently, our subject research proposal was turned down because we used Spearman's correlation to determine if there is any existing relationship between the time spent in playing video games and the grades of 240 students. We were told that Spearman's correlation could only be used at a max of 120 students, which made us really too shocked to speak (because we didn't know anything like that and also we lacked evidence to disprove our 80-year old professor). We've been reading a lot of different books so far and have not seen anything about this. I would really appreciate it if you could help us clear this confusion and find some information about the limitations of Spearman's correlation. Thank you. :)
Comment: Frankly, I think the claim is nonsensical. I can't second-guess why he might have said that - when someone says things you don't understand, *that person* is best placed to explain their reasoning.
Comment: I'd first ask for clarification - preferably with a reference - on what the problem is. You can't hope to address an unspecifed problem - you could write a hundred pages on it and still not hit the exact issue he thinks there is. If you can't ask him yourself, do he have a colleague who might find out for you?
Comment: It is a sad state of affairs when an unqualified person is in a position to review others' work.  What is the position of this reviewer?
Comment: We think so too! It really is sooo nonsensical! He didn't say anything about why there's a limited number of respondents in using spearman. We are getting really desperate on how we'll explain things to him. :( Otherwise we'll have to redo the study
Answer: The claim makes no sense to me.
If it could only be used for $n\leq 120$, then there'd be no need for asymptotic approximations to the distribution of the test statistic (since it would be easy to tabulate the exact distribution for all available $n$); there'd be no point in computing the asymptotic relative efficiency, and so on.
As it is, it's going to be a valid test an any sample size above $n=2$, though practical significance levels will only be available for $n=5$ and above; it's a permutation-test, so you can in principle calculate the distribution of the test statistic at any sample size.
The prime considerations would really be "can we get reasonable significance levels?", "can we get good power properties?"
And at all but the smallest $n$, the answer to both questions is "Yes, we can". (There's a lot to be said for Kendall's tau, actually, but that doesn't imply a problem with Spearman's rho.)
While computing exact p-values become unwieldy at moderate sample sizes there are many ways to deal with it - randomly sampling the permutation distribution is one possibility, various approximations another.
This paper$^{[1]}$ uses an Edgeworth series expansion to approximate the distribution from fairly small $n$ up to fairly large $n$ and then a normal approximation will be very suitable thereafter. The R  package uses this algorithm for its Spearman correlation test and I believe Matlab does as well. [R uses the Edgeworth expansion between n=10 and n=1289.]
$[1]$ D. J. Best and D. E. Roberts (1975),
"Algorithm AS 89: The Upper Tail Probabilities of Spearman's Rho,"
Journal of the Royal Statistical Society. Series C (Applied Statistics),
Vol. 24, No. 3, pp. 377-379
Various other approximations exist (though most are somewhat less accurate).
In any case, there seems to be no reason whatever not to use it above $n=120$.
So I am left with no clear idea what the problem can be - we can calculate accurate p-values at whatever $n$ we need. Reasonable significance levels can be chosen at all moderate and large significance levels. Power is quite good, even for linear correlation at the normal.
In the absence of more specific information, I cannot see any issue.
If you can find out what his specific objection is, it will no doubt be relatively simple to address it.
Comment: THANK YOU! This has been most useful. Thank you very much! I shall print a copy of this and let him process it in.


Roughly what date do NSF Postdoc Fellowship announcements occur?

Question: I can't find any information about when NSF announces the recipients of their postdoctoral fellowship awards. I'm specifically interested in the one for mathematics. I'd like to use this information to get a rough schedule for rolling applications.
Comment: What do you mean by rolling applications?  If you're thinking about deciding whether to apply for more postdocs after hearing about the NSF, it comes out too late for that.  The NSF is announced after the application deadlines for a lot of jobs, so you need to plan and apply under the assumption that you won't get the NSF.
Comment: There are many jobs that are not postdocs, and places like industry labs often have rolling applications.
Answer: In another answer, Zach H said that notifications for 2014 went out on January 14th.
In 2015, the date was January 26.
In general, the notifications are sent out a week or so before the coordinated postdoc deadline, the day before which most research universities agree not to require a decision on postdoc offers. http://www.ams.org/profession/employment-services/deadline-coordination/deadline-coordination  This deadline changes from year to year, but it is always toward the end of January/beginning of February.
The idea is that people should have an opportunity to find out whether they've received the NSF before making any other decisions on postdoc offers, and if they were not one of the lucky few getting the NSF, then they should have at least a week to mull over their decision.
Answer: In 2020, the informal notifications were sent out on January 26 (a Friday).
For 2021, the AMS says the NSF will try to complete the review by January 22. (Most departments will not require a response to their offer by February 1, also according to that page.)
For 2022, the AMS again says "the NSF's Division of Mathematical Sciences has agreed to complete its review of applications and electronically notify all applicants by Friday, January 21, 2022, at the latest."
Comment: Has anyone heard back from the NSF this year? I'm still trying to figure out where my application went. (Two years ago, I didn't get an official rejection until March.)
Answer: In 2014 I received an informal notice of rejection for an NSF postdoc in mathematics on January 14th, immediately prior to the Joint Meetings. Acceptance notifications were sent at the same time, though the formal decision was not posted for another eight days. I can't attest to whether this was typical.


Can I use the same account on a different phone?

Question: I am playing Pokemon Go; However, I am going to stop using the phone that I use for the app and buy a new one. If I start playing Pokemon Go with a new phone using the same account, will the data and/or Pokemon that I have caught be saved in my same account with a new phone? I feel really worried for losing everything.
Answer: Yes, you can link your account by signing in with the same Google account or Pokemon Trainer Account.
Your progress will be automatically synced, so need to worry about losing your hard-earned pokemon!