How do I share internet with Windows from my Linux box?

Question: I have a Linux (Ubuntu 12.04) PC connected to the internet with a Greenpacket WiMax USB modem. I want to share the Internet connection with another computer running Windows 7 Home Premium, connected to the Linux PC over a LAN. Is this possible? How? Is the reverse possible instead (connecting the internet to the Windows computer and sharing it with Linux)?
Comment: Did it work? Do you need any more help?
Comment: Thanks. You are so helpful. But sorry, I have no time to do this right now. I will comment as soon as possible.
Answer: You need to set up NAT on the Linux box. There are numerous howtos on the Net when you search for NAT and iptables, maybe including the distro you use. Here is a howto for Debian which should work on other distros as well: http://debianclusters.org/index.php/NAT_with_IPTables
Here are some lines that come from a German Ubuntu howto:
sysctl -w net.ipv4.ip_forward=1
iptables -A FORWARD -o eth0 -s 192.168.0.0/16 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Put them somewhere, where they are executed at startup (/etc/rc.local or you put "up" in front of every line and put the whole thing into /etc/network/interfaces) and replace eth0 by the network device that connects to the Internet and eth1 by the one that goes to your LAN.
You might also have to tell your Windows box some name servers (DNS) manually if you don't want to set up bind on your Linux box. And I trust you don't need or already have a DHCP server in your LAN.
Answer: The question asks,

Is the reverse possible instead
  (connecting the Internet to the Windows computer and sharing it with Linux)?

Here's how you can share your Internet connection from Windows to Linux.
On Windows,

Make sure internet sharing is enabled.

Go to Control Panel, find the network connection,
then right-click on the internet adapter and click "Properties".
Click "Advanced".
Right there click the radio button to enable Internet sharing.

On Windows 7:

Go to Control Panel → "Network and Sharing Center".
(You may need to go through "Network and Internet" to get there.)
Clink on "Change adapter settings".
Right-click on the network adapter and click "Properties".
Enter an administrator password, if asked.
Click on the "Sharing" tab and enable sharing.

On Linux,
With root (sudo or su) privilege,

Type this to set the default gateway:
route add default gw x.x.x.x
(Note: replace x.x.x.x by the Windows host's local IP address.
You can find it by typing: ipconfig -all in the Windows Command Prompt.)
Next type this to set the DNS:
echo "nameserver y.y.y.y" > /etc/resolv.conf
(Note: replace y.y.y.y by the DNS server address on Windows.
You can find it by typing: ipconfig -all in the Windows Command Prompt.)

In this scenario, Windows is already connected to the Internet.
After all the setup, you can try now to use the Internet from Linux.
The Linux and Windows hosts
should be able to use the Internet simultaneously.
Comment: -1: he wants to do the opposite (share the internet **from** the Linux box **to** the Windows box).
Comment: but he also interested to do the reverse. here is i am quote his question: Is the reverse possible instead (connecting the internet to the Windows computer and sharing it with Linux)?
Comment: if you want to share internet from Linux to Windows, I think the answer above given by Christian is basically correct after replacing this: iptables -A FORWARD -o eth0 -s 192.168.0.0/16 -m conntrack --ctstate NEW -j ACCEPT
with this: iptables -A FORWARD -i eth1 -s 192.168.0.0/16 -m conntrack --ctstate NEW -j ACCEPT
(note:I am only correcting the typos: -o eth0, replace by -i eth1). plus on Windows side you have to set the gateway with Linux IP and DNS address with the ISP's DNS.
Comment: after all 8 command lines you need to save the settings by type: iptables-save.
Comment: but if it doesn't work maybe there is conflict on iptables rules. in this case before those 4 command lines maybe you need to erase all previous iptables rules by type this: (1)iptables -F (2) iptables -t nat -F (3)iptables -X (4)iptables -t nat -X
Comment: Sometime this method did not work. Windows 7 Host internet ok. But I have change IP http://www.tomshardware.co.uk/faq/id-1925829/change-default-internet-connection-sharing-address-range.html. Linux can ping Windows, but cannot ping 18.104.22.168. Any Idea ?
Answer: There is a simple guide at https://oracle-base.com/articles/linux/use-iptables-to-implement-packet-filtering-and-configure-nat. But I found out, that in Windows, the DNS address that the Linux PC is using, must also be given in Windows.
I have a 3G USB modem connected to my Linux PC, and from that I have two Windows PC's that get internet. It's called (kernel) packet forwarding, and it's quite simple and quick to do - when you understand it finally.
You will need to find out your network interfaces names by running the command "ifconfig" on Linux (in the terminal), and "ipconfig" on Windows (in the command prompt). The interface names, on Linux, are at the leftmost side, like: enp2s0, enp3s0, enp0s18f2u6, lo. Now you set up packed forwarding:

First you need to enable packet forwarding on your Linux PC (see that guide I linked from oracle-base.com).

Next, you can run these commands, as that oracle-base.com guide says (but wait, and read on):
sudo iptables -I FORWARD -i my_lan_interface -o my_modem_interface -j ACCEPT
sudo iptables -I FORWARD -i my_modem_interface -o my_lan_interface -j ACCEPT
sudo iptables -t nat -I POSTROUTING -o my_modem_interface -j MASQUERADE
But there is a more robust way, that I found on the net:
sudo iptables -t nat -A POSTROUTING -o my_modem_interface -j MASQUERADE --random
sudo iptables -A FORWARD -i my_lan_interface -o my_modem_interface -j ACCEPT
sudo iptables -A FORWARD -i my_modem_interface -o my_lan_interface -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -j DROP
Here's an explanation for the commands just above (the "more robust" example), in the same order:

First command: enable masquerading on my_modem_interface so the source address is rewritten on outgoing packets. The --random flag is to have symmetric NAT.

Now we are going to configure forwarding rules. iptables, by default, will unconditionally forward all traffic. Here we prefer to restrict inbound traffic from the internet and allow all outgoing:

Second command: Allow traffic from my_lan_interface to my_modem_interface.
Third command: Allow returning traffic from my_modem_interface to my_lan_interface.
Fourth command: Drop all other traffic that shouldn't be forwarded.

When you reboot your Linux PC, you will have to reenter these commands - I have a script that runs them at each boot. You can make these changes permanent with the appropriate "service" call (again, see the oracle-base.com guide given above), but I recommend running them at each boot (in a script), as you might want to experiment and change things, and undoing what you saved is another challenge. If something goes wrong, or you want to change things, or you just don't want this feature for your current session (or at all), then just reboot your PC and they're gone - but you must disable packet forwarding yourself (before rebooting write "net.ipv4.ip_forward = 0" in /etc/sysctl.conf) to fully disable this technology.

Now you have to create a network connection (Ethernet connection) between your Linux PC and your other computers. For example:

A) On the Linux PC connected to the internet (I use Fedora), with the network connections manager, I create an Ethernet connection, select the appropriate interface (network card name, enp3s0 in my case) that will connect this Linux PC to my LAN. Be sure to select the right firewall zone or your LAN will not get internet. So since this is your internal LAN interface, set the firewall zone to "trusted", but the modem connection interface should be set to "public". Next, in the IPv4 settings tab, set that IPv4 must be used for the connection (IPv6 can be ignored), and select manual address setup. Now add the address 192.168.2.100 - this will be the address of this Linux PC on your LAN. The net mask will be set automatically (255.255.255.0, because this is a "C class" (private) address). Apply your settings and connect.

B) On the second PC (with Linux or Windows, connected by Ethernet cable to the first one above), also create a network connection (if it's Windows, look below for better details), select the appropriate network interface (the device/card which is connecting to the first PC), use manual IPv4 setup as above for the first PC, but here set the address 192.168.2.101 - this will be the address of this second PC on your LAN (these are "private" addresses, meaning that they will not be visible outside your LAN).

B1) If you want to connect Windows (operating system), go to "Network and Sharing Center"->"change adapter settings", and look for your network interface that corresponds to your LAN network card on this Windows PC, which is also connected by Ethernet cable to the first PC. Now, select that interface, right click for Properties. You will see a list. Here unselect "Internet Protocol Version 6" and double click on "Internet Protocol Version 4". Now you enter the address 192.168.2.101 - this will be the address of this Windows PC on that interface (on that [LAN/Ethernet] connection)). Tab down so netmask is filled out automatically (255.255.255.0). (The "Network Profile" can be set to "public".)

B2) It might be necessary to set the gateway address to the first Linux PC, so you would need to enter as gateway address 192.168.2.100.

C) Now, you must enter the DNS address that your first Linux PC is using. For example, my modem uses DNS address 192.168.1.1 (which I can find with the command "nmcli device show  | grep IP4.DNS", where interfacename is the name of your Linux interface connected to the internet). (If you connect to the internet with Windows, run "ipconfig" in the terminal/command prompt, look for a DNS address). And that's it. The DNS information is critical to getting an internet connection.

So putting it short:
My modem address: 192.168.1.100, DNS 192.168.1.1.
Linux PC address on LAN: 192.168.2.100, packet forwarding enabled with iptables redirecting traffic, as explained above, firewall zone set to "trusted".
Windows PC 1 address: 192.168.2.101 with DNS set to 192.168.1.1, network profile set to public. (Default gateway set to Linux PC: 192.168.2.100).
Windows PC 2 address: 192.168.2.102 with DNS set to 192.168.1.1, network profile set to public. (Default gateway set to Linux PC: 192.168.2.100).
(All computers connected together by a simple Ethernet switch with plain Ethernet cables (also called "patch cables" or "patch cords"), not crossed, because "modern" network cards do the crossing by themselves, so you can use crossed cables or not crossed cables, even mix them together in a connection.)
There is also a guide at: https://medium.com/@TarunChinmai/sharing-internet-connection-from-a-linux-machine-over-ethernet-a5cbbd775a4f, which uses Google's DNS addresses instead. Check it out.
Answer: To connect a Linux box to a Windows box (to get internet), you need a working LAN (Ethernet) connection - as said in my first post here. So basically, you need to assign static private IPv4 addresses yourself, on both machines. You might need to set the connection to "private" or "trusted" as well. Once both PC's are connected, go to "Network and Sharing Center"->"change adapter settings", and pick your network interface that corresponds to your internet connection. Right click for Properties and look for a tab related to sharing the connection. There you should be able to select your LAN (Ethernet) connection, to share with your other PC.
You might need to specify the DNS on the "internal" LAN PC, like I said in my first post here, on this thread. So you will need to run ipconfig on Windows in a command prompt to find out what DNS you are using, or use Google's DNS 188.8.131.52 and/or 220.127.116.11.


How do micro-channel plates detect neutral molecules?

Question: Micro-channel plate (MCP) detectors are used to detect photons, electrons or charged particles. But how can MCPs be used to detect neutral particles? In ion traps, the neutral molecules (after being irradiating with a laser, the ions fragment or lose electrons to produce neutral molecules or fragments) are detected with MCPs. I didn't understand the principle of how MCPs work for neutrals! Can anyone please explain this?
Comment: It is generally the case that neutral particles are detected by observing the results of further physics (decays, captures, inelastic scattering events and so on). Because I don't know anything about the experiments you are describing I won't venture an opinion as to exactly what is going on, but MCPs are often sensitive to optical band photons, so the decay of excited molecular states is one possible guess.
Comment: It is not by the decay of excited molecular states. As and example you can see in this article O.Aviv et..al. PHYSICAL REVIEW A 83, 023201 (2011) [link: pra.aps.org/pdf/PRA/v83/i2/e023201], that the MCP#3 is used to record the neutral fragments. So, I think, if it hits with sufficiently high energy the the channels in the MCP can emit electrons thereby detecting the neutrals.
Answer: To produce secondary electrons in an MCP detector, a particle has to hit it with very high energy.  Charged species are accelerated towards MCP through high difference in electric potential (like 5 kV) and when they hit the surface, they produce a cloud of plasma that includes other electrons that follow the amplification cascade.
You cannot accelerate neutral particle in this way, but if the particle is moving very fast already, it will also produce a cloud of plasma when it hits the surface, ejecting secondary electrons. In the paper that you cite, negatively charged clusters were accelerated to 4 keV and then they lost an electron through photodetachment.
Comment: Lot of articles says the use of MCP to detect neutrals. Just as an example:O.Aviv et..al. PHYSICAL REVIEW A 83, 023201 (2011) [link: http://pra.aps.org/pdf/PRA/v83/i2/e023201]. In this article the MCP#3 is used to record the neutral fragments!
Comment: @albedo: in the paper, Al clusters are accelerated to 4.2 keV, this is why it works. I will clarify my answer.
Comment: In addition to accelerating these neutral particles, you could also detect them with an MCP if their internal energy is large, for instance when they reside in excited metastable states.


Force a falling block to place in Minecraft 1.16.4?

Question: What is the best way to force place a falling block?  In other words, is there a way to make a falling block place itself in the air?  If so, what is the best way?  I know you could use barriers under the falling block so it lands and places itself, but I was wondering if there is a better way.  I want to prevent a falling block to break when landing on a torch or another block that breaks falling blocks.  To use the barrier method, I would have to copy the block to a different location, place the barrier down, wait a tick, then copy the block back.  I need this to work with automation, and as little commands as possible, so I am hoping there is a method requiring less commands.  I am making a function that runs a lot of commands that will loop multiple times per tick.  More commands = more lag so less commands would be great.  If any of this is unclear or you have any questions please let me know.
Comment: But wouldn't the barrier method update the gravity block and make it fall again anyway? Or is this an NBT edited falling block so it's any normal block?
Comment: @Penguin it's an nbt edited block.  So any block in the game.
Answer: I think you should try placing a torch on a wall and then on top of the torch you place your gravity-affected block, it should look like this:
<code>▊▊<--- Gravity Affected Block
▊/ <--- Torch
▊
</code>
Try this.
Comment: I need it to work with existing torches.  Some on the ground, some on a wall.


Is it really impossible to use K-fold cross validation for time series data?

Question: I would like to know if it is impossible to use K-fold cross-validation for time series of data. It has been discussed that it is not reasonable to predict past from future, but I think this does not make sense since time series data might be repeated in the future. Suppose a past fold is going to be repeated in the future exactly with the same pattern. Therefore, in that case, the fold that we are considering as past data will be part of the future!
Answer: K-fold cross-validation is not appropriate for time series.  It's perfectly reasonable to use the past to predict the future; the problem is that cross-validation will normally try to predict the past from the future, which is silly and not representative of how it would be used in real life.
Instead, the appropriate way is to use temporally consistent cross-validation.  In this method, we randomly pick a date; all data before that date goes into the training set, and all data after that date goes into the validation set.
If you discover that certain patterns repeat, then yes, a good model will be able to take advantage of that to predict the future accurately.  If so, great!  That will show up positively during both cross-validation and during real-world deployment, so cross-validation is indeed accurately estimating how well the scheme will perform if deployed in practice, which is what we want.


Is there a way to cancel a sending message?

Question: While the message is "sending", I discovered that I had sent to the wrong person. Isn't there anything you can do about this? I used to use Nokia. In those older phones (or systems) you simply press the "C" botton to the right and the sending message is aborted.
Answer: Airplane Mode  immediately..then force stop, then clear the data, the restart phone... Worked for me!
Answer: One way I can think of is by killing the Message application. But I'm not sure if the message sending is done by the Message application itself or if it passes the message to other process or android core to do the real transfer of message.
Anyways you can check by going to Menu -> Settings-> Manage applications -> Select all tab and select Message and click Force stop.
Comment: I'd venture a guess that the delay is caused by the Messaging application waiting for a response from the cell tower that the message has been successfully sent. If that's the case, killing the app won't work.
Comment: I'd just pull the battery out.. that'll always kill
Comment: Killing messaging service works..
Comment: I think by the time one navigates to the screen where the "Force Stop" button is, the message will probably have reached the destination and most likely have been sent from the phone. What OP needs is something like an UNDO in Gmail which basically sends a message after a specified x seconds delay, allowing a user to cancel the message.
Answer: While the message is "sending" press and hold the comment/text massage. A menu option should appear giving you the option to cancel message before it sends. Airplane mode is a good one that'll work too.
Answer: Take a look at Cancel SMS - works as I mentioned in the comment above.
There's a delay of one minute before sending, thereby allowing a user to cancel the send within a minute of typing out the message.
Be warned, the app adds a bookmark and a search shortcut.
Answer: One easy way is, putting the phone into Airplane Mode. So the sending message will be cancelled.
Answer: Yes. You can do it with the SMS UNDO app for android. It runs in the background and is very easy to use. Also you can set up timer when it will be active and the time the message will be put on hold.
Comment: Considering the number of installs the app has as of now, I suppose this answer did nothing more than shameless promotion.
Answer: Check out PVLL. The app puts a delay of 5 seconds before sending, called the "5 second rule". Works for me.
It also has a feature that lets you schedule texts in the future, and there's a sharing layer on top of SMS that lets you discuss your conversations. I use it instead of taking screenshots or cut and paste.
Comment: So far you have two answers on this site, both to promote the same app. What's your relationship with this app? It's important to be clear about this so other users can judge your recommendation accordingly.
Answer: just delete the text while its sending (click and hold on the message)
if the text is not too embarrassing just tell the person who it accidentally got sent to that you didn't mean to send it to them and that it was an accident. or every time you send a text you could create a new text (by typing in/searching for the correct phone number or contact name within your phone's address book)with the correct person's name instead of texting them from the list of names from previous texts that shows up when you open the texting app (to avoid sending it to the wrong person in the first place)
Answer: The c button you mentioned works in Nokia only if the message stays in outbox which sometimes don't work always. The closest option you can get is by using Textra SMS from play store and set the delay sending SMS option to 9seconds. If you happen to send a message to a wrong recipient, you can cancel the SMS by pressing the x button after pressing the send button.


What is the first multiple of $(x+5)$ greater than $f(x)$, if $f(x) = (x+5)q(x) + (x+3)$?

Question: This question arose while I was tutoring a grade 11 student on the subjects of polynomial division and the Remainder Theorem, and I could not provide a satisfactory answer to it. Presumably, $f(x)$ is a polynomial. I am aware we can write $f(x)$ in the form
$$
f(x) = d(x)q(x) + r(x)
$$
representing its division by $d(x)$, where $q(x)$ is the quotient of the division and $r(x)$ is the remainder, with deg $r(x) < $ deg $d(x)$. But for
$$
f(x) = (x+5)q(x) + (x+3),
$$ assuming $r(x) = (x+3)$, the strict inequality does not hold. I tried analogously shifting the question to integers, where, for example, we can write 27 upon the division of 6 as
$$
27 = (6)(4) + 3
$$
and we would then have the smallest multiple of 6 greater than 27 is one more than the quotient, so 5. But I am not sure how to extend this to the question posed.
Comment: What is the question?  There are many ways to find $q,r$, but only one where the $r$ has degree smaller than $d$.
Comment: What is the order relation on polynomials?
Comment: What do you mean by "multiple"?  What do you mean by "first" and what do you mean by $> f(x)$?  None of those have clear and unambiguous meanings.  It is obvious that $(x+5)(q(x) + 1) = f(x)+2 > f(x)$, but it isn't clear that this is a multiple (it's not a scalar multiple), that it is the "first" and it's worth noting that $(x+5)(q(x) + 2) =f(x) + x+7 \not > f(x)$ .  Your question may or may not be meaningful.
Comment: It might help to know how this question arose--was it part of a homework exercise, something the student thought of, or something else?
Comment: @fleablood I am not sure what I mean. The question was exactly as posed. Glad to see I am not the only one who found it ambiguous.
Answer: I am not clear with your question, but answering on what i have understood from your argument.
I guess your question is not correct. For polynomial division, remainder theorem implies that for f(x) and d(x) there exists some q(x) and r(x) such that
f(x) = d(x)*q(x) + r(x) where deg(r(x)) < deg(d(x)) is satisfied.
For the question you are choosing r(x) and d(x) on your own and trying to violate the theorem which is not correct.
Comment: The question given was exactly as I stated. So are you saying the question is incorrect?
Comment: it is incorrect way of interpreting the theorem i am saying, theorem says with f(x) and (x+5) there is some q(x) and r(x) such that f(x) = (x+5)q(x) + r(x) where deg(r(x)) < deg(x+5) like f(x)=x^2-25 we can have q(x) = x-5 and r(x) =0 satisfies that theorem, you are chosing d(x) and r(x) and finding the f(x) and q(x) which satisfies the theorem which is wrong, you can only chose f(x) and d(x) and find the q(x) and r(x) which satisfies it.
Comment: So in this case, we can rearrange the given expression to be (x+5)(q(x)+1) - 2. And extending from my analogy to integer division, the next multiple of (x+5) greater than f(x) should be (q(x)+1)+1, or q(x)+2?
Comment: first of all there is nothing greater or smaller in polynomials, eg we cant say x^2 > x means x^2 is greater than x, these are inequalities that are true for certain values of x, like this one is true for x>1 or x<-1 and false for 0<=x<=1. so for x>1 or x<-1 x^2 is greater than x, but for 0<=x<=1 x^2 is smaller than x
Comment: got your doubt cleared?
Comment: Please use MathJax/LaTeX when appropriate, for all mathematical text.
Comment: Well saying there is nothing greater or smaller in polynomials I think is not quite correct. We can go ahead and say $x + 10 > -x^2$ $ \forall x \in \mathbb{R}$, for instance. But for the question I posed, I am going to go ahead and say its interpretation was rather ambiguous.
Comment: put x = i in the polynomial, it will be i+10>1, i > -9 which makes no sense again at all
Comment: Yes, that's why I specified real numbers.
Answer: Observe that
\begin{align}
(x+5)(q(x) + 1)
&= (x+5)q(x) + (x+5) \\
&= (x+5)q(x) + (x+3) + 2 \\
&= f(x) + 2 \\
&> f(x).
\end{align}
So $(x+5)(q(x) + 1)$ is a multiple of $x+5$ that is greater than $f(x)$.
Whether this is the "first" such multiple of $x+5$ is a matter of
interpretation, because for $x=-4$, we have
$f(x) < (x+5)q(x) < (x+5)(q(x) + 1)$.
I suppose the idea of the exercise was that $q(x)$ is not the
quotient in the polynomial division of $f(x)$ by $x+5$;
$$
f(x) = (x+5)(q(x) + 1) - 2,
$$
and therefore the remainder is $-2$,
and the quotient is $q(x) + 1$ which is the other factor in the
"multiple" of $q+5$ that you were asked to find.
Coincidence? I think not.
Admittedly, it does seem like a rather awkward way to
think about polynomial division.
Comment: Yeah I'm going to say the question itself is pretty ambiguous. But thank you for your insight! I did end up figuring out that the intended approach was probably manipulating the expression to obtain the correct quotient for polynomial division of $f(x)$ by $(x+5)$.


On button click create dynamic form, autofill the data and post on url in Angularjs

Question: I am using AngularJS, I am trying to implement payment gateway in my web application and stuck at some step
So, at first step I have JSON data , Request method and Url on which I need to post the data.
JSON data sample :
{
   "key1" : value1,
   "key" : value2
}
Request Method : POST
url : myPaymentGatewayUrl
My requirement is :
When I click on button Make Payment, it should create a dynamic form and auto fill the data which I have in my JSON and and post that form data on url. This process should happen under the hood and I should redirect to payment gateway page.
JS function

proceedToPayemnt: function(lead_id){

    var Payment = this;
    var payment_provider = this.payment_provider;
    var selected_payment_provider = this.selected_payment_provider;
    var user_profile = UserProfile.user_profile;

    var answer = selected_payment_provider[payment_provider.psp_id];

    if(answer == 1){
        var lead_id = 145282;
        Payment.offlinePayment(lead_id);
    }else{
         var lead_id = 145282;
        Payment.onlinePayment(lead_id);
    }
   },

The button code:

<button class="button" ng-click="proceedToPayemnt()">Make Payment</button>

Please suggest a solution for above problem.
Thanks in advance
Answer: You can use ng-repeat to create controls from your JSON sample data, something like this will do that. If you dont want to display the form you can use ng-hide to hide the form, and onclick of the proceedToPayment button you can fire submitBtn click. I hope that should solve this.
<form action="URLHERE"  method="POST">

    <input type="text" id="{{key}}"  ng-model="sampleData[key]" />

  <button id="submitBtn" type="submit">submit</button>
</form>

Answer: Thanks for the solution. I referred this Programmatically submitting Angularjs form to an external url
and it worked.


Example of a Markov Process with observable states?

Question: I have a pretty good handle on Hidden Markov Models, but I can't think of any examples of a Markov process with a directly observable state. Any examples?
Answer: They are all over the place, albeit you sometimes need to make simplifying assumptions. You could model workplace participation as a Markov model. People can be in training, working, unemployed, on disability leave, maternity leave, not seeking work, retired. Retirement would be an absorbing state in this model. Individuals transition between the states, and you might want to know the overall breakdown in the society. Or you might want to model the transition matrix for different groups (say those with post-secondary training and those without).
You could model this as continuous time, or discretize. Say, consider the changes if any every three months, or whatever.
Another model could be Telecom subscription in a market with a fixed number of Telecoms. People enter the market, churn between Telecoms, and then possibly exit the system (maybe by dying, moving away, or switching technologies altogether).
Comment: Thanks! Can you define "observable" for me though? I think that's where my confusion comes from.
Comment: An observable state is one that the researcher can observe and note. In a hidden markov process, the state is inferred from other data that is observed. A physician might take measurements in a cancer patient at scheduled visits and infer from this that the patient had transitioned from one stage to another of the disease. That would be a hidden model.


Capturing Ceres

Question: Would it be possible to slightly change the trajectory of Ceres to make it end up orbiting the Earth without messing up the Solar System? How much energy  would be required and how long would the process take?
Comment: What do you mean by 'messing up the solar system'?
Comment: With minimal perturbation to other solar system's bodies. (Conservation of its global stability)
Comment: Food for thought. I'd say this is a very nice thought experiment :D
Comment: There might be instability created by having a 3-body system (Earth, moon, Ceres) to consider.
Answer: It's not possible to "slightly" change it's orbit unless you have a very very long time to wait.    When Orbits get in synch with large bodies like Jupiter, for example, then Jupiter can give a tiny tug to Ceres each orbit and if positioned just right, it might nudge Ceres towards the inner solar-system, but only over millions, if not tens of millions of years.   That's the slow way.
There's no fast way to move Ceres into an earth orbit without exerting a significant force on it.   Orbits are largely stable and to change an orbit that much would requires a serious amount of force.
My math isn't always right, but Ceres orbits the sun at 17.9 KM per S and the earth orbits the sun at about 30 KM/S - now, you might think you need to speed Ceres up, but actually the opposite, it needs to be slowed down to fall into a lower orbit and the amount it needs to be slowed down (My math would be long and clumsy), but the actual deceleration needed is about 1/2 of that velocity difference - so imagine how much energy you'd need to move an object nearly 1,000 KM from side to side, made of ice and rock, twice as dense as water (mass of about a billion billion tons) and you need to accelerate that (decelerate it) oh about 5-6 KM per second (20,000 Kilometers per hour).
Now, a lot of energy could be saved by dropping Ceres to a fly-by near mars and then doing a gravity assist, and then, using earth's gravity as well to help capture it into an orbit around the earth.   Mars weighs about 700 times what Ceres weighs, so the effect on Mars would be pretty tiny (all bets are off for Mars' 2 tiny moons though).   But at minimum, you still need to decelerate Ceres by about 3 KPS (10-11,000 KPH), and at a billion billion tons that's a ungodly amount of energy, unless you're willing to do it very very slowly, perhaps or by finding a fuel source on Ceres to generate some kind of thrust or moving it so that it's in proper synch with Jupiter so that it gets a small kick towards the sun every so often, (see Mercury/Jupiter resonance below)
http://en.wikipedia.org/wiki/Stability_of_the_Solar_System#Mercury.E2.80.93Jupiter_1:1_resonance
I love ideas like this by the way.   Ceres would be a nice source of water Though in an earth's orbit it would lose it's water over time to solar wind, so it would be a trade-off moving it closer.   Might be better to leave it where it is.
As to your 2nd question, Ceres weighs about 1/80th the mass of the moon.   It's not massive enough to "mess up" any planets in the solar system, though if it crashed into the earth for example, it would "mess up" life on the earth big time, but it wouldn't significantly change the earth's orbit.   It would change the earth's orbit a little, but only a tiny bit.
Comment: Thank you very much, I'm not really surprised by the time and energy scales.  The bad news here is that water would be partly lost.

Capturing Ceres


How will the z-buffers have the same values even if polygons are sent in different order?

Question: I know when we use Z-buffer to eliminate the hidden faces, the polygons can be in any order. But my teacher said that this does not mean that two images generated by sending polygons in different orders will have identical values in their z-buffers and in their frame buffers. How does this happen?
And if this is the case, When or how will the z-buffers and the frame buffers have the same values even if polygons are sent in different order?
Comment: TL;DR - the Z-buffer holds the depth of the closest polygon to the camera. At the end of the frame, all other things being equal, the closest poly is the closest poly, so the depth buffer value will be the same regardless of draw order.
Comment: At the end of the render the frame buffer may contain different values but, provided you haven't played with the Z test mode, the Z buffer should be consistent.
Answer: What your teacher means is that at the end of the frame, once all polygons in the scene have been drawn, the z-buffer will have the same values. This is because the z-buffer keeps the minimum Z within each pixel, over all the polygons drawn to that pixel, and the minimum doesn't depend on the order.
If you look at the z-buffer in the middle of the frame, when some polygons, but not all, have been drawn, then naturally the contents of the z-buffer will depend on what's been drawn so far, which would depend on the order in general.
With regard to the color buffer, the same things are true if all the Z values within each pixel are distinct. However there's one case where the results do depend on the order: when multiple polygons have the same Z value at a given pixel. This could happen if the same polygons are rendered twice with different colors, or some such. Then, the behavior depends on the setting of the depth test (i.e. glDepthFunc in OpenGL). If it's strictly "less", then the first polygon drawn that has the minimum Z will "win" and its color will end up in the color buffer at the end. But if the depth test is set to "less-equal", then each polygon that has the minimum Z will overwrite the one before it, and the last one drawn will end up in the color buffer at the end. So in that case, the order of drawing polygons, and the state of the depth test, do make a difference.
Comment: I wonder if his teacher was referring to non determinism of the floating point operations? Not sure if that actually happens on the GPU but I could see it possibly happening. A pretty obscure thing though, so maybe not likely what was being talked about?
Comment: @AlanWolfe That could happen with a floating-point render target, I suppose. Not sure if it's an issue for integer formats (even with blending).
Answer: If you use alpha blending, then the order of rendered polygons matters even if you use depth writes & tests. E.g. imagine you render two triangles A (red) and B (blue) with 50% opacity where the smaller triangle B is in front of A. If you render A before B then the B will appear purple, but if you render B before A then B will appear dark blue (pixels for A are not rendered where the triangles overlap).
However, if you use opaque rendering, then the frame buffer values will be the same regardless of the rendering order, except in the special case Nathan mentioned where the depth values are equal for the two triangles.
Only thing where the rendering order matters for the z-buffer result that comes to mind is if you use a specific stencil test & ops. E.g. when rendering A the stencil test passes and writes a value to the stencil buffer which causes B to fail and results in only triangle A being visible. But if you render B before A, then you see B in front of A. This will naturally influence also frame buffer values.
Answer: This is the basic implementation of the z-buffer algorithm .
Suppose the depth buffer is a matrix d[][];
for(each polygon P)
{
     for(each pixel (X, Y) on the polygon)
     {
         depth_variable = depth of P at (X, Y);
         if(depth < d[X][Y])
         {
             color_variable = color of P at (X, Y);
             set the pixel color at (X, Y) to color_variable;
             d[X][Y] = depth_variable;
         }
     }
 }

As we can see while iterating through polygons we only store the new pixel value if the new depth is less (or less than equal to depending on the setting as mentioned by Mr. Nathan Reed) than the stored one in the depth buffer, so it doesn't matter in which order you render the polygons.
The only thing that matters is the fact which polygon has the least depth at a particular pixel.
Answer: Though polygons can be sent in any order some polygons may lie in the same plane. Their respective zs can be calculated using the formula z=(-Ax-By-D)/C, and if the two polygon surfaces are at same depth then they can have same value of z.


Why is charge of the electron negative?

Question: How did scientists figure out that the charge of the electron was indeed negative? I know how the cathode ray tube experiment works, but how did Thompson know that the plate that the cathode ray beam was attracted to was positive, meaning the cathode ray was negative? What is the history behind positive and negative charges leading up to the cathode ray experiment. Ben Franklin postulated that a body with excess electricity was positive as in a surplus of electricity, and that surplus flows from positive to negative. But how and when was it discovered that electricity flows from negative to positive?
Comment: Related: http://physics.stackexchange.com/q/17109/2451
Comment: Here is an explanation of electrical flow that might illuminate this matter: http://amasci.com/amateur/elecdir.html
Answer: Benjamin Franklin proposed electric fluid theory and considered electric current to be flow of a charged fluid.  He meant to use positive to denote a surplus of the fluid, negative as a deficit of it.  No one knows how he came up with the choice, but it became the convention and as a result lead also to the labeling of charge.  I know of no fact that could lead him to that choice.  It might just be random.  Years later Thompson discovered electron, and according to already established convention, it had a negative charge.
Comment: You don't mention that Franklin was wrong. His single-fluid theory collapsed as soon as ions were discovered. (Yet many MANY grade-school textbooks teach it still.)  This leads to a galloping misconception in the sci-tech community that Electricity Is Negative And Protons Cannot Flow.   Hogwash. Battery acid is a proton conductor, +H ion being a proton. Salt water (and the ground, and human flesh) has no electron flow during electric currents; it's all positive sodium/potassium ions and negative chloride ions. Even Franklin's kite-twine was an ionic conductor with bipolar flow.
Answer: That there are two distinct types of electric charge is a metaphysical fact.
But nature is indifferent to what we choose to label these charges; up / down, left / right, positive / negative, black / white, etc.
Electrons will still flow to the plate in a CRT regardless of how we choose to label the polarity of the charge on the electron and plate.

Regarding electricity, from the Wikipedia article "Electricity":

Electricity is the set of physical phenomena associated with the
  presence and flow of electric charge. Electricity gives a wide variety
  of well-known effects, such as lightning, static electricity,
  electromagnetic induction and electrical current. In addition,
  electricity permits the creation and reception of electromagnetic
  radiation such as radio waves.

So, while we can meaningfully talk about, e.g., electron flow and charge flow, electricity flow is not particularly meaningful.
Answer: As Zeldredge said the name is arbitrary and does not matter electron could have been positive and protron negative just the name.
Answer: Answering the first part:  how was polarity first arrived at?
Simple:  electrostatics is part of electromagnetism in general, and the names of the charge polarities come from electrostatics history.
Fur touched against rubber becomes net-positive while the rubber becomes net-negative.  Early electrostatic voltmeters, the "Quadrant Electrometers," followed this standard.  These are voltmeters based on moving capacitor plates, and the ones with fixed polarity would use high-volt batteries to charge their pos. and neg. field plates.  To determine electric polarity, just check the +- using your electrometer bought from an 1800s science supply company.  Or fifty years later, the same standard was adopted when non-impulsive currents had been discovered and current meters were being sold.  You could check polarity with the d'Arsonval Galvanometer you'd bought.  The marked +- on an ammeter was determined by permanent magnet poles and the coil winding direction.
Actually it was Ben Franklin who assigned the "positive" label to the rubbed fur's charge, since earlier it had been called Vitreous.   (Rub glass against amber, and the "vitreous" glass becomes positive, while the "resinous" amber negative.)
For the Cathode Ray experiment, the positive plate would be connected to a positive terminal of a high-volt power supply.  To determine the polarity of your commercial power supply, just look at the colored terminals, or check it with your voltmeter.  To verify your voltmeter's polarity, compare it to another commercial voltmeter!  :)  Or, connect it to a zinc/copper/saltwater battery (where the zinc is always the negative plate.)  To verify that zinc battery-plates are the negative ones, use your voltmeter to discharge a capacitor where the capacitor dielectric is a sandwich: a layer of rubber and a layer of glass between adhesive metal plates:  touch them firmly together and separate, and the metal connected to the rubber side will charge up negative, the glass positive.  Now test the zinc-plate battery with your polarity-calibrated voltmeter.
Hint:  with just a piece of plastic and fur you can check your voltmeter.   In dry conditions rub the plastic on clean hair or wool.  Now ground your negative voltmeter lead, or connect it to a large conductive object.  Set it to the most sensitive voltage scale.  Now suddenly move the voltmeter's (+) probe towards the charged plastic surface.  If the meter polarity is correct, the meter will momentarily indicate a negative reading.  Yank it away again, and you'll see a positive reading.   By moving the meter lead suddenly towards a negative-charged object, you're capacitively attracting positive charge towards the end of the meter lead, and capacitively repelling negative charge into the meter's (+) connection, producing a negative reading.
Second:

But how and when was it discovered that electricity flows from negative to positive

It doesn't.
Believing that electrons equals electricity is a common widespread grade-school myth.  It's easily debunked:  in electrolyte conductors like battery-acid, the movable charge carriers, (the +H ions also called protons,) flow in the positive direction, while outside the acid, the electron clouds within the metal plates flow in the negative direction.  And in salt water the "electricity" always has two polarities: negative chloride ions and positive sodium ions.
That means that in oceans, and dirt, and in human tissue, the electric current is two separate currents, positive and negative carriers, flowing in opposite directions in the same material.   'Poor Richard' was wrong.
The Cathode Ray Tube experiment demonstrates electron beams, but K12 textbooks usually don't mention the other one, the "Canal Ray" tube with its violet beam coming out of the positive electrodes.  This tube showed the mysterious positive current made from massive particles barely deflected by a magnet.  They were high-speed positive air ions; the positive part of the electric current found in any plasma.
Besides flawed grade-school textbooks, another big source of the misconception was Navy training manuals from WWII, where apparently all proton flows were carefully avoided.  Perhaps they were too confusing for rapid "emergency training" of hoards of repair  technicians?  Instead the military students were only taught about vacuum tubes and metal wires, the conductors where the only mobile "electricity" were clouds of electrons.  With this warped view of basic physics, it's no wonder that entire generations would believe that Electricity is made of Electrons, period, and that currents made of flowing protons cannot exist.  Yet when you zap yourself, no electrons flow through your body.   You're not made of metal, after all.

Why is charge of the electron negative?


Language tabs in content editor

Question: Does anybody know any plugin for Joomla 3.x to switch between languages(ex. tabs) while editing content? You need to create pages with different languages and after that create dependencies between them by default. It takes too much time.
Answer: Have you tried FaLang?
FaLang is a (free) component for Joomla (2.x and 3.x) and is built on the base of JoomFish (which doesn't have any development anymore on J3.x).
With FaLang you are able to translate the content, categories, menu-items of Joomla without the need to duplicate the contents.
Even for some components as HikaShop, K2, jDownload and many others they made it possible to translate it.
It works like this: You create an article in your base language. If you have a paid version of FaLang, you can edit the content right after saving in the same view. Otherwise, you'll need to go to the FaLang component where you can edit the other languages.
For more details about FaLang: http://extensions.joomla.org/extensions/extension/languages/multi-lingual-content/falang
If you want a video about the plugin and how it exactly works: https://www.youtube.com/watch?v=yT8PkNKoTeE
In this video they use J2.x, but it is roughly the same as in 3.x.
Comment: Hello Robin... congrats for getting involved and tried to answer the OPs question... However keep in mind: Good (and acceptable) answers must be more than a link to an external site, resource, software. You should try to explain what the plugin does and how it could provide what the OP is asking. Please read the [answer] section of the website
Comment: Hi @FFrewin, my apologies I'll edit my answer. You are right, I was too fast with my answer.
Answer: This was not possible. Each article has a differente ID and differente settings. You need chose how language this article ID will be displayed.
Comment: Actually it's possible to write an extension to do that, but it will take a lot of time, that's why I'm asking.

Language tabs in content editor


randomly generated key reused with XOR

Question: If I have a long randomly generated key (k), XORed with a message (m), but since the message is longer than the key, there is a chance of reusing the keystream with the same message, but the key is used only onetime for every encryption process. In other words, every time I have to encrypt a message, I randomly generate a bit key with variable length.
Can we consider this technique is secure against any attack even though the keystream is been reused with the same message despite the fact that I have to save the key for every message I encrypt?
Comment: Insecure, message text can repeat just like your keystream.
Comment: This sounds like one of those "simple" encryption schemes where it is almost infinitely easier to use a well vetted and already implemented (stream) cipher.
Comment: How exactly do you expect to decrypt this message? If your key k is randomly generated per message, does that mean the decryption party has a means to generate key k based on some agreed parameters? And also, can you not generate a new key for every chunk of the message? (i.e If the message was 1024-bits but your key is only 256-bits, can you not simply generate 4 keys for each part?). Reusing keys is already bad, given your performing a simple XOR to get ciphertext from plaintext, simple ciphertext analysis can quickly determine the message based on repeats in the message body.
Comment: @owlstead +1 for "almost infinitely". Might I also suggest for defined "messages" like OP suggested, a **block cipher** would be better. As his/her messages have finite length and OP wishes to encrypt them "differently" (Implied by his/her concept of choosing a new key)
Answer: Apart from the obvious security vulnerability from using a simple XOR operation to convert between plaintext and ciphertext you also run into the massive security-flaw of each identical plaintext generates identical ciphertext.
In any given message, if a constant cipher operation is used along with a constant key, the resultant ciphertext will be same for every plaintext irrespective of the position of the plaintext within the message. This property causes patterns in the original plaintext to be revealed in the ciphertext.
Take for instance AES-ECB where even though a strong block cipher (AES) is used, a cipher operation that generates identical ciphertext for identical plaintext exposes the "pattern" of the message.
For a visual demonstration of this problem consider these images:

(Image courtesy of Wikipedia)
The first image shows the original message (a bitmap of the linux logo). The second image shows a encrypted version the same logo using AES-ECB. Notice how the pengiun can still be distinguished even after encryption.
This is due to the fact that every white sector in the image is passed through the cipher operation and generates an identical ciphertext causing the areas with differing colour to produce differing ciphertext in a manner that exposes the patterns of the original image.
To summarize, not only are you using an extremely insecure cipher operation of XOR (Information of why it is insecure is cluttered all over the web), using a cipher that generates ciphertext that is identical when the plaintext is identical is a security flaw in itself. Given that you are reusing the keystream for messages longer than the key, you definitely fall for both these vulnerabilities.

randomly generated key reused with XOR


unable to restore contacts after changing ROM

Question: I have changed the ROM on my samsung galaxy Note 2 , i have installed the cyanohgen mod. i need to restore the contacts from my old sansung kies .sbp file backup onto the new CM rom
Answer:
Open the .spb file in Kies
Select all your contacts and click save as.
In the file name field type whatever you want with en extension .vcf
Copy the newly made file to your sd card
Import from the contacts app


Should questions about audio equipment not used to create music be on topic?

Question: I thought this question was pretty obviously not on topic, but opinions seem to differ.
https://music.stackexchange.com/questions/20768/besides-a-turntable-what-equipment-do-i-need-to-listen-to-vinyl-records
Answer: The answer you'd give someone wanting to be a turntablist, and to someone who just wants to listen to music, are completely different. For creative DJing you want variable speed, bidirectional needles, rapid start and stop, etc. For listening to records you need none of this.
This question is explicitly only about listening to music. Hence if you have an answer aimed at musicianship, you wouldn't be answering the question.
Hence, for me, it's off topic.
You might argue that a Hi-Fi is a tool for musical appreciation, and that musical appreciation is part of being a musician. But even in that case, this question is analogous to "my local library stocks musical scores -- how do I apply for a library card".
I'm surprised not to see a "home entertainment" SE, where this would fit fine.
Comment: However I have updated the question and suggest it could be re-opened.
Answer: Clearly, the questioner is only going to listen to vinyl records. It's also very basic, a quick google should turn up answers enough. Just as questions about how to use your microwave (cryptic enough to warrant a question) probably isn't going to fly on Stack Overflow, I don't think this have is on topic here (if we are looking to build a build a community of musicians, rather than a place where all music related questions are welcome).
Comment: In other words, I think the question is on-topic, but the extra information the asker provides camouflages it as off-topic. Listening to music is not musical practice or performance, right? But turntables have more uses than "listening to music as a hobby". They can be part of both musical performance and practice. The question is not only relevant, but has the potential to be very useful to a wide array of musicians.
Comment: @JCPedroza: The question originally was about what constitutes a turntable, then Bob edited it, but just the title. Why is a vinyl player less localized than a DVD player (remember, the original question was only about the vinyl player. Not that it matters that much to me. Connecting your stereo equipment isn't, and shouldn't be on topic, in my opinion.)
Comment: `a quick google should turn up answers enough` I don't think that's a very good argument to use here, in a SE Q&A site. We are supposed to be what google returns as result!
Comment: @JCPedroza: I see that "How do I connect my DVD to my stereo" could be made to fit too, but I don't see us becoming a consumer audio product site will do us any good. Also, wouldn't this mindset make all questions on Music Fans SE fit here too? I am for widening the scope, but going outside of it will just scatter focus, in my mind. People who ask these types of questions will likely not be an active part of the community, and the inclusion of such questions will drag the "wrong" crowd. Hooking up a stereo is something a musician will do, but I don't see it as part of making music.
Comment: I think we should be able to see through the wording and unimportant specifications. The questioner tells us that he wants to listen to vinyl records as a hobby, so his final intention is not related to musical practice or performance **BUT** the question is relevant to the site, it's just that his situation is not. That question can be useful to DJs, people wanting to sample vinyls, people that want to include a turntable in their performance (not necessarily as a DJ) or practice (play alongs come to my mind).
Comment: It's also different setting up your vinyl player as a consumer, or in another setting. I'd have no problem with e.g. "How do I wire my DJ setup (2 turntables and a microphone, yo)?"
Comment: This discussion extended more than enough for us to explain our points. We'll have to agree to disagree on this.
Comment: When I say "useful to musicians" I'm saying "useful to musicians in the music creation or practice process". Your DVD example (which for the record I think is a straw man and a false equivalence) might be too localized, but a question regarding routing options to use a stereo as a speaker (which indirectly would include the DVD!) would be a good fit. Answers would include Mics (XLR), Guitar/Bass (TRS), samplers/cdplayers/some keyboards (RCA), etc. I don't think all consumer audio questions are a fit, but some certainly are.
Comment: @JCPedroza: Not a straw man, I might use the DVD to watch instructional videos. This might be useful to other musicians.
Comment: It's a straw man and a false equivalence because it's not even similar to the question you are comparing it to. One is about building blocks of a system, the other is about routing and connections. As I said, we can share scope with other activities, it doesn't mean that all "consumer electronic" questions are on-topic, but some of them will. As I said in the other comment, the DVD example has its place here, just not as a "DVD example" because it would be too localized. Routing methods to use the stereo as a speaker, in the other hand, is on-topic and indirectly covers DVDs (and much more)
Comment: And that's another way you are building a false equivalence and a straw man: you are carving a localized and heavily particular example to compare it to a general one. A more accurate comparison would be the routing stereo as a speaker/amp.
Comment: The edit was to make the title more explicit, and the edit to the content was just about typos and minor wording: the concept and idea remains untouched. (That's why I must insist, you guys should be able to see past those unimportant details, you give way too much weight and credit to them).
Comment: The question as originally posted essentially *was* the same as asking how to hook up a CD player to your home stereo.
Comment: @BraddSzonye: I agree, hence my DVD comparison. Which was apparently a straw man. Anyway, consensus is pretty clear as far as this type of questions is concerned.
Answer: Although I have voted to close off-topic posts in the past, I voted to leave-open and reopen this question. Yes, it may be rather straightforward, but I think it is valid, and think that we're being a little mean-spirited closing it. Leaving it open wouldn't create undue noise on the site.
Although the OP may only be trying to find out about record-players, I still think the question has merit for several reasons:

The specific equipment used for a good record player and audio setup has similarities to equipment used for live performance with other instruments or audio equipment.
Although the OP may not be interested in using a turntable as a live performance instrument, many musicians do, whether as DJs or in many styles of popular or contemporary (art) music.
Why not let somebody ask a question related to the process of listening to music? I spend about half my time as a musician listening to music. (Okay, I haven't used a record player for years, but hey…) I doubt we would close questions related to reading about music...
Comment: @MeaningfulUsername `Anyone that has a little more than a superficial interest will find these things out by him/herself` It bothers me so much that you and some other people keep using this or similar arguments. People, **we are supposed to be the site where people find out things by themselves! We are that site where people will go when doing research. We are what should appear in the search engine's results! We are THE database of answers** If you have that question about vinyls (and you can as a musician), you google it, and you find the answer **here**.
Comment: @MeaningfulUsername I agree with your view. The OP didn't have the intention of using the turntable in a way that is relevant to this site, but that doesn't mean that the question is off-topic. That's just him! The question is relevant to both musical practice and performance, and could be very useful to many musicians. The intentions of the OP shouldn't matter, but that's what got the question closed.
Comment: Anyone that has a little more than a superficial interest will find these things out by him/herself. I don't think "How do I connect my iPhone to an external sound source?" is a good question either. It's beside the topic, and it invites lazy questions.
Comment: @MeaningfulUsername You keep building straw men and false equivalences to refute my points (turntable and vinyl system dynamics are in no way as trivial as "how do I produce sound with a piano"  ), and I can only handle a handful of those before my patience ends. Judging from your comments, you either didn't really got my point or built absurd examples just to refute on their base. I think we already had more than enough space to give our ideas, and in general, we'll have to agree to disagree.
Comment: Don't get me wrong @MeaningfulUsername, I'm not saying that I *like* this kind of question, but I don't see that it does any harm to be asked here. Even if it is a simple (or even lazy) question, it might produce some thought-provoking answers. I generally agree with the close votes made by regular users; I just thought this could have been given a chance…!
Comment: I very rarely vote to close these days, but here I thought it was quite clean cut to close. But it wasn't, and I was interested in the motivations to keep it, and if we should make some scope change to open up for these type of questions. I agree that not-so-great questions might still generate very great answers.
Comment: Yes, I'm glad you raised it as a meta-question (if you hadn't, I was going to later). +1 for the question, BTW.
Comment: @JCPedroza: So there is no limit in scope, or laziness? A reasonable effort should be made for the question to be useful. This seems to be so basic as to not warrant a question. Check out one single vinyl player and you basically have the answers. I even answered the quesion in one of the comments, so dude got what he was after anyway. Being elitist is not the answer to building a community, but come-any-and-all won't serve us the best either.
Comment: @MeaningfulUsername **Limit in scope:** Yes, of course there should be a limit in scope. I see where you are coming, drawing that limit is not simple, since a musician can make music with anything! The vinyl question seems to be on the limits for some people, I just disagree with that perception.
Comment: @MeaningfulUsername **Limit in laziness:** 1) Equipment needed for vinyl playback **is not** a trivial dynamic. It was not a simple question. There are many things that can go wrong if you don't know what you are doing. 2) As long as the question is clear, I don't see why you should judge the questioner. 3) **We are the site where people come to get answers**, a "non lazy" person would have investigated first, right? And guess where he could have gotten the answer? **HERE!** In that context, there is no such thing as a "lazy question" in a site like this.
Comment: @JCPedroza: A non-audiophile vinyl player is not rocked science. The audiophile stuff will eliminate itself due to price tags. Checking out even one consumer grade turntable should answer all questions. I don't think we should provide all answers, some things should be read in a manual. There is a limit in scope, and a limit to useful questions. We draw the lines at different places. Luckily, we don't have a big problem with these type of questions, so regardless of this debate, from my viewpoint we're safe...
Comment: @MeaningfulUsername It's not rocket science, but it's not trivial either. You need to know about stylus, needles, how earth connection can get rid of noises, speeds, handling, types (belt, direct-drive), and much more. None of that is answered by "checking out even one consumer grade turntable". Also, not all those things come in the manual, and manuals are not always available (old model, second hand, etc). Again, I don't know what you think of SE sites or why you get so defensive about being informative from the roots, but we are supposed to be the manual.
Comment: @JCPedroza: You might need info on those things, but most often not. Then those issues will give rise to specific questions, even further off topic here. I don't think expert sites should be to explain the basics of the basics ("How do I produce sound with a piano?"), and here we disagree, obviously. I believe that if you are interested in something, you make at least some effort to gather information, instead of going to an SE page and waste people's time. I have no problem with alienating people who do not make this minor effort.
Answer: If the question and answers can be useful to create, perform, or practice music, then I think the intentions of the asker are not important.
Imagine someone comes and asks about the harmonic content of different types of keyboard and pianos, and how materials, shapes, and acoustics in general affect the tone of it. Then he specifies that he wants to know because he plans to eat a piano with a very rich harmonic content.
His intentions are gourmet and not relevant to this site but the question and potential answers are on-topic (as on-topic as it gets) and can be very useful to musicians.
We can share scope with other professions, hobbies, activities; and it is not a bad thing.
If the off-topic specifications still bother you, I think a better approach would be to edit  out the irrelevant or not important parts.
Comment: Imagine someone comes and asks about drainage pipes. Someone votes to close, but someone else objects: "drainage pipes can be used as a percussion instrument". I think that's closer to the situation here. You could answer with info about using a drainpipe as a percussion instrument -- but it's not answering the question asked, and the question asked is not on topic.
Comment: @JCPedroza A better example is a computer. A computer can be used to make music, but just because a computer can make music does not mean all questions about a computer are on topic here. The item itself should not deiced if something is on or off topic, but the question itself.
Comment: @JCPedroza The question is about listening to a record and what is need to do it based on the content. That is as on topic as asking about listening to a cd and what is need to do it. The content tells what the question is about. Just because some DJs use it to preform does not mean this question is relevant at all.
Comment: The problem is that the linked question *doesn't* lead to something that can be used to create music. An entry-level turntable is not a musical instrument. If the linked question were even remotely about live performance or composition or DJing or *something* on-topic I could see making an argument in support of it. But I don't think this argument is a reasonable response to a question about consumer stereo equipment.
Comment: @Slim The example was to illustrate that intentions can be unimportant, and we should be able to see through them. Regarding scope, I don't think pipes are really comparable to vinyl turntables, as the later are already widely considered an instrument and are very commonly used to create, produce, perform, and practice music every day. I'm not saying that everything is on-topic (which I clarified several times on this thread already), I'm saying that we share scope with other activities, and that's not a bad thing.
Comment: @Dom And there is nothing in my answer suggesting otherwise. My example is about independence between scope and intentions, not about scope definition. Not sure what you and slim smoked ;) Please read the very first line, the one just before the example. Your example is not better because it has absolutely nothing to do with what I'm saying (and neither the "pipes" example of slim). Using it on this context doesn't even make sense. You guys are lost.
Comment: @Dom You keep talking about things I'm not talking about. It's funny that you guys are trying to define the scope of this site, but you can't even identify the scope of one simple argument. I give up.


Dual Booting Windows while Hibernated

Question: Windows 7 and Windows 8 are both installed on my PC, on different partitions of the same hard drive. Whenever I boot the system, I am taken to a screen where I may choose which of the two to boot. If I hibernate one of the OSes and try to reboot, it skips this screen, and automatically boots the OS that is hibernated.
I need to be able to switch between the two OSes quickly while saving my session. Is it possible to boot an OS while the other is hibernated?
Answer: This is not possible.
The only way to do it would be taking out the hibernated HDD. In this case the other Windows boots normally.
Comment: They're both installed on the same hard drive. Is it possible to edit the Windows Boot Manager to ignore the hibernated status of an OS?
Comment: no this is not possible.
Answer: This is neither possible nor safe to do, one begets the other.
When you hibernate the system it stores all important information regarding user and system programs running and this will inevitably include filesystem state information as that held by the filesystem drivers.
There may well even be changes pending to be written to the disk that could potentially be suspended during hibernation (though I'd hope not).
That would mean any changes happening to any other disk while the system is hibernated could cause a large amount of instability and a force you to reboot anyway.  Back to square 1, you might as well have already rebooted between needing to use each system.
If you permanently need both then choose a one as a primary OS and use a VM such as VirtualBox for the other.

Dual Booting Windows while Hibernated


Testing profile Technical questions

Question: Where to find the technical question of different companies to prepare for written Test in Testing profile
Comment: Are you asking for a list of technical interview questions that companies commonly ask? If so, please update your question to say so, and tell us what you've done to try to answer your question.
Comment: Searching for my preparation
Answer: I have prepared few Interview questions with answers Selenium and Java related question I had during my interview which are listed here. I will be adding few more examples as well.
Also you will find lot of resources when you search google.

Testing profile Technical questions


What are the higher derivatives of a multivariate function?

Question: I have recently realized that I am not sure what it means to consider $F''(x)$ and general higher derivatives for $F: \mathbb R ^n \rightarrow \mathbb R^m$. I am clear the at the first derivative is a matrix of partial derivatives $ \left( \begin{array}{ccc}
\frac{\partial f_1}{\partial x_1}(x) & ... & \frac{\partial f_1}{\partial x_n}(x) \\
... & ... & ... \\
\frac{\partial f_m}{\partial x_1}(x) & ... & \frac{\partial f_m}{\partial x_n}(x) \end{array} \right) $. But I am not sure how to differentiate this matrix. Do I want to treat it as a vector and then get the first derivative of the function $G: \mathbb R^n \rightarrow \mathbb R^{n \times m}$ which sends $x$ to the vector of partial derivatives?
Comment: related: https://math.stackexchange.com/q/257061/173147
Comment: We may define the higher-order derivatives "all at once", rather than iteratively, as the coefficients of the best approximating polynomial. The $k$th derivative at $a$ (divided by $k!$) is a homogeneous degree $k$ form $C_k$ (for example $C_2$ is a quadratic form). By definition we should have $$f(x)=f(a)+C_1(x-a)+C_2(x-a)+\cdots+C_k(x-a)+\lVert x-a\rVert^kh(x)$$ where $h(x)\to0$ as $x\to a$. This is a combination of the ideas of Frechet and Peano derivatives.
Answer: To understand it, you have to treat derivatives as linear operators. If $f:\mathbb{R}^n\to\mathbb{R}^m$ then $$f':\mathbb{R}^n\to L(\mathbb{R}^n,\mathbb{R}^m)$$
where $ L(\mathbb{R}^n,\mathbb{R}^m)$ is the set of linear transformations from $\mathbb{R}^n$ to $\mathbb{R}^m$. It can be identified with $M_{n\times m}$ or $\mathbb{R}^n\times \mathbb{R}^m$. If you identify it with $\mathbb{R}^{n+m}$ you see that differentiate the matrix is the same as differentiate the function $f':\mathbb{R}^n\to\mathbb{R}^{n+m}$ and the last you know how to differentiate. Moreover, because $f'(x)$ is a linear transformation for all $x$, you have to understand how this transformation works and it works according with the formula $$f'(x)u=A_x u$$
where $A_x$ is the matrix of derivatives which is in your question.
To proceed we have that $$f'':\mathbb{R}^n\to L(\mathbb{R}^n, L(\mathbb{R}^n,\mathbb{R}^m))$$
Now $f''$ is a function which send $x$ to a linear transformation $f''(x)$ from $\mathbb{R}^n$ to $ L(\mathbb{R}^n,\mathbb{R}^m)$. But such linear operator can be identified with a bilinear form $g(x)$ by considering $g(x):\mathbb{R}^n\times \mathbb{R}^n\to\mathbb{R}^m$ defined by $$g(x)uv=f''(x)uv$$
Moreover, note that $$f''(x)uv=[f'(x)u]'v$$
hence $f''(x)$ is the bilinear form defined by $$f''(x)uv=[A_xu]'v$$
where $$[A_xu]'=\left( \begin{array}{ccc}
\frac{\partial \sum_{i=1}^n\frac{\partial f_1}{\partial x_i}u_i}{\partial x_1} & ... & \frac{\partial \sum_{i=1}^n\frac{\partial f_1}{\partial x_i}u_i}{\partial x_n} \\
 ... & ... & ... \\
\frac{\partial \sum_{i=1}^n\frac{\partial f_m}{\partial x_i}u_i}{\partial x_1} & ... &\frac{\partial \sum_{i=1}^n\frac{\partial f_m}{\partial x_i}u_i}{\partial x_n} \end{array} \right)$$
For example, consider the function $f(x,y)=(x^2-y,x+y^2)$. We can identify $$f'(x,y)= \left( \begin{array}{cc}
2x & -1  \\
1 & 2y \end{array} \right) = (2x,1,-1,2y)$$
and we know that $$f'(x,y)(u,v)=\left( \begin{array}{cc}
2x & -1  \\
1 & 2y \end{array} \right)\left( \begin{array}{c}
u   \\
v  \end{array} \right)$$
Now, $f''(x,y)(u,v)(z,w)=[f'(x,y)(u,v)]'(z,w)$, but $$f'(x,y)(u,v)=(2xu-v,u+2yv)$$
Now we think on $(u,v)$ in the last expression as constants and $$f''(x,y)(u,v)=\left( \begin{array}{cc}
2u & 0  \\
0 & 2v \end{array} \right)$$
which implies that $$f''(x,y)(u,v)(z,w)=(2uz,2vw)$$
The case $f^{(n)}$ is similar.
Comment: Shouldn't $M_{m \times n}$ be identified with $\mathbb{R}^{mn}$?
Comment: I was wondering if thinking in terms of chain rule (of multivariable functions) helps.
Answer: Treating the matrix of $n$th derivatives as a vector and writing the result of $(n+1)$th derivatives in matrix form indeed one way to accomplish this (one can also use Kronecker products, as I have seen with some authors).
However, one can also just use extra levels of indicies, as expressing the $N$th derivatives of a vector-to-vector function will require the use of a $(N+1)$th-order tensor.
For your example, the rank-3 tensor $G(x) =\nabla^2 f(x)$ will require 3 indices, as $G_{ijk} = \frac{\partial^2}{\partial x_j\partial x_k}f_i(x)$.
Answer: Dieudonne said it best: this is the introduction to his chapter on differentiation in Modern Analysis Chapter VIII.

The subject matter of this Chapter is nothing else but the elementary theorems of
Calculus, which however are presented in a way which will probably be new to most
students. That presentation, which throughout adheres strictly to our general "geometric" outlook on Analysis, aims at keeping as close as possible to the fundamental idea of Calculus, namely the "local" approximation of functions by linear functions. In the classical teaching of Calculus, the idea is immediately obscured by the accidental fact that, on a one-dimensional vector space, there is a one-to-one correspondence between linear forms and numbers, and therefore the derivative at a point is defined as a number instead of a linear form. This slavish subservience to the shibboleth of numerical interpretation at any cost becomes much worse when dealing with functions of several variables...

In other words, the proper way to look at differentiation does not allow us to simply repeated partial differentiate an object. We should think about successive differentials, one after the other to understand higher derivatives in higher dimensions. Sadly I have to go to class now.


Live HTML preview without updating the whole preview every time content changes

Question: I'm building a markdown editor using node-webkit (native applications using HTML/JavaScript), marked (a js markdown compiler) and CodeMirror (code editor). So I'm basically building a markdown editor using HTML and JavaScript (+ jQuery) that runs as a native application.
One of it's features is that it has a live preview of the compiled HTML. This live preview is inside an iframe and updates every time the user changes any content in the CodeMirror editor. The problem is that when the preview updates the whole document inside the iframe gets replaced. So it's basically reloading a whole webpage every time you press a key. This is not very efficient, and makes the whole application run slow. It's also a problem when you add any embedded media like a Youtube video to your document, because it's going to reload that video every time the preview updates.
I tried to solve the problem by adding a timer so the preview won't update faster than once every 250 milliseconds. This solves the slowness problem, but embedded media will still reload on every preview update.
I tried some other live preview HTML/markdown editors and most of the used the same method for a live preview as me, except StackEdit (and probably some other ones but StackEdit is a good example). I noticed that in StackEdit when you embed a youtube video somewhere in the document, and then edit some text somewhere else in the document the Youtube video doesn't reload. That's exactly what I need: only update content in the preview that has changed. How can I get my live preview to work like that?

Note: This is how the preview currently gets updated:
var HTML = marked(CodeMirror.getValue());
$('iframe').contents().find('.content').html(HTML);

(This happens every time with an interval of 250 milliseconds when the
  content of the codemirror editor changes.)
Answer: You're probably looking for a way to compare HTML with something like HTML_PREV. If that's the case, you may be looking for HTML diff algorithms, like htmldiff.js. You also might be interested in this related question.


Safe to clean iPad screen with alcohol wipe?

Question: I ordered a glass screen protector for my iPad and have just received it. In instructions, it says I have to clean the screen with the given alcohol wipe. Is it safe to use an alcohol wipe on iPad screen? I read somewhere it damages the screen...
Answer: Alcohol can probably damage the coating on the display. I wouldn't use an alcohol-based cleaner.
I accidentally used an alcohol-based liquid to clean my 2011 MBA's screen and the coating is visibly damaged by it.
See this Apple Support page: https://support.apple.com/en-us/HT204172.
Answer: If you need to clean your Apple hardware use a clean dry microfiber cloth.  It's what I see Apple employes using on all the equipment in the Apple stores.  I've been using microfiber for years on all my Apple devices and has worked great without any damage.
Note:  If necessary you can slightly dampen it with distilled water and wring it out well so it is really just ever so slightly dampened and the follow up with a clean dry microfiber cloth.
Answer: Use baby wipes. It works cleans off fingerprints
Comment: Same as using alcohol, could damage a screen coating.


Can a Canadian committing a crime against a Canadian in both the USA & Canada be prosecuted in both countries?

Question: If a Canadian citizen commits a crime against another Canadian in the USA and Canada, can that person be arrested and prosecuted in both Canada and the USA?
Comment: Do you mean that the Canadian commits a crime against another Canadian in the US, where the crime is a criminal offense in both countries?
Comment: Yes, the victim, (a Canadian) lives part of the year in Canada and part in the USA. The perpetrator commits the same criminal offenses in both Countries dependent on where the victim is. I'm hoping these crimes can be individually prosecuted in their respective Country, thus the criminal will face two sentences.
Comment: Criminals can face multiple sentences for committing a crime multiple times even if they do so in a single jurisdiction.
Answer: Yes
Usually, whoever got their hands on the defendant first would have first crack at it. The second jurisdiction would commonly not prosecute provided that justice was done in the first but they can - double jeopardy is not in play as a bar as they are different legal systems but courts usually apply the spirit that a person shouldn't be punished twice for the same act.
Comment: As I read the clarifying comment, there are multiple instances of the act committed, some subject to US jurisdiction and some to Canadian jurisdiction.  If the US convicted and punished someone for an act they committed in Florida in January, that wouldn't stop Canada from convicting and punishing that person for a separate instance of the same act committed in Ontario in July, would it?
Comment: @phoog I only answer the question- comment are for comments not clarification. As I read the question the crime may be via telecommunications or a crime that consists of multiple acts.
Comment: FURTHER CLARIFICATION:  The base crime is "stalking and harassment" however there have been instances of breaking and entering, fraud, monitoring telecommunications etc.  These are much harder to prove, and I regret not installing cameras but I continued to think "surely this will not go on another day".  It's been years now.  Putting the person in the same City/Town/Province/State/Country that I'm in every day is readily  accomplished.
Answer: If a person commits crimes in one country and then goes to another, the first country can ask the second to extradite the fugitive back to the first country.  This is heavily dependent on international relations, but USA and Canada have an Extradition Treaty.  Whether or not a person will be extradited may also depend on the severity of the crime.
A person could be tried in the United States or Canada and then extradited to the other country once they were acquitted or served their sentence.  The first jurisdiction could even decline to try the person and instead just extradite them - a lot of this depends on the Attorney Generals/District Attorneys in the applicable jurisdictions.  One other confounding factor may be applicable statutes of limitations, which may expire on one crime if the person serves a sentence for the other.


What parts of a web application should be moved to a WorkerRole in Azure

Question: What parts of a web application should be moved to a WorkerRole in Azure?
I see clear uses for a website that say, converted mp3s but what about run of the mill ASP.NET site? Should CRUD operations (for example) now be handled by a WorkerRole?
Answer: While this has been answered numerous times before in other SO questions: Web and Worker roles are essentially instances of Windows Server 2008 with or without IIS enabled. When thinking about moving tasks to a Worker Role (or even another Web Role), it comes down to performance and scaling.
If you feel that your background operations would be consuming large amounts of memory and CPU, and potentially impacting Web site performance, then move those operations to a different role and scale that role independently. You can then use Azure Queues to create work items for the different role to consume (or use a WCF service on an internal endpoint, Service Bus, or other techniques).
Combining tasks into a single Web Role will save on initial costs, as you can deploy with just one or two instances total. You'll just have to scale everything lockstep at that point.


4 PCs in the LAN (with internet access) + 1 VM PC in the same LAN and internet access

Question: I faced today a problem with setting up a working "work-place" with 4 PCs and one virtual machine placed on the one of the PCs.
I managed to go through the connecting PCs through switch into the same LAN network and after a few tweaks I also managed to provide internet connection - one of the 4 PCs has a modem connected to it (via USB) - it reads it as an ethernet connection - and I had to provide that internet to the rest of the computers. After these steps everything was working fine - all the PCs could ping themself and PCs without a mobile modem also had an actual internet connection.
The problem came up when I was supposed to connect "another-like" PC using Hyper-V with virtual Windows Server 2016 on it. I couldn't get it working - I mean I managed to put through the internet from the host into the VM Windows Server - but its IPs had to be set automaticly, because when I was trying to set it manualy (in order to get VM working in the same LAN network where all the 4 PCs where already working) - it simply lost an actual connection with the network and the rest of the PCs (besides the host PC) couldn't ping the VM - as it wasn't in the same LAN network.
I have two ways of making a virtual network in Hyper-V - one is to turn the mobile modem connected to the one of the PCs (the host) into a virtual one or trying to make a virtual ethernet connection - just like the rest of the 3 PCs are connected (via switch) - but I couldn't get it working in the both cases.

I've made a simplified representation of how does it look like. PC4 has a mobile network with internet connection. All 4 PCs are connected via switch and are in the same LAN network (ethernet1) and moreover - these take the internet from PC4 (thanks to the mobile modem - called Ethernet2). Now I launched VM in Hyper-V on PC4 - it needs to take the internet for itself and still to be in the same LAN network as rest of the PCs (it should act as PC5 actually for example). Now in Hyper-V I have two options - to make a virtual switch with Ethernet1 (LAN) or Ethernet2 (Modem) - but I couldn't make work none of these. So maybe someone could at least give a lead of how IPs and Gateways should be set - or what exact settings in Hyper-V should be done? Sorry to be so novice but it's actually my first try with something like that - never done it before.
Comment: A virtual switch including the LAN should work. What went wrong when you tried to do that?
Answer: Try out this:
Switch to Hyper-V Manager. In the right side Virtual Switch Manager, try to create a New virtual network switch. So click External and Create Virtual Switch. Name it, select the real Network adapter, click ok.
In the Hyper-V Manager, in the Network Adapter panel right click, settings. In the Virtual Switch Hardver List on the left, select the Network adapter part. On the right panel  set the Virtual swith to  External switch. Enable Badwdth Management.


Getting an IP's MAC address from behind a router

Question: I want to know, if possible, how to get a MAC address of an IP address if I am behind a router.
I tried doing a ping to the IP and checking the arp table, but the only entry is the router's MAC.
Any ideas?
Thanks for reading.
Answer: MAC addresses do not get passed on by routers. You need to look at the router's ARP table.
Edit:
Unless you have some other form of access to the machine, yes, it is impossible. If you can get onto the network it's on (VNC, RDP, SSH), then you can do it, but otherwise no.
If you're router doesn't give you the ARP table on its web interface, you could see if you can telnet in : many home routers have more advanced functions they hide from the web interface.
Comment: Yes. ARP is referred to as a non-routable protocol - it won't ever go outside of the local network. If you want to see MAC addresses, you have to be on a link-local device, either directly connected or with enough remote access to enumerate the ARP table.
Comment: If I have no access to router's arp table, then it's impossible?
Answer: It cannot be guaranteed that you can see MAC address of machines behind a router. But there are some protocols that may help you in finding MAC address from anywhere in network. For example to find MAC address of a Windows PC on other network when you know its IP address you can use command
nbtstat -A <IP Address>

To do the same thing from Linux machine (with samba installed) use command
nmblookup -R -S -A <IP Address>

If the machine in question is not a windows machine and there is no way to become part of other subnet. Then the only options are seeing MAC address table in router, or if there is common network wide DHCP server then you can see MAC address in DHCP logs. But I guess you have to be administrator for accessing router or DHCP server.
Hence if there are lot of windows machines on your network you can find MAC address for them even when are not in their subnet. But if network has lot of Linux machines then there is no good very common way to find MAC from other networks.
The above technique wont work on Linux samba servers. They will always return MAC address as 00-00-00-00-00-00.
Answer: If the IP in question is not on a directly connected subnet of the router, then the MAC won't be in your router's ARP table.
ARP is only visible / relevant for the last hop of a IP connection (layer 2).  Everything between the first routing entity and the last routing entity is layer 3, which doesn't use the ARP of the source or destination entities, but rather the ARP of the next directly-connected routing entity.
Answer: I think what you want to know is --
How can you find the MAC for a particular IP(machine) which is not the part of your subnet?
For the all the machines/IPs on your subnet the IP-MAC table is stored in ARP Cache, locally on your machine. This is the same cache which give "IP resolution conflicts". do a simple

$ arp -a | grep particularIP

Now for the machine outside your subnet -- there is no standard of the shelf application which does that, i tried to think if any ICMP message can do it, but as of now i think there is none. Well the way networking, rather layering is designed, this is a deliberately unwanted behavior. To escape or remove the information which is relevant to layers below the present, and as we across the networks IP is used, so no MAC.
See if you have cooperation at the other machine, you can write a small app, which encapsulates the the mac header and sends to you... ofcourse if u have cooperation from the other machine, why this much of effort a simple ifconfig -a does the job, that to for all the interfaces on that machine.
Answer: You can only "see" mac addresses of hosts that are on in the same subnet. Then, you can list all mac addresses using the arp command:
arp -a

or for a single IP address:
arp -a 192.168.0.1

Comment: I said that I am behind a router, so I am not in the same subnet.
Answer: If you have any access to the remote PC, or any PC on the remote network, you could use WMI or run various apps to give you the MAC address. I can't think of any other way you'd get the MAC address.
JR
Comment: No, I don't have any kind of access to the subnet :(
Answer: Do you know the device's manufacturer? If so, you may be able to get part of the MAC.
http://aruljohn.com/mac.pl
The only other thing I can think of is vxlan but I'm sure it would be more difficult to set that up than to just get access to the router which would have the MAC directly.
https://www.rfc-editor.org/rfc/rfc7348
Answer: Well as told by the folks in the other answer, ARP is a layer two protocol ans is not routable so scanning in conventional methods will not give you back MAC addresses.
example
nmap -sn target

will only give MAC addresses of devices that are on the same network segment.
There are two nmap scripts that use helpers such nbtstat and snmp
NBTSTAT
this requires the UDP port 137 to be open on the target
the nmap command is
nmap -sU --script nbtstat.nse -p 137 target

SNMP
this protocol has to be functioning, it's port open, to give us any info about the MAC of the target.
Also UDP port 161
nmap -sU -p 161 --script=snmp-interfaces target

IPV6 addresses
this works on retrieving MAC from IPv6 or similar (teredo, 6to 4, etc) addresses. I've only tried it on IPv6 address that have part of the mac on them
nmap -sV -sC target

(this is the command from nmap https://nmap.org/nsedoc/scripts/address-info.html)
but when testing it (on internal fe80 hosts), it required a -6 so
nmap -sV -sC -6 target

Answer: Try namp Intense Scan: nmap -T4 -A -v IP-address
Comment: Either you haven't understood the question, or you have no idea what you are talking about. I see no evidence suggesting that this command would ever see the MAC address on the other side of any router. Even if it did work, it wouldn't have been a good answer, because it is missing information about how it works.
Answer: i don't know about router but if you have ip address you can use nmap to obtain mac address even in your local host you can do it as well so why the hell are you want obtain that from router or some thing like that ?
if your os is linux you can use macchanger or lots of other apps so i have no idia why you want do this like that.
Comment: I think you missed the word router in the question.


Restart SSH on a machine where SSH is the only mode of access

Question: I've made some changes to sshd_config file and therefore need to restart. I'm looking tips on safely restarting ssh when getting physical access to the server would be a huga PITA.
Answer: Restarting sshd while logged in via ssh will not disconnect your ssh connection.
If you're worried about your configuration, log in a few times via ssh, and restart. If you can no longer ssh in, with new connections, you now have access to fix the problems.
Mentioned below in a comment by @Milan Babuškov: sshd -t will test your configuration for syntax correctness, if you really want to be certain.
Another suggestion, by @Ronald Pottol was to set up a cron task to restart the server with a known working configuration. Perhaps overkill, but if you're updating a mission critical server, etc... sometimes you can never be too careful.
Comment: Regarding `sshd -t` indeed, straight from the authoritative source: [Test mode. Only check the validity of the configuration file and sanity of the keys. This is useful for updating sshd reliably as configuration options may change.](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/sshd.8?query=sshd&sec=8)
Comment: Thats pretty easy, makes sense too. Thanks for the really quick reply.   FYI the changes I was making worked great ;)
Answer: If you have access to the hardware you may consider putting a terminal on the serial port /dev/ttyS0 . Then you can have a back door into your server.
simply add
SO:2345:respawn:/sbin/mingetty ttySO

to your /etc/inittab and a terminal will spawn over your serial port.  You can use a serial port concentrator or use a null modem from the server next to it.
Comment: Pretty standard, so long as you have a way to connect to the machine that is the serial terminal server.
Comment: It can be but due to virtualization it is not as necessary because you can manage via the Hypervisor.  Another cool thing is if the BIOS supports it is "Console Redirection" this will show all of the BIOS screens via your serial console.  GRUB also has the ability to display to serial console.  So there is no need for remote video to see if your server will come back online.
Comment: Cool! Is this a pretty standard practice?
Answer: Don't worry, your current session won't be disconnected, even if there's a problem with the new configuration.
After applying the new configuration and restarting sshd, just try to login a couple of times and take a look at the logs to see if everything is ok.
Answer: Or, use a cron or at job to start it back up, if you are feeling unlucky?
Comment: `cron` or `at` would work, to copy a 'known' working, i.e. the old configuration, back and then do a restart of the service...
Answer: Could you not Just run a kill -HUP in the PID of the SSH service? Its not clean but it works
Comment: Often, `SIGHUP` _is_ the clean way to reload a daemon's configuration.
Comment: `pkill -HUP sshd` closed my connection. This worked: `kill -HUP $(pgrep -f /usr/bin/sshd)`
Comment: It *is* clean in this case. From the authoritative source: [sshd rereads its configuration file when it receives a hangup signal, SIGHUP](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/sshd.8?query=sshd&sec=8)
Answer: I have found that nowadays sshd does not disconnect your sessions when restarting, especially when it is a Redhat based distro. You could always write a small script that will automatically restore your sshd config from backup and restart sshd after 5 min as a cron or at job. This will ensure that even if you get disconnected, you can get back into your server at least.
Answer: I wouldn't recommend restarting/reloading SSHD on a sshd connection. I've seen many occasions where sshd just wouldn't start back up because of a syntax error in sshd_config.
Even though everything is ok with the config file, it's risky.
Comment: You can use sshd -t to test the config file beforehand.
Comment: Thanks Milan, I quickly looked through man for an option like that, in Apache its -s so I must have been too focused on -s.
Comment: i'm going to absorb your comment into my answer, also when sshd terminates, it does not bring down the open ssh sessions, but it's good to know your syntax is valid, if you're sweating it.


How to get current instock product count for each active category

Question: I need to display categories in header main navigation but only categories which has at least one instock product (configurable) , currently I tried by checking whole product collection for each category and check weather they have at least one instock product but it kills the mysql server and taking much time as my catalog is almost more than 50,000+ . Second option I thought is running a cron but it will also not give realtime result. So is there any other way to do this ? perhaps using model_save_after event or something
Answer: Building a universal solution might be too big of a scope as there are a number of configurations to consider:

Parent may be disabled
Child products may be disabled
Stock may not be managed for some products
Minimum stock amount
Minimum allowed-in-cart amount
etc.

I'd recommend to standardize and document the relevant configuration for your store, perhaps noting these assumptions wherever you store your code. You might even want to set up config save observers which enforce these business rules. Assuming this is in place you may also want to enforce that all child products mirror their parent's category/categories association, as this will allow you to work with IDs from cataloginventory_stock_item which you can use to filter your category collection.
You'll definitely need to rewrite Mage_Catalog_Block_Navigation as it contains a the logic related to cache keys.