Bash test: what does "=~" do?

Question: #!/bin/bash
INT=-5

if [[ "$INT" =~ ^-?[0-9]+$ ]]; then

echo "INT is an integer."

else

echo "INT is not an integer." >&2

exit 1

fi

What does the leading ~ do in the starting regular expression?
Answer: The ~ is actually part of the operator =~, which performs a regular expression match of the string to its left to the extended regular expression on its right.
[[ "string" =~ pattern ]]

Note that the string should be quoted, and the regular expression shouldn't be quoted (unless you want to match literal strings).
A similar operator is used in the Perl programming language and several other general-purpose and domain-specific languages to perform regular expression matching.
The regular expressions understood by bash are the same as those that GNU grep understands with the -E flag, i.e. the extended set of regular expressions.

Somewhat off-topic, but good to know:
When matching against a regular expression containing capturing groups, the part of the string captured by each group is available in the BASH_REMATCH array. The zeroth/first entry in this array corresponds to & in the replacement pattern of sed's substitution command (or $& in Perl), which is the bit of the string that matches the pattern, while the entries at index 1 and onwards correspond to \1, \2, etc. in a sed replacement pattern (or $1, $2 etc. in Perl), i.e. the bits matched by each parenthesis.
Example:
string=$( date +%T )

if [[ "$string" =~ ^([0-9][0-9]):([0-9][0-9]):([0-9][0-9])$ ]]; then
  printf 'Got %s, %s and %s\n' \
    "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]}"
fi

This may output
Got 09, 19 and 14

if the current time happens to be 09:19:14.
The REMATCH bit of the BASH_REMATCH array name comes from "Regular Expression Match", i.e. "RE-Match".

In non-bash Bourne-like shells, one may also use expr for limited regular expression matching (using only basic regular expressions).
A small example:
$ string="hello 123 world"
$ expr "$string" : ".*[^0-9]\([0-9][0-9]*\)"
123

Comment: It's the same as what `grep -E` understands only on GNU systems and only when using an unquoted variable as the pattern `[[ $var = $pattern ]]` (see `[[ 'a b' =~ a\sb ]]` vs `p='a\sb'; [[ 'a b' =~ $p ]]`). Also beware that shell quoting affects the meaning of RE operators and that some characters need to be quoted for the shell tokenising that may affect the RE processing. `[[ '\' =~ [\/] ]]` returns false. `ksh93` has even worse issues. See `zsh` (or bash 3.1) for a saner approach where shell and RE quoting are clearly separate. The `[` builtin of `zsh` and `yash` also have a `=~` operator.
Comment: It's saner (IMO) in that it's much simpler rules. Shell quoting and RE escaping are clearly separate. In `[[ a =~ .* ]]` or `[[ a =~ '.*' ]]` or `[[ a =~ \.\* ]]`, the same `.*` RE is passed to the `=~` operator. OTH, in `bash`, `[[ '\' =~ [)] ]]` returns an error, would you know without trying it whether `[[ '\' =~ [\)] ]]` matches?  How about `[[ '\' =~ [\/] ]]` (it does in ksh93). How about `c='a-z'; [[ a =~ ["$c"] ]]` (compare with the `=` operator)? See also: `[[ '\' =~ [^]"."] ]]` which returns false... Note that you can do `shopt -s compat31` in `bash` to get the `zsh` behaviour.
Comment: To deal with characters in the pattern that might be interpreted by the shell, it's often recommended to do something like this: `pat="..."; if [[ "$string" =~ $pat ]]; then ...`. (@StéphaneChazelas's topmost comment suggested it, I'm just emphasizing it.)
Comment: @StéphaneChazelas How is it "saner" that both of this match in zsh?: `[[ "This is a fine mess." =~  T.........fin*es*    ]]; [[ "This is a fine mess." =~  T.........fin\*es\*  ]]`. Or that a quoted `*` also match? `[[ "This is a fine mess." =~ "T.........fin*es*"   ]]`.
Comment: `zsh`/`bash -o compat31`'s behaviour for `[[ a =~ '.*' ]]` is also consistent with `[ a '=~' '.*' ]` (for `[` implementations that support `=~`) or `expr a : '.*'`. OTOH, it's not consistent with `[[ a = '*' ]]` vs `[[ a = * ]]` (but then, globs are part of the shell language, while REs are not).
Answer: You should read the bash man pages, under the [[ expression ]] section.
An additional binary operator, =~, is available, with the same precedence as == and !=.  When it is used, the string  to  the  right  of  the operator  is considered an extended regular expression and matched accordingly (as in regex(3)).
Long story short, =~ is an operator, just like == and !=. It has nothing to do with the actual regex in the string to its right.
Comment: @Sokel For some, "RTFM" is easier said than done. ⋯ `man [[ expresssion ]]` and `man [[` return nothing.  `help [[` returns useful information—since `[[` an internal bash command—but does not say whether `=~` uses basic or extended regex syntax. ⋯ The text you quoted is from the **bash** man page.  I realize you said "read the bash man pages" but at first, I thought you meant read the man pages within bash. At any rate, `man bash` returns a huge file, which is 4139 lines (72 pages) long. It can be searched by pressing `/▒▒▒`, which takes a regex, the flavor of which—like `=~`—is not specified.
Comment: Can you figure out some examples demonstrating the use of `=~` in real life...?
Comment: @GeorgeVasiliou I use it fairly often in scripts that put the output from a command into a variable. Then the variable is checked to see if it matches some string pattern. This is useful for example if you want to take some action based on some error output from that command.
Comment: a link to the page where that does appeared would have helped the answer

Bash test: what does "=~" do?


Elegant way to denote the following summation?

Question: For example, $$
\begin{align}
S_1&=\frac{x_1}{2},\\
S_2&=\frac{x_1}{2}-\frac{x_1^2}{6}\frac{1}{x_2},\\
S_3&=\frac{x_1}{2}-\frac{x_1^2}{6}\left(\frac{1}{x_2}+\frac{1}{x_3}\right)+\frac{x_1^3}{12}\frac{1}{x_2 x_3},\\
S_4&=\frac{x_1}{2}-\frac{x_1^2}{6}\left(\frac{1}{x_2}+\frac{1}{x_3}+\frac{1}{x_4}\right)+\frac{x_1^3}{12}\left({\frac{1}{x_2 x_3}+\frac{1}{x_2 x_4}+\frac{1}{x_3 x_4}}\right)-\frac{x_1^4}{20}\frac{1}{x_2 x_3 x_4},\\
&\cdots
\end{align}
$$I am trying to generalize this using $\sum$ and $\prod$ notation. My attempt: $$S_n=\sum_{i=1}^{n}{\frac{(-1)^{i-1}x_1^i}{i(i+1)}\sum_{2\le j_1\lt j_2\lt\cdots\lt j_{i-1}\le n}\prod_{k=1}^{i-1}\frac{1}{x_{j_k}}},$$ which still seems complicated. I wonder if there are more elegant expressions. :-)
Comment: Please don't silently change the question after it has been answered.
Comment: @YvesDaoust Sorry for the confusion! There was no answer yet when I started editing the question. I just added the expressions for $S_1,S_2,S_3$ to describe my question more clearly. Please accept my apology.
Answer: One way is the express it as
$$ S_n := \frac1{x_1}\int_0^{x_1} \int_0^{t} \prod_{k=2}^n
   \left(1 - \frac{x}{x_k}\right) \, \text{d}x \, \text{d}t. $$
The clue is the appearance of elementary symmetric polynomials in the coefficients of $\,x_1^k$.
Comment: @MinutesSneezer Thanks for those improvements! The finite product is a polynomial in $x$ if that is what you mean.
Comment: For clarification, I suggest writing it as $$S_n=\frac1{x_1}\int_0^{x_1}\int_0^t\prod_{k=2}^n\left(1-\frac{x}{x_k}\right)\,\mathrm{d}x\,\mathrm{d}t.$$ I wonder how you managed to observed this. Is it related to polynomials?
Answer: Probably not what you are after, but observing that $\dfrac1{x_k}, k=2,\cdots4$ are the roots of some polynomial
$$\left(z-\frac1{x_2}\right)\left(z-\frac1{x_3}\right)\left(z-\frac1{x_4}\right)=p_3z^3+p_2z^2+p_1z+p_0,$$
you have
$$S_4=\sum_{i=1}^4\frac{p_{4-i}}{i(i+1)}x_1^i.$$

You can also refer to the elementary symmetric polynomials notation.
Comment: Exactly needed! Using the notation described in [Wikipedia](https://en.wikipedia.org/wiki/Elementary_symmetric_polynomial#Examples), it simply becomes $$\sum_{i=1}^{n}{\frac{(-1)^{i-1}x_1^i}{i(i+1)}e_{i-1}\left(\frac{1}{x_2},\frac{1}{x_3},\cdots,\frac{1}{x_n}\right)}.$$


What is the difference between 背 and 裏 for the backside of objects?

Question: I know that 背 can also mean height, and also refers to the spine of the book when used with books.  I also know that 椅子の裏 refers to the bottom of the chair while 椅子の背 refers to the back of the chair. But beyond that, if I am to use them with normal objects, what is the difference? For example, is there a difference between 窓の裏 and 窓の背 or 扇風機の裏 and 扇風機の背?
Answer: I was browsing BCCWJ with the keyword='の背に'. 背 in the meaning of the question is used for 椅子, ソファ, フォーク. As you mention in the question, it can be used for books as well. Practically these are pretty much all for which 背 in that sense can be used. (Cf. As regards with books, it is one of many jargons.)
I cannot come up with other objects for which the usage extends naturally.
I guess 窓 is too symmetrical to call one side 背. Using 背面 may be possible, but usually 内/外側 will be used.
As for 扇風機, the part connecting the fan part and the bottom part won't be called 背. 首 is possibly a term to call it although I never really thought about where exactly 扇風機の首 refers. The related expression commonly used is 首振り which means the head of 扇風機 swinging.
Comment: I was initially confused in that when I google exact searched for Xの背, I would normally get results, but then lookin this up again I realize that these results seem to not be using the "back" meaning of 背. Thanks! :)


In what conditions we can take ground state energy $E_0$ equal to zero?

Question: Like in 3D harmonic oscillator , $E_m = {h} \omega {(m_x +m_y + m_z + 3/2)}$, At ground state energy $m=0$ and $ E_m = h \omega(3/2)$. While discussing Bose-Einstein condensation, for calculations we considered ground state energy $E_0= 0$. In what conditions In what conditions we can take ground state energy $E_0=0$ equal to zero ?
Answer: You can only measure differences between the ground state energy and excitations (setting aside the cosmological constant problem).  That means you can safely "reset" ground state energy to zero. In fact, in quantum field theory, since each point in space(time) is assigned an oscillator of matter/radiation fields, if you don't subtract the ground states of oscillators, your total ground state energy would be infinite, since you integrate over continuous volume of space.
Answer: As the other answers have said it is almost always safe to subtract off a constant from your energy. One other case when it may not be safe is if your Hamiltonian can be varied by an external parameter. For example if you have a harmonic oscillator with a controlable frequency
$$
H = \frac{p^2}{2m} + \frac{1}{2}m\, \omega(s)^2 x^2\;.
$$
You could then ask questions such as

If I have an oscillator in its ground state with frequency $\omega_1$ and adibatically vary the frequency to $\omega_2$, how much work must I do on the system?

In this case it is crusial that include the zero point energy as it depends on $\omega$ and so will vary as $\omega$ is varied. If you neglect the zero point energy the result will be 0, but the correct result is $\frac{1}{2}\hbar (\omega_2-\omega_1)$
The key point here is that while I can select an arbitrary point for my 0 of energy, once I have done so I must use that zero constently. I cannot vary my zero as I change my Hamiltonian.
Answer: Energy is always defined within an additive constant. Therefore, a shift of energy is always possible (in statistical mechanics one has to remember that a shift of energy scale has to be accompanied by an equal shift of the chemical potential). Moreover, in thermodynamics the shift is necessary to allow a simple expression of the the consequence of extensiveness.
The only case where the shift is questionable is the case of hamiltonians which are not limited below or if they are limited below but the ground state energy of an $N-$particle system ($E_G$) is not limited by
$$
E_G\geq-B N
$$
with $B$ positive constant independent on $N$. However, in such pathological cases, the real problem  is not the shift of the energy scale, but the impossibility to get a well behaved thermodynamic.


Can an artificer's infused item still have other magic added to it after it's infused?

Question: If an item was infused by an Artificer, say using the returning weapon infusion, would it be possible to then add some other magic to the weapon. You cannot infuse a magical item, but does that limit still apply after the infusion has been made? An example might be the Hexblade Warlock's Hex Warrior feature. Would this be allowed as the RAW seem to imply it would be.
Comment: Are you asking if imbuing additional magic onto an infused item would cancel the infusion?
Comment: Yes, the question just isn't clear. Are you asking if you can add infusions to an infused item? Are you asking if it stacks with magical modifications that don't make an item magical? This just can't be determined with the current state of your question
Comment: I think what OP is trying to ask is if you can put a spell on a weapon AFTER infusing it with the artificer. He knows that you can't use the artificer infusion on a magical weapon, but can you make it magical after infusing it.
Comment: Welcome to RPG.SE! Take the [tour] if you haven't already, and check out the [help] for more guidance. Can you edit your question to clarify what exactly you're asking? Once we understand that, we can actually address the thing you're confused about. What do you mean by "adding other magic to the weapon"? Different ways to do this might interact differently with the rules, so it would help to know what sort of thing you mean.
Answer: Adding additional magic to an infused item does not negate the infusion
The requirement for infusing an item is:

Whenever you finish a long rest, you can touch a non-magical object and imbue it with one of your artificer infusions, turning it into a magic item.

Furthermore, several conditions are given for ending an infusion:

Your infusion remains in an item indefinitely, but when you die, the infusion vanishes after a number of days have passed equal to your Intelligence modifier (minimum of 1 day). The infusion also vanishes if you give up your knowledge of the infusion for another one.
[...] If you try to exceed your maximum number of infusions, the oldest infusion immediately ends, and then the new infusion applies.

There is nothing about an infusion ending if some other magic is applied to the infused item. The only requirement is that the item must be non-magical at the time you apply the infusion in order to infuse it in the first place. Beyond that, no further changes to the item will cause the infusion to end. In fact, I don't see any way in the feature's text to voluntarily end an infusion other than infusing enough additional items to exceed your maximum.
Answer: No, you can't.
In DnD 5e, there are no rules for enchanting an already-enchanted item. When you create a magic item, you create a specific item; there are no rules for turning e.g. a +1 Longsword into a +2 Longsword, and you can't create something like a +1 Mithral Plate.
Comment: Table mileage will vary. Mainly because there are not really any hard rules on enchanting either, merely suggestions.


Level shifter to convert dc voltage

Question: Can anyone help me to design a circuit which outputs 0v dc when the input is 2.6v dc and 5v dc when the input is 5v dc?
Comment: How much current do you need at the output? If it is digital signal/low current demand; Look at op-amp as a comparator(with Vref>=2.7 V)
Comment: Can u guide me to design one. Mine is digital signal. So low current demand..
Comment: Just look at the datasheet for any comparator and follow their recommended application circuit.
Comment: My question is vague. Actually my circuit has 2 nodes where the voltages can be either 2.7v dc or 5v dc. I need a single circuit to convert 2.7v to 0v and 5V to 5V to use with digital ic.
Comment: @KrishnenduK you have already got an answer. Search for a comparator with a threshold of around 3.7V
Answer: After reviewing your earlier circuit and some of the discussion there (you should modify your question to refer directly to it and also extract the important details from the discussion there and re-post it in your question here), I'll propose this circuit:

simulate this circuit – Schematic created using CircuitLab
The above circuit uses two \$10\:\textrm{k}\Omega\$ pull-up resistors for \$V_{OUT}\$. This can be changed if you need a lower impedance output when high (with some implications for the other resistor values.) I didn't gather from you a specific output impedance so I just used those.
The circuit uses \$R_6\$ and \$R_7\$ to inject some current into \$Q_1\$'s base node. Because the circuit includes carefully designed hysteresis, the output will be held low until both inputs transition to \$+5\:\textrm{V}\$. Then it will transition high. Once high, though, the output will stay high until both inputs transition back to \$2.7\:\textrm{V}\$. (The hysteresis is substantial so it should be relatively immune to noise.)
The behavior looks like this:

Here it is with added noise on the two inputs:

As I understand you, there are four LEDs indicating five states for your tank of water. With all four LEDs off, the water in the tank is below the threshold where you then want a motor turned on to fill the tank. With all four LEDs on, the water in the tank is above the threshold where you then want the motor turned off (to stop filling the tank.)
When an LED is on, the voltage on one side of the LED (relative to ground, I'm assuming) is \$2.7\:\textrm{V}\$ (which makes sense, since the LED will drop a certain voltage not unusually in that range.) When the LED is off, the voltage across it is \$5\:\textrm{V}\$ (which also makes sense, if a low-side switching circuit isn't allowing much LED current.)
I think you are then suggesting using the voltage present one two nodes, one node from one side of the lowest-level indicating LED and one node from the highest-level indicating LED as a means to signal when to operate your motor.
I see the table like this:
$$
\begin{array}{r|lccc|l}
\textrm{State} & \textrm{LED}_{low} & \textrm{LED}_{low-mid} & \textrm{LED}_{high-mid} & \textrm{LED}_{high} & \textrm{Action}\\
 \hline
\textrm{empty} & 5.0 & 5.0 & 5.0 & 5.0 & \textrm{turn motor ON}\\
\textrm{filling} & 2.7 & 5.0 & 5.0 & 5.0 \\
\textrm{filling} & 2.7 & 2.7 & 5.0 & 5.0 \\
\textrm{filling} & 2.7 & 2.7 & 2.7 & 5.0 \\
\textrm{full} & 2.7 & 2.7 & 2.7 & 2.7 &\textrm{turn motor OFF}\\
\textrm{draining} & 2.7 & 2.7 & 2.7 & 5.0 \\
\textrm{draining} & 2.7 & 2.7 & 5.0 & 5.0 \\
\textrm{draining} & 2.7 & 5.0 & 5.0 & 5.0 \\
\textrm{empty} & 5.0 & 5.0 & 5.0 & 5.0 & \textrm{turn motor ON}\\
\textrm{...}
\end{array}
$$
The very high input impedance of the given circuit should not cause any trouble for your LED displays or the circuits driving them. Use the first and last LED columns shown above as your two nodes for the circuit. It will produce a LOW output when the motor should be OFF and will produce a HIGH when the motor should be ON. Couldn't be simpler.
The output impedance might matter. But it is trivial to reduce the output impedance with a very simple added stage, if you need it.
The circuit is resistant to noise, uses parts that are available anywhere in the world where electronic parts are available, and the parts are widely supplied, too. And they cost next to nothing. Nothing boutique here. Not even close.
Comment: Very very thanks for the reply.. My circuit is a water level controller. It has 4 sensors. One at the bottom of the tank, one at quarter position, one at middle and one at the top. Correspondingly there are 4 LEDs to indicate the level of water. My aim is to swich on a motor when all LEDs are off (tank is empty) and switch motor off when all LEDS are on (tank is full). The cathode pin of LED shows 2.7v when on and 5v when off in simulation.
Comment: @KrishnenduK I don't understand the problem, then. The circuit I provided switches to \$5\:\textrm{V}\$ output (the motor should be activated) when both nodes (LED\$_1\$ and LED\$_4\$) have turned **OFF** (tank empty.) It switches to \$0\:\textrm{V}\$ (the motor should be deactivated) when both nodes (LED\$_1\$ and LED\$_4\$) have turned **ON** (tank full.) What more do you want???
Comment: @jonk you seem to have much time for that stuff..
Comment: Thanks sir.. Thanks for your valuable time. I havent got enough time to simulate the circuit today.. I will simulate the circuit and let you know soon..
Comment: Sir.. Can you please help me with the design of this circuit? By the way it simulates perfectly.. Thanks,,
Comment: @KrishnenduK The circuit is complete from the point of view of what it accepts and what it generates. What circuit design do you additionally need?
Comment: Sir.. I have connected  the components on bread board.. When i measured the voltages on the nodes, it shows 3.1v and 5.01v. Can u help me with the design part.
Comment: You'll need to work out the details as you press forward. It's just resistor changes. Leave \$R_3\$ and \$R_4\$ alone (unless you really need to change them.) Change \$R_1\$ and \$R_2\$ together, using standard values UP or DOWN. Lowering their values will reduce the hysteresis band, narrowing it by bringing the lower edge towards the higher, but without moving the higher edge much. Reducing \$R_6\$ and \$R_7\$ will move the hysteresis band voltages down without changing the width that much. \$R_5\$ is a little more critical. So small adjustments will have noticeable impact.
Answer: You can use operational amplifier like LM358 to make simple comparator. And voltage divider to get reference voltage.
Here's a schematic based on LM358 documentation:

You can get those parts anywhere. Connect your tested voltage to Vin. The two resistors on left side make voltage divider that converts 5V to 3V. And those 3V make voltage reference for LM358. When Vin > 3V then Vo will be equal to 5V (provided to powered LM358 with 5V) and when Vin < 3V then V0 will be 0V.
So it should do the job.
Comment: Actually my circuit has 2 nodes where the voltages can be either 2.7v dc or 5v dc. I need a single circuit to convert 2.7v to 0v and 5V to 5V to use with digital ic to perform some logic
Comment: @KrishnenduK I recall seeing you write that before, but... do you mean that you need TWO circuits that do the same thing? Or do you mean that this isn't single-ended, but a differential of some kind? Your situation is **not** very clear. Please add more information.
Comment: Please have a look at this thread..    http://electronics.stackexchange.com/questions/288907/controlling-motor-with-potential-on-2-points
Comment: @KrishnenduK That's clearer, now. I'm surprised you didn't reference it earlier.
Comment: Sorry.. I have researched on it several days now.. But havent got a good solution.. May be i am a noob in this. I just want to control the motor to fill the tank with the inputs from led terminals.. But its complex..
Comment: @KrishnenduK I'll post up something that might work. I did NOT read your earlier post carefully, though. However, I did find some useful information there. I'll provide a very simple, very cheap circuit. But you need to tell me if it does what you need. I may misunderstand, despite some reading.
Comment: My circuit is a water level controller. It has 4 sensors. One at the bottom of the tank, one at quarter position, one at middle and one at the top. Correspondingly there are 4 LEDs to indicate the level of water. My aim is to swich on a motor when all LEDs are off (tank is empty) and switch motor off when all LEDS are on (tank is full). The cathode pin of LED shows 2.7v when on and 5v when off in simulation.

Level shifter to convert dc voltage


radio button change only after confirm() returns true

Question: I've got a set of radio buttons in my html site. When the users changes the selection I show a dialog via the confirm('') function. I just want to change the selection if the user confirms the change - otherwise just cancel the event. My problem now is that I only got an event AFTER the value has been changes and the change is already done. How can i prevent this behaviour?
Comment: onCancel button click you can put reset using javascript, that may help you.
Answer: <code>$('.rdio').click(function(){
 var cnfrm = confirm('Are you sure?');
 if(cnfrm != true)
{
 return false;
}

})
</code>
live demo : http://jsfiddle.net/cTzVg/
Comment: Nice and simple, especially since you can replace the entire thing with a one liner `return confirm('Sure?');` but the problem is that it doesn't work in IE. Pressing cancel doesn't restore the previous selection. So saving the previous selection in a page scoped variable looks unavoidable.
Comment: This helped me! NOTE: you don't have to check `cnfrm != true` as confirm returns boolean value `true` on "OK" and `false` on "Cancel", all you have to do is rearrange your `if - else`. thanks :)
Comment: Thanks for giving solution but this doesn't work in IE. On Cancel button IE deselects all radio buttons. Please provide any work around to work in IE.
Comment: needed to fetch the current_radio and add `current_radio.checked= false` before `return false` in a case where no radio button is checked to start with (like the jsfiddle linked above). Otherwise the radio button gets checked even if confirm returned false. demo: http://jsfiddle.net/6b46y4sm/1/
Answer: This isn't easy because there is no consistency across browsers in which event is appropriate to do what you need doing. However you say from your tags you're using jQuery, so here's a solution using state tracking to revert depending on your function return:
<code>var currentradio= $("input[name='pick_up_point']:checked")[0];
$("input[name='pick_up_point']").change(function(event) {
    var newradio= $("input[name='pick_up_point']:checked")[0];

    if (newradio===currentradio)
        return;
    if (confirm('Your question here')) {
        currentradio= newradio;
    } else {
        currentradio.checked= true;
    }
});
</code>


Can I use an RSA SecurID software token on Ubuntu Linux?

Question: I have Windows, Mac, and Linux computers; but I am only able to connect to some of my company's websites through the Windows and Mac machines at the moment because they are the only ones with RSA SecurID software tokens. I'm curious: is it possible to set up a SecurID software token to work on a Linux system (in my case, Ubuntu)?
Comment: Is tehre something else going on here? Some sort of single-sign-on system in addition to the tokens?
Comment: @PriceChild: To be honest, I don't think I understand how RSA tokens work well enough to even get what you're asking. All I know is that typically, to access certain sites within my company I have to enter the string displayed by my software token into an input box. Then I can log in. Since I don't have such a token on my Linux machine, I view the websites as inaccessible. Perhaps that's grossly inaccurate; like I said, I don't really understand the whole system well enough to know.
Answer: Recent versions of Ubuntu offer the stoken package, a native open source SecurID implementation that includes a CLI, a GTK+ GUI, and a library API.
For more information see the project homepage.
Comment: This is a very impressive product.  It looks professional, easy to use, and incurs very little configuration or overhead.  Working great for me, the Windows RSA SecurID is very heavy and goes way overboard with respect to the UI for such a simple tool.  This extra complexity makes it extremely brittle and newer versions won't work.
Answer: Personally, I'm too lazy to pick up my phone, open the RSA app, enter my PIN, and then type it into the login page.  I also don't like to deal with Wine.  So, instead, I created a totally insane solution to this problem.  I wrote a script that will SSH into a Windows machine, launch the RSA app, enter your PIN, copy the result, and put it in the clipboard of your local Linux machine.  To do this you need a Windows machine that you can access via SSH with the RSA software installed.  I used freesshd as the SSH server in Windows.  You will also need AutoHotKey and PsExec.
Compile the following AHK script on the Windows machine (I put the resulting exe at C:\Program Files\RSA SecurID Software Token\rsa-securid.exe):
<code>TokenName = %1%
Pin = %2%
Run, "C:\Program Files\RSA SecurID Software Token\SecurID.exe"
WinWait, %TokenName% - RSA SecurID Token,
IfWinNotActive, %TokenName% - RSA SecurID Token, , WinActivate, %TokenName% - RSA SecurID Token,
WinWaitActive, %TokenName% - RSA SecurID Token,
Send, %Pin%
Sleep, 100
Send, {Enter}
Sleep, 100
Send, ^c
Passcode = %Clipboard%
Sleep, 100
Send, {AltDown}{F4}{AltUp}
ExitApp %Passcode%
</code>
Then use the following shell script on the Linux side:
<code>#!/bin/bash
NAME=<the rsa token name>
PIN=<your pin>
HOST=<windows host>
USER=<windows user>
PASSWORD=<windows password>
SESSION=1
PASSCODE=$(ssh $HOST "cmd /c \"C:\Program Files (x86)\Sysinternals\PsExec.exe\" /accepteula \\\127.0.0.1 -u $USER -p $PASSWORD -i $SESSION  C:\\PROGRA~1\\RSASEC~1\\rsa-securid.exe $NAME $PIN" | grep "error code" | sed "s/.*error code \([0-9]*\).*/\1/")
echo -n $PASSCODE | xclip -selection clipboard -in
notify-send --hint=int:transient:1 -i "rsa-securid.png" "Passcode: $PASSCODE"
</code>
When the script is done talking to the Windows machine, it will put the passcode in your clipboard and popup a little notification.  So basically you push a button, wait a couple seconds, and voila you can paste the passcode.
Hope that helps.
Answer: There isn't a RSA Software token for linux, so you will need to resort to using Wine (or running windows in a virtual machine).   There is a thread here where the Wine version and RSA Software version detailed that has been found to work.
Another alternative would be to get a phone based token so you are not reliant on a specific desktop and the flakiness of wine.  Most phone platforms are supported.
Comment: The phone-based solution was right in front of me the whole time and I was too stupid to notice!
Comment: See the answer below regarding _stoken_, I've tried it and I am very impressed.  As for Wine + RSA Software, I can't even get the newer versions to install or run without crashing and/or freezing (albeit I am using Wine staging 2.2).  Only RSA SecurID v410 seems to work and it's very clunky at that.
Answer: I've made myself a script to generate the passcode from command line, so I don't have to deal with a windows app. It basically runs wine in the background, grabs the output and prints it to console.


Installing softwares (including OS) in Windows Azure VM for SP installation

Question: I have a Windows Azure subscription. I have to create VMs with Windows Server 2008 R2 SP1 OS. I need to create multiple VMs so that, I can install SharePoint in one of them, SQL Server in another, Domain Controller in the 3rd one and so on. I heard that, we cannot mount ISO images into the VMs in Azure. Also, I cannot purchase pre-built VMs, due to some licensing issues. Can anyone please guide how to install OS and softwares like SharePoint, SQL Server and so on in those VMs? I heard there is an option to create a VM in Hyper-V and then upload this VM to Azure. But the issue with this is, how do we manage the IPs / Host Name / Domain. Without the domain properly setup, we cannot install SharePoint or SQL Server. So, I am confused. I am not able to find much help. Can anyone please provide some articles / links / blogs / Tutorials, explaining everything in detail?
Comment: This question is very vaguely connected to SharePoint. It should probably be asked elsewhere (like the main Stackoverflow site or for example the ITPro network on Yammer)
Comment: When you run a Microsoft Azure VM the licensing charge is included in the running of the VM (https://azure.microsoft.com/en-gb/pricing/licensing-faq/). Why make life difficult for yourself?
Comment: As far as I am concerned, it is related to SharePoint, since, it involves installing SharePoint on an Azure environment.
Answer: In your situation, you have to use a 3 tier Server farm installation instead of standalone.
-VM-1 -Application server
-VM-2 -Database server
-VM 3 -web server
Please take look on this article
https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-sharepoint-farm-azure-preview/
this article might give you an Idea about structure of installation SharePoint.
BTW this question is vaguely related to SharePoint.
Comment: I have already looked at it. It doesn't seem to help much in my case.


An infinite product of fields is not a semisimple ring

Question: I want to show that an infinite product of fields is not a semisimple ring. I know Artin-Wedderburn Theorem, but I wonder can I explain it without using this theorem? Any help will be appreciated. Thanks!
Answer: Any ideal $I$ in a semisimple ring $R$ is principal, since the inclusion map $I\to R$ is split by a surjective module-homomorphism $R\to I$.  But in any infinite product of nonzero rings, the ideal of elements of finite support is not principal (or even finitely generated).
Answer: If you know semisimple rings are Artinian and Noetherian, another way would be to  show an infinite product of nonzero rings is not Artinian or not Noetherian using chains of ideals.  Either one is equally easy to show.


What version is published online under "ahead of print" for an accepted paper?

Question: Some journals publish the article online much before the publication, under the "ahead of print" section. My question is, will they send the proofs (to the author) before putting it in "ahead of print" itself, or only right before publication in print. What version will be published online under "ahead of print"?
Comment: May vary by journal, of course.
Comment: @Buffy : The proofs are sent only a month or fortnight before the publication in print (common practice). So If they wait for the proofs then the "ahead of print" is of no real advantage.
Comment: @user118656 That does not correspond with my experience. What makes you think that that is "common practice"?
Comment: perhaps I am wrong. But the journal assistant said they will send me the proofs a month before publication. and then they said that they would also inform the publisher to keep the article in "Ahead of Print" section online. I don't know whats really the advantage of this? just a month?
Answer: Depends on journal policies. The one I'm most familiar with, the "ahead of print" articles are complete in every way except they've not been assigned to a volume & issue. If this is the case for you then of course they will send proofs to the author before putting it there.
Alternatively they can put the accepted manuscript there. If this is the case it will look very unpolished; it might not be in the journal's style, the figures might be on separate pages, and so on.
A glance at the articles already in the "ahead of print" section should reveal which is the case for you.
Comment: My experience agrees with this. After proofs have been corrected, the final version (except for volume and page numbers) is posted online, and no further changes are allowed for the printed version.
Comment: Thanks for the answer. That makes sense.


How to power a DC brushless motor without a speed controller

Question: I have a brushless motor but It doesn't power directly with a 9 volt battery, but I don't have a speed controller what else can I use to power it.
Comment: Step 1: check that you haven't destroyed it yet.
Comment: Can I use a switch or speed controller from a fan, I tested it long ago and it controls the speed of a brushed DC but I don't have it now. Can I use this to power it?
Comment: No, not at all. Magnetic fields as they are used in motors have to be changing. Brushed DC motors do this by putting current through different coils as the motor spins. The spinning itself changes the coil that is getting the current (or the direction the current travels through a single coil). In a brushless motor, there is no mechanical mechanism to change the magnetic fields. It still uses different coils to change magnetic fields, but it requires this brushless motor controller to decide when to change the current to alternating coils.
Comment: But can I use the motor to generate electricity without using any sort of controller, By spinning the rotor manually.
Answer: Brushless motors do not have commutators so they cannot be powered directly from DC sources such as batteries.  You'll have to procure a brushless motor driver from somewhere in order to use the motor.


If I plan to drive on soft ground, what can I do to avoid sinking in?

Question: I'm expecting tons of wood chips to be dropped off in part of my yard every day this year, and am wondering what I need to do so the arborist can easily drop them off as close to where I want them as possible while staying happy (not sinking into swampy soil, or tractor eating ground)?
Comment: This question doesn't seem to be related to Sustainable Living.
Comment: it is related to driving on a type of minimum maintenance road
Comment: Woodchips are very valuable to homesteaders (and folks with large gardens/yards), and homesteading is definitely all about sustainability.  Most environmentally conscious people also subscribe to "treading lightly upon the earth" — which is _literally_ what this question is about.  I think the question is fine.  I don't think it's wise or valuable to narrow the focus of SLSE to "solutions for city slickers".
Comment: @acoder Can you expand your question to include a little bit of information about existing access?  How many (viable) ways are there for the truck to access your property?  What fraction of the access is gravel/compacted sand/grass-over-clay?  How far into your property will they need to drive?
Comment: Also, do you actually mean *tons* of woodchips *every day* for a *whole* year?  That would be an absolutely insane amount of material to cope with.  A vertitable mountain of chips larger than most houses.
Comment: arborist truckloads of wood chips dumped into the garden for next year basically every day as the arborist is a neighbor
Answer: The usual solution to avoid sinking into soft ground is to release some air from your tyres so that they bulge more.  That increases the contact area with the earth, distributes the weight of the vehicle over a larger area, and reduces the likelihood and depth of sinking.
It is highly unlikely, however, that a commercial service will do this for you.  They want a place where they can quickly pop in, drop off, and leave.  Ideally, the driver wouldn't even have to exit the cab of the vehicle.
If that's the case then you have no option but to control/modify the route that the trucks will take once they come through your gate.
If you have an existing, all-weather driveway, then use that.  If you don't have an all-weather driveway, or the condition of your driveway is 'marginal', then you want to divert the trucks off it as quickly as possible.
Dad was a logger.  Brush piles, and huge volumes of sawdust and wood chips were a by-product of the logging/milling operations he was involved in.  The local soil is sandy, but low spots exist that turn swampy/boggy in the wet season.  Their solution for temporary roads through boggy areas was a 50cm deep elevated roadway made of woody debris.
Paths turn to muddy bogs due to the hydraulic pumping action that occurs as tyres drive over a particular spot.  If you create a deep enough pile of chips, it will be free-draining, and hydraulic pumping won't occur at soil level.
So, my suggestion would be for you to divert incoming trucks from your driveway as quickly as possible and get them to dump their first load straight away.  You should sculpt the pile into a type of gentle off-ramp.  Subsequent loads should extend the ramp and increase its height. Repeat until the height of the ramp is "decent" (around here ~50cm supports logging trucks).  From that point on just extend the length of the elevated woodchip road as needed and route it wherever you want.
About the only maintenance required is to occasionally rake-in the chips from the sides to the compacted ('rut') areas, and to occasionally top up (level) sections that compact more than others.
I've only just noticed your previous question about pigs and woodchips.  Assuming that this is related to that, if/when the woodchip road is no longer required you can fence it off with an electric fence and let the pigs in to eat/dismantle the road.  What little the pigs miss will quickly break down and the grass will return.
Comment: 50cm?! In some wet forestry I've worked on, slash (woody debris, limbs from trees turned into logs) is dragged onto trails in piles 1-2m high, then driven on with heavy equipment and flattened to ~0.5-1m high. Pretty sketchy to walk on but works great to protect soil and water quality. As Tim said though YMMV in terms of depth needed. Overall this sounds like the right answer: drop a pathway of chips to support the truck as it backs in, and use cardboard to facilitate.
Comment: I've used cardboard to keep vehicles out of the mud but it doesn't work so well. It's more like a snowshoe distributing weight, not really the fluffy mat that woody debris serves as. I agree though that cardboard wouldn't hurt, you'll basically just be sheet mulching the garden dirt road.
Comment: how thick would wood chips need to be as I've seen a logging TV show,and noticed that they use trees, but I need to do it with wood chips for composting reasons I have an unlimited supply of the good 3 ply cardboard, and can lay wood chips on top of it if necessary.
Comment: the pigs is a different question than this one
Comment: I'm permanently killing grass, so i can easily "maneuver" around my garden.
Comment: The thickness that will work for you depends on your soil texture, rain/moisture levels, the dump truck mass and number of axles, and so-on.  No magic number exists that works for all situations.  "It depends."  You could start relatively thin (say 10cm) and see how it goes.  If you see it getting mushy, add another 10cm layer.  Repeat until it's stable.  Or just err on the side of caution and go deep right from the get-go.  Here 50cm of woody debris on sand works for 20+ ton log trucks.  YMMV.
Comment: so if i know the soil will eat tractors on the run start 6-12 inches on 3 ply cardboard?
Comment: Can't say what effect the cardboard will have — never seen/tried that.  It might disintegrate the moment it gets wet, and provide no support at all.  I don't think it would make things worse, however, so if you have a free supply you may as well try it (on at least one section of the road).  If the soil currently "eats tractors" then I wouldn't even consider 15cm — start at 30cm and add more if needed.  Oh, and if your land slopes across the road, lay down a PVC pipe under the cardboard/chips to act as a culvert so you don't accidentally end up with a dam on the uphill side.
Comment: it's not a "road", it's a "parking lot" (garden), so it's level.
Comment: My point about depth is that the material will get very compressed, so starting with 50cm is probably too little. Start with more and watch it shrink.


Why did Aristotle place the earth at the centre of an infinite universe?

Question: A moments thought shows there can be no centre of an infinite expanse of space, it has no geometrical sense. When Aristotle places the Earth at the centre, he can surely only mean that its the meaningful centre, the place where anything of any importance can take place. Is this right?
Comment: Could you share where you came across this in his works?
Comment: I can't recall where I read that Aristotle placed the Earth at the centre. As Dorfman points out though he argued for a finite universe as opposed to the Epicurean infinite universe.
Answer:
Why did Aristotle place the earth at the centre of an infinite universe?

He didn't.
He placed the earth at the center of a finite universe.  For Aristotle, the universe is decidedly not infinite; he argued that there were potential infinities, but not actual infinities.
Comment: Not a potentially infinite universe?
Comment: Nope.  He said that nothing could actually *be* infinite.  Infinitely divisible, sure.
Comment: seems strange to grant infinite divisibility whilst with-holding extensive infinity. Presumably he grants potentially infinite time at least, or am I wrong there as well?
Comment: He did argue for temporal infinitism; see Book VIII of the Physics.
Comment: @Dorfman:he does say in Physics IV, 'if everything that exists has a place, place too will have a place, and so on ad infinitum', which sort of argues for an potentially infinite universe if he takes that argument seriously, but of course then the universe would have to be understood in a different sense
Answer: Aristotle didn't put the world at the center of the universe per se. Rather, he deduced it from his system of metaphysics and common sense observations of reality.
The world is comprised mostly of the element earth. Earth, being the heaviest of the four classical elements, tends to fall towards the center of the universe (it's natural place) if it is displaced from there. Since the world as a whole including the earthy surface beneath our feet isn't currently falling out from under us, it must already be at rest at the center of universe.
(How people were satisfied with teleological arguments for 2000 years, I'll never understand.)


Should we reject tag wiki edits that improve a tag wiki for a newly created tag that we think shouldn't exist?

Question: Sometimes we think that a tag should not exist when we see an excerpt/wiki edit when someone tries to establish the tag for the first time. At the same time, should we reject such an edit when it clearly improves the tag excerpt/wiki, or should we temporarily accept it until we eliminate/discuss the tag?
Comment: I feel like this is about something that already happened and was resolved favorably.
Comment: Examples would help, a I doubt there will be a well received blanket policy.
Comment: @ThomasMarkov I noticed this on four separate occasions, two different rejections by different users today. I think we can have a fruitful discussion about the topic. In both cases today, I accepted the edits as I thought them beneficial unrelated to the topicality of the tag. Maybe we shouldn't let tags like that establish and bring it to meta if there is disagreement about it.
Comment: If you're referring to the recent suggested edit for the [bleed] tag, the answer here is probably different for tags we think shouldn't exist, and tags that don't actually exist yet.
Comment: @AncientSwordRage I don't think we need one either, so I opened a discussion — examples from today: https://rpg.stackexchange.com/review/suggested-edits/77854  https://rpg.stackexchange.com/review/suggested-edits/77865
Comment: @ThomasMarkov I think that edit clarifies that.
Comment: I don't think the strixhaven one is representative of what you're asking here since we had already discussed it. I rejected the edit, and then left a comment on the post for the user to resuggest the edit on the shorter tag, as well as left a link to the meta discussion we had already had about the tag.
Comment: @ThomasMarkov I think it falls into "eliminate it" we did discuss it, and my question includes that. There are multiple ways we can act in those situations- a rejection with a message e. g. informs the user while an accept wouldn't (and they would ponder where the tag went after we eliminate it).
Comment: But I didn't really eliminate the tag, I just changed the name to be consistent with past usage of similar tags and the meta discussion, and engaged with the user explaining why, and let them get their suggested edit through on the right tag. Totally different situation from what you're asking about here.
Comment: But maybe I should just focus this question on the other aspect - tags that we didn't discuss yet. (The other tag is now an orphan — so eliminated, a tag that has the same function was also created.)
Answer: No, tag wiki edits shouldn't be rejected for this reason
A good tag wiki is one matter; whether the tag should exist or not is another. The matters simply don't relate. "I don't think this tag should exist" is just not a valid reason to reject an edit to its wiki. Review the tag wiki edit based on the edit's own merits. Assume the tag will stay even if you think it should be gone and give us a good wiki to work with while it's here.
If you don't think a tag should exist, the appropriate course of action is to open a question on meta suggesting its removal. Having a good tag wiki helps us manage this process by helping us understand what the tag really is and isn't about, so you should be approving good tag wiki edits even if you think the tag shouldn't exist. It also means if we actually decide to keep the tag it has a good wiki—you help the site run smoothly even if it's not entirely the way you'd have it work.
Declining the edit because you think the tag should be gone, on the other hand, is disruptive. It's withholding the opportunity for the site to work just a little bit better, even if the tag is truly doomed and everyone will agree with you to remove it.
It also means that when it comes time to ask us to remove the tag you'll have withheld information from us: you set the tag up for failure and left us not fully informed. Someone may notice that people were attempting to make that tag work better and others were obstructing that effort. This will hurt the case for removal and sway people to keep it around for further improvement and testing.
If you really want the tag gone, you should be steel manning it: that's representing the best possible version of the thing you oppose (the opposite of the straw man). You can then show that even given the best case it should still be removed. That's not done by voluntarily making the tag function worse by withholding otherwise valid edits to its wiki.
Comment: To see my initial stance mirrored here is reassuring.
Answer: If you have a question about a specific tag, you should ask about it specifically.
To me, this question seems like it is pretty difficult, maybe impossible, to give a really good answer to that isn't "depends on the tag". So that's why I'm going to offer: it depends on the tag and the context.
The better approach is, I think, to just discuss concerns we have about individual tags and individual tag curation actions when we have them, rather than try to shoehorn several unique scenarios into a general discussion like this.
Comment: I don't have a question about a specific tag, I'm asking about a general approach to a set.
Comment: @Akixkisu Right, and my answer is "the general approach should be to ask about a specific tag when you have a concern".
Comment: I know, just leaving that comment there in hopes it reduces the chance of other people thinking that this is an XY issue, so instead about a specific action. I want to make that obvious from the get-go.


How can radiation be a transverse wave? Does light really resemble a rope? How can a 3D field be a medium for non-spatial 1D waves? Need mental model

Question: I understand longitudinal waves. For example, I've got a clear mental modal of air waves: a slice of air becomes overcompressed, then the slice next to it becomes overcompressed and the first slice becomes undercompressed. The air itself does not travel, but the overcompressed and undercompressed regions do travel, and that's a wave:

I also understand transverse waves. For example, ripples on the water surface. The surface is a 2D field, the ripples oscillate in the third dimension (thus, water waves are a 3D structure). But transverse waves can also exist on a true 2D plane without the third dimension, here's an example:

But as for radiation waves, I fail to find a mental model for them. The closest one seems to be a rope: if you wobble a wire holding it by its end, it will oscillate in a sine-like pattern. I see it as a 1D field oscillating in a second dimension (thus, a wobbling wire is a 2D structure):

(these are an electric and a magnetic wave, the two are different waves that travel in different fields, they just happen to always appear in pairs)
Note how B and E arrows on the above animation demonstrate how the field wobbles without travelling.
I also know that light waves can be radially polarized and they are depicted as a spiral. This also corresponds to the wobbling rope metaphor:

But the electric and magnetic fields are 3D, yet light is not spatial like air is. When a light wave travels through its field, it looks like it occupies an 1D line of a 3D field, and this line wobbles either in one extra dimension (linear polarization) or in two extra dimensions (radial polarization).
This does not make sense to me. A wobbling rope could be a great depiction of a light wave, but it's a poor metaphor: the medium of a rope wave is a rope itself, and a rope is kinda 1D (in a sense that it's a line). But the medium for a light wave is an electirc field, and the field is 3D, it's spatial.
So how can 3D spatial field be a medium for string-like non-spatial waves? And is there a human-world analogy for this phenomenon?
PS This must have something to do with the wave-particle duality, but I don't understand that either.
UPD I no longer understand what is a transverse wave and what is a longitudinal wave.
Water ripples are transverse, right? The waves spread parallel to the water surface but the oscillations happen perpendicular to the water surface. Thus, transverse.
But if you look at the flat water surface from above (from the third dimension), it will not look like the transverse animation. It will look exactly the longitudinal one! What happens here?
Do light waves appear longitudinal when observed from a fourth dimension? Mind: blown.
Comment: There is a piece of advice about learning E&M that I give a *lot*: don't try to understand light in both the classical and quantum picture at the same same time. Pick one and learn it *well*. Then you can learn the other one on its own merits and without reference to the first. Then look at how they connect to one another. Trying to mix them is a recipe for misunderstanding until you understand both theories.
Comment: Possible duplicate: http://physics.stackexchange.com/questions/160042/is-light-amplitude-spacial Also related: http://physics.stackexchange.com/questions/184381/would-passing-horizontally-polarized-light-through-a-varying-width-vertical-slit
Comment: I think it is important for someone to say that the visualization you are showing show a single "ray" of light (which is why you are talking about it as a 1D structure), but real EM waves are spacing filling entities. The "ray" visualization is a tool for understanding where the energy flows are going, not a literal description of the structure of light.
Comment: Photons don't follow any lines. They are emitted in one place and absorbed in another, between that there is quantum electrodynamics, which certainly doesn't have anything resembling "lines".
Comment: You won't be able to develop proper mental models without understanding at least the basic phenomenology, which obviously takes some effort. If it helps, one can develop a reasonable understanding of the basics without going trough the entire theory, if you are willing to take a lot of details as a matter of trust in the theorists.
Comment: CuriousOne is absolutely right that quantum objects don't have trajectories between points of observation. That is one of the reasons not to mix the two points of view until you know each of them separately.
Comment: Please check the answer given below:
https://physics.stackexchange.com/a/171150/220036
Comment: dmckee, but the photons?.. You literally can emit a single photon, and will follow a line, it won't spread spatially.
Comment: CuriousOne, say, a photon can be considered a particle and it is emitted in point A and absorbed in point B. According to your statement, we can not say that it followed a trajectory from A to B? Is that true? Or the photon did follow the A-B trajectory, but it wasn't straight? Then was it sine-like?
Comment: I know neither branch and I will not invest a substantial amount of time into learning them. I just want my current mental models not to contradict reality.
Comment: CuriousOne, I don't mind learning, I hope that from this very post you can see my effort in learning. But I'm not spending months after months grinding away at a quantum physics textbook. I've got no scientific background, I don't even know what an integral is. I'm just scientifically curious and all I want is an adequate mental model. Is that reasonable?
Comment: Here is one satisfactory explanation:
https://physics.stackexchange.com/a/171150/220036
Answer: When a wave travels through a rope, the rope goes up and down, the position of all the 'rope-particles' changes, they oscillate and this makes up the wave.
With light, it is indeed the electromagnetic field oscillating, but you shouldn't think of the arrows that represent that field in your first picture of light as 'extending into the rest of the space'. They are not spatial, they just represent the magnitude and direction of the electric/magnetic field at that point.
Comment: For the Faraday cage: http://physics.stackexchange.com/questions/141562/diffraction-by-small-holes
Comment: So radio waves do not wobble? They travel in straight 1D lines, and each point on the line just kinda strengthens and weakens? Then why the segment size of an antenna or a Faraday cage depends on the wavelength to capture?
Comment: I'm sorry, but can you please upvote my question? I need +10 rep to answer another question.
Comment: Hmm, the wavelength means the distance between two humps of a rope. The height of each hump depicts amplitude. And the hump can be very tall even for a very short wavelength. So I do understand that sine-like rope this is a merely a metaphor for a radio wave, but the Faraday cage question from my previous comment still stands: if all radio waves are straight, why can a shorter wave pass through a Faraday cage but a longer wave can't?
Comment: Dries, as I understood from dmckee and CuriousOne, Faraday cage shields from spread waves because every point of the wave interacts with nearby points. Photons do not travel individually, the travel in a front that bounces off a mesh.
Comment: Dries, what I didn't understand is how single photons work and look like. Can they be emitted one by one in the first place, i. e. not as a spatial wave? I think I heard that optical fiber networking makes use of individual photons. But if a photon can exist individually, can it pass through a Faraday cage cell where a wave front of the same photons can not pass? Also, dmckee and CuriousOne say that it is incorrect to consider a trajectory when thinking about a single photon travelling -- I struggle to wrap my head around it.
Answer:
But the medium for a light wave is an electirc field, and the field is 3D, it's spatial.

The medium for the light wave motion is not the electric field . There are two points here:
1) Light is described by Maxwell's equations which are lorenz invariant, i.e. four dimensional, classical waves appear as a solution of the equations and they fit the data
2) The second point is that the Michelson Morley experiment showed that there is no medium on which light propagates, thus the animations you show depict the mathematics of the Maxwell equations which describe light as sinusoidal variations of electric and magnetic fields propagating in vacuum with velocity c.
When going to the underlying quantum mechanical level, light is composed by an enormous number of photons (elementary particles) which in synergy build up the classical electromagnetic wave.In a sense photons are the medium on which the classical wave rides. How this happens is a matter of understanding quantum field theory.
Maybe this picture can give you a feeling.

So it is more complicated than your visualizations.
Comment: As I tried to explain "light" and "electric fiedl" are classical models very useful macroscopically, but it so happens nature is at the basic level quantum mechanical and the classical light emerges from the underlying quantum mechanical level of zillions of photons with wavefucntions and probabilities in superposition to form the classical electric field. Field theory in quantum mechanics proposes an operator field for each standard model particle, and thus the photons appear from creation operators on the photon field, and then the classical emerges from the photons.
Comment: You can find the mathematics here http://motls.blogspot.com/2011/11/how-classical-fields-particles-emerge.html but you have to know quantum field theory basics to understand it.
Comment: I think this is unhelpful, as you do not need to understand quantum mechanics to understand electromagnetic waves. The same way you don't need QFT to understand water waves.
Comment: "The medium for the light wave motion is not the electric field" -- well, what field it is then?
Answer: EM waves are produced when atoms are made to move more quickly. Heat can do this. When EM waves are emitted from the excited atoms, the EM waves propagate in all directions of a compass (shape of a pancake). Simultaneously, the EM waves shoot off photons at right angles, up and down from the pancake. The photons then propagate as an expanding sphere in all directions. So the left-over EM waves lose their photons in the form of light, but they keep their subatomic particles - protons, electrons and other subatomic particles. These left-over EM waves account for all atoms and matter in the universe. Light never travels as waves. Light waves don't exist. Light only travels as moving photons.
Comment: "Light waves don't exist" — that's a bold statement.


Bash script for logging in ftp

Question: I have seen this question: link
I have similar, if not the same request. I'd like to create a script that will log me in ftp server. I do not want to automate the whole exchange, I just want to speed up the login. Security is not an issue, it can be most insecure way of doing it, I don't care, I doubt anyone would try to access the server, and even if someone does, I still don't care. =)
I have tried this:
#!/bin/bash
ftp -n ftp.domain.com
quote USER user
quote PASS pass

It seems to log me in successfully, but when I try to issue a new command I get:
530 You aren't logged in
ftp: bind: Address already in use

Answer: try putting
machine ftp.domain.com
login user
passwod pass

in .netrc in your home dir.

Bash script for logging in ftp


WhatsApp Web Messages

Question: Can I open the same WhatsApp from a phone on several computers at once? So that people can answer or send several messages at the same time?
Answer: The answer is No. If you open several WhatsApp Web sessions you will see this massage:
WhatsApp is open in another computer or browser.
 Click "Use Here" to use WhatsApp in this window.

WhatsApp Web Messages


CiviCRM upgrade from 4.6 to 5.3 > [warning] Both parameters should have an equal number of elements Relationship.php:2222

Question: Subject says it all. Just wondering if anyone has seen something like this before?
Comment: I've seen it but haven't yet dug into what is generating it.
Answer: This error is displayed when some Names for a relationship type do not match the Labels.
For example in civicrm_relationship_type table you may have something like
name_a_b = Mayor
name_b_a = Mayor
label_a_b = Mayor of
label_b_a = Mayor is
You can correct these either in SQL or via the UI

UPDATE
To identify the rows causing the issue
select name_a_b, label_a_b, name_b_a, label_b_a from civicrm_relationship_type where name_a_b <> label_a_b;
select name_b_a, label_b_a from civicrm_relationship_type where name_b_a <> label_b_a;

To fix we want to set the name = to the label
Make a temporary backup - this will be dropped when you log out of mysql.
create temporary table temp_civicrm_relationship_type as select * from civicrm_relationship_type;
update civicrm_relationship_type set name_b_a = label_b_a where name_b_a <> label_b_a;
update civicrm_relationship_type set name_a_b = label_a_b where name_a_b <> label_a_b;

Confirm that the number of rows updated matches result of the query.
(nb I just grabbed this from a ticket in our own system but hope it is helpful in your case)
Comment: A tiny addendum: it seems SQL is the only place for edits, since it looks different via CiviCRM GUI (at civicrm/admin/reltype?reset=1) and in, say, phpmyadmin.
Comment: Just wondering what do we change to stay safe: name or label? One of this might be used/hard-coded somewhere (across templates for example)  so we may break things. I'd say it is labels, but not really sure. Besides, making labels the same as names might not always have a semantic sense.


Transformation of standard normal distribution $\Phi(x)$

Question: Can I write $\Phi(ax)$ as $b\Phi(x)$ for some constant $b$, please? FYI, $\Phi(\cdot)$ is the cdf for standard normal random variable. Is there such relationship?
Comment: Note that the first one will always be between 0 and 1 and the second one will always be between 0 and b.
Answer: Your question doesn't specify but I assume you mean for some given constant $a$ and that the relationship should hold for all $x$ - i.e. that we should have a single $b$ that works for any $x$. (If you want $b$ to be a function of $x$, that's quite a different question)
This is quite clearly impossible, since $\Phi(ax)$ is bounded between 0 and 1. Since any value of $b$ other than $1$ will either make $b\Phi(x)>1$ for some $x$, or will make it unable to attain all values (because it will have a maximum smaller than the maximum value of $\Phi(ax)$).
Hence $b$ can only be $1$.
This then implies that $a$ can only be $1$.

That is, the only way for this to be true across all $x$ is for both $a$ and $b$ to be 1.
Comment: Sorry, I certainly mis-represented my question here. I am still working on this question http://stats.stackexchange.com/questions/101258/find-the-umvue-for-phi-mu
Comment: And I am trying to re-arrange the given integral so that I can find  an unbiased estimator for $\Phi(\mu)$. Any ideas?


Can every possible 'imaginary number' be expressed in terms of $i$?

Question: The domain of the function $f(x)=\sqrt{x}$ can be extended to all real numbers by introducing a new number, $i=\sqrt{-1}$.
Can this be done for any function, say $\arcsin{x}$, or $\log{x}$?
What is $\arcsin{2}$? Or $\log{-3}$?
Answer: We define the set of complex numbers $\mathbb{C}$ the set of $\mathbb{R} \times \mathbb{R}$, the cartesian product of the set of real numbers on itself.
On these Complex Numbers we define operations such as summation and multiplication by scalar.
We define them in such a way that the couple $(0; 1)$ just so happens to have the property that:
$$ (0; 1)^2 = (-1; 0) $$
And being such an important property, it has its own name as a number.
This can be done in many ways. Numerical sets are constructed easily in modern mathematics. You can define your $\log{-3}$ using complex numbers. In fact, the logarithm function is defined in the complex plane for every non-zero complex $z$.
$$ \log{-3} = \log{i^2} + \log{3} = 2\log{i} + \log{3} $$
Let $i = e^{i(\frac{\pi}{2} + 2k\pi)}$ for any $k \in \mathbb{Z}$. The logarithm of the imaginary unit is then defined as:
$$ \log{i} = i(\frac{\pi}{2} + 2k\pi) $$
Since we get an infinite amount of answers that depend on k, we usually only take the "main value" of the logarithm: that is, whenever $k=0$.
You don't need to define any new numerical set in order to solve a negative logarithm.
EDIT: As some have stated, the sine function in the complex plane is surjective.
$$ \sin{x} = \frac{e^{ix} - e^{-ix}}{2i} $$
And you can solve it to be:
$$ \sin{x} = 2 \implies x = \arcsin{2} = \frac\pi2-i\log(2+\sqrt3)$$
Answer: Euler's formula tells us that $e^{ix} = \cos(x)+i\sin(x)$. Therefore, (in a sense) $\ln (-3) = \ln3+\pi i$, since
$$e^{\ln{3}+\pi i} = e^{\ln 3}e^{\pi i} = 3(\cos \pi + i\sin \pi) = -3$$
(note: $\ln 3+k\pi i$ would have worked for any odd integer $k$)
Similarly, if we let $z = \frac{\pi}{2}-i\ln(2+\sqrt 3)$, then
$$\sin(z) = \sin(\pi/2)\cos(i\ln(2+\sqrt 3))+\cos(\pi/2)\sin(i\ln(2+\sqrt 3)) = \cos(i\ln(2+\sqrt 3))$$
Since $e^{ix} = \cos(x)+i\sin(x)$, we have that $\cos(x) = \frac{1}{2}(e^{ix}+e^{-ix})$, and so
$$\sin(z) = \cos(i\ln(2+\sqrt 3)) = \frac{1}{2}\left(\frac{1}{2+\sqrt 3}+(2+\sqrt 3) \right) = 2$$
However, it is not always the face that functions can be "extended" in this manner. As said in a comment, for example, there is no reasonable way to define $\ln 0$ as a complex number.
An issue that I've glossed over is that it seems that there are multiple ways to "choose" a value for $\ln (-3)$ and similar expressions. This is similar to the issue that there are multiple solutions to, say, $\sin(x) = 1/2$, and so $\sin^{-1}(1/2)$ is defined by making a reasonable "choice" from among the solutions to the equation.
Answer: Multiplying with $i$ rotates 90 degrees in the complex plane. One way to be able to reduce that to smaller steps is:
You can use a number really close to positive 1 (just a tiny little bit imaginary). For example:
$$z = \exp\left[\frac{2 \pi \cdot i}{k}\right], \, \text{ $k$ very large integer}$$
Now $z^k$ will be $1$. So you can reach all points on the unit circle with an angular resolution of $k$ steps per rotation. Now what is needed is to get off the unit circle. We can do this with a real radius $$r\in \mathbb R : r = 1+\frac{f}{100}$$ where f is the step in growth percentage. Now we can reach any complex number on a polar grid with the power functions and integer exponents:
$$r^{e_1}\cdot z^{e_2}, \, e_1,e_2 \in \mathbb{Z}$$


Holding cost vs carrying cost vs storage cost

Question: I was reading an article on supply chain management and encountered a number of inventory costs like ordering, carrying, shortage, holding, storage costs. I cannot understand the difference between holding, carrying and storage cost. Literally these costs sound the same. But the article mentions separate costs for these terms. Web searches didn't clear my confusion. Certain sites say that holding cost and carrying cost are the same. Certain says they are not the same. Kindly differentiate these costs.
Comment: Out of curiosity, could you please link the article you were reading?
Comment: Sorry I was reading from a hard copy. The article dealt with performance analysis of a supply chain using coordination mechanisms. Going through the results got me confused, as there were separate values for holding and storage cost.
Answer: According to a buddy of mine who was a faculty member in the area of purchasing / sourcing / procurement (they change their name every few years), "holding cost" and "carrying cost" are used pretty much interchangeably. They include costs to operate storage facilities, pilferage, spoilage, insurance and opportunity cost of capital tied up in inventory. He is not familiar with any formal use of "storage cost". One might speculate that it could be direct costs of storing stuff (facility operating costs, pilferage, spoilage, maybe insurance) but not including cost of capital. Maybe.
Answer: I agree that holding cost, carrying cost, and storage cost all sound like the same thing. The only thing I will add to the answer by @prubin is that often holding costs are expressed as a percentage of the value of the product. So, you might have a holding cost rate of $i=25\%$ and a product value of $c=200$, in which case the holding cost is $50$. Perhaps the article is using one of those terms (holding/carrying/storage) to refer to the rate and another to refer to the cost?
In any case, I would say that any distinction between those terms is idiosyncratic to that article. In other words, that article might define them a certain way, but other articles/books will define them in different ways, and/or use them interchangeably.
Answer: The unit of each cost shows the nature of that type of cost. With that, I mean if you look through the units, you can easily figure out whether:

The cost is fixed (it is independent of the inventory amount of products). For instance, the cost of operating a storage facility which does not depend on whether you store one unit of product or many units.
The cost is variable and can be calculated based on the amount of the product in your facility, for example, the cost of storing one car engine is different than that for 1000 engines. This cost can include carrying costs for instance. If your products(by nature) are affected by the length of time that you hold them on the shelf, your holding cost is a variable cost as well.

As you see, based on the assumptions that each paper has, your costs can be defined either as a fixed or variable cost interchangeably. Based on what I have mentioned(and of course based on the definitions in the paper) those costs can be defined as follow:

Holding cost: variable cost which depends on the number of units of a product that you have in the inventory and the length of time that you keep those products on the shelf.
Carrying cost: variable cost which depends on the number of units and the distances that each unit of product is being carried inside the storage or from supplier to the storage location.
Storage cost: fixed cost that can include all the costs related to the opening and operating a storage center.

I hope it makes sense for you after re-investigating those costs in the paper.


Does an electron change the electric field in a parallel plate capacitor?

Question: We know that the normal electric field direction in a parallel plate capacitor normally goes from the positive plate to the negative plate, so going from a high potential to low potential. Thus, if we were to place a positive charged object into the plates, the positive object would go from a higher potential to lower potential, as the object would start with potential energy and end with kinetic energy. However, if we place a electron in the capacitor, the electron has a high potential energy in the negative plate... and accelerate towards the positive plate. Would we say that it is going from a lower potential to a higher potential in terms of the parallel plate, or would the field follow the energy flow of the electron, going from high potential to low potential?
Answer: Since potential does not depend on the "test charge", then yes, we say that the negative charge is going from a lower potential to a higher potential. i.e. the negative charge just moving in the field will experience a positive potential change $\Delta V>0$
However, since the change in electric potential energy is given by $\Delta U=q\Delta V$, if $q<0$ and $\Delta V>0$ then $\Delta U<0$. So the negative charge still loses potential energy, which is needed since it is gaining kinetic energy, and the electrostatic interaction is conservative.
Answer: No, you can't say that the electron increases it's potential energy. It may be true regarding the parallel plate capacitor to say that the electron moves from a region of lower potential to a region of higher one (considering the convention).
Any charged particle will tend to move from a region of higher potential energy to a region of lower potential energy.
It's just a matter of convention that the electric field lines are drawn in accordance with the behavior of a unit positive test charge. If you want your test charge to be an electron, just reverse the direction of the electric field lines.
Answer: Potential energy is given by qV. Q for an electron is negative and by moving from the negative to the positive plate, it will have negative potential energy gain or will lose potential energy.


What is the difference between resize and reshape when using arrays in NumPy?

Question: I have just started using NumPy. What is the difference between resize and reshape for arrays?
Comment: Have you tried any research?
Comment: ```sum(ndarray.shape)``` and ```ndarray.size``` are the same after ```ndarray.reshape```.  Those values will be different after ```ndarray.resize```
Comment: This isn't an exact duplicate, but it may help: http://stackoverflow.com/questions/41171034/how-does-the-numpy-resize-and-numpy-reshape-function-works-internally-in-python
Answer: Reshape doesn't change the data as mentioned here.
Resize changes the data as can be seen here.
Here are some examples:
>>> numpy.random.rand(2,3)
array([[ 0.6832785 ,  0.23452056,  0.25131171],
       [ 0.81549186,  0.64789272,  0.48778127]])
>>> ar = numpy.random.rand(2,3)
>>> ar.reshape(1,6)
array([[ 0.43968751,  0.95057451,  0.54744355,  0.33887095,  0.95809916,
         0.88722904]])
>>> ar
array([[ 0.43968751,  0.95057451,  0.54744355],
       [ 0.33887095,  0.95809916,  0.88722904]])

After reshape the array didn't change, but only output a temporary array reshape.
>>> ar.resize(1,6)
>>> ar
array([[ 0.43968751,  0.95057451,  0.54744355,  0.33887095,  0.95809916,
         0.88722904]])

After resize the array changed its shape.
Comment: since OP did not specify, i'll point out that `ar.resize(rows,cols)` changes the initial array in-place, while `np.resize(ar,X)` only outputs a resized array, with `ar` staying the same.
Also, if the new size is larger than original `ar`, `ar.resize` adds zeroes at the end, while `np.resize` repeats the original `ar`
Answer: One major difference is reshape() does not change your data, but resize() does change it. resize() first accommodates all the values in the original array. After that, if extra space is there (or size of new array is greater than original array), it adds its own values. As @David mentioned in comments, what values resize() adds depends on how that is called.
You can call reshape() and resize() function in the following two ways.
numpy.resize()
ndarray.resize() - where ndarray is an n dimensional array you are resizing.
You can similarly call reshape also as numpy.reshape() and ndarray.reshape(). But here they are almost the same except the syntax.
One point to notice is that, reshape() will always try to return a view wherever possible, otherwise it would return a copy. Also, it can't tell what will be returned when, but you can make your code to raise error whenever the data is copied.
For resize() function, numpy.resize() returns a new copy of the array whereas ndarray.resize() does it in-place. But they don't go to the view thing.
Now coming to the point that what the values of extra elements should be. From the documentation, it says

If the new array is larger than the original array, then the new array is filled with repeated copies of a. Note that this behavior is different from a.resize(new_shape) which fills with zeros instead of repeated copies of a.

So for ndarray.resize() it is the value 0, but for numpy.resize() it is the values of the array itself (of course, whatever can fit in the new size). The below code snippet will make it clear.
In [40]: arr = np.array([1, 2, 3, 4])

In [41]: np.resize(arr, (2,5))
Out[41]:
array([[1, 2, 3, 4, 1],
      [2, 3, 4, 1, 2]])

In [42]: arr.resize((2,5))

In [43]: arr
Out[43]:
array([[1, 2, 3, 4, 0],
       [0, 0, 0, 0, 0]])

You can also see that ndarray.resize() returns None and does the resizing in-place.
Answer:
reshape() is able to change the shape only (i.e. the meta info), not the number of elements.
If the array has five elements, we may use e.g. reshape(5, ), reshape(1, 5),
reshape(1, 5, 1), but not reshape(2, 3).

reshape() in general don't modify data themselves, only meta info about them,

the .reshape() method (of ndarray) returns the reshaped array, keeping the original array untouched.

resize() is able to change both the shape and the number of elements, too.
So for an array with five elements we may use resize(5, 1), but also resize(2, 2) or resize(7, 9).

The .resize() method (of ndarray) returns None, changing only the original array (so it seems as an in-place change).
Answer: Suppose you have the following np.ndarray:
a = np.array([1, 2, 3, 4]) # Shape of this is (4,)

Now we try 'a.reshape'
a.reshape(1, 4)

array([[1, 2, 3, 4]])

a.shape         # This will again return (4,)

We see that the shape of a hasn't changed.
Let's try 'a.resize' now:
a.resize(1,4)

a.shape         # Now the shape changes to (1,4)

'resize' changed the shape of our original NumPy array a (It changes shape 'IN-PLACE').
Answer: One more point is:
np.reshape can take -1 in one dimension. np.resize can't.
Example as below:
arr = np.arange(20)
arr.resize(5, 2, 2)
arr.reshape(2, 2, -1)


Matlab: Detect Peaks and Signal Jump

Question: I want to detect 6 peaks in a signal. I am open to any suggestions. There is one problem where my signal sometimes jumps high and stays higher than the rest of the signal. I don't know why this happens but would like a solution to lower the signal back to the points where the rest of the signal was lower, which might help detect all 6 peaks. I attached a picture.
Comment: If you know that the jump is greater, or much greater than the peaks, themselves, and if you know an estimate of the value of the jump, then you can simply detect first when it occurs (as per the pic, say val=80), and when that happens subtract its value (the pic shows ~160), then, when the jump drops below 80, you know it has past and the trick is no longer needed, until the next jump. In the meantime, perform detection of the peaks as you wish. Two ifs, though.
Answer: I don't recommand that you use a simple derivative. It's not a robust method, especially when there's noise or when the changes that you want to detect are spread on many samples.
There are 2 on-line algorithms that I used in the past that are pretty robust
1 - Filtered derivative algorithm
This algorithm uses a filtered derivative as the name implies. It's insensitive to noise and by selecting the proper number of samples you can easily detect a change that occurs on many samples.
https://www.fs.isy.liu.se/Edu/Courses/TSFS06/PDFs/Basseville.pdf Section 2.1.4
2 - CUSUM (cumulative sum)
https://en.wikipedia.org/wiki/CUSUM
This algorithm detects a change in the mean. If the change exceeds a certain threshold, a change is detected. From there, you can estimate the amplitude of the change.
Answer: I think the easiest option is to detect the massive sudden increase/decrease.
Try calculating the difference between samples. If this difference is too big (positive or negative), we substract this difference on all future measured samples.
Create a variable for this offset. start with an offset of 0, when de absolute value of the difference between samples is too big, add this (non absolute) difference to the offset, then all next samples are $x_{new}=x-offset$.
Comment: How do you define "to big" ... what determines if it is too big ... 2 standard deviations, greater than the mean, what metric could  I use ...
Comment: Try to calculate the difference in the samples. for sample $i$ calculate the difference between sample $i$ with sample $i-1$. The threshold to detect if the difference is too big should obviously be less than the smallest signal jump you've encountered, but not small that you detect a false signal jump. In the example you've provided, I would go for a threshold value like 75.
Answer: Try calculating a moving-window fit of a well-chosen test function to your data. This would also remove the necessity of removing your signal jumps. Your peaks don't really look like a peak to me, but more like a smeared-out box-car function. You could choose the analysis window in such a way that it is approximately equal to the width of the peak and use something like $a(x-w_\textrm{center})^4 + c$ as a fit function ($w_\textrm{center}$ is a shift of the window center so that your parameter $a$ yields a maximum in the middle of your peaks). You will then have to set an appropriate threshold on the resulting series of $a$-parameters, which should have a much clearer peak-like structure. You can also concentrate only on the negative values of $a$ to identify only the peaks and not the dips between the peaks.
Answer: I wrote this to detect shapes that I know before hand (like sawtooth and steps).  So if your "peak" shapes are consistent, it could find those two without changing the original signal.  You need to play with parameters, but I think it will work:
https://www.mathworks.com/matlabcentral/fileexchange/61291-shape_projection_filter?s_tid=prof_contriblnk
And then I've always had success with peakfinder:
https://www.mathworks.com/matlabcentral/fileexchange/25500-peakfinder-x0-sel-thresh-extrema-includeendpoints-interpolate

Matlab: Detect Peaks and Signal Jump


Transfer large amount of data in chunks

Question: I need to copy data from one server to another however the only median we have is a small HDD. What is the best way to split up the data and merge it back on the other end without creating archives as the first server is full?
Comment: Are you sure that is the only possible solution?  What about via the network?  Is physically removing the drive a possible solution?  Or maybe temporarily adding another drive to use during archiving?
Comment: @heavyd Sorry, none of those are possible for this job
Comment: What OS are you using? Is it one file, or many files? If you are comfortable with Linux boot up an Ubuntu live-cd on each computer, and use netcat to send the file over a lan cable. Destination: `netcat -l 1234 > "/folder/file.file"`. Source: `netcat 127.0.1.2 1234 < "/folder/file.file"`. Substitute values obviously. This would save you having to do any splitting, but if you're doing more than one file it will be a pain.
Answer: You haven't specified your operating system, which makes this question harder to answer.
However, HJSplit is a GUI file splitter/joiner available for Windows/Linux.
For the Linux/Unix command line, there's also split, which can be rejoined with cat.  Usage instructions with an example are available on the Wikipedia page here.

Transfer large amount of data in chunks


Change "show desktop" shortcut in macOS and Windows

Question: I am using one Windows 10 and one Mac laptops and I want to make them consistent in the shortcut key to show desktop. Right now, the key in Mac is F11 and in PC it is Win+D. Is there a way to change one of them to the other so that I can use the same shortcut when using any laptop? This would make my life much easier and save me time. I checked the options for Mac and looks like there is no Cmd+D option -- given macOS Cmd corresponds to the Win key, this shortcut would have been useful.
Answer: The Cmd key in macOS is used in a fashion akin to Control in Windows -- common shortcuts like Undo, Cut, Copy and Paste are mapped to Cmd+Z, Cmd+X, Cmd+C, Cmd+V, etc. The Cmd+D shortcut is frequently used by web browsers for the Add Bookmark command, and in the Finder for Duplicate, so remapping it to a system-wide shortcut may not be a great idea.
That's not to say it isn't possible, though! You can set this as a shortcut in the Keyboard preferences pane -- switch to the Shortcuts tab, click "Mission Control", then double-click the line for "Show Desktop" and type the shortcut you'd like to use. Some really bad shortcuts (like unmodified letters or numbers) can't be selected, but there are few other requirements.

I'm not aware of any similarly easy way to remap Win+key shortcuts in Windows.
Answer: Both operating systems you have specified have software available on the 'net called keyboard remapping software. As this is not the Software Recommendations SE, I won't specify, but the variety of choices is quite large.
There is a near-duplicate of this question, although the OP requests no third-party software. Your question did not have this limitation, hence the suggestion for using keyboard remapping software.
Alternatively, hot-key programs can accomplish a similar result. Mapping/setting the hot key for F11 to Win-D might be simpler and/or the program you select with that focus may have less overhead.


communication between two raspberry pi

Question: Hello everyone i am new to raspberry pi and apologize if its funny..i have seen projects using raspberry pi as FM transmitter..and i am wondering if i can make mobile phones from raspberry pi that can have voice communication and video communication without the mobile towers(obviously the range matters with antenna size)..it will be like peer to peer communication and own encryption schemes that will avoid censorship. is this feasible or has some disadvantages??
Answer: It can be done, using wifidongles.
Set them up in ad-hoc mode and transfer the data. You probably need 2 (webcams with) microphones that connects to the USBport which works on the RPi as well, so a sufficient powersupply to go with those. 'Walkie Talkies' or portophones are probably easier and cheaper though ;-)
Comment: Thanks for your help:my point is that if we can create ad-hoc networks that act as peers and help each other we no longer need this telecommunication companies(if we can have certain bandwidth),i think we can set up webs servers and setup links (like internet)..i mean we can work as torrents work but everything will be ours..isn't it ?
Comment: I see your point.. I guess you haven't seen anything about what Edward Snowden showed us? Everything what goes over the internet can be monitored. And setting up a fast new network besides the internetlines will be not doable. So no, it will never be 'ours' if you it's gotta be big (on the level of the mobilephones networks)
Answer: I believe it is feasible and what would make it easier would be if you were to find a community of like minded people interested in "off grid" communication.
This is how I would set it up:

Find someone to experiment with and who lives line of site to your home.
Set up a WLAN using off the shelf radio transmitters. i.e. You point your respective transmitter/receivers to each other. I personally use a nanobeam.
Transmitter is plugged into a PoE which is plugged into your router.
You will need a private WLAN ip address range. Set up some routes either on your router or on your actual computers...
Build your a simple rasberry pi cell phone tower

You may need to figure out how to limit the signal to the confines of your respective homes.

The RasberryPi will need to talk to your LAN, this is the piece of the puzzle you will need to solve.
And you will need to connect to the local cell phone network you create with your mobile device. And you wont need a sim card, they work just fine without them.

This is more or less how it would work:
<code>  **You -> mobile phone -> RPI -> LAN -> WLAN -> LAN -> RPI -> mobile phone -> friend**
</code>
Essentially no one will be able to plug into that network to listen to calls however you are limited to just calling your friend...
Where I am from we have a pretty big WLAN with almost 2000 people in it. We are networked every which way to sunday and essentially have our own private / dark internet. 2000 people have invested on average, $800 USD per AP, thats a $1.6 Million network spread over the community... and free to be run within our communities standards.
A rasberry pi mobile type network would spring up in much the same way and would rely on lots of people spending small amounts to build a free communication network. This is a project we are definitely going to work on.
Hope this encourages you to forge ahead.
Comment: Thanx...It would be great if i can work in your project,add me on firstname.lastname@example.com
Answer: At best this sort of thing is sketchy because of radio transmission regulations. Even ignoring that the project would be difficult. While the Pi can FM transmit, there's no receiver. You'd need to find a USB linux compatible one, or add on a USB sound card with audio in from a FM receiver. Then you'd need to make the transmission scripts, decode the received signal... there's a lot going on here. Better off to just buy or build a regular 2-way radio.
Comment: Thanks for your help:my point is that if we can create ad-hoc networks that act as peers and help each other we no longer need this telecommunication companies(if we can have certain bandwidth),i think we can set up webs servers and setup links (like internet)..i mean we can work as torrents work but everything will be ours..isn't it ?

communication between two raspberry pi


Showing that a centre of the 2D linear system $\dot{\mathbf{x}} = A \mathbf x$ is Lyapunov stable

Question: Consider the 2D linear system $\dot{\mathbf{x}} = A \mathbf x$ with $$A = \begin{pmatrix} 0&1\\ -4 & 0\end{pmatrix}.$$ The eigenvalues of this matrix are $\lambda = \pm 2i$, meaning that the phase portrait will be a center. How do I show that the origin $\mathbf x = 0$ is Lyapunov stable for this system? i.e. for any $\epsilon >0$, I need to find a $\delta(\epsilon)>0$ such that $$||\mathbf{x}(0)||< \delta \implies ||\mathbf{x}(t)||<\epsilon .$$ I am really confused about how to show this for an arbitrary $\epsilon$, how can one probe the Lyapunov stability of such systems where the fixed point is a centre?
Answer: Since this is a linear system, you can find the solution explicitly. The solutions curves will be ellipses, and if the half-axis lengths are $a<b$, then $\delta = \epsilon a/b$ will work.
Answer: If you are allowed to use a Lyapunov function to test for stability (rather than provide an $\epsilon-\delta$ proof), consider the following...
Let ${\bf x} = \pmatrix{x\\y}$. If we write the system out using variables: $$\dot{\bf x} = \pmatrix{0 & 1\\ -4 & 0}{\bf x} \qquad\implies\qquad\begin{cases}\dot x &= y\\\dot y &=-4x\end{cases}$$Suppose we think the function $V(x,y) = 2x^2 + {1\over2}y^2$ might be a good candidate for a Lyapunov function. To show it is, we have that $V(0,0) = 0$, and $V > 0$ for any $(x,y)\in\mathbb R^2\setminus(0,0)$. Then, $$\begin{align}\dot V &= 4x\dot x + y\dot y\\ &=4x(y) + y(-4x) \tag{Substitute from above}\\ &= 4xy - 4xy \\ &= 0.\end{align}$$
This implies that the origin ${\bf x} = {\bf 0}$ is stable (and thus also Lyapunov stable) for this system.
Comment: I am trying to show specifically with $\epsilon-\delta$ proof


Why is '#!/usr/bin/env python' supposedly more correct than just '#!/usr/bin/python'?

Question: Anyone know this? I've never been able to find an answer.
Comment: @S.Lott: Have *you* read it lately? On my Debian box, it's one of the most unhelpful man pages I've ever seen, and that's saying something. (Here's the whole "Description": Set each NAME to VALUE in the environment and run COMMAND. Yup, that would clear him right up.)
Comment: not a ton. i'm on osx and the env manpage is rather ambiguous there.
Comment: One problem with env is that you can't add -u or any other option to be passed to the python executable
Comment: Also a very good answer on a very related Unix SE question is [here](http://unix.stackexchange.com/questions/29608/why-is-it-better-to-use-usr-bin-env-name-instead-of-path-to-name-as-my/29620#29620).
Comment: @Telemachus: Yes, I did read it.  It's why I found the Wikipedia entry.
Comment: interesting point. luckily, this isn't needed often for a shebang.
Comment: A very related (duplicate?) question: [Why do people write #!/usr/bin/env python on the first line of a Python script?](http://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-first-line-of-a-python-script)
Answer: If you're prone to installing python in various and interesting places on your PATH (as in $PATH in typical Unix shells, %PATH on typical Windows ones), using /usr/bin/env will accomodate your whim (well, in Unix-like environments at least) while going directly to /usr/bin/python won't.  But losing control of what version of Python your scripts run under is no unalloyed bargain... if you look at my code you're more likely to see it start with, e.g., #!/usr/local/bin/python2.5 rather than with an open and accepting #!/usr/bin/env python -- assuming the script is important I like to ensure it's run with the specific version I have tested and developed it with, NOT a semi-random one;-).
Comment: Of course, you can always use #!/usr/bin/env python2.5 to constrain the set of semi-random choices :=)
Comment: -1 for several reasons: /usr/local/bin is not a standard path for python, would work only for *locally compiled installs*; Enforcing minor version at shebang a bad idea: may protect from 2.4, but it also claims your script is *incompatible with, say, 2.6 or 2.7*. Minor version restrain is a task for distutils/setup.py, package management system, or conditional imports, *not* shebang; Also, as @Ned said, you should not hardcode paths or prevent user for having his python 2.5 in ~/bin if the system does not provide one. **So, bad future-proof and abysmal portability.**
Comment: +1 for justification of NOT using "env python". Made me realize that if I want to use "env python", I'd better be coding for the lowest common denominator, since I'd have no control over the version of python the user has first in the PATH.
Comment: Be aware also of the fact that using `#!/usr/bin/env python` and virtualenvs will execute the script in current venv! This may or may not be a good thing, depends on your use case.
Comment: +1 Great explanation, thanks! I hadn't come across that usage of "env" before...now I have something to add to my scripting bag-of-tricks.
Comment: #!/usr/bin/env python3 would be a good compromise for those using python3, I reckon. i.e. it's specific enough but not too specific. My 2c.
Answer: From wikipedia

Shebangs specify absolute paths to system executables; this can cause
  problems on systems which have non-standard file system layouts
Often, the program /usr/bin/env can be used to circumvent this
  limitation
Answer: it finds the python executable in your environment and uses that. it's more portable because python may not always be in /usr/bin/python. env is always located in /usr/bin.
Comment: env is not always there, but we are increasing the probability of the script finding python on more machines. :)
Answer: It finds 'python' also in /usr/local/bin, ~/bin, /opt/bin, ... or wherever it may hide.
Comment: That's a bit misleading.  It's only going to find the first "python" on your current $PATH and Python instances on OS X can be pretty good at hiding.  In particular, the standard framework builds from python.org and others have "bin" subdirectories within the framework where "python" and other executables and scripts are stored.  It's very easy to end up with multiple instances which may or may not have symlinks to them in the usual places, like /usr/local/bin et al. Managing $PATH on OS X in this case is not as straightforward as on systems without framework-style builds.
Comment: @KennethReitz: if `/usr/bin/env` does not exist, your system is broken. `env`is a required tool by POSIX standard.
Comment: thanks! it actually caused a problem for me because, for some reason, env didn't' exist.
Comment: @MestreLion, POSIX is not a requirement for running python.
Comment: @KennethReitz: true, but shebangs are used only in POSIX environments. Windows (and python) ignores them, so I assumed you were on *nix environment, otherwise your original question is moot.
Answer: You may find this post to be of interest:
http://mail.python.org/pipermail/python-list/2008-May/661514.html
This may be a better explanation:
http://mail.python.org/pipermail/tutor/2007-June/054816.html