In the following example, how is y given the value of 1?  I added some logging to see values and don't understand how/where y is assigned...   (function() {     function foo(x) {         var callNum = 0;         var baz = 3;         return function (y) {             callNum++;             console.log("callNum: " + callNum);             console.log("y: " + y);             console.log("baz: " + baz);             console.log("x: " + x);             console.log(x + y + (++baz));         }     } var moo = foo(2); // moo is now a closure. moo(1); moo(1); })();   Here's the fiddle output log:       callNum: 1        y: 1        baz: 3     x: 2      7      callNum: 2      y: 1      baz: 4      x: 2      8
How would you explain JavaScript closures to someone with a knowledge of the concepts they consist of (for example functions, variables and the like), but does not understand closures themselves?  I have seen  given on Wikipedia, but unfortunately it did not help.
I am struggling to convert .dwg to .shp, ideas? Any ideas as to how can I convert dwg to shp?  I tried Kosmo and gvSIG. gvSIG kind of worked but it seems like I lost information.. in addition everything was converted into lines, no polygons. I can manually recreate the polygons, but there must be a better program to do this conversion.  Ideas? I am new to this and not sure what to make of all the options available. I am interested in putting a machine-learning-related preprint, which will potentially be submitted to places like NIPS/ICLR/ICML in the future.   arXiv.org perpetual, non-exclusive license to distribute this article (Minimal rights required by arXiv.org)  Creative Commons Attribution license (CC BY 4.0)  Creative Commons Attribution-ShareAlike license (CC BY-SA 4.0)  Creative Commons Attribution-Noncommercial-ShareAlike license (CC BY-NC-SA 4.0)  Creative Commons Public Domain Declaration (CC0 1.0) Left inverse implies right inverse in a finite ring Let $R$ be a finite ring with identity $1$, and assume $\exists x,y\in R$ such that $ xy=1$. How can I show it implies $yx=1$? Is there a problem with the ClearBits data dump? How to create a shortcut that executes an xdotool command to simulate a key press? I'm trying to simulate a media key press using a custom shortcut.  So far, I've been able to achieve the simulation I need using the command:  xdotool key XF86AudioPlay   It works perfectly, it pauses or starts the music player every time it is run.  The problem comes when trying to run it as a shortcut.  First I tried to run an alias with a custom shortcut, but it did not work.  As explained on :     The commands run by keyboard bindings are not parsed via a shell. Your best bet is to create a directory bin in your homedir.   Next I created the suggested script and named it simplay:  #!/bin/sh xdotool key XF86AudioPlay   It is located inside a bin folder which is part of the PATH, this works fine and can be run from any location.  When trying to create the Custom Shortcut, I was unable to get it to execute, the configuration is the following:  Name: test Command: simplay  Shortcut: Ctrl+Alt+R   After searching a bit more I found another way to execute the shortcut:  gnome-terminal -e simplay   I tried it on a terminal and noticed that when executing it it would rapidly open a new terminal window, execute the child process, pausing the music and immediately close the window.  I changed the command on the shortcut and when hitting it I noticed the same behavior opening a terminal and immediately being closed but this time the child process did not pause the music, which makes me think that the script has been called on all my previous attempts but it is somehow not being able to execute.  How can I solve this problem according to your knowledge? 'Some index files failed to download' while updating A friend offered me a brain teaser to which the solution involves a $195$ pound man juggling two $3$-pound balls to traverse a bridge having a maximum capacity of only $200$ pounds. He explained that since the man only ever holds one $3$-pound object at a time, the maximum combined weight at any given moment is only $195 + 3=198$ pounds, and the bridge would hold.  I corrected him by explaining that the acts of throwing up and catching the ball temporarily make you 'heavier' (an additional force is exerted by the ball to me and by me onto the bridge due to the change in momentum when throwing up or catching the ball), but admitted that gentle tosses/catches (less acceleration) might offer a situation in which the force on the bridge never reaches the combined weight of the man and both balls.  Can the bridge withstand the man and his balls? Count work days between two dates How can I calculate the number of work days between two dates in SQL Server?   Monday to Friday and it must be T-SQL. Word to describe someone who publishes many works? What word describes an author who publishes many works?  "Profuse" comes to mind, but this word has a broader meaning. Is RSA key size the size of private key exponent? I have implemented a key pair generation scheme for RSA algorithm. I have taken the length of private key exponent as RSA key size, but then I've got to know that RSA key size is the size of the modulus $n$. Is it wrong to take RSA key size as the size of the private key exponent?  To generate a private key of 1024 bits, I increase the size of private key exponent regardless the modulus $n$. This is my first question on here. I'm trying to numerically solve the Schrödinger equation for the  and find the energy eigenvalues and eigenfunctions but I am confused about how exactly this should be done.  I've solved some initial value problems in the past using iterative methods such as Runge–Kutta. I've read that  is the way to solve Schrödinger's equation but Wikipedia also describes it as an iterative method for initial value problems.  How do I use it to solve an eigenvalue problem?  This confuses me for the following reasons:   Wouldn't iteratively solving the DE require knowledge of the energy eigenvalues to use as input to the calculation? I don't know the eigenvalues yet; they're precisely what I'm trying to calculate. If I did that, wouldn't I simply get a unique solution, instead of a family of eigenfunctions and eigenvalues?    I've seen some mention of "tridiagonal matrices" being generated somehow, but am not sure what the elements of that matrix would be or how that applies to the problem. Leandro M. mentioned that "the discretization defines a finite dimensional (matrix) eigenvalue problem". This seems like the correct road I should be going down, but I haven't been able to find anything that explicitly explains this process or how the matrix is constructed. If this is the correct procedure, how is such a matrix constructed? How To: Execute command line in C#, get STD OUT results How do I execute a command-line program from C# and get back the STD OUT results? Specifically, I want to execute DIFF on two files that are programmatically selected and write the results to a text box. So, my update to 13.04 didn't go very well. Due to the lack of a decent driver (Yes, i'm unlucky to have a legacy driver which doesn't play nice with the new Xorg.), I had to mess around with stuff to first troubleshoot and afterwards "fix" my system.  I've finally got unity back, but now CtrlAltarrow and CtrlAltShiftarrow don't work anymore. They are bound in "keyboard" > "shortcuts", but nothing happens when I try it. A strange thing is that other keyboard shortcuts, like ctrlaltt to show terminal are still working.  I noticed that CtrlAltarrow doesn't show in the list with "unity shortcuts" (the list that shows when you hold the super key).  Does anyone know how to re-enable this way of workspace switching?  I enabled workspaces in the appearance menu. It doesn't have any effect though. Switching via the workspace-switcher in the unity dash works fine though.  CCSM is installed, but I can't seem to find a way to add keyboard bindings there.     System: ubuntu 13.04 64bit Use of substitution into the integral $\int_0^2 \frac{\arctan x}{x^2+2x+2}dx$ Why does range(start, end) not include end? Why does just splitting an Ethernet cable not work? I thought the Ethernet is logically a one-line communication bus (for argument's sake, I am excluding hubs). All machines attached on the bus hears the same signals and the machines themselves try to avoid collisions by randomly backing off.    If so, why would splitting one Ethernet line from my home router into two and connecting two computers not work? Why do I have to add a switch to it?  What the Internet said would not work.                                                             +----------+                                                +----------&gt;|computer 1|                                                |           +----------+     +------------------+       +---------------+     |4 port home router+------&gt;|simple splitter|     +------------------+       +---------------+                                                |           +----------+                                                +----------&gt;|computer 2|                                                            +----------+   What the Internet said I should do                                                             +----------+                                                +----------&gt;|computer 1|                                                |           +----------+     +------------------+       +---------------+     |4 port home router+------&gt;|    switch     |     +------------------+       +---------------+                                                |           +----------+                                                +----------&gt;|computer 2|                                                            +----------+   Is this because of the signal degradation (reduced electric current)?    Thank you for all the answers! The reason why I did not just use the two ports of my home router is...  The 4-port gigabit router is in my room, and I had put a computer in another room (also my room, though). Since a wired network is far more reliable and secure, I had bought a long Ethernet cable and and connected the computer to the router. Now I was thinking about adding another computer to that room. I could buy another long Ethernet cable, but then there will be two cables between the rooms. The one line already is a minor annoyance, so I thought if I could share the one line between the two computers in that room. A switch would work, but it requires power and is a little bit pricey. That is why I wondered why it would not work to simply split the physical Ethernet cable.  Apparently I do not completely understand how Ethernet and a switch work. I just have some bit of knowledge I heard in my college class. $ d_1,d_2\mid n\iff {\rm lcm}(d_1,d_2)\mid n\ $ [LCM Universal Property] Is $$d_1\mid n,d_2\mid n\iff [d_1,d_2]\mid n$$ true ? And if yes, how can I prove it ? I recall that $[d_1,d_2]$ is the least common multiple.  My tries  For the implication : Let $d_1\mid n$ and $d_2\mid n$. Then, $d_1d_2\mid n^2$. By the way, since $d_1,d_2\mid n$, we have that $(d_1,d_2)\mid n$ where $(d_1,d_2)=:\gcd(d_1,d_2)$  and thus $$[d_1,d_2](d_1,d_2)\mid n^2.$$  Question: How can I get $[d_1,d_2]\mid n$ from this?  For the converse, since $d_1,d_2\mid [d_1,d_2]\mid n$, the claim follow. How to remove the lines which appear on file B from another file A? Children's bike problem with back wheel My daughter has sparkle and glitz 12 inch bike with stabilizers (training wheels). Since we purchased the bike every now and again the back wheel keeps spinning when she is pedaling. This seems to happen more when there is a bit of an incline.  Any suggestions what problem could be? Lenovo Yoga 13 Realtek wireless driver