Why we use liquid crystals in LCDs?

Question: Does anyone know why do we use Liquid crystals in LCD's.Why can't we use transistors to switch light on/off instead of using polarizing filters to change pixels light/dark.Is there any specific reason why we use Liquid crystals in these type of displays?
Comment: This should be migrated to engineering beta.
Answer: When LCD displays were invented back in the last millenium, there simply were no LED displays that could have competed with them. OLEDs existed in theory, but could not be built, and anorganic LEDs were way too expensive to built displays out of them. And there were problems with producing blue LEDs. The first LCD displays were also plain black-and-white displays without any backlight. They simply included a mirror at the back, so that the ambient light would either be reflected through the display a very light gray, or filtered out to display black.
Including a backlight into an LCD display was simple, straight-forward engineering. Making LEDs cheap was harder. Making OLEDs work reliably over the lifespan of a typical display was next to impossible.
As such, when LCDs with backlights got cheap enough to be able to compete with the bulky CRT displays, it was them who took the market. (O)LED displays simply were not ready at the time. LCD displays also still had quite a few problems like luminosity, switching speed, and color saturation. But they could be produced reliably in sufficient sizes, and they were the only display type that could be built into a laptop. Monitors for desktop PCs only followed later when the LCD displays got rid of the worst of their childhood problems.

So, the answer to this question is rather historic, not physical. LCDs simply were the first technology to be ready to displace the CRT displays, and market inertia favors them up to this date. (O)LED displays would be much more economical, faster switching, and provide better colors. But LCDs are established in the market, and have accumulated tons of small production cost optimizations over the years, making it really hard for any newcomer technology to compete with them.
Answer: Apparently it was technologically easier to have only one light source and change the the opacity of the material in front of it, rather than to have millions of individual light sources and switch them. And we actually use transistors.
This video is pretty informative: https://www.youtube.com/watch?v=jiejNAUwcQ8
Comment: :Could you tell then why we use transistors if it actually requires millions of individual light sources.
Comment: It does not. Have you seen the video?
Comment: :That's right.But I couldn't get why you have mentioned that "we could use transistors".
Comment: Well, you need something to turn the individual pixels on and off, whether the pixels are part of a passive LCD, or an active LED display.  Transistors are good at switching things on and off. You would still need transistors for an active display.
Answer:
Does anyone know why do we use Liquid crystals in LCD's [sic]

By definition, Liquid Crystal Displays (LCDs) would not be Liquid Crystal Displays if they did not use liquid crystals.

Why can't we use transistors

LCDs do use transistors.
LCDs compete with other types of display, such as LED displays. A chief advantage of LCDs is their much lower power requirements. This is why they dominate in applications such as digital wristwatches.
Comment: Most small LCD displays are _passive_:  There are no transistors in the display itself.  (Of course, there are lots of transistors in the peripheral circuitry.)  Displays that have transistors on the glass itself usually are labelled "active matrix" or something similar.
Comment: The power advantage of LCD is only when you have no backlight, or ignore its contribution. For the typical LCD monitor, an (O)LED display would be much more efficient because it only generates the light that's actually needed, and does not generate tons of light that will be filtered back out again by the color filters, the black pixels, and the wiring of the matrix. Even if your monitor displays perfect white, the color filters will remove at least 67% of the light produced by the backlight. (O)LED displays do not have this light waste problem.

Why we use liquid crystals in LCDs?


What do !punish and !forgive commands do on some hardcore Battlefield 3 servers?

Question: Playing on some Hardcore Battlefield 3 servers, if I get teamkilled by someone, I get a prompt to type either !punish or !forgive. What do these commands do to that teammate? I tried asking a few times in chat, but nobody ever answered me.
Answer: !punish and !forgive are commands added by plugins, and there are multiple plugins which add these commands.
In almost all cases, !forgive just means you ignore the violation, if it was unintentional.
One of the more common ones is Insane Punisher which uses !punish to kill the person who team killed you.  There are some plugins, however, which make !punish kick the person off the server.
Comment: And that's why Hardcore sucks. People jump around in front of you while you are firing and then have you punished even though it is their fault.
Comment: Wow, kick them? That's pretty extreme. Killing them is even better of a punishment than just kicking them from the server. They can re-join and all, but still, it just seems like it would be extreme to kick someone who simply teamkilled once in a long while.

I remember that some servers are set to auto-kick someone who teamkills a certain number of times (say 3) with one minute, or something like that; I find that acceptable, regardless to whether the teammate !forgives or !punishes. But allowing a teammate to get them kicked from an occasional team kill is a bit extreme.
Comment: do you know if there is any difference between `!forgive` and taking no action?
Comment: @vartec, I think !forgive is there so that if you're sure something was unintentional, you won't accidentally !punish for it later.
Comment: @agent86: ok, makes sense. I thought it might also vary on if TK counts towards TK/minute kick counter.


Where does the Muffin Man live in Shrek?

Question: Yes, I know he lives on Drury Lane, but where is Drury Lane located? I thought it was in Far Far Away, but the Shrek Wiki says Duloc, since Lord Farquaad knew about him. I changed Duloc to Far Far Away on the Muffin Man's Shrek Wiki page, but it got changed back to Duloc? So which kingdom does he live in?
Comment: Just a note, unless you have a source, I would recommend not editing wikis. Adding information just because one "thought" that's what it was is what makes wikis so low quality.
Comment: @NKCampbell Excuse me, he did what?
Comment: There could be two muffin men and also, Gingy is clearly lying to Farquaad.
Comment: @NKCampbell I'm confident there's up to 13 Muffin Men.
Answer: The Gingerbread Man apparently lives Duloc during the original Shrek, being close enough for Lord Farquaad to torture in the first movie.  He mentions the Muffin Man, but we do not see the Muffin Man in that movie, or have any indication of where he lives (aside from "Drury Lane").  Watching only Shrek, we might reasonably conclude the Muffin Man lives in Duloc - why else would Gingerbread Man and Lord Farquaad discuss Drury Lane so casually?
However, in Shrek 2, we see the Gingerbread Man reunited with the Muffin Man, and they conspire to create Mongo and storm the castle in Far Far Away.  Given the distance between Duloc and Far Far Away ("pok!") it seems clear that the Muffin Man lives in Far Far Away.
I would say that, having watched only Shrek, it would be reasonable to assume that the Muffin Man, and Drury Lane, were in Duloc.  But to move Shrek 2 along, the Muffin Man was concretely placed in Far Far Away.
So the answer is different depending on which movie you want to reference.
Comment: Perhaps the Muffin Man relocated to Far Far Away during Farquaad's persecution of fairy tale creatures. The interrogation scene seems to imply that the Muffin Man and/or his wife had been granting asylum to wanted fairy tail creatures; it makes sense that they'd want to flee for the safety of both their fugitive friends and themselves.
Comment: maybe the Muffin Man moved to FFA between the events of Shrek and Shrek 2?
Comment: I think "moved" is an excellent theory, guys, but between "well-crafted explanation" and "sloppy continuity" the *Shrek* movies only get one vote from me...
Comment: nice! @DaniellYancey - great minds thinking alike
Comment: Another Shrek Wiki user changed it back to Far Far Away, so no need to worry about it anymore.


What is the partial derivative of $f(x,y(x))$?

Question: What is the total derivative of $f(x,y(x,z))$ with respect to $x$? Is it $$\frac{\partial f}{\partial x}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial x}?$$
If this is correct, what is $\frac{\partial f}{\partial x}$? It seems to me that partial $f$ partial $x$ is equal to the derivative of $f$ with respect to $x$. What is the difference? I mean, suppose $f(x,y(x,z))=x^2+y(x,z)$ and $y(x,z)=x^2+z.$ So we have $f(x,y(x,z))=2x^2+z.$ Hence $\frac{\partial f}{\partial x}=4x.$ On the other hand, $\frac{df}{dx}=\frac{\partial f}{\partial x}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial x}=4x+1\cdot 2x=6x.$ Am I making a mistake?
Comment: The meaning is clearer if you introduce a function that only explicitly depends on the independent variables: $g(x,z)=f(x,y(x,z))$. Then you mean $\frac{\partial g}{\partial x}$, which is still a partial derivative (since $z$ is held constant), even though $g$ depends on $x$ in two different ways. By contrast if you had $g(t)=f(t,x(t))$, $\frac{dg}{dt}$ is indeed a total derivative.
Answer: Your computation of $\frac{\partial}{\partial x}f(x,y(x,z))$ is correct, but I think what you're stumbling on in your subsequent example is that
$$
\frac{\partial}{\partial x}f(x,y(x,z)) \neq \frac{\partial f}{\partial x}.
$$
The expression on the left is a composition of functions. The expression on the right is a shorthand for $\frac{\partial f}{\partial x}(x,y)$, which is the derivative of $f$ with respect to $x$ at the point $(x,y)$, where neither $x$ nor $y$ are given in terms of other variables.
It might help conceptually to write down the composition as a separate function. In the case of $f(x,y(x,z)) = x^2 + y(x,z)$ for $y(x,z) = x^2 + z$, you really have a new function $g(x,z) = f(x,y(x,z))$, and the chain rule indeed says that
$$
\frac{\partial g}{\partial x} = \frac{\partial f}{\partial x}(x,y(x,z)) + \frac{\partial f}{\partial y}(x,y(x,z))\cdot\frac{\partial y}{\partial x}(x,z),
$$
but this is very different from and does not say that $\frac{\partial f}{\partial x} = \frac{\partial f}{\partial x} + \frac{\partial f}{\partial y}\frac{\partial y}{\partial x}$. To verify that this is true, note that we can calculate the lefthand side directly as
$$
    \frac{\partial g}{\partial x} = \frac{\partial}{\partial x}(2x^2 + z) = 4x,
$$
and the righthand side as
\begin{align*}
    \frac{\partial f}{\partial x}(x,y(x,z)) + \frac{\partial f}{\partial y}(x,y(x,z))\cdot\frac{\partial y}{\partial x}(x,z)
   &= \frac{\partial}{\partial x}(x^2+y)|_{y = x^2 + z} + \frac{\partial}{\partial y}(x^2 + y)|_{y = x^2 + z}\cdot \frac{\partial}{\partial x}(x^2 + z)\\
   &= 2x + 1 \cdot 2x = 4x.
\end{align*}
Answer: The mistake is that $\frac{\partial f}{\partial x}$ means two different things in these cases. In the first case, we assume that $z$ does not depend on $x$, meaning $\frac{\partial z}{\partial x} = 0$. We can write $f(x,z) = 2x^2 + z$. So we get $$\frac{df}{dx} = \frac{\partial f}{\partial x} = 4x.$$
In the second case, we have $f(x,y) = x^2 + y$ with $y(x,z) = x^2 + z$ Whether or not $y$ depends on $x$, we always get $\frac{\partial{f}}{{\partial x}} = 2x$. For the total derivative however, we have to take implict dependencies into account, giving
$$\frac{df}{dx} = \frac{\partial f}{\partial x} + \frac{\partial f}{\partial y}\frac{\partial y}{\partial x} = 2x + 1\cdot 2x = 4x.$$
Comment: Regarding the second case, since $f$ ultimately depended on $x$ and $z$, should we have $\frac{\partial f}{\partial x}$ instead of $\frac{df}{dx}$ in the right hand side of the last equation? If so, the notation $\frac{\partial f}{\partial x}$ is meaning two things: one is the total derivative with respect to $x$ and the other is the partial with respect to $x$, right?
Comment: @Kun I dont' see any $\frac{df}{ dx}$ in the rhs of the last equation. The answer to your question is that there are different notations for the total derivative and the partial derivative. $\frac{\partial f}{\partial x}$ is the partial derivative, and $\frac{df}{dx}$ is the total derivative. They only are equal if there is no implicit dependence on the variable in the function.
Comment: But one classic textbook says under the condition that $f$ depended on two independent variables, we should write $\frac{\partial f}{\partial x}$ to stand for the total derivative. This is because $f$ does not soely depent on $x$. But if so, we have the problem of using one notation for two different meanings. Do you see what I am saying?
Comment: @Kun not really because I cant believe someone would define $\frac{\partial f}{\partial x}$ to be the total derivative, as it is universal notation for the partial derivative (it's even in the latex commands). Which textbook are you referring to?
Comment: Stewart's calculus


Silex token authentication

Question: I create my first app with silex. Only logged in users can use the app. In the first page i create a login form, so the user can authenticate. My security provider look like:
<code>$app->register(new Silex\Provider\SecurityServiceProvider(), array(
        'security.firewalls' => array(
            'secure_area_edison' => array(
                'pattern' => '^/admin/',
                'form' => array('login_path' => '/', 'check_path' => '/admin/login_check'),
                'logout' => array('logout_path' => '/admin/logout', 'invalidate_session' => true),
                'users' => function () use ($app) {
                    return new App\Services\UserProvider($app['db']);
                },
            ),
        )
    ));
</code>
Every url after '/admin' require that the user was successfull authenticated. Everything works fine and now i want to extend my app with an API. I create a new controller which retrieves data from database and return a JSON reponse, this work also fine.
But how can the user authenticate for this API? Should i create a new column in my user table like "hash" or "token"? Users which will retrieve the JSON Response must send the token in every get request, is this the correct way?
The url can look:
<code>/admin/api/allProducts/token/<TOKEN>
</code>
Answer: you should use token base authentication instead of passing token in every get request.
refer : https://github.com/thcolin/silex-simpleuser-jwt

Silex token authentication


Can I write " The bag is black colour?"

Question: We know that "The bag is black." is a correct sentence.
But, a lot of people write "the bag is black colour". Is this sentence grammatically wrong or acceptable?
Comment: @tchrist Judging by the user name, I would guess Ming is Chinese. While I've never actually heard anyone use _black colour_ as an adjective either, even by Chinese people, it would be a very understandable error to make for a Chinese person, since all colour terms (noun or adjective) frequently take _色 sè_ 'colour' (by itself only a noun) at the end. So _包是黑(色)的 bāo shì hēi(sè) de_ 'the bag is black' is equally correct and common with and without the extra word 'colour'. To someone whose English is limited, a direct translation is easily imaginable and I'm sure quite common.
Comment: What proof do you offer that "a lot of people" write that wrong version?  I've never seen it.
Comment: Well, if you want to use both "black" and "color", you'd have to say "the bag is black *in* color", or "the bag is *a* black color" (which suggests it isn't perfectly black, but a kind of black; this construction works better for less absolute colors, like pink or orange), or "the bag's color *is* black". But even with these adjustments which make the sentence *grammatically* correct, *stylistically* it's still very clunky, and *logically* irkingly redundant.
Comment: This is very common among non-native speakers because it is the natural way to express in their native tongue. It's incorrect in standard English, both grammatically as well as technically.
Answer: Grammatically wrong.
Your first (valid) example of "The bag is black" uses 'black' as an adjective.
It would also be valid to say "The bag is black coloured"; here the word 'black' is used as a noun modifier for the adjective 'coloured'.
Also idiomatic would be "The bag is black in colour" ('black' as adjective, 'colour' as noun).
"The bag is [or has] a black colour" is also fine, as 'black colour' acts as a compound noun being used to express a quality, property or relationship of the bag (similar to "The tube is a cylinder", "The car has a door", "The man has a child").
But in "The bag is black colour" you're saying the noun and the compound noun are equal, which they are not.
Answer:
*The bag is black colour

This sentence is ungrammatical. The reason is that colour is a singular countable noun. Singular, countable nouns in English must have a determiner:

*I have pen
I have a pen/ the pen /my pen/ this pen/ one pen/ John 's pen / which pen/ any pen

So you can say:

The bag is a black colour

or you could use the adjective coloured

It's black coloured.

However, neither of these is very good style, because everybody knows that black is a colour!
Comment: *Black is the colour of my true love's hair...*
Comment: @Araucaria: 1) You're welcome. 2) Put the asterisk directly before the first letter of the sentence, no space. That's the linguistic convention; it apparently also defeats the formatting favor that the software would otherwise do for your convenience. It's much harder to arrange when you're using italics for examples, which is also the linguistic convention.
Comment: @John, 1) thanks for the edit. 2) How'd you make the asterisk come out as an asterisk instead of a bullet point, which is what always happens to me?
Answer: 'The bag is black colour' is not grammatically acceptable I'm afraid and I would suggest;

'The bag is black in colour'

However, stating

'The bag is black'

is also fine, because black infers it is the colour of the bag that you are describing
Comment: @Chenmunka: it's quite an explicit statement, so little is implied. If I would say _the bag is coated in sooth_, it _implies_ that it is black.
Answer: The usage is not right. More appropriate usage would be something like

The bag is of the color, black.

or instead just use,

The bag is black in color.
Comment: The comma in your first example is superfluous.  It would not be normally be present.

Can I write " The bag is black colour?"


MySql query returns null on ocassions

Question: I'm not sure what exactly is causing this but on occasions a mysql query that I know has to return results will sometimes return null as a result. I've seen this happen twice before but as I couldn't find anything in the error log I just updated everything and just assumed it should be ok now, but I just recently saw the same error happen again. Is there any reason why Mysql would return null as a result even when the query should return an actual value?
At the moment I'm kind of stumped and my best guess would be maybe data corruption? Can't find much on google about this issue so I decided to ask for advice before I go off buying a new hard disk for my computer. Any insight you can give me into this problem will be greatly appreciated, thanks!
Answer: Sorry for posting this is an answer, my reputation is not high enough to post a comment.
Without more details on your query it will be difficult to give an answer.
If the query is something as simple as "select * from table" then it would be strange to get random nulls.
If your query is using some kind of where clause it could be that your query is randomly using the wrong value. You should try catching the null responses and logging the query that you just tried to run.
Comment: I know the query is not the issue, otherwise it wouldn't work at any point in time, the query does depend on a variable being passed to the script, however, other queries that use this same variable are executed in the script successfully before the query that fails, well, fails. Still have no idea what is causing it, waiting for it to happen again now that I have the general log enabled
Comment: I still advocate adding some logic to detect the null case and logging lots of information about the variables, query, values, etc. The query log may not show anything more than that something is null. And if you are waiting a long time for the next error, you'll be waiting twice as long for the second one.
Answer: Your best bet is to enable the general query log and then inspect both the query log and the error log when you receive an unexpected NULL result. To enable the general log, set this in the [mysqld] section of your my.cnf.
general_log_file = /path/to/query.log
general_log      = 1

Keep in mind that unlike the binlog, all queries are written to the general log, even SELECT queries, so the log can consume a lot of space. So if you do this, keep an eye on things.
Additionally, check the output of dmesg for any filesystem-related errors.
Comment: I've enabled general logs already. I'm waiting for the error to happen again so I can see if there is anything useful there, the thing is this error happens very rarely, so I'll be waiting a while. I checked dmesg and can't find anything interesting there either, the only line I could find relating to mysql was this (although I'm pretty sure that's normal apparmor behaviour): type=1400 audit(1462745659.434:82): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="/usr/sbin/mysqld" pid=8917 comm="apparmor_parser"
Answer: Ok so I have figured this one out. Mysql was not the problem as I had initially suspected. The php script that is executed returns an xml file, and I was using firefox to run the web app that executes this script via an ajax request. Turns out firefox seems to have a bug that sends multiple ajax request when it is dealing with xml files, which was causing the database to update and then when the second request came in the result was null (the update would render the query's results as null). I have fixed this by making sure that each request is unique.
Thanks for the help everyone!

MySql query returns null on ocassions


Does the Parker Solar Probe mission investigate the flow of currents near the sun?

Question: Does the Parker Solar Probe mission investigate the flow of currents near the sun? If so, were equivalents of Birkeland currents detected? What were the values of these currents?
Comment: Here is rather bulky review of Parker scientific results for the first 4 years: https://link.springer.com/article/10.1007/s11214-023-00952-4. But, readind diagonally, I could not find "currents". The authors usually tell about "waves" and "structures". One can read "Conclusions" chapter.
Comment: "The signature of the ambipolar electric field has also been clearly revealed in electron data (Halekas et al. 2021a; Berčič et al. 2021a) as a deficit of electrons moving back towards the Sun. This loss of electrons occurs more than 60% of the time inside 0.2 AU. " Could these be some equivalents of Birkeland currents?
Answer: Electric currents certainly flow in the corona. The idea that the corona is heated by electrical heating in turbulent current sheets goes back to Parker in the 1970s.  Very large currents can be inferred from the effects on the magnetic field of the sun, as large as $2.5\times 10^9 \mathrm{A}$  (source) (more than 1000 times greater than the Birkeland currents)
While the study of the electromagnetic fields in the solar corona is a prime science goal of the Parker probe, I can't find a paper that gives a new value for the magnitude of currents in the solar corona.
Also the Birkeland currents are due to the interaction of the solar wind with the Earth's magnetic field, the current flows in the solar corona are driven directly by the sun and its own magnetic field.


Compare two java property files using shell script

Question: How to compare two property files in two different folders using shell script
input can be path of the two folders?
There are multiple files in both folders and each files needs to be checked
Answer: You probably need to explain your requirements a bit more. However it's most likely you can do what you want with the diff command (with a little help from sort and/or grep).
Let's assume you have two files: a.properties and b.properties
If you simply want to know if the files are different in any way, you can use
diff a.properties b.properties

You'll get no output if they're identical or a list of differences.
If you want a comparison on a more semantic level, that is, are the two sets of properties identical, then you need to do a bit more. The files can differ textually, but mean the same thing to Java programs that use them. For example, the properties can occur in a different order. There can be blank lines, other whitespace and comments.
If this is the case, do you care if the comments are identical? They won't effect the operation of your program, but they have a meaning (and value to those reading the file). If you don't care, strip them out.
You probably don't care about blank lines as they have no meaning.
You also need to handle the following case:
a.properties:
    prop = value
b.properties:
    prop=value

Again, different textually (note the spaces around the equals) but have the same meaning in Java.
Starting simple, let's assume the properties occur in the same order.
Ignore blank lines:
diff -B a.properties b.properties

Handle random white space (eg. around the equals sign)
diff -w a.properties b.properties

Combine all of this:
diff -w -B a.properties b.properties

Strip out comments:
grep -v '^#.*$' a.properties > a.tmp
grep -v '^#.*$' b.properties > b.tmp
diff -w -B a.tmp b.tmp
rm a.tmp b.tmp

Allow for properties in a different order, strip comments:
grep -v '^#.*$' a.properties | sort > a.tmp
grep -v '^#.*$' b.properties | sort > b.tmp
diff -w -B a.tmp b.tmp
rm a.tmp b.tmp

Answer: You should look into using diff or sdiff.  I would recommend sorting your files beforehand and removing any blank lines to reduce the amount of noise; e.g.
file1=/var/tmp/foo.txt
file2=/var/tmp/bar.txt

sort ${file1} | grep -v '^$' > ${file1}.tmp
sort ${file2} | grep -v '^$' > ${file2}.tmp
sdiff ${file1} ${file2}

Comment: @Adamski - what about comments in the property files?
Comment: this will show differences between comments as well
Comment: @StephenC - grep -vE "^$|^#" will work for you
Answer: For semantic comparison, better use PropDiff.
Usage: [flags] properties-file1 properties-file2 [-f filenameOrPathPrefixForResults]
   flags:
     -c  property settings that are common to both p1 and p2, where p2 take precedence
     -u  union p1 and p2 where p2 has higher precedence
     -1  properties settings that are only in p1
     -2  properties settings that are only in p2
     -d  intersection of properties in p1 and p2 that have different values
     -e  intersection of properties in p1 and p2 that have equal values

Answer: comm is a useful utility. It can tell you what's in file1 and not in file2, what's in file2 and not in file1, and what's common between the two files. It requires the two files to be sorted first.
I upvoted @antispams PropDiff answer since it seems to be exactly what you're asking for.
Answer: Try to use diff program, calling "diff /path/to/first/file /path/to/second/file" and cat a grep them. For special uses of diff (if you need anything special), try to search man diff.
Answer: Depends on what you want. Is a different comment a difference? Whitespace? Order? I think easiest would be a small groovy script. Is this an option? If no, make sure to strip comments abd whitespaces and sort the output before using diff
EDIT: while it's possible to let diff ignore whitespace, I'm not sure whether this is what you want as whitespace might be part of a properties value
Answer: This Groovy allows you to diff two properties file.
You can pick 2 diff modes:
1. Show properties that are missing from one another
2. Compare the values to see similarity & differences
https://gist.github.com/aimtiaz11/f786346e0c0d11a5475cfb64e84e9459
Comment: please add relevant parts of your link here
Comment: Every part in that link is relevant. You will need to put the groovy script where the properties files are and then run it. The setup steps are detailed there along with the actual script.
Answer: See another PHP code to diff properties files on my blog:
php list_missing_properties.php "file1.properties" "file2.properties"


Is $\ell^1$ complete with this norm?

Question: For $x \in \ell^1$ we set $\Vert x\Vert = \sup\limits_{N \in \mathbb{N}}|\sum\limits_{n=1}^{N}x_n|$.
One can easily see that this is a norm on $\ell^1$. I was wondering if this space is now complete. I tried finding an absolutely convergent series that does not converge, but I did not find anything.
Answer: The space $\ell^1$ is not complete with this norm. To find a counterexample, you may consider the sequence of sequences $x_n \in \ell^1$ defined for $n \ge 1$ by
$$x_n = (x_{n,k})_{k \ge 1} :=  \left( \frac{(-1)^k}{k}\right)_{1 \le k \le n}$$
and
$$x = (x_k)_{k \ge 1} := \left( \frac{(-1)^k}{k}\right)_{1 \le k}$$
Note that we have $x_n \in \ell^1$, but $x \notin \ell^1$.
We may check the sequence $(x_n)_{n \ge 1}$ converges to $x$ with regards to the norm $\| \cdot \|$. Indeed, let $\epsilon > 0$. We have
$$\left|\sum_{k = 1}^N x_{n,k} - x_{k}\right| = \left|\sum_{k = n+1}^{N} \frac{(-1)^k}{k} \right|$$
and since the series $\sum_k \frac{(-1)^k}{k}$ is convergent, we may find $n_0$ such that all those partial sums are smaller than $\epsilon$ for every $n \ge n_0$. Which gives us $\|x_{n}-x\| \le \epsilon$ for $n \ge n_0$. From this, we can deduce that $(x_n)_{n \ge 1}$ is a Cauchy sequence in $\ell^1$, but it has no limit in $\ell^1$.
Comment: this has not much to do with the question, but do you know if this norm has a name ?
Comment: This norm is essentially the $\ell^{\infty}$ norm for series. Given some sequence $x = (x_k)_{k \ge 1}$ let us denote $\sum x = \left(\sum_{i = 1}^k x_i\right)_{k \ge 1}$ for the associatied series. Then we have :

$$\|x\| = \left\|\sum  x\right\|_{\infty}$$

The space of bounded series (which contains $\ell^1$) is complete for this norm, but $\ell^1$ is not closed inside of it (so it was possible to take a sequence of $\ell^1$ whose limit was not in $\ell^1$).

Is $\ell^1$ complete with this norm?


AC current probe readings connected to an oscilloscope

Question: I have a Fluke clamp on reading a 11 amps on for an AC load.
I bought two different AC-DC current probes for the scope.
The DC readings are great and match dc loads.
When reading the AC load for the 11amps on the scope, I get 160mv peak or 320 peak to peak.
The probe claims 40amp scale use 1mv=100ma.
This gives me 16,000ma peak or 32,000ma peak to peak.
How does this calculate to 11amps?
Answer: AC DMM's assume sine input and convert to RMS
so if they measure Vpp then conversion is 1/(2√2) to \$I_{RMS}=
\frac{32A_{pp}}{(2*√2)}=11.3A\$

If your input is clipped it will read less than true RMS or spikes more than true RMS.

and if they measure precision FW rectified average it is converted again to RMS=Vavg x 2/π or Vavg= 0.637Vpk  or Half Wave rectified RMS=1/π * Vavg
Comment: Some DMM are true-RMS DMM and don't assume a sine input. It will still be the RMS value ultimately and not Vpp.
Comment: True, If he gets what I computed can you assume I am correct. and if says TRUE RMS, they will understand "True" means independent of waveform but perhaps BW limited. Or did you think I was not aware of that?


Can I use self-levelling compound over old carpet adhesive?

Question: Can I use self-levelling compound over old carpet adhesive? I've ripped up the current carpets and found a couple of strips of very old carpet glue that are proving a NIGHTMARE to remove from the concrete. Do I have to? I'm going to use a primer, and then go about 4mm with the self leveller, and then put floating floorboards over the top of that. My real question is if the old glue will mess with the levelling compound in any way and cause me problems later. And if I do try remove, what should I use?
Comment: Self levelling compound would need to be spread over the whole floor to make it level with the strips.  If the floor is not flat( dips/humps) then go for it.  If the floor is flat, then removing those strips might be better.  What you are going to put on the floor after and what you are using to remove the glue(edit into question) will get better answers.
Answer: If that glue is totally dry and crusty then I would opt for a good mask and a belt sander.
If it's sticky then try some brake cleaner and good ventilation.
Comment: Yes, a belt sander and some heavy grit belts would get this done in a very short time.
Answer: Yes but I personally wouldn't. I had the situation as you and I chose to remove the glue as it might have contained asbestos. I suggest you rent a floor scarifier which will properly and effortless remove any protuberance - ask the supplier for an accessory for removing glue. For me (amateur), it took a day to remove the complete old leveling compound up to the concrete for 50sqm.
If you do elect not to do that, make sure you liberally use a quality primer before laying the mass


Rear sprockets not turning easily

Question: I recently bought a women's Schwinn "Clear Creek" 18-speed mountain bike at a yard sale.  The rear derailleur is broken, and the rear sprockets are rusty and don't turn easily against the wheel.  I think I can replace the broken derailleur, but what should I do about the rear sprockets?  I'm not so worried about the visible rust as I am about the fact the there is such resistance when I turn them freely against the wheel.  Should I remove them and grease them somehow? Are there bearings in them that can be replaced?
Comment: My guess is that an 18 speed mountain bike uses a freewheel, so if the problem is in the freewheel unit, you'd get a whole new freewheel. It is a BSO, so don't stick too much money in it. If its too much friction in the wheel itself, you can try repacking the bearings and or adjusting the hub.
Comment: Are you handy with tools?  Are you prepared to get a bit dirty and invest some time?   I think you need to get the rear wheel off, and remove the freewheel or cassette to see what its like.

Worst case, you now own a parts donor bike.
Comment: All you can do is take it apart and see what's broken.
Comment: Note that one very likely cause of this is trash caught between the cluster and the hub.
Comment: Thanks, all, for your comments.  I'm still learning the lingo, though.  I just learned that when I said "sprockets" I really meant "cassette."  Still don't know what BSO means...
Answer: Rusty sprockets aren't typically going to be an issue. As long as the teeth aren't too worn in, then the cogs themselves will be fine. However, if the cogset (likely a freewheel) itself is having difficulty rotating, it's likely the grease in the ratcheting mechanism has seized up, or the pawls are broken or faulty.
The internals of the freewheel might "wake up" if you try taking it for a spin, but it also might just be busted.
While servicing freewheels can be difficult, it is possible and the late Sheldon Brown could explain the process better than I could. The information is a little dated though, and might not be applicable to the part you have on hand.
Freewheels are a fairly inexpensive part, though there are some tools you'll need to remove the old one to put a new one on. If you don't have them and aren't willing to invest, your local bike shop would be able to mount it.
The busted derailleur is something you can probably handle, since that's usually just a couple of bolts to mount it. Watch out for the derailleur hanger though, since that's often damaged before, or with, the derailleur itself.
Something to keep in mind is that if your cogs are rusted, your cables might not be in great shape either. Look them over and pull on the brake levers. If they're unresponsive, stiff, or slow to retract, they'll likely need replacement. Gear cables will cause trouble with shifting.
Good luck and happy wrenching!

Rear sprockets not turning easily


Could charm, bottom, and even top matter form under the right circumstances?

Question: Strange matter forms because turning some of the down quarks into strange quarks unlocks lower energy levels, and this can lower the system's overall energy at high densities. If the density was pushed higher and higher, could this process repeat for charm, bottom, and top quarks? I'm not suggesting this could happen outside the hypothetical realm--anything that could create the density required for this to happen would probably collapse into a black hole.
Comment: It seems to me that your answer depends strongly on the conditions under which strange matter could form. Remember that "never" remains a possibility for long-lived strange matter.
Comment: In "principle", yes--what is your concern?
Answer: If you google "strange matter in cosmological models" , you will see a number of references for papers calculating this with various models. From the latest:

In this paper, we have examined the Kantowski–Sachs space-time in the presence of strange quark matter with the appearance and non-appearance of strings in f(R) gravity. Here, R is the Ricci scalar of the space-time. Exact solutions of the field equations are obtained by considering the following conditions (i) hybrid scale factor, (ii) the proportionality of shear scalar (σ) with expansion scalar (θ) and (iii) power-law between the scalar-on function F(R) and average scale factor a(t). We have investigated some physical and geometrical properties of the models, and their behavior is thoroughly studied with the help of graphical representation

Highly technical calculations allow the answer to be "yes" it could exist in the timeline of the present cosmological model. A density graph can be seen here .


Meaning of prefix length with ip addr add noprefixroute

Question: When assigning an ip address to a network interface with ip addr add noprefixroute, what effect will the specified prefix length have? When noprefixroute is not used, the prefix length is used to automatically create and delete a route for the network prefix of the added address. Does it have any function other than that?
For example, what is the difference between
ip addr add noprefixroute 10.137.0.36/16 dev eth0

and
ip addr add noprefixroute 10.137.0.36/32 dev eth0

?
Answer: Indeed there doesn't appear to be much useful difference, but there's at least one: the way a secondary address is handled won't change, whether a route is added or not.
When a 2nd address is added to the same interface as an other address with the same netmask within the same network, it's classified as a secondary address. When the first address (primary, without the secondary property) is removed, all other matching addresses in the same IP LAN, all secondaries, are also removed.
Example:

from scratch:
# ip addr flush dev eth0

add the main address (the first):
# ip addr add noprefixroute 10.137.0.36/16 dev eth0

add an other address within the same IP LAN, using the same netmask
# ip addr add noprefixroute 10.137.0.42/16 dev eth0

check current state
# ip route
# ip addr show dev eth0
2: eth0@if10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 0e:00:00:74:02:fd brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.137.0.36/16 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet 10.137.0.42/16 scope global secondary noprefixroute eth0
       valid_lft forever preferred_lft forever

remove primary (first) and witness 2nd gone too
# ip addr del 10.137.0.36/16 dev eth0
# ip addr show dev eth0
2: eth0@if10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 0e:00:00:74:02:fd brd ff:ff:ff:ff:ff:ff link-netnsid 0

This wouldn't have happened with two /32 because they would both be considered primary addresses (Using /32 they are not part of the same IP LAN). By the way, there's a parameter to promote a secondary as primary instead of deleting all secondaries: promote_secondaries.
Conclusion: noprefixroute affects creation of routes, but not other properties linked to addresses.
I don't know if there are more visible differences. Maybe something can be found with ARP when settings such as arp_ignore or arp_announce are changed from their permissive default: unlike arp_filter their description is about addresses, not routes.
Comment: You should also check this Q/A where the answer addresses a more common difference (use of broadcast) than the one I mentioned here: https://unix.stackexchange.com/questions/769210/how-exactly-does-linux-use-the-prefix-length-assigned-to-network-interface


Can I mix tie dye into wall paint?

Question: Can you mix white wall paint and tie dye you use for clothes? I want to paint my walls different colors but the only thing I have is white paint and found some tie dye you use for clothes and it's permanent so I was thinking you could do it. That should work, right?
Comment: paint!=fabric, so i doubt it will work (ph balance, emulsify, non-fading, etc).
Comment: You might be disappointed with how little the dye colors your paint. It takes a substantial quantity of actual paint dye to get anything close to bold coloration. It's not like dying fabric, wherein you're not diluting the dye a thousandfold.
Comment: "Tie dye" is a process, not an additive. At least, it used to be. Tie the cloth in knots and dye it. The dye doesn't penetrate into the knotted parts. So, no, you can't tie dye a wall.
Answer: Not a hard no but you may want to reconsider for a few reasons:

As @dandavis pointed out - the compounds may not work well together.  This could cause long term negative effects.  OTOH it might not.
The hand mixing of paint will take a lot of mixing to get it even.  However, if you're going for a tie-die look this might work in your favor (but probably not)
All paint is sold as white - the paint store will happily, for free (usually) make it whatever color you like at no charge and mix it for you.
Answer: I did the same thing, used procion fabric dye as a colorant. I added hot water to form a liquid and it colored the paint very well however when I had to paint over it, not a single water based color blocking primer worked. 8 coats later I finally resorted to the oil based Kilz with the gold label, the one that off gasses so violently that I had to wear a mask, open all the windows, and my neighbors complained...that one finally worked. The color was a dark navy blue and that didn't help but the bottom line is that it bled and bled and bled. Will never do that again. On the other hand, as an artist, I love using procion dyes to make my own alcohol inks for use in painting and in epoxy resin. Alcohol inks are very expensive. You can also use fabric dye to color concrete and plaster but it's not super UV resistant and will fade in direct sunlight. I always seal anything I've used fabric dye to color because it can still "dye" anything that touches it, long after its "dry".  As far as tinting paint, I buy the colorants from Sherwin Williams and Benjamin Moore (Novo Color and Maixitoner) because I can tint my own paints on the fly as well as use them in resin, concrete, or put them directly into various mixing mediums. I get into artistic modes that often have me working in the middle of the night when nothing is open so I want to be able to make whatever I need right when I need it. Another fun thing to have on hand is pigment powder.
Answer: You may be able to do it, but you have to take into account some things.
White paint is filled with a lot of Titanium Dioxide, which is a VERY strong and opaque colorant.  This is going to make your colors very muted.  Fabric dyes aren't going to be strong enough to overtake this.
Next, a lot of clean colors, especially reds and yellows, have a tendency to fade with exposure to light when used in paints.  Keep this in mind.  A good green can fade because the yellow will break down over time.
So if you are ok with pastels, give it a shot, but don't expect strong colors and don't expect the particular shade you achieve to last.
A final note, this paint is going to be next to impossible to match perfectly.  Contents of the dye may or may not react with the solids that are responsible for the sheen of your paint.  That could make touch ups look terrible even if you match the color perfectly.
Answer: My daughter added purple clothing dye to my white paint and painted 3 walls in her room....she moved out and I repainted. I am still painting... About 8 coats later and the walls now look pink and splotchy.  Bad idea...DONT DO IT
Answer: I Found this thread because (obviously) I was contemplating the same thing. However, I don't plan to use it on the walls. I was going to make chalkboard paint and I've done it with craft acrylic paints, but I think a nice matte or eggshell latex would be better. More durable. And I'm only applying it to hardboard. I have used fiber reactive (non-brand procion) for lots of things. To refill my printer ink (works pretty killer if you have PURE turquoise, lemon yellow and fuschia. These colors are not mixed so therefore don't split and feather) Ive used it to refinish wood (Also killer. I'll try to attach a pic of that) to dye fabric of all types, including protein based like silk and wool which is not specifically meant to be used on such fibers, but a little citric acid and a microwave makes magic on silk. I'm contemplating a more permanent purple on my hair... Just the ends that keep washing out. Tinting stone or brick and bleach will make it disappear if it's not right or you spill it on concrete. Honestly the possibilities are endless. Even plastic with the right chemical compound. I want to try it in electroplating. I have pounds of the stuff to F*** around with.
Anyway, if I can find this place again, I'' show you how my latex chalkboard paint turns out. I'm going for a very deep violet shade, so I can't think of anything better than dye to get it there. But yeah, never on the walls. I have seen that first hand by accident on a small splash. That stuff don't mess around. And latex being water base is the perfect vessel in which to travel through coats unless it's been properly sealed.
Comment: As it's currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).

Can I mix tie dye into wall paint?


No boot menu after installing Ubuntu 11.10 on a Dell Windows Vista Home laptop computer?

Question: I just installed Ubuntu 11.10 on a friends Dell Inspiron laptop.  I normally boots up to Windows Vista Home Edition.  As part of the install procedure I reduced the size of the largest ntfs partition to allow space for an ext4 root partition and a small swap partition.  After the install completed it prompted to restart and what followed was a reboot with Windows coming back up without any multiboot menu screen.  Where is the grub boot menu?
Answer: You'll need to install GRUB manually. To do that you'll have to boot up using a live CD then do the following:

Setup a chroot environment.
open a terminal and mount the root partition to /mnt
sudo mount /dev/sdXy /mnt

sdXy being the root partition of your installed ubuntu, e.g. /dev/sda5. you can find that out using
sudo fdisk -l

next, mount some virtual devices
 sudo mount -bind /dev /mnt/dev
 sudo mount -bind /proc /mnt/proc
 sudo mount -bind /sys /mnt/sys

chroot into the installed system
sudo chroot /mnt
finally, (re)install GRUB
grub-install --recheck /dev/sdX
sdX is the internal hard drive, probably /dev/sda
and while we're at it, we may as well update it, too.
update-grub

if there were no errors during the installation, you can type "exit" to leave chroot nd then simply reboot the computer. you should then be able to boot both windows and linux.


How does a typical http(s) load balancer work?

Question: I know that there are some situations that we encounter heavy http(s) load on a server and we should use a load balancer to distribute load among several back-end servers.
But I've a confusion here! Lets suppose that too many users (lets say 100,000) are trying to access simultaneously to example.com:80 and a load balancer (e.g Apache mod_proxy_balancer or any other stand-alone load balancer) wants to distribute this load among several back-end servers, but still all traffic has to be passed across the front-end server which brings about a heavy traffic on that server & even though all the requests are parsing at back-end servers, front-end server still have to manage them (suppose that in best case it has to create a single unique thread for every request which causes this server simply crash after creating 100,000 threads at a moment!).
Now my question (that may sounds funny to an expert!) is that how a load balancer can handle such situation? In other words, how front-end server can establish a link directly between clients & back-end servers without having to tolerate such heavy network load? (I know in this situation we can't call back-end servers really 'back-end'! but assume that its OK for now) Does this scenario need any application-specific alter? (e.g. in order to simply redirect clients with http Location header to other servers)
Answer: This depends on the purpose of the load balancer i.e. what type of workload it's supposed to balance. The reverse proxy based HTTP(S) load balancers are distributing the load between application back-ends generating the content.
Reverse proxies are not trying to balance network load, and compared to all the tasks dynamic applications do, passing network traffic (and possibly serving static content) is a relatively simple task.
For example, database access can be load balanced, too. Most of the database queries involves only reading from the database, so while writes needs to be replicated immediately across all the database servers, reads can be distributed evenly.
Network load balancing is a different area. For example, one common method for balancing (network) load between cluster servers is round-robin DNS records, where the same hostname simply has more than one A records.
Comment: A smart load balancer can always choose the same back-end for the same client. Among many other designs. This is just a quick overview. :)
Comment: To add, There is also the redundancy aspect together with the load sharing aspect. A load balancer can allow backend nodes to go offline, without impact to end users if the application allows it. Moving the same thought up one layer brings the focus to load balancer redundancy: two or more load balancers may share a common cluster address, providing both load sharing and redundancy at the load balancer layer itself. This answers the 100,000 threads part.
Comment: Yup.  Of course, if you have some webapp that is using sessions or similar to store data - authentication status, profile info, etc - then those need to stay on the same server instance, OR you need to use a centralized db for all of the servers (or both).  So another possibility is to have one A record, which then redirects randomly (or in round robin order) to different hostnames that all serve the same content. User goes to example, is redirected to ww2.example or ww32.example or whatever and then stays there for the duration of their session.


Magento 1.8 Payment methods

Question: We need to show the payment method based on stores. We have 4 type of payment methods(ICICI,HDFC, Paypal,Authorize.net ).
Our client request to show payment based on stores (Store1,Store2). We also checked in admin panel, there is only set country based payment method.
We need show the payment method of stor1 is ICICI and HDFC.
And Stor2 is Paypal and Authorize.net.
How to  do this?
Answer: When you log into the admin section and navigate to the payment methods part of the configuration you will see that most payment methods have a flag "Is Active".
You will also see that on the left hand side you can switch to different store levels for setting store specific configuration.
Sadly though most payment types only have the active flag allowing to change on a website level and not a store level.
You could try updating these payment methods so that they have the flag <show_in_store>1</show_in_store> and this should then allow you to update the active flag for each payment method on a store level.

Magento 1.8 Payment methods


Prove that we can express any permutation as a product of permutations of the form $(12)(13)...(1n)$

Question: I know that any permutation can be written as a product of transpositions. Does that complete the proof? I don't think so, because suppose we need $2\rightarrow 3$, we can't write that in the form $(1n)$.
Answer: As you've correctly stated, any permutation can be expressed as a product of transpositions. Then, as long as we can generate any transposition, $(kl)$ from a product of the form, $(12)(13)...(1n)$, we can write any permutation as some product of $(12)(13)...(1n)$. Consider, $$(kl)=(1k)(1l)(1k),$$ which is indeed a product of transpositions of the form, $(1n)$.
Comment: Thanks! So basically, if we have a particular permutation, then as long as we can generate the transpositions needed to write it as a product of those transpositions, we're good?
Comment: Yes. That is how it works. Consider some permutation which can be written as $(k_1l_1)(k_2l_2)(k_3l_3)...(k_nl_n)$. As long as we can generate all of these transpositions with products of the form $(1n)$, we can generate the original permutation.


Recommendations for music games for children

Question: Can anyone recommend some good music games for small children? I thought something like a virtual piano or drum, but with a very simple GUI. My girls are three and six, and they already love to play tuxpaint, I am looking for something similar for music.
Answer: Probably a bit too much for a 3 year old but your 6 year old might like Frets on fire !
A game of musical skill and fast fingers. The aim of the game is to play guitar with the keyboard as accurately as possible.
Players must press buttons to keep in time with the rhythm of the music, shown by markers on screen. An official online high score list allows players to show off their skills to competitors around the globe.
The game comes with an easy to understand tutorial to get players started, and a song editor lets players edit and compose songs for use in the game.

What 6 year old does not like buttonbashing? :D
You should get an old keyboard though!
Comment: Yeah, get an old keyboard or you may find that some keys don't work after :)
Comment: I actually play this myself. Good pick! And good advice about an old keyboard.
Answer: A good children orientated distro is doudoulinux.
One of there recommended young children applications is a virtual keyboard such as this:

You can play this virtual keyboard with the keys of your computer.
Similarly - but I think better is Drumstick Virtual Keyboard (from the software center) which you can easily make a full screen keyboard by double clicking the title bar.

DrumStick Piano Keyboard
Install the following software packages from the Software Center:

DrumStick Piano Keyboard
timidity

Run DrumStick and connect to timidity by the menu option "Edit - Output Tab - Timidity:0"
Virtual Keyboard ## .
Install the following software packages from the Software Center:

Virtual Midi Keyboard
aconnect
timidity

To connect the virtual keyboard to play sounds via the timidity synth:
timidity &

run the virtual Midi Keyboard app
vkeyd &

and then connect the two pieces of software together
aconnect 129 128

Obviously you could script this together to run from a desktop icon.
Comment: I tried out DrumStick Piano - my six year old loves it. I also installed DrumStick Drum Grid, she is having a lot of fun. I have seen Doudoulinux before, I think I am going to put it on an old PC for the kids.
Answer: There is a game where you mimic the notes of an alien craft.  It's called "Ninth Kind", and you can download the deb package of it here here.  There is also a game called "Simon clone" that is a much simpler version of this game.  It's deb package is found here.  And there is a little noise maker that is fun to mess around with and is also very simple called "Pitch Perfect" a deb package of it is found in the music section.
Answer: there is a good game called Audiosurf. It can be installed via Steam. How-to: Steam under Linux


Skip List vs. Binary Search Tree

Question: I recently came across the data structure known as a skip list. It seems to have very similar behavior to a binary search tree.
Why would you ever want to use a skip list over a binary search tree?
Comment: Scalability. See [A Provably Correct Scalable Concurrent Skip List](https://www.cs.tau.ac.il/~shanir/nir-pubs-web/Papers/OPODIS2006-BA.pdf) and Search ["skip list" concurrent](https://www.google.com/search?q="skip+list"+concurrent&oq="skip+list"+concurrent) which shows a [1,024 intel Threading Challenge 2010 entry](https://sites.google.com/site/1024cores/home/parallel-computing/concurrent-skip-list).  The more flat shape of a skip-list makes concurrent changes easier and simpler.
Answer: Skip lists are more amenable to concurrent access/modification.  Herb Sutter wrote an article about data structure in concurrent environments.  It has more indepth information.
The most frequently used implementation of a binary search tree is a red-black tree.  The concurrent problems come in when the tree is modified it often needs to rebalance.  The rebalance operation can affect large portions of the tree, which would require a mutex lock on many of the tree nodes.  Inserting a node into a skip list is far more localized, only nodes directly linked to the affected node need to be locked.
Update from Jon Harrops comments
I read Fraser and Harris's latest paper Concurrent programming without locks.  Really good stuff if you're interested in lock-free data structures.  The paper focuses on Transactional Memory and a theoretical operation multiword-compare-and-swap MCAS.  Both of these are simulated in software as no hardware supports them yet.  I'm fairly impressed that they were able to build MCAS in software at all.
I didn't find the transactional memory stuff particularly compelling as it requires a garbage collector.  Also software transactional memory is plagued with performance issues.  However, I'd be very excited if hardware transactional memory ever becomes common.  In the end it's still research and won't be of use for production code for another decade or so.
In section 8.2 they compare the performance of several concurrent tree implementations.  I'll summarize their findings.  It's worth it to download the pdf as it has some very informative graphs on pages 50, 53, and 54.

Locking skip lists is insanely fast.  They scale incredibly well with the number of concurrent accesses.  This is what makes skip lists special, other lock based data structures tend to croak under pressure.
Lock-free skip lists are consistently faster than locking skip lists but only barely.
transactional skip lists are consistently 2-3 times slower than the locking and non-locking versions.
locking red-black trees croak under concurrent access.  Their performance degrades linearly with each new concurrent user.  Of the two known locking red-black tree implementations, one essentially has a global lock during tree rebalancing.  The other uses fancy (and complicated) lock escalation but still doesn't significantly outperform the global lock version.
lock-free red-black trees don't exist (no longer true, see Update).
transactional red-black trees are comparable with transactional skip-lists.  That was very surprising and very promising.  Transactional memory, though slower if far easier to write.  It can be as easy as quick search and replace on the non-concurrent version.

Update
Here is paper about lock-free trees: Lock-Free Red-Black Trees Using CAS.
I haven't looked into it deeply, but on the surface it seems solid.
Comment: @deft_code: Intel recently announced an implementation of Transactional Memory via [TSX](http://software.intel.com/en-us/blogs/2012/02/07/transactional-synchronization-in-haswell) on Haswell. This may prove interesting w.r.t those lock free data structures you mentioned.
Comment: Not to mention that in a non-degenerate skiplist, about 50% of the nodes should only have a single link which makes insert and delete remarkably efficient.
Comment: @Jon, yes and no.  There are no known lock-free red-black tree implementations.  Fraser and Harris show how a transactional memory based red-black tree is implemented and its performance.  Transactional memory is still very much in the research arena, so in production code, a red-black tree will still need to lock large portions of the tree.
Comment: Rebalancing does not require a mutex lock. See http://www.cl.cam.ac.uk/research/srg/netos/lock-free/
Comment: @JuanBesa, _"14% better than the best known concurrent dictionary solutions"_.  Are you comparing against skip-lists?  The other paper inadvertently points out that lock based trees are `O(n)` for n < 90, whereas skiplists (also a dictionary) are `O(1)`!  14% doesn't seem to be enough when the `O` is that disparate.
Comment: I think [Fizz' answer](https://stackoverflow.com/a/28270537/1847419) is more up-to-date (from 2015) rather than this answer (2012) and therefore should probably be the preferred answer by now.
Comment: I wanted to update this answer. There are currently two lock based efficient binary search trees. One is based on AVL trees (http://dl.acm.org/citation.cfm?id=1693488) and the other (Warning! shameless plug) is based on red black trees. See http://www.actapress.com/Abstract.aspx?paperId=453069
Comment: Any comment on [Respawned Fluff's recent answer](http://stackoverflow.com/a/28270537/15055)?
Comment: Think I'm going to try to apply that basic mechanism to AVL.  As I see it from a quick read, the basic solution to rotation (which is the fundamental problem) is to have a retry-block which is the raising of flags in the elements you need to control - if you can raise them all, then you're safe to proceed as other threads will fail and be retrying to get those flags.  Simple genius!
Comment: @BlankXavier, Hmmm, that sounds suspiciously like using a spinlock instead of a mutex for a regular lock based tree.  It may be more performant, but I want to see some benchmarks.  In particular against the a lock-free skiplist and a locking skiplist.
Comment: All helper mechanisms are essentially spinning mechanisms - it's just that rather than dumbly spinning, which performs no work, by spinning on a helper mechanism *which if it completes permits you to continue your own work*, then you're doing something useful - you're lock-free, in fact...
Answer: First, you cannot fairly compare a randomized data structure with one that gives you worst-case guarantees.
A skip list is equivalent to a randomly balanced binary search tree (RBST) in the way that is explained in more detail in Dean and Jones' "Exploring the Duality Between Skip Lists and Binary Search Trees".
The other way around, you can also have deterministic skip lists which guarantee worst case performance, cf. Munro et al.
Contra to what some claim above, you can have implementations of binary search trees (BST) that work well in concurrent programming. A potential problem with the concurrency-focused BSTs is that you can't easily get the same had guarantees about balancing as you would from a red-black (RB) tree. (But "standard", i.e. randomzided, skip lists don't give you these guarantees either.) There's a trade-off between maintaining balancing at all times and good (and easy to program) concurrent access, so relaxed RB trees are usually used when good concurrency is desired. The relaxation consists in not re-balancing the tree right away. For a somewhat dated (1998) survey see Hanke's ''The Performance of Concurrent Red-Black Tree Algorithms'' [ps.gz].
One of the more recent improvements on these is the so-called chromatic tree (basically you have some weight such that black would be 1 and red would be zero, but you also allow values in between). And how does a chromatic tree fare against skip list? Let's see what Brown et al. "A General Technique for Non-blocking Trees" (2014) have to say:

with 128 threads, our algorithm outperforms Java's non-blocking skiplist
  by 13% to 156%, the lock-based AVL tree of Bronson et al. by 63% to 224%, and a RBT that uses software transactional memory (STM) by 13 to 134 times

EDIT to add: Pugh's lock-based skip list, which was benchmarked in Fraser and Harris (2007) "Concurrent Programming Without Lock" as coming close to their own lock-free version (a point amply insisted upon in the top answer here), is also tweaked for good concurrent operation, cf. Pugh's "Concurrent Maintenance of Skip Lists", although in a rather mild way. Nevertheless one newer/2009 paper "A Simple Optimistic skip-list Algorithm" by Herlihy et al., which proposes a supposedly simpler (than Pugh's) lock-based implementation of concurrent skip lists, criticized Pugh for not providing a proof of correctness convincing enough for them. Leaving aside this (maybe too pedantic) qualm, Herlihy et al. show that their simpler lock-based implementation of a skip list actually fails to scale as well as the JDK's lock-free implementation thereof, but only for high contention (50% inserts, 50% deletes and 0% lookups)... which Fraser and Harris didn't test at all; Fraser and Harris only tested 75% lookups, 12.5% inserts and 12.5% deletes (on skip list with ~500K elements). The simpler implementation of Herlihy et al. also comes close to the lock-free solution from the JDK in the case of low contention that they tested (70% lookups, 20% inserts, 10% deletes); they actually beat the lock-free solution for this scenario when they made their skip list big enough, i.e. going from 200K to 2M elements, so that the probability of contention on any lock became negligible. It would have been nice if Herlihy et al. had gotten over their hangup over Pugh's proof and tested his implementation too, but alas they didn't do that.
EDIT2: I found a (2015 published) motherlode of all benchmarks: Gramoli's "More Than You Ever Wanted to Know about Synchronization. Synchrobench, Measuring the Impact of the Synchronization on Concurrent Algorithms": Here's a an excerpted image relevant to this question.

"Algo.4" is a precursor (older, 2011 version) of Brown et al.'s mentioned above. (I don't know how much better or worse the 2014 version is). "Algo.26" is Herlihy's mentioned above; as you can see it gets trashed on updates, and much worse on the Intel CPUs used here than on the Sun CPUs from the original paper. "Algo.28" is ConcurrentSkipListMap from the JDK; it doesn't do as well as one might have hoped compared to other CAS-based skip list implementations. The winners under high-contention are "Algo.2" a lock-based algorithm (!!) described by Crain et al. in "A Contention-Friendly Binary Search Tree" and "Algo.30" is the "rotating skiplist" from "Logarithmic data structures for
multicores". "Algo.29" is the "No hot spot non-blocking skip
list". Be advised that Gramoli is a co-author to all three of these winner-algorithm papers. "Algo.27" is the C++ implementation of Fraser's skip list.
Gramoli's conclusion is that's much easier to screw-up a CAS-based concurrent tree implementation than it is to screw up a similar skip list. And based on the figures, it's hard to disagree. His explanation for this fact is:

The difficulty in designing a tree that is lock-free stems from
  the difficulty of modifying multiple references atomically. Skip lists
  consist of towers linked to each other through successor pointers and
  in which each node points to the node immediately below it. They are
  often considered similar to trees because each node has a successor
  in the successor tower and below it, however, a major distinction is
  that the downward pointer is generally immutable hence simplifying
  the atomic modification of a node. This distinction is probably
  the reason why skip lists outperform trees under heavy contention
  as observed in Figure [above].

Overriding this difficulty was a key concern in Brown et al.'s recent work.
They have a whole separate (2013) paper "Pragmatic Primitives for Non-blocking Data Structures"
on building multi-record LL/SC compound "primitives", which they call LLX/SCX, themselves implemented using (machine-level) CAS. Brown et al. used this LLX/SCX building block in their 2014 (but not in their 2011) concurrent tree implementation.
I think it's perhaps also worth summarizing here the fundamental ideas
of the "no hot spot"/contention-friendly (CF) skip list. It addapts an essential idea from the relaxed RB trees (and similar concrrency friedly data structures): the towers are no longer built up immediately upon insertion, but delayed until there's less contention. Conversely, the deletion of a tall tower can create many contentions;
this was observed as far back as Pugh's 1990 concurrent skip-list paper, which is why Pugh introduced pointer reversal on deletion (a tidbit that Wikipedia's page on skip lists still doesn't mention to this day, alas). The CF skip list takes this a step further and delays deleting the upper levels of a tall tower. Both kinds of delayed operations in CF skip lists are carried out by a (CAS based) separate garbage-collector-like thread, which its authors call the "adapting thread".
The Synchrobench code (including all algorithms tested) is available at: https://github.com/gramoli/synchrobench.
The latest Brown et al. implementation (not included in the above) is available at http://www.cs.toronto.edu/~tabrown/chromatic/ConcurrentChromaticTreeMap.java Does anyone have a 32+ core machine available? J/K My point is that you can run these yourselves.
Comment: I miss the importance of cpu-cache locality emphasized here. Whenever you traverse pointers in a data structure, you risk encountering a cache-miss that has a serious penalty, since data fetched from RAM is in the order of 100 times slower than cpu's local cache. That is the reason why linked list vs array-based list comparisons shifted massively in favor of array-based lists.
Answer: Also, in addition to the answers given (ease of implementation combined with comparable performance to a balanced tree). I find that implementing in-order traversal (forwards and backwards) is far simpler because a skip-list effectively has a linked list inside its implementation.
Comment: Sure, that true if you want to traverse all in one function call. but it gets much more annoying if you want to have iterator style traversal like in std::map.
Comment: isn't in-order traversal for a bin tree as simple as: "def func(node): func(left(node)); op(node); func(right(node))"?
Comment: @Evan: yes it works as long as the node parameter is cut out of the tree during a modification.  The C++ traversal has the same constraint.
Comment: @Claudiu I just saw an upvote on my answer and remembered this exchange! At the time I was entirely unfamiliar with coroutines, so I honestly didn't fully understand what you were saying. So yes, that would be a very good solution for languages that have them.

However, I do still maintain that a skip-list offers the most simple in-order traversal given that it is simply: a matter of following the `node->next` pointer :-).
Comment: @Evan :Not in a functional language where you can just write in CPS.
Comment: @Evan: `def iterate(node): for child in iterate(left(node)): yield child; yield node; for child in iterate(right(node)): yield child;`? =). non-local control iz awesom.. @Jon: writing in CPS is a pain, but maybe you mean with continuations? generators are basically a special case of continuations for python.
Comment: @Claudiu: is that roughly equivalent to `it++`? If so, that's terribly inefficient.
Comment: @Evan: no, that's the code to set up the iteration. the equivalent of `it++` would be calling `.next()` on the resulting generator. to actually iterate you'd do: `for child in iterate(head): op(child)`.
Comment: @Claudui: but what if you simply have an instance of an iterator and just want the next one? Even if the map has changed since you got that iterator (which is ok for many usages of `std::map`) does that still work?
Answer: In practice I've found that B-tree performance on my projects has worked out to be better than skip-lists.  Skip lists do seem easier to understand but implementing a B-tree is not that hard.
The one advantage that I know of is that some clever people have worked out how to implement a lock-free concurrent skip list that only uses atomic operations.  For example, Java 6 contains the ConcurrentSkipListMap class, and you can read the source code to it if you are crazy.
But it's not too hard to write a concurrent B-tree variant either - I've seen it done by someone else - if you preemptively split and merge nodes "just in case" as you walk down the tree then you won't have to worry about deadlocks and only ever need to hold a lock on two levels of the tree at a time.  The synchronization overhead will be a bit higher but the B-tree is probably faster.
Comment: I think you shouldn't call Binary Tree a B-Tree, there is a completely different DS with that name
Answer: From the Wikipedia article you quoted:

Θ(n) operations, which force us to visit every node in ascending order (such as printing the entire list) provide the opportunity to perform a behind-the-scenes derandomization of the level structure of the skip-list in an optimal way, bringing the skip list to O(log n) search time. [...]
  A skip list, upon which we have not
  recently performed [any such] Θ(n) operations, does not
  provide the same absolute worst-case
  performance guarantees as more
  traditional balanced tree data
  structures, because it is always
  possible (though with very low
  probability) that the coin-flips used
  to build the skip list will produce a
  badly balanced structure

EDIT: so it's a trade-off: Skip Lists use less memory at the risk that they might degenerate into an unbalanced tree.
Comment: quoting MSDN, "The chances [for 100 level 1 elements] are precisely 1 in 1,267,650,600,228,229,401,496,703,205,376".
Comment: Why would you say that they use less memory?
Comment: @peterchen: I see, thanks. So this does not occur with deterministic skip lists?

@Mitch: "Skip Lists use less memory". How do skip lists use less memory than balanced binary trees? Looks like they've got 4 pointers in every node and duplicate nodes whereas trees have only 2 pointers and no duplicates.
Comment: @Jon Harrop: The nodes at level one only need one pointer per node.  Any nodes at higher levels need only two pointers per node (One to the next node and one to the level below it), though of course a level 3 node means you are using 5 pointers total for that one value.  Of course, this will still suck up a lot of memory (moreso than a binary search if you want a non-useless skip list and have a large dataset)...but I think I'm missing something...
Comment: this would be a reason against using the skip list.
Comment: @askgelal: I was assuming you had actually read the article you in fact quoted. I think you meant to say "Please stop directly..."
Comment: @peterchen: Sure but which case is pathological?
Comment: @Jon: Skip list heights are randomly chosen, so there is a finite probability all end up as 1.
Answer: Skip lists are implemented using lists.
Lock free solutions exist for singly and doubly linked lists - but there are no lock free solutions which directly using only CAS for any O(logn) data structure.
You can however use CAS based lists to create skip lists.
(Note that MCAS, which is created using CAS, permits arbitrary data structures and a proof of concept red-black tree had been created using MCAS).
So, odd as they are, they turn out to be very useful :-)
Comment: "there are no lock free solutions which directly using only CAS for any O(logn) data structure". Not true. For counter examples see http://www.cl.cam.ac.uk/research/srg/netos/lock-free/
Answer: Skip Lists do have the advantage of lock stripping. But, the runt time depends on how the level of a new node is decided. Usually this is done using Random(). On a dictionary of 56000 words, skip list took more time than a splay tree and the tree took more time than a hash table. The first two could not match hash table's runtime. Also, the array of the hash table can be lock stripped in a concurrent way too.
Skip List and similar ordered lists are used when locality of reference is needed. For ex: finding flights next and before a date in an application.
An inmemory binary search splay tree is great and more frequently used.
Skip List Vs Splay Tree Vs Hash Table Runtime on dictionary find op
Comment: I took a quick look and your results seem to show SkipList as faster than SplayTree.
Comment: It is misleading to assume randomisation as part of skip-list. How elements are skipped is crucial. Randomisation is added for probabilistic structures.

Skip List vs. Binary Search Tree


How to develop a Nightly Builder

Question: I was told to create a tool like a Nightly Builder for a JUnit project. It's a client-server project with oracle database.The tests are based on QTP. Also there is a test interface written on C#. The tester can click on the interface to choose which tests to run and get a report from each test. So I have to make this procedure automated. So what tools should I use?
Thanks in advance
Best regards
Comment: Why not use one of the excellent existing systems that do everything already?
Answer: Have you considered using CruiseControl or like tool?  We use this at my work and it was easy to get up and running with Junit and/or TestNG.  Other tools to consider are buildbot, continuum, hudson, etc.   (Go to google and type "cruisecontrol vs" and see a bunch of other auto builder tools.)  Then see how they handle nightly builds.... here's a reference for CruiseControl.
Comment: Do you know how to use CruiseControl with QTP? If so please answer this question http://stackoverflow.com/questions/2601325/how-to-implement-cruise-control-with-qtp
Answer: You should use Quartz. In the quart scheduling xml file you can specify it to build your project. In your project you should have junit test cases execute whenever a build happens. This way you can achieve a daily build process. If your project already utilizes Spring framework then you can use the spring job scheduler helper library too (it's a wrapper around quartz).
Ideally you should use hudson to manage the daily builds but I am not sure if your organization utilizes it or not.
Hope this helps.

How to develop a Nightly Builder


What do you call a person who does not stand up for themselves

Question: What do you call a person who does not stand up for themselves? I'm looking for a word to describe how a slave thought of his kind back before the Civil War started. The word have to be a synonym to weak. It also has to describe sameness. This word also has to mean fitting in by force, but is OK with it.
Comment: A sample sentence please!
Answer: There are a few different options covering various aspects of your request. "Passive" literally means not taking action, while "submissive" or "subservient" would mean acting the way a slave 'should', but they don't carry any connotations about being 'okay with it' - you can act subservient but still resent your position.
A slave might be described as "knowing their place" if they are seen to accept their position. "Stockholm Syndrome" is a general term for the phenomenon of someone identifying with their captor. Terms like "Uncle Tom" or "house negro" have been used to describe slaves complicit in their own slavery or the slavery of others, though these are fairly inflammatory and shouldn't be used casually.
It's important to note, though, that most slaves would not have thought of themselves in this way - the idea of the happy slave is largely a myth, at least within the American chattel system, and slaves resisted in lots of ways besides open rebellion.


LCD Display text disappearing

Question: I'm using LCD display and keypad to control my stepper motor. My stepper motor uses a 12Volts, 2Amperes power supply and I used L298N as its driver. My code functions well but the problem is everytime I plug in the power source for the stepper, the LCD starts malfunctioning. The display texts disappears but the light is still on. LCD gets its power source in arduino mega 5v, the l298N driver also utilizes the same 5v source from it. I think that's the problem, currents jamming in because l298N also has a pin connected the the 12Volts, 2Amperes power source..... I'm not sure if that's the problem guys pls help me fix it. THANKS
Answer: Clearly the combination of the loads that you are placing on the +5V pin is causing a sag of the voltage to a level that is lower than the LCD can still remain functional. This could be a constant sag with too much load or it could be a transient fault that happens when a load switches or you try to hot plug a load.
A constant sag situation would require that you find a separate hefty 5V supply to drive some of your load requirement.
For the transient type situation stop hot plugging. And for a transient due to the load switching you can benefit from adding bulk capacitance to the 5V line to GND at the loads that are switching.
Comment: i think so too =) ...but I wasn't sure until you said it. Now I have some similar answer ...thanks a lot
Comment: The thing is I only plug-in the 2amps power source when I'm about to press the button to switch on the stepper motor because i don't want the l298N driver to get so hot it is because I didn't put the heatsink on yet. I tried to plug the 2amps powersource before I power up the arduino and it no problems occurred. But, in my project the powersource for the stepper motor should not be always switched on. It will only turned on when i pressed a button
Comment: If you insist that you must hot plug your loads then you have to get an oscilloscope on the 5V line and start evaluating why it has a transient when the load is plugged in. This could be some surge through the driver device. As a minimum try placing the input signals to the driver at various different states to see if some will reduce the surge that occurs.

LCD Display text disappearing


Magnetic flux and magnetic flux desity

Question: I'm looking for a short explanations describes the difference between the magnetic flux and magnetic flux density in the most easiest way.
Answer: To put it simply,
Magnetic flux is the amount of magnetic field passing through a given area. The unit is Tm2 or Wb.
Magnetic flux density is the amount of magnetic field passing through a unit area. The unit is Wb/m2 or T.
Think about it this way: normal density, as in the density of objects, is the mass per unit volume. To find the mass, you just multiply it by the volume. This is basically the same thing.
Answer: In general, the density of a quantity $A$, let's call it $\varrho_A$, is the quantity that you need to integrate to get the quantity. For example, the density of the mass is the mass density, which you might be familiar from mechanics. The type of the integral depends on the situation. For example, you can have 1,2 and 3 dimensional mass densities and they require 1, 2, 3 dimensional volume integral respectively. In this case, the density is a scalar function, but in your case it's a vector, and the integral is not a volume integral but a surface integral, but the concept is the same: the flux of a surface $A$ id the integral of the density on that surface, i.e.
$$\Phi_A=\int_A B \cdot \mathrm{d}S$$

Magnetic flux and magnetic flux desity


In R, what is the best graphics driver for using the graphs in Microsoft Word?

Question: I use R to make neat graphs that I use in Microsoft Office documents. According to this page, the best quality is obtained with the PDF driver. Unfortunately, Word doesn't support importing PDF figures. What should I use?
Comment: @mark999 LaTeX simply is not an option for collaborating with non-mathematical people.  As Gavin Simpson explains, high-quality graphics can be incorporated within Word documents by choosing appropriate formats.
Comment: @mark999 Sadly I have to agree with whuber. LaTeX isn't really an option outside of a few fields, and even ones that are fairly math intensive still use Word as the default. I considered it for awhile, then dropped because it was more trouble than it was worth for collaborating.
Comment: You can put PDF figures into Word. Use "Insert object". Side note: If you've never used LaTeX before, I highly recommend trying it as an alternative to MS Word.
Comment: @mark999: Thanks for your suggestion. I tried it, but unfortunately I could not get anything better than a pdf icon in the document. I have to use Word in this context because I work with other people who use Word. LaTeX is nice, but it's not for every project or everyone.
Comment: @whuber, I agree with you, and EpiGrad I partly agree with you. I probably do 90% of my writing in LaTeX and the rest in MS Word (I only use Word when I don't have a choice). static_rtti: I don't know what's going wrong for you, because I have put pdf files into Word documents without any problems.
Comment: I decided to go with EMF. I found that converting them to "Office Drawings" results in horrible Word slowdowns, so I kept them as they are. They don't look as good as the PDF, but I guess I'll have to satisfy myself with that.
Answer: Depends on how you will be using your Word documents and what types of figures you wish to include in the document.
If the figures are standard R plots with a moderate number of points/data, then vector-based formats will provide the best reproduction and allow for easy rescaling of image size whilst having small filesize. EPS via postscript(...., onefile = FALSE, paper = "special") in such cases would be the best format if you're outputting to a PDF or printing on a laser printer that knows postscript. Unfortunately, Word uses a third-party plugin to load EPS figures which produces a crappy low-res bitmap preview which is displayed on screen - when printed you get the high quality EPS though.
If the plots could be considered rasters (surface plots or image plots [heatmaps] with a high number of "pixels"), or if the plots contain a very large number of points, retaining the vector information for such plots will result in a large file size and high processing costs to load into Word and store in memory as you are working on the document. In such cases, I would use a high-res TIFF or a PNG via tiff() or png() respectively. See the help files for assistance in setting the size of the image in pixels and the resolution. These devices will render the figure as a bitmap image, which if given sufficient size/resolution will tolerate some amount of rescaling but will tend to be far more efficiently stored when the number of data points or cells is very large.
Do consider also that not all devices support transparency, largely because the underlying file formats do not allow it; postscript() doesn't support transparency, pdf() and png() do. cairo_ps() does support transparency but in doing so will actually produce a bitmap image in EPS format, which might not be what you want.
Do note that if saving your document out to PDF, bitmap figures will be downsampled to some degree. I forget how Word controls this, but it had two settings in the Save dialog when PDF type was selected and one of those will downsample the images to produce a smaller file size. This will be associated with some loss of quality so be careful which option you choose. This is not specific to Word - OpenOffice.org and LibreOffice have the same features, but they offer far finer grained control of how the images are compressed and whether they are compressed or not. This arises because PDF was designed for both on screen and on printer reproduction. You don't need the high resolution in images if displaying on the screen for the web. Higher res images result in larger file sizes, so the intended destination of the PDF could be set, which affected how the PDF was created.
Comment: Thanks, good tip.  postscript seems to speak nicely to Word for printing.  Unfortunately the poor preview on the screen is a non-trivial problem.  In my environment a lot of Word documents are sent around and read on screen.
Answer: If you are on Windows try win.metafile. It is vector format, if I remember correctly, and it  plays nicely with Word.
Answer: R graphics in windows can be pretty tricky. The biggest problem that I have is that anti-aliasing is not working properly in Windows. For some reason I need to use the Cairo device plugin to get it nicely formatted.
I've tried both Cairo and cairoDevice package and currently I find the cairoDevice to be the easiest and most reliable, there is a StackOverflow post about this.
To use the cairoDevice package all you need is to:
# Create the device
Cairo_png(filename="my_file_name.png",
    width=16,
    height=16,
    pointsize=18)
# Do a plot
plot(x, y)
# Saves the file
dev.off()

You can also save in PDF/svg-format and then use Inkscape to edit your graph, change fonts etc and then export it to png format.
Comment: @JoshO'Brien - Good point. I've since my original answer written two blog posts on this issue: http://gforge.se/2013/02/exporting-nice-plots-in-r/ and http://gforge.se/2013/03/exporting-plain-lattice-or-ggplot/
Comment: Yes. A Cairo png device is what I've found produces the nicest looking plots for on-screen viewing in a Word doc. On machines for which `capabilities("cairo")` is `TRUE`, you can alternatively just use `png(..., type="cairo")` or perhaps something like `png(..., type="cairo", res=200)` to get similar output.
Comment: Super, thanks for the links. Somehow **I** had missed the `units="in"` option until I read them. Wish I'd known about *that* a year or two or 10 ago! Since yours is the best answer here, it might be worth editing it, or adding an update up top about the `type="cairo"` option with the built-in device -- especially given its advantages even relative to the **Cairo** package functions...
Answer: If you are working on a PC, it is quite convenient to insert
figures into Office documents in emf format via the clipboard.
emf  is a windows native vector graphics format and it allows
you to edit the figures with MS Office tools.  It's not perfect
but it's a quick way of generating a simple report.
If your documents are at all complicated, MS Word handling of
figures is horrible.
Answer: PDF, ps,SVG, or eps are vector based graphics device. JPG, TIFF,PNG,...etc are Raster graphics. When it comes raster graphics, the trade off is between the size and quality.  By adjusting width,height and other formatting you could keep high quality in raster graphics. You could take PNG or JPG format to insert the image.
SVG images may insert in MSWORD document. You can check this.
Comment: Note that R's svg device sometimes gives you raster when you don't expect it.
Answer: The easiest way migth be chosing .png files so did I. Yet word does show them quite blurred - at least in my case. Back when i was using Eviews i tried .epswhich resulted in an own set of problems but the quality was better. I think in the end you have to chose between the lesser of two evils.
Comment: I think the blur is due to the Word scaling algorithm. You may have better results resizing in an image editing program before inserting so it is displayed at 100% by Word.
Comment: or create the png file at the desired size in the first place.  The defaults are `width = 480, height = 480, units = "px", pointsize = 12,` but you can change these in your R script
Answer: This does not directly answer your question, but you can get better integration between R and MS Word using either the R package R2wd or the commercial software Inference for R. These provide Sweave-like direct integration of R and MS Word, eliminating cut-and-paste or save-and-load, and making it easier to update plots in the document from the command line. I have not used these but I do use Sweave and recommend literate programming, which is supported by all of these tools.
Sweave is the most widely used literate programmiing tool among R users. It is LaTeX + R, and is how R vignettes and many books and journal articles are written.
The Word + R tools promise a less daunting interface for new users. LaTeX has a steeper learning curve than Word.
However, at $199/yr, inference for R makes it challenging for others to reproduce your analyses, unlike Sweave, which is part of base R.