Will a cylinder misfire immediately fire the check engine light?

Question: A family member is claiming their 4cyl engine on a 2000 Chevy S10 Extreme LS is misfiring. However we're not seeing a check engine light. Wouldn't that automatically trip the check engine light for sure?
Comment: I'm not sure, but I ***believe*** it depends on the type of misfire and the system which is observing it. A misfire due to a non-firing injector is different from a dead coil which is different from a grounded spark plug (where energy leaks directly to ground instead of jumping the gap) ... I'm sure there are other misfire types I'm not mentioning. The other thing to think about here is ... *is it actually a misfire?* There could be other reasons it seems like a misfire, but it isn't.
Answer: A misfire is detected primarily by the crankshaft sensor. It will actually detect a speed variation caused by a weak contribution from the weak cylinder. The computer knows which cylinder is misfiring by the crank location. A fault code is triggered when a misfire is detected multiple times. Many times a misfire is detected before it is noticed by the driver. Misfires can also be tracked using a scan tool.
Answer: My car misfired for years with audible ping, sometimes quite badly, without any check engine light (CEL).  It wasn't until I soaked the engine with Seafoam for several days that the dashboard light suddenly appeared.  As it turns out, there was a leak around the PCV valve all that time.  Now, no more light and the car runs great.
I had the same phenomenon with a Dodge Ram 2500 pickup truck.  It hesitated, guzzled gas, and generally ran poorly with no check engine light.  I sprayed Marvel Mystery Oil through the intake at idle and let it sit for twenty minutes.  When I restarted, a CEL immediately appeared and persisted.  In that case, it was corrected by replacing the gas cap.
Carbon buildup on an old car masks a check engine light, due to the fact that oxygen sensors measure the health of combustion only indirectly.  Carbon absorbs fuel during the compression stroke of a cylinder, then releases excess fuel during the power and exhaust strokes.  Carbon on intake valves retards the proper vaporization of atomized, micro droplets of fuel.  The result is uneven combustion -- lean misfire during the initial, critical portion of the power stroke, followed by excess, dirty flame at the end of the power stroke and the exhaust stroke.  Oxygen sensors might ordinarily detect a lack of oxygen under such circumstances, but if an air leak is added to the mix, the computer compensates with positive fuel trim, maintaining acceptable oxygen parameters.  No CEL light is triggered.
The driver, however, definitely notices something amiss.  Poor fuel economy is pronounced.  All the while, diagnostic computer data (OBD II) may not appear terribly abnormal.
I see your car is model year 2000.  Assuming high mileage or city driving, you likely have the same frustration I did.  You cannot rely on a CEL light!


Reducing resonance in a piezoelectric ultrasonic transducer

Question: I am using a piezo transducer to launch an ultrasonic pulse in air, at a frequency of 125kHz. A picture of the received waveform is attached. My question concerns how I can (electronically) limit the long resonance tail in the emitter pulse which I assume is because of the relatively high Q of the device.
Comment: You are showing the received waveform, but asking about the transmitter?
Comment: How did you made sure that the ringing isn't happening in the receiver? In the transmitter you can try to connect a loading resistor in parallel with the transducer to eat the ringing energy.
Comment: Not sure of your circuit, but could you put a FET across the transducer so that when you are "done" transmitting, you activate the FET and place a short across the transducer?  Or combo it with @user287001 idea and use the FET to insert a resistor.
Comment: Usually mechanically. Resonance is mechanical. Damper attached to back side.
Comment: It's mostly the construction of the transmitter (and receiver, if separate). Mechanical 'Q'. We found transducers designed for Doppler use were basically worthless for pulsed applications no matter the circuitry.
Answer: Yes, these transducers tend to have high Q, which makes them "ring" like a bell.
In the example below, a 40kHz piezo was measured and fitted to an electronic model that substitutes L-C-R components for the mechanically-resonant components. For this transducer, the electrical equivalents were:

Lm = 92.1 millihenries
Cm = 175.384 picofarads
Rm = 634 ohms

The value of parallel capacitance is real, measured with a capacitance meter: 1.3 nanofarads.

The current through the series arm comprising Lm, Cm, Rm is proportional to physical motion of the transducer. When driven directly from a voltage source, current takes a long time to rise to full amplitude (purple trace, I(R3)).
An external inductor (L2=12.42 mH) along with a damping resistor (R1=5400 ohms) gives a significantly faster, critically damped rise time (green trace). The penalty paid is far less current - making the transducer less sensitive.

The simple approach of damping with a resistor (R1=5400 ohms) is wasteful of available transducer signal. An impedance-matching transformer would be a better, more costly alternative.
Comment: @glen_geek I would have thought that would make the resonance worse?
Comment: What does that graph look like when you open V1 after the 1ms?
Comment: @Aaron **Opening V1** would disable 5400 ohm damping - not something you'd want to do if damping the resonant "tail" is important. If you simply drive V1 to 0V after 1ms, then damping is similar to the rising waveform shown in the time graph above (green, I(R2)).
Comment: *"...drive V1 to 0V after 1ms..."* that's what I was after, thanks!
Comment: What is the resonant frequency of the L in combination with the transducer C?
Comment: Dirk: The external L (12.42mH) resonates with the 1.3 nf capacitance inside the transducer at 39.6 kHz.


How to avoid orange buildup on shower tile grout?

Question: Once a month, I have to use an old tooth brush to gently remove the orange buildup on the grout between our shower tiles. I don't have to use any solvents or chemicals. A little water is all that I use. What can I do after each shower to minimize this buildup? Using a tooth brush after each shower would be too time-consuming of course. I prefer natural remedies. For instance, would a watered-down white vinegar spray on the areas help without damaging the grout? Thank you for your time.
Comment: Is this all over the shower, or just underneath the shower head?
Answer: Orange?
Filter out the iron in your water supply.
Comment: Iron filtering would typically be installed where the main water supply enters the house, and it would then filter the entire water supply for everything in the house, not just a particular area.
Comment: This water is coming out of my shower head. I have never heard of a filtering system for bath areas.
Answer: Your stain is bacterial. The only way to get rid of it permanently is to get rid of what it feeds on -- soap residue etc. If you're in the pacific northwest, its presence is quite possibly due to the US government doing biological weapons testing during the cold war! (This is not a conspiracy theory, see Wikipedia: https://en.wikipedia.org/wiki/Serratia_marcescens#Role_in_biowarfare_testing)
Since it's biological, a good soak and scrub with bleach is the solution.


Android - How to resume the last activity when launched icon is clicked or when back button is clicked

Question: I am working on a tracking application that use another third party application such as google map.
Lets assume my application has 4 activities ( act1, act2 , act3 and act4 ).
on act3 activity i am calling google map application to calculate the distance and view the routing. But once i clicked on the back button of the tablet, or go back to the home page and clicked on the launched icon, the act1 is displaying instead of act3.
However, my application is still running on background.
So my question here how can i make the application is opened the last activity which is act3 in our example, when the back button is pressed or when the launched icon is clicked.
Thanks,
Answer: Store the name of the running activity into shared preferences in the onPause of every activity (if you're exiting by pressing home button) or in onBackPressed (if exiting an activity by pressing back button).
Then create a launcher activity which reads the shared preferences and launches the specific activity.
Lastly remove the launcher activity from the activity stack so that the app doesn't go back to it on pressing back button.


homebrew beer pasteurization?

Question: I finnish my beer its fully carbonated and bottled on 22 oz bottles (co2 comes from priming sugar)
now.. can start the pasteurization process ?
or that only will work with forced carbonation beer ?
thanks
Answer: Pasteurizing home brewed beer is rarely done for two reasons: it's complicated, and you don't really need it.
Pasteurizing beer is done in industrial breweries to preserve the beer and kill all residual yeast, because the brewery wants the beer to remain 100% the same once it goes out the door. This is not as critical with home brewed beer. Furthermore, the yeast in a homebrew bottle acts as a natural preservative by removing the oxygen from the beer (and about 30-40% from the head space as well) which gives the beer an extended shelf life.
Bottom line: if you practice good sanitation and bottle condition your beer you don't need pasteurizing!! In fact, pasteurizing a bottle conditioned beer kills the yeast and prevents it from further developing the flavor of the beer as it matures. So for a bottle conditioned beer  pasteurization is in fact the last thing you want!
Also note that pasteurization destroys some of the flavor. This is fine for industrial lagers that have little flavor to begin with, but not for a home brew!
To answer your final question, pasteurizing can only be done on the fully carbonated, packaged beer. The beer is force-carbonated, bottled, capped and then pasteurized, bottle and all.
Answer: From what I've read lately, there is some use in homebrew pasteurisation for non-alcoholic/low-alcoholic beers, where alcohol does not create a hostile environment for other organisms that can spoil your beer. Additionally if you create such beers with a yeast like SafBrew LA-01 your beer will also contain residual sugars that the yeast can't digest:

This yeast does not assimilate maltose and maltotriose but assimilates simple sugars (glucose, fructose and sucrose)

These beers are therefore more at risk of spoiling.

Basically, the risk of pasteurising fully carbonated beer is the increase in pressure in the bottle during the process. You kill bacteria and other organisms by heating the beer − but it also increases pressure directly, and indirectly by driving the CO2 out of the beer and into the head space. If the pressure becomes too large, bottles will start to fail, and eventually explode. Once the beer cools, it will re-absorb the CO2.
A guide on homebrewtalk.com summarises the situation for cider, where pasteurisation seems to be a more common process, as follows:

Heat pasteurize bottled cider which is carbonated to no more than 3 Volumes of CO2
Do this at no more than 65C-70C for 10-12 minutes then let the bottles cool down

It should be comparable for beer, as most components (CO2, yeast, headspace volume, etc.) work exactly the same. The main things that could change are how much CO2 a beverage can hold at a given temperature, and how quickly it reaches that equilibrium once it's heated to said temperature. This beerandbrewing.com article is the cleanest write-up of the process for beer that I've found so far, but it doesn't talk about carbonation pressure at all − just impact on flavour.

homebrew beer pasteurization?


Equal a priori probabilties in statistical physics

Question: In Statistical physics by F.Mandl  he introduces the postulate of equal a priori probabilities, which states that for an isolated system all microstates compatible with the given constraints of the system are equally likely to occur i.e. have equal a priori prbabilities. He then goes on saying that as a result of this postulate, "the probability that the system is in the macrostate specified by $(E,V,N,a)$ is proportional to $\Omega(Ε,V,N,a)$. It's the result of this postulate that I'm finding hard to understand. It makes sense to me but what im struggling is to understand is the correlation between the two, meaning how we determined the result from the postulate he introduced.
Answer: This is a problem in probability theory. A probability space is roughly speaking a set of outcomes $\mathcal{S}$ together with a probability measure $\mathbb{P}$ which, for every subset $\Sigma\subset \mathcal{S}$ of the outcomes gives you the probability that the outcome you are interested in be there. There is a technical aspect that such $\mathbb{P}$ must be defined in a $\sigma$-algebra of subsets of $\mathcal{S}$ but you don't need to bother with this right now.
The probability measure $\mathbb{P}$ has to obey:

For every $\Sigma\subset \mathcal{S}$ we have $\mathbb{P}(\Sigma)\in [0,1]$ so that probabilities lie between $0$ and $1$;

Some outcome has to occur, so that $\mathbb{P}(\mathcal{S})=1$;

If $\{\Sigma_i\}$ is a discrete collection of pairwise disjoint subsets $\Sigma_i\cap \Sigma_j =\emptyset$ then the probability of the union is the sum of probabilities $$\mathbb{P}\left(\bigcup_{i}\Sigma_i\right)=\sum_i \mathbb{P}(\Sigma_i).$$

In your case $\mathcal{S}$ is the set of all possible microscopic states and $\mathbb{P}$ gives the probability that the actual microscopic state realized be in some subset of $\mathcal{S}$. We further assume $\mathcal{S}$ to be finite.
Now let be given a tuple $\mathbf{X}$ of variables describing the macroscopic state. In your question you take $\mathbf{X} = (E,V,N,a)$ but it could be anything really.
We can group microscopic states according to values of $\mathbf{X}$. This means that we can consider $\Sigma(\mathbf{X})$ to be the set of all states in $\mathcal{S}$ compatible with the macroscopic state $\mathbf{X}$. Notice that $\Omega(\mathbf{X})$, the number of microscopic states compatible with $\mathbf{X}$, is the number of elements in the set $\Sigma(\mathbf{X})$. In mathematical notation we write this as $\Omega(\mathbf{X})=|\Sigma(\mathbf{X})|$.
Now we introduce your postulate and derive its consequence:

Postulate: All microscopic states are equally likely.

Mathematically the postulate tells us that if we take any two distinct singleton sets, $\{s\}\subset {\cal S}$ or $\{s'\}\subset {\cal S}$ with $s\neq s'$, containing two distinct states $s$ and $s'$, then $$\mathbb{P}(\{s\})=\mathbb{P}(\{s'\}).$$
Now let $\Sigma(\mathbf{X})$ be given. Decompose it as a union of singletons for each of its elements:
$$\Sigma(\mathbf{X})=\bigcup_{i=1}^{\Omega(\mathbf{X})}\{s_i\},\quad s_i \in \Sigma(\mathbf{X}).$$
Now take the probability $\mathbb{P}$ and use property (3). Moreover also use that $\mathbb{P}(\{s_i\})=p$ because of the postulate.
$$\mathbb{P}(\Sigma(\mathbf{X}))=\sum_{i=1}^{\Omega(\mathbf{X})}\mathbb{P}(\{s_i\})=p \sum_{i=1}^{\Omega(\mathbf{X})}1=p \Omega(\mathbf{X}).$$
Therefore the probability that the system is in a microscopic state compatible with the macroscopic state $\mathbf{X}$ is proportional to $\Omega(\mathbf{X})$ with proportionality constant being the common probability to all microscopic states.
Finally we can determine $p$. Decompose $\cal S$ in the union of its constituents, take the probability and apply conditions (2) and (3). The exact same derivation as above shows that $p = 1/N$ where $N$ is the total number of states.
Comment: So if i understand this correctly every microstate has the same probability to occur but it just so happens that some microstates give the same macrostate?
Comment: Also the postulate states that the microstates who give the same macrostate have equal probability, not that all the microstates are equaly likely, so shouldn't it be $ \{s\} \subset \Sigma $ ? Does that change anything?
Comment: As for the first question, yes, the postulate states that every microstate has the same probability to occur, but given a macrostate there is a whole set of microstates which are compatible with it. The number $\Omega(\mathbf{X})$ is the number of such microstates. Regarding the second question saying that "all microstates are equally likely" is exactly the same thing as saying that "all microstates occur with same probability".
Comment: Regarding my second question. Isn't it something different to say that all microstates occur with the same probability and something else to say that given a specific macrostate, the microstate that give the macrostate have the same probability to occur?
Answer: Suppose we have a volume with two identical compartments. Initially, the compartments are separated, and each contains a different gas: Compartment $A$ contains the gas $a$ and compartment $B$ contains the gas $b$.
At time $t=0s$ we open a valve, so that the two gases are no longer separated. Shortly after we opened the valve, the gases will not been mixed completely. However, with time passing by, this imbalance will decrease. The thermal equilibrium state is reached, when the two gases are completely mixed.
The described scenario is intuitive. However, the physical explanation for the mixing is given by the law a equal priori probability. To emphasise this, let's consider some questions:

What is the probability that a specific molecule of gas $a$, which we call $a_1$, is in the compartment $A$? The law of equal prob. tells us that we have $P(a_1 \in A)=1/2 = P(a_1 \in B)$. We can ask this question for each specific molecule, and the answer will always be the same.
Assuming independence between the location of each molecule, we can calculate the probability that $a_1$ is in compartment $A$, $a_2$ is in compartment $A$, and $a_3$ is in compartment $B$. The law of equal probability tells us, that this is
$P(a_1 \in A) \cdot P(a_2 \in A) \cdot P(a_3 \in B) = 1/2^3$.
If we specify $N$ particular molecules, we would obtain the probability $1/2^N$. So, as long as we specify the molecules, every configuration has the same probability.
The probability changes, if we consider the molecules as indistinguishable. If we are no longer interested in which compartment which molecule is, but only how many molecules of gas $a$ are in compartment $A$, we obtain a probability distribution, which is sharply peaked around the $50\%:50\%$ case.

Maybe a simplified model is also useful, so let's consider a system which consists of three spins and a magnetic field $B$. Each spin can be either

up: $|\uparrow\rangle$ = parallel to B-field, or
down: $|\downarrow\rangle$ = anti-parallel to B-field.

Suppose we also know that the total energy of the system is
$E = - \vec \mu \cdot \vec B =  - \mu  B$.
Hence, we know that two spins are up and one is down. The system occupies one of the following allowed configurations:
$$
|\uparrow\rangle, |\uparrow\rangle, |\downarrow\rangle \\
|\uparrow\rangle, |\downarrow\rangle, |\uparrow\rangle \\
|\downarrow\rangle,|\uparrow\rangle,  |\uparrow\rangle
$$
So, in this system it is not true that each spin points with the same probability up as it points down. However, each of the three allowed configurations are have the same probability.
Comment: I understand your explanation but what i'm not asking that exactly. You just explained to me the postulate of equal a priori probabilities, but what im asking is lets say for your 3 spin model, why the probabilty of the macrostate with energy $E=-\mu B$ is proportional to its statistical weight, and how you can derive this with  the postulate of equal a priori probabilities.
Comment: That does not make sense: If we use two down spins and one up spin, we obtain again three different micro states. However, the probability that the system is in one of these micro states is zero, given that the energy is $E=-\mu B$. In your question, you stated the following variables (E, V, N, a). These variables define **restrictions**, under which we maximise the entropy $S = k_B \ln(\Omega)$.
Comment: ok fine the example i made was bad but i still don't understand this phrase then "the probability that the system is in the macrostate specified by (E,V,N,a) is proportional to Ω(E,V,N,a)"
Comment: The three spin example is not a macro state, so let's consider the gas example. Here the macro state is  "approx 50% of the $a$ atoms in compartment $A$ (and analog for $b$ atoms)". Maybe, plot the probability that you have 20 atoms and how they are distributed among the two compartments.
Comment: Let's consider a system with 3 dipoles like your example with a fixed magnetic field and volume and also lets say we don't know the energy value. According to the postulate and its consequence each macrostate has a probability of occuring that is proportional to the statistical weight of the macrostate. Im trying to understand how this postulate leads us to this conclusion


How to turn off TexStudio forcing text on you while typing?

Question: When typing code like \( or \begin{equation} TexStudio is hijacking my document inserting closing \) and adding red boxes its expecting me to type inside of to somehow make go away, and it's slowing me down and interfering with what I wish to type. How do I disable this "helpful" feature?
Answer: On the top bar, click Options > Configure TeXstudio.  Then select Show Advanced Options in the lower left.  Then select Adv Editor in the left pane.  Then unselect Auto Completion Parentheses.

EDIT:
I believe that you are looking to turn off the Auto Completer which puts in the words.  In the left pane, click on Completion.  Then unselect Automatically start completer when typing LaTeX-Commands.

Hope this helps!
Comment: Thank you. What does unchecking "Overwrite [...] Placeholder" accomplish? The expected behavior of typing over the outlined braces inserted by TexStudio did not change. Additionally, `\begin{equation}` etc. still inserts additional text and I don't see the option to disable it here, but maybe this feature is more acceptable ... It would be good if you would add how to disable this feature as well.
Comment: @DBinJP Added in answer for disabling the completer, which is what I think you are looking for.
Comment: The edit is absolutely what I was looking for. Now the editor doesn't bog down my typing and freeze up as it searches for completions. Just writing something as simple as $1 \leq i \leq n$ makes it freeze up and query commands that complete "\l". Ridiculous.


Pi 3 B+ no audio device found

Question: I have been trying to use Alexa on my Raspberry Pi 3 B+ (running Stretch). I ran Alexa successfully, with a USB microphone and a speaker connected through the 3.5mm jack, about a week ago and went on to make a python program that does not in any way tamper with the 3.5mm jack or the audio driver. Today I started Alexa again and there was no audio output. I connected to the Pi through VNC and found that the sound icon on the top right of the screen is muted. I clicked the icon and the drop down menu says "No volume control on this device." I would like to know the cause and solution of this issue. I have searched for solutions through Bing but had no luck.
Answer: Also check the /boot/config.txt file. It should look like this:
<code># Enable audio (loads snd_bcm2835)
dtparam=audio=on
</code>
Comment: `dpkg -S /boot/config.txt`; `apt reinstall `
Comment: That worked perfectly. Thank you very much. Is there somewhere I can find a default `config.txt`. I am afraid that I messed mine up
Comment: Each config.txt is unique to the version of the Pi your using, the firmware, and the version of OS. I'm not sure its easy to find the exact one for your config short of a fresh install. FWIW: Raspi-config typically adds the changes at the end of the file.
Answer: I suggest you run raspi-config, look at Advanced Options>Audio and make sure the "1 Force 3.5mm ('headphone') jack" option is selected.
Then reboot...
Comment: It throws out the error `There was an error running option A4 audio`, and tbitson's answer solved my problem. Thank you for your suggestion!
Answer: Equivalently to going to raspi-config and forcing an output (hdmi or jack), if you are in GUI mode, you can more simply do a right-click on the audio icon that is still grey, to select the correct audio output. For me it was stuck in "no audio device" until i clicked on the icon.

Pi 3 B+ no audio device found


Data transfer from arduino to raspberry pi wirelessly?

Question: How do I send data to raspberry pi connected over wifi from arduino connected to a laptop which is in turn connected to the same wifi network as raspberry pi?
Answer: What is it that you want to send ? If it is just sending some files, Raspberry Pi can be set-up as as ssh server and you connect to it from your laptop with a ssh client. See here for more on Raspberry Pi ssh.
If you are looking to send data in a client-server fashion, then obviously, a server should be running on the Pi and the appropriate client on the laptop and the data transformation for the application layer protocol.
Comment: Thanks for your answer. I would like to know how to send data in client-server fashion. I have installed LAMP server on my PI and I have used phpmyadmin to set up the database. How to use laptop as a client for data transformation?
Answer: As cogitoergosum says, you can connect the laptop to the raspberry pi over ssh, and you can connect the raspberry pi to the laptop with serial commands.
You can then use Processing to connect the arduino and the wifi together on the laptop.
If you want to remove the overhead of the laptop to remove it sometime, look in to the X-Bee shields. There is a wifi one there but they can be costly.


Color spectrum Image - How to create

Question: I want to create a color spectrum image for a project. How do I create an image like this in photoshop?
Answer: I was able to create a near replica in photoshop by using a rainbow gradient left to right.
And then creating 2 layers- one with black to transparent gradient in the bottom and white to transparent gradient on top.
That did the trick I think.
Comment: You can pull the same trick in other color spaces to obtain different spectra.

Color spectrum Image - How to create


How can a negative charge move towards a position of a higher electric potential but lose electric potential energy?

Question: I understand that the equation is: change in electric potential = (negative)change in electric potential energy / unit charge.  And I understand that if q is negative, then the change in electric potential will be positive, therefore increasing.  What I am having great difficulty understanding however, is the concept.  How exactly does this happen?  A diagram would be useful and very much appreciated, thanks.
Comment: Energy is conserved, which means that the charge has to be either accelerated (i.e. gain kinetic energy) or the energy has to be dissipated as heat, which is what happens in resistive conductors.
Comment: Well, that is *exactly* the same thing that occurs with the gravitational interaction... Why does a mass lose potential energy while approaching the center of mass ?
Answer: What you understand has to be refined a bit. Potential is defined referring to what happens to a positive charge in a field. A positive charge is moved by the electric field from the higher to the lower potential. Therefore, a negative charge is moved in the opposite direction. See the diagram:

Now to your formula:
Indeed, for a positive charge in an electric field
$ (1) \ \Delta V = V_{final} - V_{initial} < 0.$
Pay attention that the electric potential energy is equal to
$ (2) E_{potential} = qV .$
Therefore,
$ (3) \ \Delta E_{potential} = q \Delta V < 0.$
The electric force accelerates the positively charged body increasing the body's kinetic energy, on the expense of the body's potential energy which decreases.
Now, for a negative charge the forces move it from the lower potential to the higher one. Nothing wrong happens. According to the inequality (1), $\Delta V > 0$, however, due to the definition (2), the equality (3) gives again $\Delta E_{potential} < 0.$ because $q$ is negative. So, again the electric force accelerates the body increasing its kinetic energy on the expanse of the potential energy of the body, which decreases.
Comment: $Xardov : All the best, I am very glad.


When is the integral of a square less than the square of the integral?

Question: I know Cauchy-Schwarz tells us
$$
\left(\int_a^b f(x)\, dx\right)^2 \leq (b-a)\int_a^b f^2(x)\, dx
$$
is true for all functions $f \in L^1(a,b)\cap L^2(a,b)$ where $a,b \in \mathbb R$.  I was just wondering if there was a general case for which the "opposite" inequality holds, i.e. when is
$$
\int_a^b f^2(x)\, dx \leq C\left(\int_a^b f(x)\, dx\right)^2
$$
true for some value $C$?  I know it holds for at least a few elementary functions (e.g. $f(x) = |x|$, $a = -\pi$, $b=\pi$, and $C=1$), and I know $f(x)$ needs to be positive (otherwise you could pick an odd (non-zero) function on a symmetric interval and contradict it immediately).  Any insight would be greatly appreciated.
Comment: @TomChalmer $L^2$ is not a closed subset of $L^1$
Comment: Possible duplicate of [Integral of a square compared to the square of an integral](https://math.stackexchange.com/questions/1233205/integral-of-a-square-compared-to-the-square-of-an-integral)
Comment: There's something called reverse holder inequality. Also, you could try Jensen's inequality for concave functions
Comment: Great question!
Answer: The constant $C$ does not exist, even if you require that the function $f$ be bounded from above by a constant $M>0$.  To see this, let $N$ be a positive integer such that $\dfrac1N< b-a$.  For each integer $n\geq N$, define
$$f_n(x):=\left\{\begin{array}{ll}
M&\text{for }x\in\left(a,a+\frac{1}{n}\right]\,,\\
0&\text{for }x\in\left(a+\frac{1}{n},b\right)\,.
\end{array}\right.$$
Then, $$\int_a^b\,\left(f_n(x)\right)^2\,\text{d}x=\frac{M^2}{n}\text{ and }\int_a^b\,f_n(x)\,\text{d}x=\frac{M}{n}\,.$$
Therefore, $C$ cannot exist; otherwise, you will have $$C\geq n\text{ for every integer }n\geq N\,.$$

It is also not sufficient that $f$ is only bounded from below by a constant $m\geq 0$.  To see this, let $N\geq m$ be a positive integer such that $\dfrac1N< b-a$.  For each integer $n\geq N$, define
$$f_n(x):=\left\{\begin{array}{ll}
n&\text{for }x\in\left(a,a+\frac{1}{n}\right]\,,\\
m&\text{for }x\in\left(a+\frac{1}{n},b\right)\,.
\end{array}\right.$$
Then, $$\int_a^b\,\left(f_n(x)\right)^2\,\text{d}x=n+m^2\,\left(b-a-\frac{1}{n}\right)\text{ and }\int_a^b\,f_n(x)\,\text{d}x=1+m\left(b-a-\frac{1}{n}\right)\,.$$
Therefore, $C$ cannot exist; otherwise, you will have $$C\geq \frac{n+m^2\,\left(b-a-\frac{1}{n}\right)}{1+m\,\left(b-a-\frac{1}{n}\right)}\text{ for every integer }n\geq N\,.$$

On the other hand, if $f$ is bounded from below by a constant $m>0$ as well as being bounded from above by $M>0$, then you can say something.  Note that
$$\int_a^b\,f(x)\,\text{d}x\geq m(b-a)\,.$$
Therefore,
$$\left(\int_a^b\,f(x)\,\text{d}x\right)^2\geq m(b-a)\,\int_a^b\,f(x)\,\text{d}x=\frac{m(b-a)}{M}\,\int_a^b\,M\,f(x)\,\text{d}x\,.$$
As $f\leq M$, we have
$$\left(\int_a^b\,f(x)\,\text{d}x\right)^2\geq \frac{m(b-a)}{M}\,\int_a^b\,\big(f(x)\big)^2\,\text{d}x\,.$$
That is, $$C:=\frac{1}{b-a}\,\left(\frac{M}{m}\right)$$
suffices.
We can actually do better by finding the smallest possible value of $C$.  First, note that
$$\big(M-f(x)\big)\,\big(f(x)-m\big)\geq 0\text{ for all }x\in[a,b]\,.$$
Therefore,
$$\big(f(x)\big)^2\leq (M+m)\,f(x)-Mm\,.\tag{*}$$
Thus,
$$\int_a^b\,\big(f(x)\big)^2\,\text{d}x\leq (M+m)\,\int_a^b\,f(x)\,\text{d}x-Mm(b-a)\,.$$
We shall show that $$C:=\frac{1}{b-a}\,\left(\frac{(M+m)^2}{4Mm}\right)$$ suffices.  Note that
$$\small C\,\left(\int_a^b\,f(x)\,\text{d}x\right)^2-(M+m)\,\int_a^b\,f(x)\,\text{d}x+Mm(b-a)=C\,\left(\int_a^b\,f(x)\,\text{d}x-\left(\frac{2Mm}{M+m}\right)\,(b-a)\right)^2\geq0\,.$$
Thus, from (*), we indeed have
$$\int_a^b\,\big(f(x)\big)^2\,\text{d}x\leq \frac{1}{b-a}\,\left(\frac{(M+m)^2}{4Mm}\right)\,\left(\int_a^b\,f(x)\,\text{d}x\right)^2\,.$$
The equality holds if and only if there exist two disjoint subsets $A$ and $B$ of $[a,b]$ such that $A$ has Lebesgue measure $\dfrac{m}{M+m}\,(b-a)$, $B$ has Lebesgue measure $\dfrac{M}{M+m}\,(b-a)$, and $$f=M\,\chi_A+m\,\chi_B$$ almost everywhere.  Here, $\chi_S$ is the indicator function of a set $S$.  Since the inequality above is sharp, $C=\dfrac{1}{b-a}\,\left(\dfrac{(M+m)^2}{4Mm}\right)$ is indeed the smallest possible value.
Comment: Thanks! That was a very helpful answer. I imagined the constant would need to depend on $f(x)$ somehow, but the explicit construction is nice. I think there is a small typo in your second counterexample though. Shouldn't it be $int_a^b (f_n(x))^2 dx = n + m^2(b-a-\frac{1}{n})$?
Comment: Yes, thanks.  It was a typo.


Using a larger validation data set reduces the chances to select an overfitted model

Question: Does a larger validation data set reduce the chances to select an overfitted model?
Answer: One note: by adding more data (rows or examples, not columns or features) your chances of overfitting decrease rather than increase.
The two paragraph summary goes like this:
Adding more examples, adds diversity. It decreases the generalization error because your model becomes more general by virtue of being trained on more examples.
Adding more input features, or columns (to a fixed number of examples) may increase overfitting because more features may be either irrelevant or redundant and there's more opportunity to complicate the model in order to fit the examples at hand.
There are some simplistic criteria to compare quality of models. Take a look for example at AIC or at BIC.
They both show that adding more data always makes models better, while adding parameter complexity beyond the optimum, reduces model quality.

Using a larger validation data set reduces the chances to select an overﬁtted model


Why do we think Spin is angular momentum as opposed to some other quantity?

Question: What leads us to the conclusion that spin is angular momentum? Could it not be some other quantity? Sorry if this is a rookie level question.
Comment: Because it behaves like angular momentum: (1) it follows the angular momentum algebra, (2) it interacts with magnetic fields in the normal way, (3) it adds to other angular momenta to make total angular momentum, etc., and all of this matches experiments.
Comment: Possible duplicates: [Spin and Angular Momentum](http://physics.stackexchange.com/q/216216/50583), [Can spin and macroscopic angular momentum convert to each other?](http://physics.stackexchange.com/q/13783/50583), [Spin, orbital angular momentum and total angular momentum](http://physics.stackexchange.com/q/184454/50583)
Answer: By treating spin as angular momentum a lot of phenomenon could be explained.

Conservation of angular momentum makes sense only if you include spin with the orbital angular momentum. Spin-orbit coupling will mix these quantities even if the system is isolated.
The algebra of the spin operators (which can be represented by the Pauli matrices) is analogous to the angular momentum algebra.
Charged systems that have an angular momentum will have a magnetic moment. They act like little magnets. The magnetic moment of electrons can be measured using Stern-Gerlach-like experiments. These experiments also elucidate the quantum nature of spin.

The idea that electrons may have an intrinsic angular momentum was theoretically proposed to explain the anomalies in the spectrum of hydrogen. It is necessary to explain the behavior of the spectrum when the atom is subjected to magnetic fields.
Comment: @HolgerFiedler as their internal constituents are quarks which are charged and therefore contribute to the magnetic dipole moment of the neutron...
Comment: Neutrons are uncharched particles but also have a spin and a magnetic dipole moment.
Comment: @Bruce Lee This does not contradict the phenomenon that the measurement of the neutrons magnetic moment gives a result, does it?
Comment: @HolgerFiedler to the contrary, it explains your observation made in your first comment..
Comment: @HolgerFiedler A better question would be ask if a neutrino (which is point-like, neutral, spin 1/2 particle) has a magnetic moment? I don't know the definitive answer, but the consensus seems to be that it is very very small.
Comment: @biryani possibly it might be due to effects of interactions of neutrinos with $W+/W-$ and $e$ leading to a vertex function like diagram...
Answer:
The generators for spin follows the same commutation relation as that of angular momentum. i.e
$$[S_{x}, S_{y}] = iS_{z}$$ obeys the similar commutation rule for angular momentum

$$[J_{x}, J_{y}] = iJ_{z}$$
The similarity in algebra is an indication why spin should be considered to be angular momentum, although it is not the complete reason.

It has been observed experimentally that spin couples to orbital angular momenta as in systems obeying $L-S$ coupling. It follows similar rules of angular momenta addition as resulting from the addition of two angular momenta. The observed spectrum in such a coupling observed matches theoretical predictions accurately if spin is considered to be angular momentum. This completes the reason why spin should be considered as angular momentum.
It gives rise to a dipole moment in case of charged objects, similar to what angular momenta does.


copying music, pictures and movies from a galaxy s 4g to the pc

Question: My daughter would like to copy (not transfer) her songs, pictures and a movie she has on her Galaxy S 4 G cell phone over to our PC.  How can she do this?
Answer: It would be really helpful if you mention which operating system your PC is running.
On Windows 7 and above, you simply need to connect the phone to your PC using a USB-MiniUSB cable. You should then be able to access the files on the phone via Windows Explorer. You can then use Windows Explorer to copy files to and from your PC.
On Windows XP and below, you will need to either:
a) download and install Samsung KIES
b) download and install the Samsung Mobile Device USB Drivers
Once the drivers/software are installed, follow the same steps as for a Windows 7+ PC.
Answer: Regardless of the operating system, your daughter could simply use a remote management app like AirDroid. The advantage is: This app is installed on the device, and on the "remote" (here: PC) no special software is required but a web browser. Connection is either done via a shared WiFi network (both devices on the same network), or via the Aridroid server (if there is no shared network, and you have no problems routing your data via alien servers).
Airdroid uses a nice interface, which gives you desktop feeling inside of your browser:

Airdroid (source: Google Play; click image for larger variant)
Not only can you simply drag-and-drop files to transfer, but you can also manage other aspects of your device: accessing its contacts, writing SMS, viewing pictures, and a lot of other things.
And when your daughter is visiting her girlfriend, and wants to share some files with her: No hazzle with drivers or thinking about what OS might be in use. Simply fire up Airdroid, enter the displayed URL in her girlfriend's browser, put the password in the browser, and there she goes.
"Unwanted access"? Sure, if she let's her device lying around unlocked, so someone could fire up Airdroid and make the connection. But honestly, without Airdroid in the same situation the same person simply needed a cable to connect, and could do the same. And as not letting the device lying around unlocked should be a common-sense pre-caution, all stays as safe as before :)


Can we please have topics and sub topics on StackOverflow?

Question: Sometimes I just wish things were a little more organized, maybe with topics and sub topics.
Comment: > "I think taggings purpose is best served for searching (indexing)"  That's backwards.  For _text_ content you don't need tags for indexing.  You use them for _categorization,_ which is different. http://meta.stackexchange.com/questions/2779/could-the-tagging-system-be-enhanced-to-support-tag-synonyms/2782#2782
Comment: Often I wish things were more organized, while preserving the dynamic aspect that is also essential.
Answer: Tags work very nicely IMHO - no need for a hierarchy.
Comment: I love the current format.
Comment: Different strokes for different folks I guess :)
Answer: See Tags (n). Far more robust than a tree model and at the same time, shock and surprise, far easier to map to a natural human mental model.
Edit: here's a more detailed answer. I work for a large enterprise (more than 100k employees) and one of my responsibilities has been to craft an "enterprise-2.0" collaboration strategy. After an exhaustive audit, analysis and discussion with anyone who has been involved in anything collaboration-related over the past decade in my organization, one of the most obvious conclusions is this:
Any information taxonomy that does not arise organically from the content which is being created will fail. Miserably.
Second: our brains do not work in hierarchies. The human brain does not like to organize things into strict trees. Our brain looks more like a giant mess of index cards connected to a number of other cards by string. This maps very closely to tags. A great real-world example of this is iTunes. Every music library in the world was, by most measures, a failure because no one thinks in trees. Organizing music into artist subfolder album takes discipline and is unpleasant because it's unnatural. Programmers are a little better at it because we do have to think in trees. The bad thing is, we think in trees so often we start to believe that's normal, when it's actually a discipline we've had to learn and nature we've had to overcome. iTunes dumps everything into a bucket and lets us slice it down how we want to at a given moment - our brain follows the right thread to the right index card. Find by title or album or artist or genre or whatever.
This where search comes in. Tagging and search are precisely how we now find things. Yahoo! doesn't maintain their stupid directory any more because no one uses it. We type what we want into a box and we get that. Browsing is a thing of the past, unless you want to do it for your leisure - which is not what Stackoverflow is here for.
Tagging is proven to be the best solution to self-organize and crowdsource content. If you have a better idea, describe it in detail.
Comment: but topics are tags in themselfs, kind of line aggregated tags.
Comment: I don't disagree with tagging, I think taggings purpose is best served for searching (indexing) however, displaying the content is possibly best served in an organised way..
Comment: Then have dynamic topics, take multiple tags and then group then into 'editiable' topics, then render a 'forum' using those shifting topics. Don't know just a thought
Comment: Your argument is good but http://www.youtube.com/watch?v=oozFn2d45tg will disagree that "our brains do not work in hierarchies"
Comment: @bobobobo thanks for the video. We can also find a ton of resources which will argue the opposite. I have simplified an extremely complex and only partially-understood issue to make a point. Just because it has more layers does not mean it is wrong.
Answer: There are already enough programming-related forums around. They actually seem much less organized to me. What do I do if my question belongs in multiple categories, repost the same question in multiple sub-forums?
I think SO is great precisely because it allows for more natural categorization of everything.
Comment: put it in the first most broadest topic that it supports?
Answer: The chaos is very natural to all programmers.
Comment: I totally agree!
Answer: No hierarchies....  That's one thing that drove me to drink after a couple of weeks (hours) at Experts-ex.......  God I hate drilling down.
Comment: Drill, baby! Drill!
Answer: Subtopics might do well to lump close/repeated questions into.
Answer: Tagging >= Grouping
If tagging used well,then it is able to perform hierarchical groupings. This is how I use tagging to make grouping possible.
 http://www.flickr.com/photos/45412920@N03/4293243741
If others think so as well, we can promote this usage. Say post questions on writing an IPhone Instance Menessage Client, So I try to tag it this way "IPhone Instance Menessage Client", hope other who writes IM Client would the same way,so I would be able to locate the message in a better organized way.


Coming of age 90s short story about transcendentalism

Question: The main characters name is Gabe and the supporting characters often joke and call him "gabe-boy" so it sounds like "gay boy". I know Emerson and Thoreau are heavily mentioned in the book and there is some supernatural out of body experience scene at the end. Name of book and author?
Answer: Possibly Daniel Hayes's Flyers.

When Gabe Riley and his friends start filming a horror movie at the town's infamous Blood Red Pond, his own life begins to take a weird turn. Why is his father, a charmer with a weakness for the bottle, more melancholy than usual? Why is his shy younger brother acting so furtive? And, strangest of all, why do the lights keep going on and off in Mr. Lindstrom's house while the old man is hospitalized with a stroke?

"Gabe-boy" shows up in a Google Books search of the book, as does apparently "gay boy" (although it wouldn't show me the actual text). Seems to be "coming of age" (this review outright states it), and was published in 1998. Also, one of the summaries here says "This is a busy book, with lots of action, words, and philosophical ramblings on Emerson, transcendental meditation, and karma. Even so, the story captures the essence of sophomoric, adolescent male slapstick as only Hayes ... can."
Comment: You beat me too it.  I found a text blurb on good reads.  He's also reading a book by Emerson.
Comment: @Cone_of_Silence: Yeah. Google search for me led me to Goodreads and then to a few other reviews.
Comment: That's it! Thank you so much, my life is complete. I also learned better how to search for books! Thanks!
Comment: @carb0nshel1: No worries. I found it by searching on *book  "gabe boy" emerson*


Is there an actual example where inline is detrimental to the performance of a C program?

Question: In many debates about the inline keyword in function declarations, someone will point that it can actually make your program slower in some cases – mostly due to code explosion, if I am correct. I have never met such an example in practice myself. What is an actual code where the use of inline can be expected to be detrimental to the performance?
Comment: Note that `inline` is just a suggestion; the compiler is free to ignore it.
Comment: Have many compilation units all include the same big inline method and use it only once, then you might have a degenerate example... Still, depends on not doing link-time-code-generation or such things.
Comment: As @dan04 said, it is not required for the compiler to listen to you, and generally it is pretty smart.
Comment: A lot of places, for example max function ('int max(int a, int b)') could just be inline (also can be defined as macro actually and will have the same effect). The program won't 'JUMP' to that function in memory and won't load the stack with the variables. TONS of uses.
Comment: Of course inline can be detrimental - if not, the compiler (or developer) would just always inline everything, all the time.  It increases register pressure and code size / L1i cache footprint, either of which can easily be bigger performance issues than function call overhead.  TANSTAAFL.
Comment: bloated generated code might cause instruction cache miss.
Answer: Exactly 10 years and one day ago I did this commit in OpenBSD:
http://www.openbsd.org/cgi-bin/cvsweb/src/sys/arch/amd64/include/intr.h.diff?r1=1.3;r2=1.4
The commit message was:

deinline splraise, spllower and setsoftint.
     Makes the kernel smaller and faster.
     deraadt@ ok

As far as I remember the kernel binary shrunk by more than 100kB and not a single test case could be produced that became slower and several macro benchmarks (like compiling the kernel) were measurably faster (5-10% if I recall correctly, but don't quote me on that).
Around the same time I went on a quest to actually measure inline functions in the OpenBSD kernel. I found a few that had minimal performance gains, but the majority had 0 measurable impact and several were making things much slower and were killed. At least one more uninlining had a huge impact and that one was the internal malloc macros (where the idea was to inline malloc if it had a size known at compile time) and packet buffer allocators that shrunk the kernel by 150kB and had a significant performance improvement.
One could speculate, although I have no proof, that this is because the kernel is large and we're struggling to stay inside the cache when executing system calls and every little bit helps. So what actually helped in those cases was just the shrinking of the binary, not the number of instructions executed.
Comment: Similar changes in removing inline was done years ago in the linux kernel as well.
Answer: Imagine a function that have no parameters, but intensive computation with a consistent number of intermediate values or register usage. Then Inline that function in code having a consistent number of intermediate values or register usage too.
Having no parameters make the call procedure more lightweight because no stack operations, that are time consuming, are required.
When inlined the compiler have to save many registers, and spill other to be used with the new function, reproducing the process of registers and data backup required for a function call possibly in worst way.
If the backup operations are more expansive, in terms of time and machine cycles, compared with the mechanism of function call, especially if the function is extensively called, then you have a detrimental effect.
This seems to be the case of some specific functions largely used in an OS.


system,exec calls in linux not work from php its work fine if i run directly to putty

Question: I am try to execute some command trough php.
like kill {process id}
Those command works fine using putty command prompt
 but same thing if i use with php its nothing happen .
Comment: Add the PHP code you're attempting to execute.
Comment: $command="kill ".$pieces[1];
  //p($command);
  passthru($command);
Answer: The shell command you're trying to execute will run with the permissions of the process running the PHP binary ( I.e. apache , etc...)
When you're logged in via putty/ssh, the kill command has your permissions.
Unless you suexec the PHP /apache or are trying to kill a process owned by the same user as that running the PHP/apache, you're not going to have much luck.
Comment: what to do for run this from php ?
Comment: I presented two methods in my answer.  Use suexec to change the sync ownership of process to kill or run the process that you want to manage with the same user that runs PHP.   Ultimately the limits placed are supposed to be there for system security.  If this is running on a shared host, much of this will be prohibited from a security stand point.


Plugin for Eclipse IDE to check language grammar

Question: I'm, looking for a plugin (or some kind of extension) for the Eclipse IDE so it can check grammar, and flag mistakes like "The dog dog is lost" etc.
Answer: I have used a tool called LanguageTool for grammar check in the past.  It's an excellent free proofreading software for grammar, style, and spell checking.  It also has a list of addons supporting Eclipse.  The original author and the addon listed on the LanguageTool wiki is deprecated, but linked below is a fork that is said to be the successor.
Note: I have not used this plugin, however, I have used LanguageTool

languagetool-eclipse-plugin
Eclipse plug-in for Languagetools
This plugin contains an Eclipse plug-in to use the spell checking engine LanguageTool in the Eclipse IDE. This repository started of as a fork of https://github.com/auguster/languagetool-eclipse-plugin but as the original remote included the languagetools JARs it was recreated from scratch.

This is a screenshot from the website, which should implement the same check in the addon
Comment: Thanks very much, but even for the replacement eclipse plugin the update site is broken, and it doesn't seem possible to get this up and running in any logical way


what server hardware does the amazon cloud use?

Question: Does anyone know the hardware vendor amazon uses for their EC2 cloud?
Answer: Amazon statement
Regarding CPU

Amazon EC2 is built on commodity hardware, over time there may be several different types of physical hardware underlying EC2 instances. Our goal is to provide a consistent amount of CPU capacity no matter what the actual underlying hardware

A blog showing some research made on the hardware is here
http://huanliu.wordpress.com/2010/06/14/amazons-physical-hardware-and-ec2-compute-unit/
Points from the blog
High-memory instances

Dual-socket Intel Xeon X5550 (Nahelem) 2.66GHz processors.
Intel Xeon X5550 processor has   4 cores, and each core is capable of hyper-threading

High-CPU instances

dual-socket Intel Xeon E5410 2.33GHz
E5410 only has 4 cores

Standard instances

Single socket Intel Xeon E5430 4 core 2.66GHz processor
or
Single socket AMD Dual-Core Opteron 2218 HE Processor
Comment: updated points from the blog in the answer..
Answer: I don't know the answer (if indeed there is a single answer) but effectively, it doesn't matter one bit. The only thing that customers get is virtualized. Amazon could replace everything overnight without even impacting customers.
Maybe they do what Google does and buys whiteboxes without cases in pods, and replaces the whole pod when it goes bad.


Prediction of mortality based on age before and after a certain event

Question: I have data on about 320 people. I am trying to predict their mortality before and after a certain event. I tried to apply a logistic regression model using dead or alive as dependent variable and age-as independent. The problem is that there are several people in some age groups, and out of these groups some survived and some died. Not sure how to combine ages and ratio of alive/dead on the x-axis if i use a logistic regression.
Answer: Assuming you are not predicting 0/1 mortality per se but are predicting time until death, it sounds like you want to assess the impact of an intervening event on the instantaneous risk of death.  That can be dealt with using a time-dependent covariate in a Cox proportional hazards model.  Alternatively you can set up a state transition model that is perhaps more interpretable.  These are discussed in https://cran.r-project.org/web/packages/survival in the vignettes.


Migration project to iOS 7 required or not?

Question: I have project which was developed iOS 6 and when I install it on device with iOS7 it's looks good. But now I update xcode to 5th version and now it's look not so fine. I know about application migration. My question is will I have some problems if I will continue using xcode 4 and upload to Apple will be targeted to iOS 6?
Answer: Your iOS 6 app runs in a compatability mode when run on iOS 7. You can currently submit apps compiled with older versions of Xcode but they will stop accepting them at some point -- and probably quite soon.
To directly answer you question: no, you don't have to update now. But assuming you will want to maintain the app for more than another couple of months it's some work you'll have to schedule.
Update: Apple will require new and updated apps to be compiled with Xcode 5 from February 1 2014, around four months after iOS 7 came out.
Comment: I had the the screen to upgrade. I clicked skip. Is there anyway that I can manually migrate it. I am looking in xCode but didn't see any option for migration.
Answer: You are fine with Xcode 4 -- for now. But I would advise to get familiar with the iOS 7 SDK and Xcode 5 as soon as possible.
You did not explain why "it's look not so fine". Just set the target OS to 6.0, and it should really behave exactly the same way, maybe with a couple of more warnings.
Comment: I am arrived a bit later, so I can only confirm what you already say. Also, I really did not know about the app behaving the same if compiled with older version.
Answer: I have left a project on the App Store, compiled with iOS 5.
With my surprise (I did not know about that) I found out that the App, running on iOS 7 device looks perfectly fine, without all the problem of elements positioning, just as it was on an iOS 5/6 device. Even the keyboard is displayed old style.
On the contrary if I run with a simulator, everything is messed up. So I choose to leave as it is, and plan a layout upgrade in the nearest future.
Answer: Yes. You can use 4.
You want you can build against an older sdk with 5.
How to build against older iOS versions with the latest Xcode downloads?


Disappearing horses

Question: I've recently noticed this glitch that every once in a while, my horse disappears when I climb off it. I am playing 1.14 Minecraft java. Usually, it reappears when I restart the world. The computer I am playing on isn't very powerful, but I also saw it happen on another computer, which is slightly more powerful than mine. So please tell me if it's just me who loses my horses (which is very unlikely), a glitch, or is it just my computer. Thank you very much!
Answer: It's a visual issue. I don't currently know the report number, but closing+reopening the world/leaving+rejoining the server is a workaround.
Comment: Thanks a lot, I suppose that's what I'll have to do, it's happening less and less though.

Disappearing horses


Individual column widths of Jtable in netbeans

Question: I'm new to using JAVA.. How do i set individual column widths of a JTable in netbeans?
Answer: Is this about using the Swing GUI builder (formerly Project Matisse) in NetBeans, or about creating a table by hand while using the NetBeans IDE?
JTable's TableColumnModel's TableColumn column widths are generally controlled by setting it's preferred width. Depending on the layout you may want to modify the minWidth and maxWidth fields of the TableColumn.
If you're using the Swing GUI builder you could call this after initComponents() in the containing panel's constructor, or if you're using static data in design mode you can right-click the table, choose Table Contents, and set the widths as you add columns using the Customizer Dialog. There is also the option to "Customize Code" in design mode to modify pieces of the IDE managed initComponents method.
Setting the widths by hand after initComponents() may be the easiest and least magical initially.
<code>public MyPanel() {
initComponents();
TableColumn col = table.getColumnModel().getColumn(0);
col.setPreferredWidth(100);
}
</code>
Note: I'm referencing NetBeans IDE 6.8 as I answered this, menu items and dialogs may differ.


I have contradictory results in a research paper, how do I proceed with my analysis?

Question: I am performing a simple acid-base titration investigating the efficency of different pure antacid compounds, and in my results, I found out that NaHCO3 neutralized the fastest (using a pH by time graph). Later on, I decided to further prove these results, by calculating pKb values for each base, and out of my three bases (Mg(OH)2, CaCO3, and NaHCO3), NaHCO3 had the highest pKb, which would suggest that it is the weakest base, and wouldn't neutralize the fastest. What should I do in this situation??
Comment: What do you refer to / how do you qualify «fastest»?  This is not a kinetic analysis because (assuming aqueous solution) the neutralization of $\ce{H+}$ by $\ce{OH-}$ to yield $\ce{H2O}$ will be a fast one anyway.  Maybe you refer to «to neutralize amount $x$ of acid, amount $y_1$ of antacid (1) is necessary, which is half the amount of $y_2$ using antacid(2)», or a plot of pH value in function of the volume of antacid added.
Comment: You text does not match the title. What research paper?
Comment: Look up the pK values. Edit your question, add a table with the values from literature, and those you calculated from your measurements. *Show* your calculation.
Comment: As Buttonwood says that you can't really think on kinetics. At most you can relate how long there will be a base depending on availability. It can have different grains size (also overcame by the fast reaction, btw) or it can be in a jelly carrier. But this would mean comparing different drugs / formulation not really the bases.
Answer: I think I know what your problem is. Yes, $\ce{NaHCO3}$ is the weakest base of the three, but it is the most soluble in water. Thus, the neutralization can occur throughout the solution. For $\ce{CaCO3}$ and $\ce{Mg(OH)2}$, the rate limiting step is dissolution of the solid. Neutralization only occurs at or near the solid surface.
You also need to be careful mixing kinetic (speed, lower case $k$) and thermodynamic (upper case $K_b$) parameters. The thermodynamic parameters tell you how likely a reaction is, not how fast it will proceed.
However, in this case, we can also see that the reaction with $\ce{NaHCO3}$ is most likely. The acid-base equilibrium is not the only equilibrium to consider. We also need to consider the solubility equilibrium summarized by the solubility product constant $K_{sp}$. For example, for $\ce{CaCO3}$, $K_{sp} = 3.30\times 10^{-9}$ for the following equilibrium.
$$\ce{CaCO3(s) <=> Ca^2+(aq) + CO3^2-(aq)}$$
$$K_{sp}=[\ce{Ca^2+}][\ce{CO3^2-}]$$
The equilibrium equation for neutralization is, with $K_b = 10^{-5}$:
$$\ce{CO3^2-(aq) + H2O(\ell) <=> HCO3^-(aq) + OH-(aq)}$$
$$K_b = \dfrac{[\ce{HCO3^-}][\ce{OH-}]}{[\ce{CO3^2-}]}$$
The overall reaction is then:
$$ \ce{CaCO3(s) + H2O (\ell) <=> Ca^2+(aq) + HCO3^-(aq) + OH-(aq)}$$
$$K = [\ce{Ca^2+}][\ce{HCO3^-}][\ce{OH-}] = K_{sp}K_b$$
Now we have what we need to evaluate the three bases thermodynamically:
$$\begin{array}{l|l|l|l|l}
\text{Formula} & \text{solubility} & K_{sp} & K_b & K = K_{sp}K_b \\ \hline
\ce{NaHCO3} & 96 \text{ g/L} & 1.31 & 2.24 \times 10^{-8} & 2.92\times 10^{-8} \\
\ce{CaCO3} & 1.3\times 10^{-2} \text{ g/L} & 3.30\times 10^{-9} & 1.00 \times 10^{-5} & 3.30\times 10^{-14} \\
\ce{Mg(OH)2} & 6.4 \times 10^{-6} \text{ g/L} & 5.61\times 10^{-12} & 50.1 & 2.81 \times 10^{-10} \\
\end{array}$$
From these data, the overall equilibrium constant is largest for $\ce{NaHCO3}$ because it has the highest solubility despite being the weakest base.
Comment: All of these values are from the corresponding Wikipedia articles, (except the $K_{sp}$ of $\ce{NaHCO3}$, which I had to calculate from the solubility.
Comment: For the interested, lower case $k$, as in IUPAC [here](https://goldbook.iupac.org/terms/view/O04322), about kinetics' rate constant.  Which is, by convention, different to upper case $K$ about equilibrium constants, as in IUPAC [here](https://goldbook.iupac.org/terms/view/E02177).
Comment: @BenNorris, if it isnt too much to ask, could you please provide me with the source of where you go the values displayed above on the table?


Freezer not cycling on

Question: I've been thawing 30lbs of meat in the refrigerator. I discovered some of the food items in the freezer started to thaw. The temperature in the fridge before I took out the meat was 37 degrees. The temperature in the freezer was 23 degrees. Will thawing large quantities of frozen food in the fridge prevent the freezer from cycling on?
Comment: This is presumably a fridge-freezer (with a single compressor). You should specify. As a quick fix, pressing the fast freeze button might deal with the freezer issue, though the defrosting might be slowed.
Comment: Yes, a fridge-freezer with one compressor.
Answer: Fridge freezers (the common type with a single compressor) are often designed in the assumption that a certain amount of heat will leak into the fridge, i.e. they have a minimum operating temperature of a cool room temperature.  They can't control the temperatures of the fridge and freezer completely independently.  Some models only have one thermostat, while in others cold air from the freezer is circulated through the fridge and back to the freezer, putting a load on the cooling circuit and turning on the thermostat.
You can sometimes work round this by pressing the "fast freeze" button if you have one.  This will force the freezer to run, but may slow down defrosting.
Wrapping the defrosting items in a thin insulating layer will also mean they defrost more slowly, and cool the fridge less.
Starting the defrost at room temperature would avoid this but you have to be careful to not end up with outer layers sitting around at room temperature.
A good compromise may be to start defrosting at room temperature, then transfer to the fridge when the outside of the frozen item is still around freezing point.  A light insulating wrap will slow this process down and make for more uniform defrosting; you can leave this on when you transfer to the fridge.  You would probably be talking about quite a few hours at room temperature, especially if it's multiple packs you can rearrange when you check to make sure they're still frozen.

Freezer not cycling on


Does 'Grab some food' always mean to 'buy' food?

Question: I was in a situation where all my classmates in college had a dinner together which our school prepared for us on our first day of school.  There were some cans of beverages on the other side and someone told us we can have them without charge. And some of us didn't hear that, so i said to them "You guys can grab some beverages over there."
Now i'm wondering grab as in 'grab food' can mean getting food free of charge as well  since I've always heard people say things like "Let's grab some coffee" meaning "buy" some coffee..
Does what i said to them sound natural? Or would there have been better ways to say that?
Answer: From my understanding, "grab some food" is close to "get some food". So it basically means acquire food, regardless of the method used. So buying it or fetching it from the kitchen would both fall under "grabbing food".
Comment: Yes, "grab some food" is typical youth-speak for get (buy) some take-out food. So annoying, especially in light of most parents exhortations to children to not "grab food"...:)


How to create virtual appliance like bitname and turnkey linux

Question: i have a question i am bit of a linux user sort of programmer but i couldn't understand is how to develop your own virtual appliance similar to bitnami and turnkey and if there is a way please tell me!!
Answer: Take a look at TKLPatch, a simple tool for customizing and extending any of 100+ appliances in the TurnKey Linux library. The resulting patch can be used to generate an ISO that can be installed in a VM or on real hardware.
If you have any questions or need help, feel free to post to the TurnKey forum.
Answer: Updated info
Hopefully my necro-posting adds some value...
The new TurnKey build tool is TKLDev. It uses a similar paradigm to TKLPatch, but instead of requiring you to start with an ISO; it builds completely from source.
So long as you can script the install (and there's almost always a way that you can) and it will work on Debian, then you can build yourself a software appliance in a load of different build types (inc. OVA, VMDK, hybrid ISO etc) using TurnKey Linux's TKLDev build engine. The major VM platform that it doesn't (yet) support is Hyper-V but the ISO installs.


Can I list the published papers that I did intern work for even if I'm not an author

Question: I am applying to grad school for a Masters in Environmental Science. (My BS is in Biology). I interned throughout high school and college for NIH. I did the basic lab tech type of work, but there were 2 papers that were published which I helped work on. Obviously, I am not an author on either of those papers, however I think they show the kind of work of which I have been a part. I can't find any format for listing this type of thing, so perhaps I should exclude the reference completely? However, I went to a CV writing workshop and was advised that any papers I contributed to in any way should be listed. I would appreciate any advice on this subject. Thank you.
Comment: Do those papers contain written acknowledgements of your help?
Answer:
However, I went to a CV writing workshop and was advised that any papers I contributed to in any way should be listed.

That's bad advice for an academic CV.  You only list papers on which you are an author.  I haven't ever seen exceptions to this rule - if you list them it will at best be confusing, and at worst seen as fraudulent.
You can certainly list your job as research experience, and in any graduate application, you can and should explain in more detail what you did and how it contributed to published research.  You should also ask your supervisor or PI to write a letter of recommendation which explains your contributions and their importance, and how it shows your preparation for graduate study.
Comment: +1 for "ask your supervisor or PI to write a letter of recommendation which explains your contributions". I think this is the best you can get out of your work if you are not an author.
Comment: If you are very early in your career and you have very few or no actual authored papers, you could possibly list them so long as it was abundantly clear these were "outputs from projects I contributed to", and that you're not claiming authorship.


How do I set start date with the core date field?

Question: I need set the start date (e.g. now +1) for my date field. How can I do this on Drupal 8.1.x?
Answer: When you create your field, you have the option of setting a default value.  Set the Default Value to Relative Date and then ender "+1 day" into the textfield, and proceed with setting up the field.
When you create new entities with that field, it will default to the current time +1 day, which you can then change if needed.
Answer: The core date field doesn't support a start and end date, it's a single value field. See this discussion for the nitty-gritty for when the field was originally added, and the current issue about adding end-date support.
Date 'range' fields, with the option for a start/end date, are supported by the contributed Date module. Though the D8 version is still in dev so YMMV.


Cross product and the right hand rule - what is the intuition behind it?

Question: I understand that by convention, the cross product is defined to be the vertical projection of vector $A$ on $B$ in the case of $A \times B$. But the vertical projection of $A$ on $B$ would still be in the same coordinate-plane as $A$ and $B$. Why should the resultant cross-product necessarily point in the orthogonal direction given by the right hand rule? We have always taken it for granted when solving problems, and my textbook does not make any attempt at an explanation.
Comment: You are mixing up the scalar and the cross product. The scalar product is a projection, the cross product is related the area of the parallelogram spanned by the two vectors. The fact, that it is a vector orthogonal to A and B (which breaks down in dimensions other than three) is best understood when considering differential forms and the Hodge duality.
Comment: possible duplicate of [What is the physical significance of dot & cross product of vectors? Why is division not defined for vectors?](http://physics.stackexchange.com/q/14082/)
Comment: Why do you talk about the vertical projection in this connection?
Comment: @Steeven Sorry, I meant to refer to the area of the parallelogram that the two vectors form.
Answer: The right hand rule and cross product of matrices is a convenient and useful tool for describing natural phenomena in three dimensional space.  Like all conceptual tools, it was devised by humans to acquire knowledge, and to further our ability to predict and to manipulate aspects of our world.  We use it because it fits with nature.
Examples ($\times$ denotes cross product):

The direction of magnetic force, electric current, and magnetic field derived from the Lorentz Force Law: $$F = q * (E + (v \times B))$$ where $F$ is the force felt by charge $q$ moving at velocity $v$ through an electric field E and a magnetic field $B$.  (E, v and B are vectors.)
The direction of the magnetic field around a current carrying wire: $$F = L * I \times B$$ where $F$ is the force on the wire, $I$ is the electric current (assuming positive charges are flowing), $L$ is the length of the wire, and $B$ is the direction of the magnetic field.
The direction of the torque axis when force is applied to the axis:  $$\tau = r \times F$$ where $\tau$ has the direction along the axis of rotation from which angular velocity of torque is applied, $r$ is the displacement vector along the lever arm through which torque is applied, and $F$ is the force vector applied at that distance.
The representation of a rotation vector (Euler vector), useful when describing any rigid object that rotates around an arbitrary axis.

The right hand rule works so well as an adjunct to matrix cross products in vector multiplication, that we might think nature follows math, rather than math following nature.  The ancient Greek Pythagoreans believed as an article of faith that "all is number".  But math is essentially no more than a language with tests for internal consistency and reality checking.  We may get so drunk on the power of math that we turn it into something more real than the world to which we apply it, as the ancient Greek Pythagoreans did.
All language, beyond primitive simple words mimicking the sounds associated with natural phenomena, is arbitrary. Though its roots are in primal perceptions, language becomes arbitrary and abstract as humans expand the range of thought, and devise tools to extend their perceptions and power.  (http://rstb.royalsocietypublishing.org/content/369/1651/20130299).
Math is no different. First came counting or "natural" numbers, then rational numbers, then irrational numbers, then zero, then negative numbers, then the square root of -1 and "imaginary" numbers, and then many more extensions of the concept of numbers (http://en.wikipedia.org/wiki/Number), including cross products of matrices and the right hand rule.
Comment: @Steeven: You are right, I mistakenly applied the cross product to scalars.  As they are vectors, no additional angle is needed.  Comments like yours make Physics SE accurate great!  I edited the answer.
Comment: The magnetic field is an arbitrary choice. The direction of the force depends on the cross-product, but so does the direction of the B field produced by a given source (assuming we define the curl with the same convention as the cross product), so if the cross-product was defined with opposite sign, the force would still come out the same.
Comment: @The Photon:  The cross product is a pseudo vector.  Its interpretation is an arbitrary convention, like the convention that electrical current is a flow of positive charge, which actually is opposite to the flow of charge carriers.
Comment: Nice thorough answer. It is a mistake, though, to include the cross product $\times$ *and* the $\sin \theta$ at the same time. The $\sin$ is rather the rewritten scalar form, when we remove the $\times$. It should either be $\tau=r \times F$ *or* $\tau=r*F*\sin\theta$, not $\tau=r \times F * \sin\theta$ (same for point 1.). If you correct this, you get my upvote.
Answer:
Why should the resultant cross-product necessarily point in the orthogonal direction given by the right hand rule?

Because, we made it to do so.
Other math tools/methods give other results. And we made them to do so too. We could make a mathematical method that brought any result we wanted. But some methods, tools and definitions turn out to fit with the real world.
Remember that math is a tool invented to describe phenomena among others. If we find some kind of a connection in the real world, we can design a mathematical tool to describe it.

You can sit down and invent any mathematical definition/tool of your own. Something with another value and another orientation after using it on two vectors. Something completely different, if you like. It is up to you. If it happens to be useful for anything, it might catch on and become a recognized mathematical rule.
Maybe in a few years, people will start asking, why this rule really is as it is. And your answer will simply be: Because it happens to describe something that we want to describe.
The question should not be, why the tool gives that resulting orientation. It should rather be, why those phenomena that fit that description work in that way.
Comment: The convention, that the cross product of two vectors is represented by the right hand rule, is consistent with the convention of our coordinate system, the cartesian coordinate system. But I want supplement Steeven. In nature there are phenomena that really can be described with vector cross product. The most obvious phenomenon is the Lorentz force. Moving electrons, crossing a magnetic field, experience a force, perpendicular to both vectors. This force has a maximum if the electron's velocity and the magnetic field are perpendicular and equals zero if they are parallel or antiparallel.
Comment: The Lorentz force is not a rule, it is a law. The Lorentz force for electrons and antiprotons $\vec F = q \vec v \times \vec B$ follows the left hand rule. This does not contradict the equation above because q is negative for electrons and antiprotons.
Comment: To follow up on the addition by @HolgerFiedler, many expressions appears to be describable with a cross-product. Angular momentum $L=r \times p$, moment $\tau = r \times F$ etc.
Comment: @Steeven But this seems to be pseudo vectors. The Lorentz force is the only that points in a direction without any convention has to be defined. The direction of moment is a confection, the direction of Lorentz force is given by nature.
Comment: @HolgerFiedler That is because $\vec B$ is (approximately) a pseudo-vector and "vector cross pseudo-vector" gives a vector.
Comment: @SebastianRiese Could not agree in the sense, that the direction of the magnetic field is measurable, the direction of a moment is not. Hence the moment vector direction is pure convention.
Comment: @HolgerFiedler Being a [pseudo-vector](https://en.wikipedia.org/wiki/Pseudo_vector) is just a statement about the transformation behaviour under parity. And the defined direction of a magnetic field is just as arbitrary, as the defined direction of angular momentum!
Comment: We are talking about the resulting vector Lieentz force: polar vector × pseudovector = polar vector
Comment: @HolgerFiedler I understand your point, and agree most of the way. The torque "vector" is simply a convention made to fit the cross-product rule. But, another way to view it is, for the vectors $F$ and $r$ applied at a point, the torque will work around *an axis*, which certainly is perpendicular to both. This axis is pointed out by the cross-product, not by convention but by the nature of the mechanism. (The *sign* of that vector is then the only convention in this.)


Best way to clone an installation (copying to identical hardware)

Question: Kind-of like this question but slightly different (I think), in that I have 6 identical Acer Aspire Revo R3610 machines. One is (almost) configured to my requirements - when I'm done preparing it I'd like to make the other 5 machines absolutely the same. I'm very new to Ubuntu, what's the most straightforward (easiest) way of doing this?
The machines are going to live on different networks if that might otherwise be a problem (eg with Windows you can clone disks but you then have to make registry changes afterwards if they're going to run on the same network etc). The hardware in all 6 machines is, I stress, the same!
How can I efficiently clone one source image on to these identical machines?
Please restrict one software/solution per answer
Answer: Clonezilla sounds like it fits your needs
Comment: One benefit of using tools like partimage and ntfsclone (which is what Clonezilla uses to create the disk image) is that they understand the underlying filesystem on each partition, which allows them to copy only used blocks. As dd does not have this functionality, it must copy every byte of the partition, regardless of whether or not it is used.
Comment: Totally the right tool for the job. My Mum runs 'Mumbuntu' and I take a snapshot of her Acer Revo periodically using clonezilla and take it home to restore on a Revo I own as a backup. Works a treat.
Comment: It sucks. Failed to clone after two days work. Hangs on alculating bitmap... Use Windows and Acronis Trueimage
Comment: Will DD not make the bootable backup CD? Is that the reason use CloneZilla?
Comment: @YumYumYum: `dd` makes *copies* of a file/partition/drive. So if you clone a bootable CD (either `.iso` image or a `CDFS` partition) the result will be bootable as well. But `dd` will *not* "convert" a given set of folders/files to a bootable image.
Comment: Clonezilla makes an "almost" perfect copy.  Most everything works except Chromium.  It looks like it is launching then just silently gives up.  So here is the solution: go into the software installer, remove it then add it back again and log it back into Google to get bookmarks and extensions.
Answer: dd
A low level copy using dd would do the trick!
Watch out for conflicting IP addresses and hostnames.
Basically put the source drive and destination drive in the same machine, boot into a live cd.  And run something like the following where /dev/sda is the source and /dev/sdb is the destination:
dd if=/dev/sda of=/dev/sdb bs=4096
I remember the operands by:
if -> input file
of -> output file
bs -> block size (how many bytes to read at a time)
Comment: Sure why not? =/ I've seen people do that and I've seen people not do it. Is there a style guide somewhere to answers?
Comment: How safe is this, considering any public/private keys used by for example OpenSSH would be identical? What would we need to change to keep the system safe (different where we wan't it to be different)?
Comment: if you have Dynamic IP enabled, temporary before making that Bootable/backup CD/USB. There should not be any issue i believe for conflicting IP. As long as it back up A to Z that really matters to me, because of lot of drivers i had.
Comment: What do you mean by run "something like this?  I am positive of sda and sdb but don't understand why you picked that bs.
Answer: The easiest way to do this is to run a bare bones Ubuntu installation on your hard drive, install VirtualBox and set up a virtual Ubuntu machine.  Run your virtual machine and set up that installation just like you want it with all the bells and whistles you want.  Do all of your working and playing on the virtual computer.
VirtualBox maintains the virtual machine as a large disk image file (.vdi) along with a few other much smaller configuration files.  Whenever you want to backup your virtual machine, just shut it down and copy its directory to your backup location.  I use a Passport external drive for this purpose.
Right now, there is both a Windows 7 and an Ubuntu 12 virtual machine on that external drive.  All of the system updates, programs, personal files, pictures, whatever, get saved in those virtual machines.  A backup of this type is very fast, as one big disk image file will transfer much quicker than a bunch of individual files would.  Since VirtualBox maintains the files in that format all the time, the virtual machine is always configured to be backed up.
One advantage of that setup is that I can run those virtual machines off the external drive on any computer with VirtualBox installed, so now, instead of lugging my computer all around, I just bring my external drive with both Windows and Ubuntu, install VirtualBox on whatever computer I plan to use (I have all the VirtualBox installation files also on my external hd - they are available for all the main operating systems), and I am ready to go.  I can either copy my virtual machine to the computer I am using, or just run it off of the external drive.
If your computer crashes and dies at some point, who cares, you just grab your Ubuntu installation disk, install it on your new or repaired computer, hook up your external drive, install VirtualBox, and copy your virtual machines back on to your computer - problem solved with minimal stress, loss of time, and loss of data.  How much data you lose depends on when you last backed up.  For myself, I do a new backup whenever I make a major change or add a hard to get program.  Just make sure that your virtual machine is operating normally when you do it.  You would not want to copy a corrupted machine over a good one.
And no, I don't work for VirtualBox.
Comment: Love it.  Upvote.  I might just do this on my next machine.
Comment: Very cool approach!
Answer: Create an image using Remastersys, transfer it to a pen drive using the Startup Disk Creator utility and install on other system.
Answer: Partimage
Another great cloning utility which I've used, as well. Features a terminal gui.
Comment: this is include in system rescue cd -> http://www.sysresccd.org/Main_Page
Comment: partimage does not support ext4 or btrfs [source](http://www.partimage.org/)
Comment: That rules me out.  ext4
Answer: I would get one computer all the way you want it, and install the openssh-server package. Generate a ssh key pair with ssh-keygen -t rsa. Add the public key to /root/.ssh/authorized_keys2. Then I would boot the new computers with a live cd and plug in a usb stick with the ssh private key. Use gparted to create a new partition. Then mount the new partition and run something like sudo rsync -avzx -e "ssh -i /media/disk/path/to/privatekey" --exclude=".gvfs" root@<ImageComputerIP>:/ /path/to/new/partition/
Use the blkid command to find the UUID of the filesystem you just created. Edit the /path/to/new/partition/etc/fstab to reflect the new UUID (and filesystem type if you used a different filesystem.)
Then I would follow the instructions on https://help.ubuntu.com/community/Grub2/Installing#via_ChRoot about how to install from a chroot.
A simplified version of that page (which doesn't account for lvm, software raid, or bcache, or separate /boot like the wiki page does):

Mount the critical virtual filesystems. Run the following as a single command:

for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done

Chroot into your normal system device:

sudo chroot /mnt

Reinstall GRUB 2 (substitute the correct device with sda, sdb, etc. Do not specify a partition number):

grub-install /dev/sdX

Recreate the GRUB 2 menu file (grub.cfg)

update-grub

Exit chroot: CTRL-D on keyboard

By the way, this works good for backup, too. Ubuntu, unlike Windows, doesn't seem to have problems being transplanted to different hardware. I've put hard disks from one computer in another and it did fine, and I've copied installs to different hardware and it did fine.
Comment: Thanks for this - I've got another one coming up shortly, I'll give this a try. Cheers
Comment: The referenced link currently doesn't mention chroot nor any methods. That's why it is a good idea to quote relevant parts of your sources.
Comment: @Henno The wiki page was moved. The problem with including the page is that the wiki keeps up to date with new things like bcache and just copying the contents of the page will miss those updates, but the downside to  just linking that is stuff can move on you. Either way, link updated, and a stripped down version included.
Answer: I use ddrescue for exactly this task. It works flawlessly. Super simple.
See this thread on technibble for details
Comment: Link rot is why this answer should at least include some of the details.  Like, how to install it and start it running, at the very least.
Answer: G4L
Ghost for Linux
Ghost for Linux is a hard disk and partition imaging and cloning tool similar to Norton Ghost(c) and (tm) by Symantec. The created images are optionally compressed, and they can be stored on a local hard drive or transferred to an anonymous FTP server. A drive can be cloned using the Click'n'Clone function. g4l  supports file splitting if the local filesystem does not support writing files >2GB. The included kernel supports ATA, serial-ATA, and SCSI drives. Common network cards are supported. It is packaged as a bootable CD image with an ncurses GUI for easy use.
Comment: OMG.   This is precisely what I have wanted for ages.  Even for Windows.  TNX for the post.  I'll check it out right away.
Answer: Fsarchiver
I don't know why no one mentioned this. This is especially handy when you want to restore the partition's content on another file system type (for example, restoring ext4 content to ext2 or reiserfs) or you want to restore to an smaller partition.
I used it and it's very easy. For example, to clone a partition say /dev/sda1 you use a command like this
fsarchiver -A -j 2 -z 1 savefs /media/anwar/USB_Drive/myrootpartition /dev/sda1

The -A option allows you to copy partition even if it is used! Great feature!
-j 2 says to use 2 CPU core for compression. Useful for multi-cored CPU and if you use compression
-z 1 sets the compression level.
To restore the file system you used
fsarchiver restfs /data/myrootpartition.fsa id=0,dest=/dev/sda2

The id=0 says you're restoring the first filesystem from the archive (Even if you don't saved multiple partitions on a single archive, you need to specify it). And dest=/dev/sda2 sets the destination of the restoring.
Answer: I do this a lot, using rsync.
First you can run rsync to load all the data to an external hard drive (your external hard drive should be in ext4 - I use this, so I know it works):
I assume you have two partitions: /dev/sda1 (root) and /dev/sda2 (swap).
Run in your original computer:
sudo rsync -avuorpESHAX /* /your/hard/drive

After copying the data, boot your next computer with an usb stick, and format the internal hard drive as the original hard drive.
Mount your external drive to /mnt, and copy the UUIDs of all partitions. Edit the UUIDs of the partitions of the new computer and put the same UUIDs you have copyied from the original data (it is in /mnt/etc/fstab).
Shut down the swap:
sudo swapoff -a

Create a new swap using the original UUID, copyied from /mnt/etc/fstab:
sudo mkswap /dev/sda2 -U original-UUID

(I supose your swap is in /dev/sda2)
Next, change the UUID of /dev/sda1: (the partition should be unmounted in order to change UUIDs)
sudo umount /mnt
sudo tune2fs /dev/sda1 -U old-UUID

Done this, mount the destination partition:
sudo mount /dev/sda1 /mnt

Reverse rsync to the destination:
sudo rsync -avuorpESHAX /media/your-backup /mnt

Reinstall the grub:
sudo grub-install --root-directory /mnt /dev/sda

This will work.
Remember to edit /etc/hostname and /etc/hosts to change the hostname for each machine in order to avoid network conflicts.
Answer: Having never done been in this predicament (I don't have hundreds of servers - I've always just used base images), I can only give you my gut instinct.
That aside, I would say netboot is probably your best bet. Create a master server, get it doing what you want and then have all your other machines boot and install from it. Scripting things to happen automatically (ala run-once) shouldn't be too hard. You do all the secondary things through kickstart.
More (although it's a little old): https://help.ubuntu.com/community/PXEInstallServer
Edit: There's an application called system-config-kickstart that should help make generating the kickstart file quite a bit easier. YMMV.
Comment: As far as I know this `system-config-kickstart` is made specially for `fedora`.
Answer: Another option for mass-installs is the Ubuntu Landscape/private cloud approach where you (basically) provision servers dynamically based on a pool of hardware. Clever stuff.


Calculating pixel size on an iPhone

Question: Is there a way in the iPhone SDK to calculate the size (in millimeters) of a single pixel?
Answer:  Answering the question as asked about the size of pixels:
Pixel size on an iPhone and iPod Touch

The earlier iPhones (pre-iPhone 4) Apple iPhone Technical Specifications said :  480-by-320-pixel resolution at 163 pixels per inch(ppi).  About 0.006135 inches per pixel or 0.1558282 mm per pixel.
The first three iPod touch generations stated the same 163 ppi.
The iPhone 4  specs said 960-by-640-pixel resolution at 326 ppi .   So pixel width is 1 inch  / 326 pixels per inch or about  0.003067 inches per pixel or 0.0779 mm per pixel.  You use points, not pixels.  Edit:  As noted in Olaf's comment, below, pixels are actually addressable, using half-points.
The fourth generation iPod touch (Sept 2010) has
 specs  the same as the iPhone 4, 960-by-640-pixel resolution at 326 ppi
The iPhone 4S (Oct 2011) is unchanged from the iPhone 4 in terms of resolution.
The iPhone 5 (Sept 2012) specs said 1136-by-640 pixel resolution at 326 ppi.  Pixel size is unchanged.  Screen diagonal is 4 inches.
The iPhone 5C and iPhone 5S (Sept 2013) have the same resolution, pixel size, and diagonal as the iPhone 5.
The  iPhone 6, 4.7 inch,  (Sept 2014)
specs are 1334-by-750-pixel resolution,
at 326 pixels per inch (ppi).  pixel size is unchanged from 4, 4S, 5 5s.
The iPhone 6 Plus, 5.5 inch, (Sept 2014)
specs are 1920-by-1080-pixel resolution,
at 401 pixels per inch (ppi).  pixel size is about 20% smaller.  The pixel width is 1 inch / 401 pixels per inch or about 0.002494 inches per pixel or 0.06334 mm per pixel.

Pixel size on an iPad

The iPad 1 and  2 are 9.7 inch (diagonal) display with 1024-by-768-pixel resolution at 132 ppi per the iPad specs.  That is about .0075758 inches per pixel or 0.1924 mm per pixel.

The new iPad  (March 2012) is a 9.7 inch (diagonal) display with 2048-by-1536-pixel resolution at 264 ppi
per the current iPad specs.
 That is about .0037879 inches per pixel or 0.09621 mm per pixel.

The iPad Mini (1st generation - October 2012) is a 7.9 inch (diagonal) display with a 1024-by-768-pixel resolution at 163 ppi per the original iPad mini specs.  That is about
.006135 inches per pixel or 0.156 mm per pixel.

The iPad Mini 2 (2nd generation - October 2013) is a 7.9 inch (diagonal) display with a 2048-by-1536-pixel resolution at 326 ppi per the current iPad mini specs.  That is about
.0030675 inches per pixel or 0.0779 mm per pixel.

The iPad Air 2 (October 2014) and the iPad Mini 3 (October 2014) have the same resolution, pixel size, and diagonal as the previous versions of those products.

Comparison of the iPad Air, and iPad Air 2, iPad Mini, iPad 2 and iPad3.

You don't need to have the iPhone SDK calculate the size of a single pixel.  One option is to determine what you are running on and then select the needed mm size.
The iPhone (up to and including the 4S) / iPod Touch screen sizes, with a 3.5 inch (diagonal) display are NOT exactly 2" x 3".   They are a tiny bit smaller than that.  The iPhone 5 has a 4 inch (diagonal) display.
What the questioner may actually need:  points.
See Removers comment to the previous answer.  Coordinates are specified in points, not pixels.
Comment: of course they are individually addressable. You can specify positions on half-points, which would make your graphics look fuzzy on old iphones, but just as crisp on iphone 4. (or you could use opengl, or an offscreen buffer and copy it to the screen for low-level access)
Comment: When people are saying 960 by 640 or 640 x 960 here, why are they not saying whether this is portrait or landscape mode? Please specify.
Comment: The mode depends on how you are holding the iPhone or iPad.  See this http://stackoverflow.com/questions/4482893/iphone-what-is-mean-landscape
Comment: The iPad Mini resolution is 163 ppi, not 162 ppi. Per spec linked in the answer.
Comment: This all is true unless an app runs in upscaled mode: e.g when the app has no launch image for iphone6, the app runs ins iPhone5 emulation  mode, giving schreen width and height of an iphone5. So to correctly detect the current point size measured in milimters , one has to find out the machine name, and store a table of known screen sizes in milimiter. and then caluclate via the got mainscreen.size
Answer: Well, the size of a pixel is a constant. The screen size of a current iPhone or iPod touch  2" x 3" (50.8 mm x 76.2 mm) and the resolution is 320 x 480 pixel.
50.8 / 320 (or 76.2 / 480) => the size of 1 pixel is 0.15875 mm x 0.15875 mm
Comment: indeed the pixel density has been doubled for iphone 4 but no need to test for it in your applications since the coordinates you specify are in points, not pixels. where pixels:points used to have a 1:1 ratio, they now have a 2:1 ratio.
Comment: Agreed, little point to calculate the value of a fixed known value.
Comment: Thanks for that. I did originally think of doing that, but then it occurred to me that if they changed the screen size and resolution in a future model then I would have more changes to make to make my application display nicely on the new device.
Comment: Well, I think if future versions change the pixel density (currently 160 ppi) you would check the device model and use different constants. I guess if Apple changes resolution and/or screen size on future models, they will provide that API in an updated SDK.

Calculating pixel size on an iPhone


displaying a report in report viewer VS 2010

Question: I am trying to display an already existing .rdl report in report viewer. Is this possible, or does the report have to be created in Report Viewer?
Answer: You can use a report viewer control and set it to use a Server Report.
http://msdn.microsoft.com/en-us/library/ms252104.aspx.
Yes, you definitely can pull up an existing report.