Difference between multithreaded programs on single and multiple cores

Question: When programming using (pre-emptive) multithreading model on a single processor, we need to deal with synchronization, deadlocks, etc. Do any additional concerns appear (and correspondingly, new techniques used) when switching to multithreading on multiple processors?
Comment: Just found some related articles: [Multi-Core Processors are a Headache for Multithreaded Code](http://blogs.grammatech.com/multi-core-processors-headache-for-multithreaded-code) and [Working with Multiprocessors](https://docs.oracle.com/cd/E19455-01/806-5257/6je9h034a/index.html)
Answer: Fundamentally, the other issue is cache consistency.  Threads that use memory to communicate have potential issues with modern architectures.
A single core processor only has one cache, and so it is always consistent, meaning that there are only the usual race conditions and deadlocks (around locking) for sharing information between threads via memory.
A multi core processor typically has separate cache areas for each cpu.  That means that there is some potential for the different cpu's caches to be inconsistent, which is a another area for problems in sharing information between threads; this goes by the topic of memory models.
x86 and x64 have very strong memory models, so are forgiving to programmers who forget to declare volatile or use proper fences and/or barriers (say, as required by C/C++ standards).  (FYI, a strong memory model takes work to implement and as such increases power consumption and hurts performance.)
Other hardware architectures (especially RISC architectures, like MIPS, others) with multi core rely more on software doing the right thing for maintaining cache consistency; software must use fences and barriers to communicate what about constantly changing memory is important between cpus.
Sometimes weak memory model issues are hidden by higher level software, such as the Java or C# runtime, but this area is sadly complex and there are often subtle bugs in algorithms.
The concept of memory model goes to what the processor must reload in the cache by re-sourcing from main memory when it sees certain conditions.  If all conditions cause cache reloads that slows down the processors and often for no helpful reason from a software perspective.  The problem is to decide what memory modifications are significant to be shared with other cpus and what aren't; hence differing architectures make different trade offs.

As an aside, on a custom embedded systems using as single core, you can create the capability to determine if it has been interrupted within a series of instructions (say by keeping an interrupt count and capture on start and compare on end, or maybe just by turning off interrupts instead).  If it hasn't been interrupted within a series of instructions, software can make the assumption that it has functioned atomically.  These techniques don't work (they doesn't give use the same guarantees) on multi-core processors.
Answer: The problem that locks solve is not caused by multiprocessing (i.e. two threads executing simultaneously on different cores), but by a lack of atomicity.
So when we say:
<code>lock (lockObject)
{
    // This code is atomic...
}
</code>
... because any thread entering that critical section has to wait until the current thread is done executing.  This is true whether or not multiple cores are in play.
Multi-processing is faithfully simulated on a single-core machine with hardware interrupts. When multiple cores are used, no new problems arise that aren't already solved with the usual concurrency techniques.


Unrelated panel or symbolic panel in comics book

Question: Sometimes, in movies, you see people (2-3 persons) talking while we zoom into a flower or some seemingly unrelated shots or shots that have symbolic meaning. I am wondering if it makes sense to do that in a comics book, because it would be harder to understand what's happening, because the text bubbles would make it impossible to know who's talking since we can't hear the voices of the people talking.
Comment: A graphic novel would be rather dull if it was just pictures of people's faces and conversation. You definitely should try and show other things, and there are many ways to link dialog to speaker, not least of which is having each character speak in a distinctive way.
Comment: Alan Moore actually used this technique in Watchmen.
Answer: Word balloons can point anywhere on the page
In the example below, dialog is not trapped inside individual panels. Yet, the flow of dialog is still very easy to follow because it follows 1 simple design rule:
top-to-bottom depicts time
Words that are higher on the page, are read before words lower on the page:

There's more going on in the scene than just dialog and time
Notice how the balloons waiver right and left. To the casual eye the balloons are just moved to the empty spaces of the art work.
But for anyone paying attention the balloons are communicating something more. The main character is reaching a conclusion. As he speaks, his word balloons progress to the right – this character is not just saying words, he is convincing himself of a radicalized point-of-view. The balloon that is farthest to the right is his most extreme statement (but not all the way, he has not completely radicalized).
Reading top to bottom, the inset panel starts with a close-up of this character. His expression is is angry, upset, assigning blame. Notice how the 'world' inside this panel is missing, the background is a color gradient suggesting he is 'heating up' with rage and it is blocking out his perception of the world – he is isolated in this emotion.
The dialog that aligns horizontally with this panel are the words that go with this moment, even though half the balloons are outside of the panel pointing elsewhere.
Moving down the page, the angry 'internal' panel disappears. In the exact spot we now see his friend who is attempting to talk him down. The friend occupies the same approximate volume as the 'angry' panel. He is acting as a conscience in counterpoint to the radical emotions.
The friend's word balloons pull the dialog back to the left – he is literally turning the direction of the conversation. There is a short gap in the dialog (top to bottom) where we see the main character has changed. He is no longer isolated. He is sad, not angry. The last lines are all the way to the left as we are grounded again in the world (quite literally as we see his feet touching the ground, in parallel with these final words).
Comics have not been trapped inside sequential storyboard boxes since the 1960s
There are 8 lines of dialog and at least 3 story beats in this 'scene', but only 2 'panels' which are nested not sequential. It follows the 1 rule – the inset panel begins just slightly ahead in time, reading from top to bottom. Casual readers will have no problem navigating the page.
But the artwork is rich in its own symbolic language. The character's hand escapes from the 'inner' box, a 3D-layer effect that also subtly implies his inner conflict is manifesting into action. His thoughts are no longer contained.
His angry word balloons have completely escaped the inner panel, hovering over a background of pollution – there is no ambiguity here: the artwork is filled with cues telling an emotional story.
There are 2 characters speaking, but only 1 of them is depicted twice, because that character changes. The speech balloons point to character mouths, but not necessarily inside the visual 'moment' they are associated with. Panels do not indicate time, or 'camera' POV – a movie cannot do this.
Time is represented by flowing the dialog balloons top to bottom regardless of the artwork, but the real point of the scene is the main character having an inward moment that makes him angry, while his friend is pulling him out of that emotional hole – visually represented with an internal panel, surrounded by a borderless representation of 'reality' which is not hemmed in by a panel box.
Comment: Who knew Sonic the Hedgehog was so deep?
Answer: You only need to worry about
Continuity
The reader has an expectation of continuity, that is:

if a character was speaking in the previous panel, and the conversation continues on the same topic in the same speaking style in the symbolic panel, then the reader will attribute the speech bubble to the last speaking character.

if two characters were speaking, the same applies from above, with the added benefit that the speech bubble pointing to one side will be attributed again to the character whose speech bubble pointed to that side earlier.

if you are opening on a symbolic panel with multiple characters speaking, then either you provide the non-symbolic panel afterward to clarify who said what, or refer to the conversation later, attributing it to some characters.

if you abruptly change topic, language style and show a symbolic panel, only to return to a different panel with a different conversation, it may be quite jarring. It could become a narrative device if done repeatedly and eventually clarified. I have seen this happening in some mangas in which the action shifts abruptly to weirdly symbolic panels in which some unknown voices talk about weird topics. It is clarified later on that the voice belong to supernatural entities that are toying with our world and their casual conversation is just to show that they don't care about us. In this case the repetition establishes continuity, so that the reader knows what to expect from these symbolic panels.
Answer: Two devices I've seen used to make it clear which characters are talking when they're not in-panel are:

give all characters a unique style/color for their speech bubbles
draw their face in the speech bubble


Salesforce.com >> Role Hierarchy related areas to focus

Question: There is a role hierarchy revision in the application. Users need to move from their existing role hierarchy to a new role hierarchy.
This is going to impact Report and Dashboard folders. I want to know what all other areas will impact and I need to think before deploying a new role hierarchy with the existing user base.
List view also needs to consider! what else?
I want to make sure that users will continue to see what they were used to even with the new role hierarchy. The old role hierarchy needs to get deleted once the new one is in place.
Comment: Please try to avoid adding tags which have nothing to do with your question just because Salesforce is in the name. This being the Salesforce stack exchange, every question should have to do with Salesforce, and any tag indicating as much would be useless. In this case, `[roles]` is a much more obvious choice.
Comment: Okay...was not aware of this! Thank you!
Answer: Changing the role hierarchy will definitely change sharing. Make sure you review your sharing rules and recreate them for the new hierarchy. Also, as you observed, review your reports, and save them using the new hierarchy. I recommend using Save As so you still have a copy of the old reports until you're done. It is recommended that you fix sharing before moving users, as moving users and then fixing sharing may cause significant sharing locks (hours or even days in large orgs) if you move users and then implement new sharing rules. What should only take a few minutes to a few hours can easily turn into a few hours or weeks if you move the users before creating the sharing rules.
Comment: So can I conclude by saying that things to consider with the new role hierarchy are -
1. Assign the existing user to new role hierarchy >> UserRole object
2. check for folder >> Folder object
3. check for Sharing setting across all objects [standard, custom]
That's all! or anything more to consider...
Comment: @Neha That's basically it. Just remember not to assign users until you're done fixing sharing. You'll save a ton of time that way.
Comment: 1. Assign the existing user to new role hierarchy >> UserRole object
2. check for folder >> Folder object
3. check for Sharing setting across all objects [standard, custom]
4. Price Book(s) sharing
I forgot to mention pricebooks earlier!


Transplanting raspberries in Nov after first planting them in the previous spring

Question: I live in south central KY. I have raspberry bushes I dug up Nov 5th this year. They were just set out back in the spring this year. Two of them have long canes now. I found 3 berries on them when I dug up. But had not noticed any other berries previously. Should I cut all the canes back to the ground. They are currently setting in pots with root ball and some potting soil on top. Also should I wait and plant after the leaves fall off or go ahead and replant now.
Answer: You should have replanted them when you dug them up, if the original site is not where they will be long-term. But if they haven't been left to dry out too much they should be fine if you replant them as soon as possible.
Pruning advice varies for different types of raspberries, and we (and possibly you) don't know what type you have. For all types, any canes other than last year's new ones should be pruned off after leaf fall. For some types, pruning off last year's new canes will negatively impact next year's fruiting.
In an established bed, thinning of the canes you're leaving is also needed, (or at least beneficial) but that's unlikely for a new set of plants getting transplanted.


Who can know that I am using Tor for browsing?

Question: I am using Tor browser to browse, and download things. My question is: If I visit a website using Tor browser, then who knows, or who can know, that I am using Tor browser? And what will he get? That is, will he know what websites I browsed using Tor, or only the information that I am using Tor?
Answer: Your ISP knows that you are using Tor. But it doesn't know specifically that you are using the Tor browser, except of course if you just downloaded it. Also, your ISP may share that information with other potential adversaries.
However, your ISP does not know what websites you visit using the Tor browser. Neither do the first two relays in circuits that your Tor client creates to reach them (entry guards and middle relays).
The Tor exit relay in each of those circuits does (of course) know what websites you visit through it. However, it doesn't know who you are, unless you reveal that information in the process. Given that, it's important to always use end-to-end encryption, HTTPS for websites and TLS for email clients.
Websites that you visit know that you're using Tor, because there is a public list of relays (excluding only bridges). However, websites don't know who you are, unless you reveal that information to them.
Answer: The EFF made a clickable diagram which illustrates what your ISP (and other parties) can see when you browse the web using Tor and/or HTTPS: https://www.eff.org/pages/tor-and-https


Dependent moderators in meta-analysis

Question: I am running a three-level meta analysis with about 250 included studies and ~1200 contrasts. I try to get a glimpse on the heterogeneity by running moderation analyses. However, I know that most of my moderators are statistically dependent which is a problem for interpretability (Lipsey, 2003). What would you think would be the best idea for dealing with moderator dependency? Running all moderators of interest within one model and see whether their significance survives, combine levels of moderators to new dummy variables (e.g., moderators: Study Design: A vs. B, Participant type: C vs. D --> Moderators AC, AD, BC, BD), or other solutions?
Answer: Following the multiple moderator model solution actually provided insightful results. Taking all other pre-specified moderators into account, one moderator did not further explain heterogeneity in effect sizes. I interpret this finding as such that this moderator was only significant due to its interrelation with another meaningful moderator.
Maybe not the most elegant solution, yet in my opinion still meaningful.

Dependent moderators in meta-analysis


After hitting a rock, an ore/gemstone came out. Does it have a use?

Question: After hitting a rock, it broke into pieces and revealed a silver ore.  I did this to another rock a couple of days later, and it revealed a ruby.  This appears to be a new class of objects unique to New Leaf, but I'm not sure what they're for.  Do these items have a purpose beyond being sold?
Answer: Ores/Gemstones can either be sold (for a tidy sum depending on rarity) or be used in custom furniture at Re-Tail (through Cyrus, once you unlock him).
To unlock Cyrus, you need to accomplish four requirements:

Sell at least 100,000 Bells worth of items to Reese
Own at least 100 different types of furniture (in your catalog)
Own at least 50 different items of clothing (in your catalog).
Be a resident of the town for over 7 days.

Afterwards, he should wake up and be be able to customize any of your furniture. Here, you can basically create your own furniture designs or use one of the default ones present in the game. I don't remember seeing restrictions on what ores and gemstones you can add, just on the amount. It's during this design process where you can include the ores/gemstones. Moreover, if you gave Cyrus a piece of furniture combined with a ore or gemstone, you can receive some unique furniture which displays the ore/gemstone's characteristics.
Comment: Can you elaborate more in your answer about Cyrus? For example... can this be done to all furniture, or are there restrictions?  Is there any process I need to go through to get him to accept the ores?  My town is only a few days old, and consequently he's busy sleeping every time I see him. The answer in its current state doesn't offer sufficient detail for me to accept yet.
Comment: Oh sorry about that! I'll add in the information for unlocking Cyrus and more about the customization process in an edit shortly.
Comment: Thanks for the edit. I appreciate the detail you added, as that cleared things up for me!
Comment: Welcome to be of service to you. Have fun with the game!


Op amp output DC operating point variation with load current

Question: Consider a cmos op amp in non inverting configuration. For a small load current, we expect the output DC voltage to be the input DC voltage multiplied by closed loop gain. As the load current is increased, DC open loop gain reduces. For e.g, the open loop gain can reduce from 80dB to 40dB as the load current increases from 10mA to 30mA. 40dB of open loop gain corresponds to an error in closed loop gain of about 1%. Will the DC output voltage reduce by 1% as the load current changes from 10mA to 30mA? It doesn't seem to be the case from simulations.
Comment: "*As the load current is increased, DC open loop gain reduces.*" Where did you learn that? Can you give a link?
Comment: My understanding is that as the load current is increased, eventually the output pmos/nmos will go out of saturation, causing the gain to reduce.
Answer: Fully BIPOLAR opamps may have gain reduction as Iload increases, what with operating point variation as finite-beta reflects Iload back into HighZ nodes.
This would be similar to a change in Early voltage.
Fully CMOS opamps, with the load merely changing the Vout as the FETs' triode-region alters with a true ohmic delta_Volts = Rtriode * delta_Iout,
are exhibiting a voltage_divider effect which is not a genuine drop in forward voltage gain.
Comment: Thanks for your answer! "Fully CMOS opamps, with the load merely changing the Vout as the FETs' triode-region alters with a true ohmic delta_Volts = Rtriode * delta_Iout, are exhibiting a voltage_divider effect which is not a genuine drop in forward voltage gain."    Are you saying that when the open loop gain is small, the output voltage would be decided by a voltage division between Rload and the mosfet resistance in triode region? And when the gain is large, output DC voltage would be closed loop gain times the input DC voltage? Then at what gain will the 1st mechanism take over the 2nd?
Answer: This is what I understood from simulations. Assume that the op amp consists of a differential stage as first stage and a single ended stage as the 2nd stage. As the load current increases, the gate voltage of the 2nd stage input device changes, which is the same as the 1st stage output. This results in a higher differential output in the first stage, compared to the case with 0 load current. The offset resulting from this would be the differential output divided by the gain of the 1st stage. So it is more of the 1st stage gain which decides the output voltage error.


How do you breed a Blue Moon Dragon?

Question: I just got an app notification that a Blue Moon dragon is available for breeding. Now I must know how to breed it! What is the best combination of dragons?
Comment: Better find it quick! It's apparently only available til Monday!
Comment: An anonymous user posted this as an edit to the question: "I got one with a scorch and storm".
Comment: Naturally that sounds like an answer rather than a question edit.  I'm sure they were just trying to help though.
Answer: Keep in mind that this is a ultra rare dragon and you will need some random luck to get it.
Cold Dragon + Lightning Dragon Is one confirmed combination,however using any lightning and cold elements should suffice.Any dragon + Storm Dragon is another rumor.
more info
Comment: Looking on the wikia, it says It's bred exactly the same as the Moon dragon, so cold and lightning are *required*. Any other elements will just reduce your chance, I'd think. It also has a breed time of 29 hours and 31 minutes.
Comment: I tried many times with straight Lightning and Cold with no luck. Eventually I switched to Storm + Lightning and Storm + Plant and got my pair. Whoo hoo!
Comment: @Arremer I have since researched and found that the statistically fastest combos are (Firefly OR Scorch) + Storm.  Statistically you'll have success ~10 hours faster (on average) with continuous breeding.
Answer: I got one with a cold dragon and a lightning dragon on my first try
Answer: On my first try I got one with fire and storm, and on my second try I got one with sonic and iceberg.

How do you breed a Blue Moon Dragon?


How and why do concentrated solutions react faster?

Question: It seems intuitive that concentrated solutions would react faster, but, when I stopped and thought about it, I got confused. Wouldn't concentrated acids and bases be in contact with less water than their more diluted counterparts, therefore being less dissociated and having less ions (H+ or OH-) available for reactions? How would completely concetrated acids (since bases would be solid) even react as acids?
Comment: Acids and bases do not have to dissociate to react with each other. The proton transfer can occur directly between them, though this is rare in practice, because before you run out of water, you typically begin to lose acid to the gas phase.
Comment: What if the acid is not gaseous on its own, but liquid like H2SO4?
Answer: Strong acid dissociate, because they are stronger acids then $\ce{H3O+}$, and react with its conjugated base $\ce{H2O}$:
$$\ce{HA + H2O -> A- + H3O+}$$
Additionally, the $\ce{H3O+}$ activity coefficient steeply grows in concentrated acids, and so does the acid reactivity.
In concentrated $\ce{H2SO4}$ and oleum, the role of $\ce{H3O+}$ is overtaken by $\ce{H3SO4+}$:
$$\ce{2 H2SO4 <=> H3SO4+ + HSO4-}$$


Legality of using a symbol as a signature for credit cards, checks, etc.?

Question: A friend of mine today told me that he signed everything using a specific symbol (a star) that he draws instead of his name "for security".  Is this a legal practice to do when signing for your credit card purchases, checks, etc.?  Is it even worth doing for "security"?
Comment: Is your friend *The Artist Once Again known as Prince*?
Comment: @MrChrister Or *The Artist Formerly Known as The Artist Formerly Known as Prince* :P
Comment: like in cartoons when dumb characters mark down an "X" for their names?
Answer: Except in areas where there is a specific law against it, symbols or other marks may be used as a signature.  There is no added "security", however.  I would think in most cases a symbol is much easier to duplicate than a handwritten name.
In situations where the primary purpose of the signature is contractual, e.g. signing a will, marks are more likely to be allowed.  You can't get out of a contract by claiming you didn't write your signature correctly.  Where the primary purpose is verification of identity, such as signing your passport, your name is most often required.
Comment: Working in a bank, I can promise that we verify signatures all the time.  The exceptions would be when we know a customer well enough to call them by name as they walk in our door - otherwise, we take such precautions extremely seriously.
Comment: @MrChrister Checks from ATMs don't disappear into space, they are checked as well.  Same thing with the internet, they check the images for signatures and such -- probably even more carefully.
Comment: Does anyone really verify a signature anymore anyway, though?
Comment: I had mine checked a couple weeks ago, actually.  It was somewhat heartening.
Comment: @Benjamin Chambers - what about those banks that allow deposits into the ATM or over the Internet?
Comment: @Ether: Yes, signatures are still verified in many scenarios. For example, if someone steals your documents and pretends he is you to take a loan when you object it was not you who took the loan one of the factors is whether the signature on the loan agreement matches yours. Which is one more reason why using a symbol doesn't add security.
Answer: Legally, in the US, any mark you make signifying intent is allowed to be your signature. One caveat: the recipient gets to decide if the mark is sufficient for their purposes.
I use a signature that is not my name most of the time, due to a prior identity theft. But many people are ignorant of the law (how many of us actually need to be that familiar with contract law??), and protest that they need an "actual" signature. After explaining the law, if my signature is not accepted, I am, by law, required to make whatever mark is requested of me (initials, full name written out, etc).
Occasionally, I also query what they would accept in the case of a person with severe arthritis, a person who had had a stroke, or for some other reason had lost motor function without losing cognitive function. What about writers with non-Latin names? What about doctors, whose signatures are notoriously impossible to read, to the point that a single character cannot be identified?
It would be needlessly burdensome to require every signature for every purpose to be a fully written name.
Answer: When doing a recent refinance on my house, the closing agents spoke of banks that would refuse paperwork if the signed name didn't match the printed name.   If the printed name included a middle initial, they expected the signature to include the middle initial.
While not a proof of legal/illegal, you wouldn't be able to refinance with this bank using a star as your signature.


Anchor ToolStripProgressBar to right of StatusBar(StatusStrip)

Question: I have a form with a statusbar that has 2 ToolStripStatusLabels followed by a ToolStripProgressBar. I want the progressbar to be always anchored to the right of the statusbar - so when the window is resized/maximized, it should automatically move/repaint.
I thought this would be as simple as setting the 1st (left aligned) ToolStripStatusLabel's Spring property to true, so when the form is resized/increased in size, and there is more space available, the 1st ToolStripStatusLabel would fill up that space and automatically push the ToolStripProgressBar to the Right.
But not only does that not do what I want - the 1st ToolStripStatusLabel actually covers up both the 2nd StatusLabel and the ProgressBar, basically occupying the whole statusbar.
None of the ToolStrip controls have Anchor or even a MinSize.
SO how do I :

Anchor the ToolStripProgressBar to right of StatusBar(StatusStrip)
Mix some fixed size items (e.g the ToolStripStatusLabel2 and ToolStripProgressBar) with a variably sized ToolStripStatusLabel1 that grows when there is extra space?

Thanks in advance for your time and help !
~IM
Answer: There's a simple solution. Make one fake ToolStripStatusLabel, empty the .Text and set .Spring = true;
After that, add your ToolStripProgressBar. Make sure the order is label first, then progressbar.
Answer:
Set the StatusStrip, LayoutStyle property to HorizontalStackWithOverflow.
Set the control Alignment to Right for the control you want to be to the right.
Comment: This works, but the StatusStrip property is named "LayoutStyle," not "Layout."
Answer: For all who may be interested.. Anchor property is available, although in Code only (not in designer) ...but in any case, it DOES NOT work.. I left a BUG in Connect and got the generic WillNotFix with the Message seeming to indicate they'll consider it only for a major revision.
For some reason the "Spring" property seems to be erratic.. In my ultra-simpistic examples it is working, but in some others where I do some custom painting (but in Child Forms in a MDIPArent, with the latter having ht eStatusBar) it is not. In those cases, there's still a simple workaround though - in the ReSize event of the MDIParent Form (that has the statusbar) change the size of the StatusLabel to make it bigger in the same proprtion as th width-change, so it pushes the ProgressBar to the right edge of the StatusBar
Answer: First change AutoSize to false
toolStripProgressBar.AutoSize = false;
Then subscribe statusStrip's size changed event
statusStrip1.SizeChanged += statusStrip1_SizeChanged;
Finally change the bar's width in the event handler
private void statusStrip1_SizeChanged(object sender, EventArgs e)
{
   toolStripProgressBar.Width = statusStrip1.Width - 95;
}


Flash Builder 4.5 vs Flash?

Question: So I want to build Android & iPhone apps.  I'm somewhat confused at the different options available with Adobe.  I understand that there is a product coming out, Adobe Flash Builder 4.5 that will allow cross platform mobile development using Flex and Actionscript. Now I have Adobe Flash CS5, and when I create a new project it gives me the option to make an iPhone something.  Can I build iPhone/android apps with Flash CS5? If so, how? Else what do I need?
Answer: You can build iPhone apps from CS5 without any other tools by creating a new iPhone project. However, in order to target android and get the latest performance improvements for iOS, you should be using Adobe AIR 2.6 and the ADT. The ADT can only be used from the command line currently, though it will be integrated into Flash CS5.5 and Flash Builder 4.5.
The ADT accepts an AIR SWF file as input and the AIR 2.6 namespace can be specified in the app descriptor xml file. This means it is possible to target Android and iOS from Flash CS5 by creating an air project, specifying the AIR 2.6 namespace in the app descriptor xml, and then using the ADT to package the apps. The two platforms vary a little in what is required in the app descriptor and the command line options used are slightly different. Additionally the iOS platform requires an active iOS developers certificate.
Information on the command line options used in the ADT on the iOS certificate requirements can be found here.
UPDATE -
Here's a quick run through of setting up a FlashDevelop workflow for Android and iOS development.
First download FlashDevelop and allow it to automatically download and install the latest Flex SDK. The default path is C:\Program Files\FlashDevelop\Tools\flexsdk\bin. Once you have FD up and running, download and install the AIR 2.6 SDK which includes the ADT used to create native mobile applications. To install the AIR 2.6 SDK you extract it into the Flex SDK folder, overwriting any changes.
Make sure you can compile SWFs using FlashDevelop. There are a few different paths you can go down to build your SWF, probably the easiest to get started if you're familiar with Flash is using Flash Professional to compile. Make sure you set up your FLA to use ActionScript 3 and target Flash Player 10 (this should actually be set to AIR 2.6 but the Flash CS5 IDE doesn't support it).
Alternatively you can use Flash CS5 for asset management only or avoid CS5 altogether and embed assets directly into your AS3 code. The FlashDevelop forums are probably the best place to find this info.
Once you have SWFs compiling, you can set up your application descriptor xml (additional mobile specific info here). You will also require a developers certificate to create Android apps, and a developers certificate and mobile provisioning file to create iOS apps. Once you've got all the necessary pieces (SWF, App descriptor file, developers certificates and provisioning file) you can use the ADT to package your swf file into a native app. The ADT is a command line tool found in the AIR 2.6 SDK (now in your Flex SDK directory).
The command line structure I use to test on android is:

adt -package -target apk -storetype pkcs12 -keystore "path/DevelopersCertificate.p12" -storepass DevelopersCertificatePassword "path/AppName.apk" "path/ApplicationDescriptor.xml" "path/SourceSWF.swf"

Some sources I've seen specify an .air file as the input. This isn't necessary. A swf works fine.
And for iOS:

adt -package -target ipa-test -provisioning-profile "path/Your.mobileprovision" -storetype pkcs12 -keystore "path/DevelopersCert.p12" -storepass DevCertPassword "path/AppName.ipa" "path/ApplicationDescriptor.xml" "path/SourceSWF.swf"

There are additional command line options you can use to specify app icons and other external assets that can be found here.
I recommend creating a batch file to call the ADT for both Android and iOS once you've got the command line options sorted. This lets you build for two platforms with one click. There is a way to call the ADT from FlashDevelop, but I found that the batch file is easier to create and maintain.
UPDATE 2 - This answer is quite outdated now. FlashDevelop now does most of the grunt work for you including downloading the latest SDK and handling the ADT options. I strongly suggest you check it out if you're interested in mobile development using actionscript.
Comment: If you don't mind, I could use some help getting the right tools here. I'm an avid iPhone and Android developer (native), but Adobe has an overwhelming amount of information on their sites that I am left unsure.  So Lets say I download FlashDevelop. What else do I need to download? Adobe Air? Flex? Then how do I start? I am very eager to learn Flex/Actionscript and make cross platform applications, but I need a "Hold your hand" tutorial to get started. There is too much information scattered across too many facets.
Comment: Hi @spentak. I agree, the documentation is pretty terrible. I've updated my original answer with the method I used to set up my development workflow. Hopefully it'll get you started. Let me know if anything is unclear.
Comment: Ethan, Amazing answer! This puts me in the right direction here. Thanks much!
Answer: You can do it with notepad and the command line if you wanted. They are just different IDEs, and a matter of personal preference.
Personally, I detest writing code in flash CS5. It was not at all designed to be used as an application development tool. It sure does make pretty animations though. :)
edit
You may need to wait for CS5.5 for any built in GUI support. However, there is nothing stopping you from building an AIR app and running the packager on the compiled result.
Comment: the Flash IDE is completely unsuited for any amount of programming. +1 to you. I still use the IDE to embed and compile, and yes, make some sweet animations, but I'm a huge fan of FlashDevelop when it comes to writing and editing code.
Answer: I think that an application based on Flash in Android or Iphone device, consumes more power.
That's why all the developers try to build an application with HTML 5 which more comfortable and less coast in point of view power and alimentation.
Also, you have to know that Flex project is not for Adobe now !
Adobe is abandoning Flex SDK and putting it out to Apache, perhaps to die, or to enforce this project. To be followed ...

Flash Builder 4.5 vs Flash?


Keeping bananas fresh for longer

Question: Is there any way to keep bananas fresh for longer? We tried putting them in the fridge but their skins turn black very fast.
Comment: related : http://cooking.stackexchange.com/a/5005/67
Answer: The skins turn black in the fridge, but the fruit itself is fine. Cooks Illustrated tested if refrigerating bananas keeps them good longer, and they found it does—five days longer. Extract below:
Most people store bananas on the countertop, and we wondered if chilling the fruit could slow ripening. To find out, we left 12 pounds of bananas at room temperature for three days until they were perfectly ripe (signified by a firm but yielding texture). We then moved half of the bananas into the refrigerator, leaving the remainder at room temperature.
For the next few days, the bananas were nearly indistinguishable. After four days, however, the room-temperature fruit became markedly soft and mushy, while the refrigerated fruit remained firm, despite blackened skins. We continued to taste the refrigerated bananas after the room-temperature samples had been discarded and were delighted to discover that they lasted an additional five days (so, almost two weeks after purchase) before the flesh became overripe.
The explanation is simple: As a banana ripens, it emits a gas called ethylene and develops acids that aid in ripening. Cool temperatures slow down the production of ethylene and acids, thereby decelerating ripening. However, refrigeration also causes the cell walls of the peel to break down, releasing enzymes that cause the formation of black-brown pigments.
Answer: Store them in a well ventilated place. Cool (15 degrees Celsius) and dark will probably do them good too. And buy green bananas.
Your bananas are alive. Seriously, they continue to live after they have been picked. Breathing, cell metabolism, hormone production, etc. goes on. You cannot stop this process, you can slow it a bit.
In many plants, fridge temperatures trigger their own growth slowing processes, because they are evolved to stop growing in winter months. But in tropical fruit, this doesn't work, because there are no cold months where they grow. Instead, it exposes their sensitive cells to an environment they are not meant for, and they change a lot. Bananas go black, tomatoes change their taste radically, and so on.
Still, keeping them coolish and dark may do them good, because it still gives them less energy to spend on ripening.
One of the mechanisms which controls ripening in fruit, including bananas, is ethylene gas. It is a positive feedback mechanism. Ripe fruit produces ethylene, and unripe fruit ripens faster when exposed to ethylene. People tend to stick green bananas in bags to make them ripe faster. If you can keep them well ventilated, the ripening will slow down.
Still, don't expect any wonders. Bananas will ripe after being plucked, no matter if on the tree or not. And they will overripen in few days, even when held far from ethylene. Starting with green bananas gives you more headroom, but you still have a few days only.
Comment: Ethylene gas is heavier than air, so having no sides and an elevated position is best. Also no direct sunlight.
Comment: Covering the stem part of the cluster with shrink plastic also help in keeping the peel healthy (evaporation leak from the stem end).  Your useful note on tropical climate is concurred by [Leonard Cohen in his Banana Song](http://www.youtube.com/watch?v=7qXI6Yp21fk).
Answer: Jolenealaska makes a good point - bananas should not be kept with other fruit, which is why fruit cages often have a long extension with a hook above - this keeps the bananas suspended away from the other fruits. Even better is a banana hook with no fruit cage beneath. The amount of ethylene is critical, so keeping them away from other fruits which are also producing ethylene helps to slow down the ripening process.
Comment: By that logic, one should also keep the bananas away from each other....
Comment: @SAJ14SAJ Dear oh dear, for heaven's sake - it's the ethylene from other fruits in the bowl one's trying to avoid, not to mention the two way street of its affecting other fruits too. Keeping each banana in splendid isolation might well delay ripening, but really, life's too short, surely.
Comment: Are bananas themselves not one of the largest ethylene emitters?
Comment: Yup. And your point is?
Comment: Since they are the worst offenders, it seems isolation would be indicated, not just from the other fruits.
Comment: @SAJ14SAJ Each banana emits ethylene as by product of it's own ripening process, which is already very fast. It needs large amounts to ripen, and the small amount from other bananas will not significantly effect it, but it will effect other fruit
Comment: @TFD I can only say bologna, as this is a family board.
Comment: @SAJ14SAJ What you saying? The amount of ethylene used to ripen shipped bananas would ruin the same volume of apples, how does that not make sense?
Answer: Bananas that are refrigerated turn black, but that's only the peel. The fruit inside keeps way longer if you leave them on the counter. Easily a week to 10 days depending on how ripe when you put them in the fridge. No loss of flavour or texture.
Answer: I always buy two bunches of bananas. One Bunch that is perfectly ripe and ready to eat within a few days. The second bunch is as green as I can find. I then keep these two bunches separated in my kitchen. This allows me to have bananas for a period of about 7 to 9 days without problems. Additionally when I get them home, the first thing I do is submerge the stems in a bowl of water with soap to eliminate any fruit fly eggs. This works very well!
Answer: To keep them pleasant for just eating by themselves keep them at room temperature. Refrigerating or freezing them quickly turns them black. They'll develop bruising as they ripen if they're resting against anything (including each other), so keeping them suspended by their stems helps keep them a nice even yellow banana hooks. Once they ripen (darken and soften) beyond the point that they're pleasant for "out of hand" eating they're still a very useful ingredient. Overripe bananas have much more flavor and aroma than yellow ones. For baked goods ripened all the way to black is perfect. Let them ripen to nearly mushy at room temperature, then freeze. Once you have several bananas stored that way you're halfway to a very nice banana bread. I peel them and freeze in a Ziploc bag, but many people swear by leaving them unpeeled for freezing, and that certainly works too.
Comment: The OP is storing them at room temperature, quite aware that refrigerating them doesn't work, and asking how to keep them fresh longer. I'm not sure I see how this addresses that?
Comment: Bananas are perceived as "fresh" when they're yellow without brown spots. The banana hooks directly address that. The freezing tip extends useful life of the bananas, very intertwined with the word "fresh".
Comment: Ah, I read the part about hooks as simply preventing bruising, not actually extending the shelf life. I will not delete this then, but it could be vastly improved. The first sentence tells the OP to do what they're already doing. The second repeats back what they already said in the question. And although it's not explicitly stated, it's almost certain that the OP wants to just eat the bananas, not bake with them, so the advice about freezing is certainly correct but not necessarily helpful.
Comment: With respect to hooks, recommended because of the claim that fresh = yellow... overripe bananas are obviously overripe (and may have little brown spots), whether or not they have bruises. Preventing bruises is still good though, of course.
Answer: You can't keep bananas very long.  So just buy what you can eat in about 3 days, period.  This is 80 years of dealing with bananas.
Comment: There's a very small 'optimimum' period, in my opinion, but you should be able to stretch them out to at least a 5 day window.  And if you buy bunches that are at different stages (I generally try to get the most green + the most yellow bunch), you can have bananas over an even longer period.
Answer: Ethylene gas absorbers should prolong banana life, but I've never tried them, and do not know if their absorbing capacity is high enough to merit the cost.
Looks like ethylene absorbers are used commercially so there's at least some chance that the consumer level products will work.
Comment: They're used commercially because they pack things in crates & shipping containers ... they don't have the freedom to just let there be lots of air exchange.

Keeping bananas fresh for longer


Payoff from an option contract

Question: In period 1 the consumer of type $\theta$ selects an option contract consisting of an up-front fee, $B>0$, and exercise price, $\bar{R}$. The consumer pays $B$ at the end of the first period. In period 2, he realises his valuation, $\theta$, distributed on $[0,1]$ by CDF $G(\theta)$ with density $g>0$. His expected payoff, from choosing contract $(B, \bar{R})$, should thus be $-B+\int_{\bar{R}}^{1}(\theta-\bar{R})g(\theta)d(\theta).$ However, in the paper I am told that it is instead: $-B+\int_{\bar{R}}^{1}(1-G(\theta))d\theta.$ Are these two expressions equivalent? What does it mean to integrate a CDF in this fashion? Thank you.
Answer: The CDF satisfies $G(0) = 0$, $G(1) = 1$ and $G'(\theta) = g(\theta)$.
Integrating by parts, with $u = 1- G(\theta)$ and $dv = d\theta$, we have $du = -G'(\theta)\,d\theta = - g(\theta)\,d\theta$, $v = \theta$, and
$$\int_{\bar{R}}^1(1- G(\theta)) \, d\theta = \left.(1- G(\theta))\theta\right|_{\bar{R}}^1 + \int_{\bar{R}}^1 \theta\,g(\theta) \, d\theta = -(1- G(\bar{R}))\bar{R} + \int_{\bar{R}}^1 \theta\, g(\theta) \, d\theta\\=-\bar{R} \int_{\bar{R}}^1 g(\theta)\, d\theta+ \int_{\bar{R}}^1 \theta\, g(\theta) \, d\theta = \int_{\bar{R}}^1 (\theta-\bar{R}) \, g(\theta) \, d\theta$$

Payoff from an option contract


Firewalls (ufw vs apf) on Ubuntu

Question: On my LAMP servers, do either of the firewall interfaces (ufw or apt) allow you to setup rate limiting to automatically ban brute force attempts (e.g. via SSH)? Or, is it best to install fail2ban in conjunction with strict firewall rules?
Answer: For ufw look into the limit command.
sudo ufw limit ssh

From the ufw man page section on the limit command:
RULE SYNTAX
   [...]

   ufw supports connection rate limiting, which is useful  for  protecting
   against  brute-force  login attacks. ufw will deny connections if an IP
   address has attempted to initiate 6 or more connections in the last  30
   seconds.    See  http://www.debian-administration.org/articles/187  for
   details.  Typical usage is:

     ufw limit ssh/tcp

Comment: Is this the same functionality of fail2ban's ssh jail?
Comment: @TrentScott Don't know. I don't use fail2ban.
Answer: I ALWAYS recommend spending the time to learn how the firewall rules work.
UFW may meet your needs today but it's limited, and it may not do what you need tomorrow and you need it RIGHT NOW.
Spend some quality time with some webpages talking about IPTables (properly called NetFilter). It's time well spent if your setup will be growing in complexity or scope in the future.
Answer: ufw is not more than an interface to manage netfilter rules. From man ufw, you can read:
ufw - program for managing a netfilter firewall

Several netfilter modules can be used to implement different security measures. Have a look at this page. You can see limit and iplimit modules. You can find also recent module.
Fail2ban is nice as it allows you to block some IPs by modifying your firewall rules. It can scan log files to detect breaking attempts. Also, it can be configured to do an arbitrary action such as alerting you and/or executing some script, etc...

Firewalls (ufw vs apf) on Ubuntu


Is there a term for words that when reversed, form other words?

Question: I'm aware of what a palindrome is. What do you call words that, when reversed, form other words, such as ton (not) and part (trap)?
Comment: I nominate *drowkcab*.
Comment: I hereby nominate *backwords* as a neologism to cover this term.
Comment: @Jay Elston Hello Might and Magic player.
Answer: Semordnilap is a common name for them, which has been pretty well accepted.
I know that Carroll used them in his work, but I think the term (read it backwards) was invented later.
Comment: Hey, Guys, try Googling "Semordnilap", rather than just down-vote correct answers.
Comment: On the face of it, *semordnilap* fails since the reverse of palindromes should be the same words. And it does not even look like a word, compared say to *esrever*.
Answer: Wikipedia's Palindrome article gives semordnilap, as Mark Wallace's answer correctly pointed out. It also lists several alternatives:

volvograms, heteropalindromes, semi-palindromes, half-palindromes, reversgrams, mynoretehs, reversible anagrams, word reversals, or anadromes.

Such pairs could also reasonably be called mutual palindromes, by analogy with mutual recursion and mutual quine
Answer: It is a type of anagram:

An anagram is a type of word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly once; e.g., orchestra = carthorse,
Any word or phrase that exactly reproduces the letters in another order is an anagram.

Nota Bene: The emphasis is mine.
Comment: How can you be sure? I mean it seems so, but what gives you certainty? Anyway, here is a reference http://www.english-for-students.com/Palindromes-1.html, though would like to have better
Comment: @Unreason I like that link however the technical description of an Anagram seems to be the closest/ right fit. So for now I'll have to go with that. Thanks all the same
Comment: while it seems that these would BE anagrams, I think the OP is looking for something more specific than that. Particularly that the word/phrase that makes another words just when reversed. Anagrams have additional context. Stop -> Pots fills the OPs requirements and those of an anagram, but "anagram" being reaarranged to "nag a ram" is an anagram, but doesn't fill the OPs requirements
Answer: It is an Anadrome.

An anadrome is a word that has its spelling derived by reversing the spelling of another word. It is therefore a special type of anagram. There is a long history of names being coined as ananyms of existing words or names for entities related to the thing named by this subset of anadromes.

https://en.wikipedia.org/wiki/Anadrome
Comment: This was already given in a different answer.
Comment: A search for the word anadrome from dictionary.com doesn't produce an output. However the word [Anadromous](https://www.dictionary.com/browse/anadromous) does turn up as a nearby word which I assumed would, in definition, yield an explanation tending towards the transformative but doesn't.
Answer: The word levidrome was created by a six-year-old Canadian boy, called Levi Budd, who realized that there wasn't a term for a word which when read backwards spelled a different word. For example, spits and tips, stop and pots, stressed and desserts
The word levidrome is a blend of the boy's first name and palindrome, a word or phrase that runs the same backwards and forwards, such as "race car".
William Shatner sent a tweet to the editors of Oxford Dictionaries extolling the virtues of this newly coined word. At 9:39 AM - 8 Nov 2017 the editors replied:

Thank you very much for your email to Oxford Dictionaries. We are always grateful to receive contributions and feedback, but because of the quantity of correspondence, we are not in general able to reply personally to specific content comments or language queries. All submissions are passed on to our editorial team, who will take your comments into consideration when updating the dictionary data.
  Kind regards, The Oxford Dictionaries team

An editor at  Oxford Dictionaries made a YouTube video dedicated to Levi, which was posted on their blog November 24, 2017
So, the neologism has not yet entered the Oxford English Dictionary but its editors are keeping a close watch.  In the meantime, levidrome has its own hashtag on twitter.
Thanks to social media and because Levi Budd is still a child the term levidrome stands a reasonable chance of sticking than the unpronounceable, and virtually meaningless, semordnilap. We may remember how to write it (it's palindrome backwards) but it's highly unlikely that we would ever say it in everyday life.
Levidrome slides into everyday lexicon Mar. 31, 2018


Single-boot vs dual-boot

Question: Will a single-boot install run any better than a dual-boot?
Running Ubuntu-mate (16.04 beta 64bit) alongside Vista. 2GB ram, Athlon 64 x2 5200+. Ubuntu is running fine. (Better than Vista, actually.) But only using a sliver of disk space thanks to years of running Vista.
Answer: The only thing that would change if you were to go to a single boot is that you would get to use the disk space that Vista is installed on.
It's not going to change the performance of Ubuntu to single boot.
Once the OS boots it is the king of the castle. All of the computers resources belong to it. You only share the storage space on your hard drive.
Answer: A Single boot install is not going to affect the performance of the currently running instance of OS. While running your OS, the other partitions are read as storage like it would read a usb stick.
p.s. Vista is known for heavy RAM memory usage (1-1.5Gb OS alone) so you are right, you should be experiencing better performance on Ubuntu as it it less demanding.
Answer: When you dual-boot, you have two operating systems, either on the same hard drive or on different hard drives. Either way, only one OS can be using CPU / memory resources at a time.
If you had an infinite amount of hard disk space, you could theoretically load up as many operating systems as they could hold, and none of them would affect the speed of any other.
The reason most people don't go above dual / triple booting is that it simply isn't necessary most of the time. Most users can accomplish everything they need to do on a given system with 2 or 3 OS choices.
As others have said, Vista is notoriously slow by itself. I recommend 8.1 or 10 if you don't mind the NSA looking over your shoulder, but as always when it comes to these decisions, it's up to you.
Answer: Short answer: No.
Accurate answer: Depends on your setup, and the circumstances at a given time. However even in the scenarios where there is a performance boost (eg: lower access times for harddrives if OS is nearer outside of drive, SSDs may see less write amplification in some scenarios, etc) you aren't going to notice, because the difference will be minute. You'd likely have to collect detailed stats just to prove there was a performance boost.
People don't single-boot for performance, it's usually a choice made about space.

Single-boot vs dual-boot


How to increase disk space in Wubi (Ubuntu via windows)?

Question: I installed Ubuntu via Windows 7. I allocated only 8 GB space to it, but unfortunately now I want more space without reinstalling or creating another partition. Is there any way to increase the disk space in the Ubuntu? Please help me to figure it out ?
Answer: According to this guide, you can use LVPM
As an alternative, you can use the following script to move /home to a dedicated virtual disk.
Download wubi-add-virtual-disk, open a terminal and run:
<code>sudo sh wubi-add-virtual-disk /home 15000
</code>
Where the first argument is the directory to move to a new dedicated disk, and the second argument is the size in MB.
You should now reboot. If you are happy with the result, you can now remove /home.backup. To undo the changes remove /home, copy rename /home.backup to /home and remove the /home line in /etc/fstab.


Not sure how to make the topology uniform

Question: I have a staff that I am creating and wanting to import into Zbrush, but I am having a hard time getting a good topology on the faces of this staff. Is there any way to make the faces into quads or a more uniform tris?
Comment: Try a decimate modifier. By default, you need to be in wireframe view in object mode to see the changes in real time. Experiment with all 3 un-subdivide types, however I think "collapse" or "planar" are most likely to work for you.
Answer: The Remesh modifier is your best option to do this quickly. Turn the Octree Depth up until you have enough resolution.


How to calculate (or do we observe) range of exchange particles in QFT?

Question: In this question Can hydrogen atom exchange induce attractional forces between $e^-e^-$?  one answer showed the range of exchange particle but not how to calculate. how do we calculate/know what are range of exchange particle? Do we calculate or observe?
Answer: We can calculate it . To explain this, let us consider nuclear beta decay
$n \rightarrow p + e^- + \nu_e$
where the exchange particle is the $W$ boson. This particle was calculated (and observed*)
to have a mass of about $80$ $GeV/c^2$. We calculate its range using the uncertainty relation
$\Delta E \Delta t \geq \frac{h}{2}$
Now assuming that the uncertainty in energy $E \approx mc^2$ is comparable to the energy of the $W$ boson
we can rearrange the above relation
$$\Delta t \approx \frac{h}{mc^2}$$
to give us the distance
$$D \approx c\Delta t = \frac{h}{mc}$$
and given
$mc^2 \approx 80$ $GeV/c^2 = 1.28 \times 10^{-8} J$
we get
$$mc = 4.27 \times 10^{-17} \, J s/m$$
and using
$$h= 6.62 \times 10^{-34} Js $$
giving us the range of the $W$
to be
$$D = 1.55 \times 10^{-17} m$$
This is an order of magnitude 10 times the diameter of a proton.
*I noticed you have "virtual particles" as one of your tags and in the link you provided, but here the W boson is real (observable) but has a very small lifetime due to its instability (when considering energies above its rest mass). It can also arise as an unobservable virtual exchange particle during certain scattering processes).
Comment: The mass/energy above is that for the W boson. Not a neutron.
Comment: "is comparable to the energy of the W boson" the energies available in a neutron decay is very small.  To be real, it has to be on mass, which is not possible at the mass of the neutron. I think the argument is wrong.
Comment: "is comparable to the energy of the W boson" the energies available in a neutron decay is very small. To be real, it  has to be on mass, which is not possible at the mass of the neutron. I think the argument is wrong.if we accept your last comment of real mass.. The calculation here hyperphysics.phy-astr.gsu.edu/hbase/Forces/exchg.html .
Answer: For clarity:

If a force involves the exchange of a particle, that particle has to "get back home before it is missed" in the sense that it must fit within the constraints of the uncertainty principle. A particle of mass m and rest energy E=mc2 can be exchanged if it does not go outside the bounds of the uncertainty principle in the form

A particle which can exist only within the constraints of the uncertainty principle is called a "virtual particle", and the time in the expression above represents the maximum lifetime of the virtual exchange particle. Since this exchange particle cannot exceed the speed limit of the universe, it cannot travel further than c times that lifetime. The maximum range of the force would then be on the order of

Note that this expression implies that a zero mass for the exchange particle implies a force of infinite range. The rest masses of the exchange particles for the electromagnetic force and gravity, the photon and the graviton, are taken to be zero and those forces are presumed to be infinite in range.

The same as the answer by Dr jh .
It is improtant to note that Heisenberg uncertainty arguments give a large envelope within which the specific interactions are limited. The potentials though are very important.  In the case of zero mass, the gluon has zero mass but the range of strong interactions is very small, due to the form of the strong potential .
The paper that started the discussion does not use this Heisenberg uncertainty envelope way of calculating ranges. See the complexity in a recent paper here in getting an effective potential.
Comment: Very good Anna.


What are the 3 red squares?

Question: Whenever I start a match of apex, I always see three little squares in a line, with the middle one being dotted. As soon as I get into the game though, it is gone. It is only ever there when you see the little player count loading screen thing. What is it, and if its bad (because it looks like the slow connection symbol I get some times), how can I get rid of it?
Comment: Provide a screenshot of what you mean
Comment: @XtremeBaumer I will try when I get home. It's not the easiest to screenshot as it only appears sometimes, and when it does its for a small period of time.
Answer: Packet Loss (red squares)
Packet loss is represented by two squares with a dotted square between them, all arranged diagonally.
This means your computer is failing to send information or receive it from the Apex server. If your character is freezing for a while then suddenly teleporting, or if you're shooting someone and they're not receiving damage, that might mean you're experiencing packet loss and that the server never received information from your end.
You can also interpret it as an extreme latency. If in high latency it takes longer for information to be transferred, in package loss, some information is never transferred. And just like with latency, this issue is commonly linked to your own connection.

What are the 3 red squares?


Can't enable error messages for PHP on my web server

Question: I'm trying to disable error messages for PHP on my Apache2 web server, but it's not working.
I have enabled it in the php.ini file.
error_reporting = E_ALL
I deliberately introduced errors in my test.php script, and in the script itself, I have included the following, but no errors are displayed.
init_set('display_errors', 1);
init_set('display_startup_errors', 1);
error_reporting(E_ALL)

What am I doing wrong?
Comment: Which PHP version are you using, and what is the path to your php.ini file?
Comment: this is my file /etc/php/7.3/cli/php.ini
Answer: The php.ini file, located at /etc/php/7.3/cli/php.ini, is only responsible for the command line interface.
If you use the echo phpinfo(); function in a script to display your configuration, you will see the following lines:
Configuration File (php.ini) Path
Loaded Configuration File

The lines will show the path as /etc/php/7.3/apache2 and /etc/php/7.3/apache2/php.ini for your Apache2 web server.
To edit the configuration for your Apache2 web server, you need to modify the file /etc/php/7.3/apache2/php.ini.
So, there are two php.ini files available.


Loop pictures from a folder and display fullscreen slideshow

Question: Need a Linux solution for looped slideshow from pictures in some folder. Pictures may be deleted and added, so it's a bonus if it doesn't stop/crash if currently shown picture is deleted.
Answer: If you use Gnome desktop, then you can use its official image viewer program for slide shows:
eog --slide-show /path/to/picture_directory

With Eog pictures can be removed or added during the slide show. Actually, if you add picture during the slide show, it will be automatically included.
Comment: Using this on my Raspberry Pi, I was not able to add or remove files without restarting the slideshow.  Not a criticism, just FYI.
Comment: You clearly deserve a medal
Comment: On Ubuntu 16.04 using XFCE desktop, this worked but, while most UI elements were polished (fade-in and out, etc), an unwelcome menu bar was visible at the top at all times, even in full-screen slideshow mode. This will not be acceptable for every use.
Comment: Sounds like an out of the box solution to me.
Comment: I second Butters, this did not work on Raspbian. The added pictures never show up, and removed pictures generate errors from EOG. Perhaps this is due to the fact I'm reading from a rclone'd folder (from Google drive), but either way it does not work in some circumstances.
Answer: This is going to sound crazy, but it works (better than I expected even) and is not that hard to setup. The idea is to make your viewing program look at a single file and then have a command line process that copies each of your files in your directory to that file you view.  I tested this with Geeqie and gthumb and it actually works pretty well. gthumb even can handle the image being updated every second and both supported the name of the file type being different from the actual file type (jpg, png, gif, etc).
So here is what you do:

Make a directory with only your pictures in them.
open a terminal window and change to the directory made in the previous step.
Run this command, substituting 5 with however many seconds you want to wait in between updates.
while true ; do for i in * ; do cp "$i" ~/slideshow.jpg ; echo $i ; sleep 5 ; done ; done

Open gthumb and view the image in your home directory called slideshow.jpg, it should rotate the picture. You can make gthumb full screen now if you need to.
Try adding and removing pictures from the picture directory.  It won't actually update until its finished going through the whole directory each time, but it will update.  The echo $i is in there just so you can see what picture it just copied into place each time.

When you are ready to stop the slideshow, you can press Ctrl-C in the terminal window.
Comment: Brilliant. It takes a genius to understand the simplicity.
Answer: From http://www.instructables.com/id/Easy-Raspberry-Pi-Based-ScreensaverSlideshow-for-E/
using feh
feh -Y -x -q -D 5 -B black -F -Z -z -r /media/
Comment: You also need to add the option `-R seconds` so that the file list is refreshed periodically.
Comment: You might also want to add `--auto-rotate` to rotate images correctly based on EXIF data.
Answer: Impressive does the job well, with (or without if you wish) transitions.
Slideshow in random (-X) order with 3 seconds delay (-a 3) and autoquit at the end (-Q) :
impressive -XQa3 *

It's worth noticing that it allows scripting, and is multiplatform.
The only drawback is that it currently crashes if there is a directory in the list of files.
Comment: awesome application! perfect for what I want to do!
Comment: If only it allowed to auto-rotate images based on EXIF data. Did not find any option to do this. :(
Answer: I found fbi (frame buffer image viewer) quite useful-
Simple command, something like :
fbi -noverbose -a -u -t 6 /home/user/location/*

More options available withfbi --help and can be installed, depending on distro with apt-get install fbi
Comment: This doesn't work when run from [yakuake](https://www.kde.org/applications/system/yakuake/): `ioctl VT_GETSTATE: Inappropriate ioctl for device (not a linux console?)`
Comment: Works great from tty command line.
Comment: You'll probably have to specify a particular tty, using `-T 2` for example to select `tty2`. You'll probably have to muck around with permissions after that.
Comment: Does not work from command line on current Raspbian with screen attached :( Also seems to be lacking EXIF-based auto-rotate feature (I read).
Answer: The best Linux solution for me is feh
sudo apt install feh
feh -rzsZFD 5 /home/my_folder

It has many options, in this case it will show recursively a random picture from my_folder (and its subfolders) every 5 seconds.
Answer: I looked at many different solutions to this problem, including fbi, feh, and more.
I ended up using pygame of all things. This may not be clean, ideal, or optimal, but it does the job, it provides quick changes between slides without a long dark space between (fbi does this if you needed it to exit and restart to vary the  timing between slide changes as is my case). Nonetheless, it is running (tested, deployed) code. As an added advantage, this code appears to be impossible to break out of into a shell and appears to be safe to run from .bashrc on an autologin. (This is added safety on a system that has no keyboard).
If you change the slide list and/or timing in the configuration file, you'll need to restart the script for changes to take effect. If you just replace the existing slide files, the changes will be picked up at the next slide change.

import pygame
import sys
import time
import os
import re

# Initialize the display
#pygame.init()
os.environ['SDL_NOMOUSE'] = '1'
pygame.display.init()
pygame.mouse.set_visible(False)
size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
black = 0, 0, 0

print("Obtained screen dimensions (", size, ")")

screen = pygame.display.set_mode(size, flags=pygame.HWSURFACE|pygame.DOUBLEBUF)

# Get the slide show data
LIST = open(os.environ['HOME']+"/data_dir/slide_order.txt","r")
slides = []
for line in LIST:
    line = line.rstrip('\r\n')
    if (re.match('^[\w\d\. ]+\t+\d+$', line)):
            (fn, duration) = re.split('\t+', line)
            duration = int(duration)
            print("Adding file:", fn, "for", duration, "seconds")
            slides.append([fn, duration])
LIST.close()

while True:
    for (index, values) in enumerate(slides):
        print("Retrieved (",values,") at index:",index)
        (fn, duration) = values
        print("Loading image")
        image = pygame.image.load(os.environ['HOME']+"/data_dir/"+fn)
        print("Scaling image")
        image = pygame.transform.scale(image, size)
        irect = image.get_rect()

        print("Clearing buffer")
        screen.fill(black)
        print("BLIT")
        screen.blit(image, irect)
        print("Display Image")
        pygame.display.flip()
        print("Sleeping...")
        time.sleep(duration)
        print("Awake")

sys.exit(0)

Answer: So I found deltaray's answer really genius and I just wanted to expand on a script I have been using that takes from their answer.
The script right now exhaustively without repeats selects from the current working directory a random image while skipping over the script if selected, then applies deltaray's answer.
Here is the script.
#!/bin/bash

selected_indices=()

function select_random_file() {
  local files=(*)
  local count=${#files[@]}

  if (( count > 0 )); then
    local random_index=$(( RANDOM % count ))

    # Check if the index has been selected before
    while [[ "${selected_indices[@]}" =~ $random_index ]]; do
      random_index=$(( RANDOM % count ))
    done

    # Add the index to the selected_indices array
    selected_indices+=($random_index)

    local random_file=${files[random_index]}
    echo "$random_file"
  else
    echo "No files found in the current directory."
  fi
}

while true; do
  selected_file=$(select_random_file)
  cp "$selected_file" ~/slideshow.jpg
  echo "$selected_file"
  sleep 30
done


Saddle position for a long steep climb

Question: Various sources indicate that when climbing to slide back on the saddle. In about a month I plan to attempt Whiteface Mountain with its 13 km at an 8% grade. If I manage this climb I will be at my limit. Should I move my saddle back for the climb?
Comment: The advice is seems like nonsense. To keep your center of gravity ahead of the bottom bracket, so that you have a mechanical advantage in pedaling, you have to shift forward when climbing, since your seatpost has tilted backward.  Speaking of tilt, adjusting the tilt of the saddle so that it is level at 8% might not be a bad idea.
Comment: Can you quote the sources, coming from a MTBing perspective, this is counter to anything I have experienced. Weight back downhill, weight forward uphill (more accurately, weight centered over the BB at all times, but seat moves with respect to BB as slope changes)
Comment: @Kaz maybe the advice was getting at using more quads as opposed to hamstrings during the climb.
Comment: Back would be a bad thing to do.  As the grade rises, your saddle moves further behind the rear axle (vertically) which unweights the front wheel.  Its very hard to balance, apply power, and steer if there's not enough weight on the front.   So you'll have to be off the saddle and leaning forward to provide front wheel weight.  I've found moving the full waterbottle to the frontmost cage to have a small but noticeable impact on weight distribution.  Your hands will be best forward, which may be hoods or whatever leans you forward the most.  And pace yourself up the climb!
Comment: @mattnz - Nosing up on the saddle in mountain biking is more a function of being able to keep the bike stable and maintaining traction than it is about mechanical advantage (if you are lifting the front wheel  or breaking traction you are at a much bigger deficit).  In road riding neither of these are problems.  Here changes in body position typically relate more to improving mechanical efficiency. As such, MTB advice may not be entirely appropriate for the OP.
Comment: So you have a 28 tooth on the rear - whats the front chainring?  I'm guessing a compact double or a triple ?
Comment: 34 on the chain ring. Not to explode from the wattage I will not be able to ride faster than about 9 km/hr. Consequently a less then optimum cadence, and I have been practising low cadence climbing.
Answer: Most of the new schools of thought  suggest moving back or forth on your saddle is more of an indication that the saddle offset isn't set up correctly, than it is advantageous.  I would tend to agree.  If you find yourself constantly shifting forward or backwards, this likely indicates that the saddle isn't in the correct position.
Old school fitting have been obsessed with KOPS (Knee over pedal spindle), but this was originally derived as a general method to determine whether or not a frame size was appropriate (i.e., if you couldn't get into KOPS, you needed a different size). (There isn't even consensus on how you even measure KOPS as everyone landmarks the knee differnently - this can result in over 1cm difference in offset alone).  Depending on your body proportions and bike position if you setup your bike to comply with KOPS this may have  put you into a sub-optimal position, which is why you may find yourself moving forward or backwards.
Best advice is to go out with a set of allen keys and level and ride a reasonably long climb.  If you find your self wanting to move forward, try moving the saddle forward  (0.5cm at a time) then retry. Eventually you should be able to fine tune your fit.  The level is used to ensure you can keep the attitude of your saddle (i.e, nose up, level, or down) the same between trials.  Optimal saddle attitude is a topic onto itself (I feel a lot of "experts" have little understanding on the functional bio-mechanics of  hips and how this inter-plays with saddle attitude.)

In about a month I plan to attempt Whiteface Mountain with its 13 km at an 8% grade. If I manage this climb I will be at my limit. Should I move my saddle back for the climb?

Honestly, I think gearing will be the most important factor for surviving 13 km at 8%.  I have done a 40 km ride at a similar gradient and being able to spin is a life saver (when I saw the "only" 19 km remaining I shed a tear). There are lots of long cage road derailleurs and wide range cassettes available now.  I would consider this as the most important change over fine tuning such as saddle offset.
Comment: +2 for the remarks on KOPS and gearing.
Answer: It is not necessary to change your saddle position for climbing. It will not increase your chances to overtake this mountain. It will only give you a less confident feeling as you are riding in a position you are not custom to.
I recommend to do this at the most comfortable position you know and that is your current saddle position.

Climbing advice:
If you can, try and stay in the saddle, going in and out the saddle costs energy. I only recommend going out the saddle when you feel the current section you are on is too steep ( but you must feel this for your own ) or you feel you should change the tension on the muscles ( climbing is a constant tension for the muscle and to change the feeling you can go in and out the saddle ).
As for you being at the limit. I don't think that this is possible, almost anyone can do these climbs if you have the right gears to do it and the motivation to get to the top!
Comment: In a previous attempt last summer I failed horribly. At 2.5 km my lower back and glutes became too painful to continue. I have had a quality bike fit, and I have been doing strength and core exercises since that time. In 2017 I have logged over 5,000 km, and twice a week I do hill repeats on an 8 – 10 % grade.
I'm a stubborn 70 year old and refuse to change my 28 on the rear cassette. My estimate of prolonged wattage (150) suggests that I will need to ride slowly (8 - 9 km/hr), to have any chance. I need all the help that I can get!
Comment: Wow @Bob your quite the example of a mental strong cyclist! I respect that! I know the pain of refusing to change the rear cassette.. I used to race with the espoirs in Europe (i'm belgian) and after 3 years of being almost fully inactive we went to do the marmotte course.. still riding my old competition bike with the 11-21 rear cassette.. It just felt silly to replace it so I know the pain :D but you should really consider it. What is the gear you have at the front (please don't say 39) :D
Comment: @Bob Be careful with your now-72-year-old knees. You're less likely to damage them pedalling faster in an easier gear than pedalling slower at the same power, which requires higher forces.
Comment: @Bob I find a 34x28 is still over-geared for many climbs and my FTP is little more than 2x yours! There is no shame in some in easier gears. With 11 speed I find there is little penalty to running a 32 cassette, and a lot to gain.
Answer: Moving backwards in the saddle straightens out the leg and increases the peak power output (hence why track sprinters have their saddles set so high), but it also reduces efficiency.
The advice to slide backwards in the saddle was probably meant for short steep sections.
Think about getting a gear ratio that lets you pedal at a reasonable speed and sit in as normal a position as you can as this will be the most efficient and effective.
Answer: Depends on whether road biking or mountain biking.  in mountain biking you are looking for traction on uneven terrain when climbing - sitting forward facilitates traction on both tires.  In road biking, you have smooth tires and smooth terrain.  Shifting slightly back in saddle when climbing increases traction on the rear wheel, which is the only wheel taking your power (front wheel is passive), and reduces friction on the front tire, which is what you want.
Comment: Welcome to the site! I'm not really convinced by this: unloading the front wheel while putting out a lot of power is likely to cause a wheelie. And if reduced load on the front wheel were desirable, wouldn't we ride that way all the time? Why just on climbs?

Saddle position for a long steep climb


Summary of differences between Java versions?

Question: What are the major differences in between Java version in terms of software development? Where can one find a summary of the most important changes related to programming?
The Release Notes such as http://www.oracle.com/technetwork/java/javase/releasenotes-136954.html can be hard to read.
For example there is new code structure "for each" in Java 1.5.
Comment: In the compiled Java documentation from [http://javadoc.allimant.org](http://javadoc.allimant.org/), you'll find a *what's new?* section in the table of contents. A [Java Version History](http://en.wikipedia.org/wiki/Java_version_history) is available on Wikipedia.
Answer: This is a summary of the excellent Wikipedia article about the Java version history. It is highly selective (and biased on what I know and use), otherwise it would simply turn out to be a copy of the article.
The bold parts are what really brought the language forward as a whole. As you see, not every release has bold parts.
Java 11
JSR 384, what's new
Language changes:

Local-Variable Syntax for Lambda Parameters

Library changes:

JEP 321 Http Client standardized

Java 10
JSR 383, what's new
Language changes:

Local variable type inference (var keyword)

Java 9
JSR 379, what's new
Language changes:

further continuation of Project Coin (small language improvements)

Library changes:

Java Platform Module System (jigsaw)

modularization of the platform itself
makes modules a first-class citizen meant to replace the messy classpath with modules with real dependency information

Other changes:

People seem to have gotten over the 1.x naming convention, almost no one calls this "Java 1.9".

Java 8 (a.k.a 1.8)
JSR 337, what's new
Language changes:

lambda expressions (JSR 335, includes method handles)
continuation of Project Coin (small language improvements)
annotations on Java types

Library changes:

Improved Date and Time API

Java 7 (a.k.a 1.7)
JSR 336, features and enhancements
Language changes:

Project Coin (small changes)

switch on Strings
try-with-resources
diamond operator

Library changes:

new abstracted file-system API (NIO.2) (with support for virtual filesystems)
improved concurrency libraries
elliptic curve encryption
more incremental upgrades

Platform changes:

support for dynamic languages

Java 6 (a.k.a 1.6)
JSR 270. features and enhancements
Mostly incremental improvements to existing libraries, no new language features (except for the @Override snafu).
Java 5 (a.k.a 1.5)
JSR 176, features and enhancements
Language Changes:

generics (that's the big one)
annotations
enum types
varargs, enhanced for loops (for-each)

Library changes:

concurrency utilities in java.util.concurrent

Java 1.4
JSR 59
Language changes:

the assert keyword

Library changes:

regular expressions support
NIO
integrated XML handling

Java 1.3
Mostly minor improvements, really.
Platform changes:

HotSpot JVM: improvement over the original JIT

Java 1.2
Language changes:

the strictfp keyword

Library changes:

a unified collections system
Swing as a new UI-System on top of AWT

Platform changes

a real JIT, greatly improving speed

Java 1.1
Language changes:

inner classes

Library changes:

AWT event changes
JDBC, RMI
reflection

Java 1.0
Initial release, everything is new ;-)
Comment: The explanation for why Java 6 had so little changes seems to be at [JSR 270 page](http://www.jcp.org/en/jsr/detail?id=270): it looks like back then, they were experimenting with idea of _time-driven_ releases instead of _feature-driven_: "goal is to ship feature releases on a regular 18-24 month cycle..."
Comment: Hey Axel, please do not  feel bad, at all. Certainly let's blame the web! Why can't we republish the contet from Wikipedia here on PE? Why do we have to resort to copy and paste? Why is there no mechanism to display content from Wikipedia in pE? IMO this should be basic stuff. Imagine java 1.9 comes out what do you think. Which page will be kept uptodate ?this answer is just copy and paste, programmers should avoid it, no?
Comment: @AndreasScheinert: the focus of Wikipedia is different from SE. The full Wikipedia article would definitely be too much information for this question. Also, I think that the licenses would not allow copy-and-paste of content.
Comment: @gnat: that sounds about right, but the answer is stuffed enough as it is, I'd like to keep additional info like this out of the list.
Comment: @JoachimSauer yup, your answer sounds about right without these details "embedded". Though... it probably wouldn't hurt if you add links to respective umbrella JSRs for 1.4 and later releases, that would implicitly cover it, along with maybe more details


How to pass a string variable data from Form2 to Form1?

Question: It's a program that reads student data from a text file and displys it in a listbox(Form1). From there on you can add a new student to the textfile by clicking on "Add" button that shows another form(Form2) and you input the new student data into the appropriate text boxes. Afterwards you can press "Add" button(Form2), but the Add Student(Form2) window comes up again with all the inputted data gone, and if I place the new student info into the text boxes again and click "Add", the program jumps back to the Form1 and a message box suppose to say what was added to the textfile, but nothing was added except for empty listbox items.
Answer: Normally Form1 instantiates Form2 and shows it. You could add a public property getter on Form2 which will contain the necessary information and Form1 could fetch it from the instance of Form2 when needed.
Answer: I think you have the assignments backwards; you're setting the textbox values to elements of the string array, which are all null because they were never set. Try that first.
Another thing you could do is place the instance of the data array on Form1, and pass it by reference to Form2's constructor. That way, Form2's job is simply to collect data, and doesn't really have to know implementation details about Form1; all it needs is an array of strings (or preferably a class with named properties) in which to store its data. Form1 can then examine the DialogResult of Form2, and if it's "OK" then Form1 knows that there's data in the array it passed to Form2, and it can handle manipulation of its own ListView and writing to the file.
Answer: Make properties on the second form and then on the first form check the properties to get the value.


Intellij reformat on file save

Question: I remember seeing in either IntelliJ or Eclipse the setting to reformat (cleanup) files whenever they are saved. How do I find it (didn't find it in the settings)
Answer: This solution worked better for me:

Make a macro (I used Organize Imports, Format Code, Save All)
Assign it a keystroke (I overrode Ctrl+S)

Note: You will have to check the box "Do not show this message again" the first time for the organized imports, but it works as expected after that.
Step-by-step for IntelliJ 10.0:

Code -> "Optimize Imports...", if a dialogue box appears, check the box that says "Do not show this message again.", then click "Run".
Tools -> "Start Macro Recording"
Code -> "Optimize Imports..."
Code -> "Reformat Code..."
File -> "Save all"
Tools -> "Stop Macro Recording"
Name the macro (something like "formatted save")
In File -> Settings -> Keymap, select your macro located at "Main Menu -> Tools -> "formatted save"
Click "Add Keyboard Shortcut", then perform the keystroke you want. If you choose Ctrl+S like me, it will ask you what to do with the previous Ctrl+S shortcut. Remove it. You can always reassign it later if you want.
Enjoy!

For IntelliJ 11, replace
step 2. with: Edit -> Macros -> "Start Macro Recording"
step 6. with: Edit -> Macros -> "Stop Macro Recording"
Everything else remains the same.
IntelliJ 12
8. The Preferences contain the Keymap settings. Use the input field to filter the content, as shown in the screenshot.
Comment: In IntelliJ 11:

1: Start macro recording: Edit -> Macros -> Start macro recording.
2: Follow instructions above.
3: Stop macro recording: Edit -> Macros -> Stop macro recording.

In the Keymap the macro is saved to the Macros folder instead of the Main Menu -> Tools folder.
Comment: If you're happy with how code is reformatted then this approach works much better if you choose to reformat **all** code in the project and save all. Otherwise when you make multi-file edits only the active one is reformatted before all modified are saved.
Comment: in V 2021.2.2 this has become a built in feature in `File | Settings | Tools | Actions on Save`
Comment: i am using intellij 11. The macro formates only the file which is open and not the whole project. What can i do?
Answer: I suggest the save actions plugin. It also supports optimize imports and rearrange code.
Works well in combination with the eclipse formatter plugin.
Search and activate the plugin:

Configure it:

Edit: it seems like it the recent version of Intellij the save action plugin is triggered by the automatic Intellij save. This can be quite annoying when it hits while still editing.
This github issue of the plugin gives a hint to some possible solutions:
https://github.com/dubreuia/intellij-plugin-save-actions/issues/63
I actually tried to assign reformat to Ctrl+S and it worked fine - saving is done automatically now.
Comment: The Plugin was (as of now) last updated _10.02.2016_ and says `Compatibility
   This plugin works with Java 6+ and Intellij IDEA Community Edition after 131 (around version 13).`
I don't know which Version of IntelliJ Android Studio is based on. Can you check this?
Comment: I'm slowly adding new products (Android Studio, PyCharm, etc.), you can use a beta version and follow advancement here https://github.com/dubreuia/intellij-plugin-save-actions/issues/18 (I'm the plugin dev)
Comment: I used this but after updating to Android Studio 1.5.1, I can't find it anymore.
Comment: Almost worked for me. Unfortunately, the "reformat code" would do only a subset of the things that "Code > Reformat code" does (at least for Scala code). Why is that?
Comment: Tried this but IntelliJ saves far to often. Organizing imports pops up ever 2-3 keystrokes.
Comment: Confirming Ash, in my case it launches reformatting every 2 seconds.. :O OMG
Comment: There seem to be hints on how to solve this issue in this github thread of the plugin https://github.com/dubreuia/intellij-plugin-save-actions/issues/63
Comment: The plugin will only trigger (and reformat) when you switch windows. If it happens more often then that, it is because another plugin interfere with the save mechanism (Eclipse formatter for example). Open an issue on https://github.com/dubreuia/intellij-plugin-save-actions/issues with installed plugins and I'll try to correct the problem by filtering save event (I'm the plugin dev).
Comment: Unfortunately, this plugin does not perform a complete "cleanup" action, so not sufficient for anything except including inspections auto-fix and simple re-formatting.
Answer: Below is Neil's answer updated.
IntelliJ 13 Steps:

Code -> Reformat Code

Edit -> Macros -> Start Macro Recording
Code -> Reformat Code
File -> Save all
Edit -> Macros -> Stop Macro Recording
Name the macro (something like "formatted save")
File -> Settings -> Keymap
Right click on the macro. Add Keyboard Shortcut. Set the keyboard shortcut to Control + S.

IntelliJ will inform you of a hotkey conflict. Select "remove" to remove other assignments.
Comment: I disagree, @GaneshKrishnan. This workaround does not bind the "save key" to the "reformat key". It binds it to a macro that "reformats *and* saves", which is exactly what was asked for by OP and what is implemented in Eclipse, but triggered with a check box.
Comment: But this removes the "Save" action. What the poster has seen is that in Eclipse we have the option to format code and organize import automatically when a file is saved. This option is (I assume) absent in IntelliJ idea. This is a work around which involves binding the save key to the reformat key.
Comment: I think maybe for step 1 you mean "Code -> Show Reformat File Dialog" to set the defaults for Reformat File Dialog (so that they are set correctly for step 3 - Reformat Code)?
Answer: I set it to automatically clean up on check-in, which is usually good enough for me. If something is too ugly, I'll just hit the shortcut (Ctrl-Alt-L, Return). And I see they have an option for auto-formatting pasted code, although I've never used that.
Comment: Ctrl+Shift+F is *Find in Path*.
Comment: You can also use Ctrl-Shift-F to format.  That works way better for me, since Ctrl-Alt-L is the lock screen command on Ubuntu.
Comment: How do you set up something to happen on check-in?
Comment: Does that work if you are not checking in using intelliJ i.e I think it won't work if you checking in using command line tool.
Comment: How does that answer the question?
Comment: @Ben it doesn't, but it was enough for OPs problem problem, even tho he asked about a specific way f solving it - which was not answered.
Answer: Rejoice! In IDEA 2021.2 there is finally "File->Settings->Tools->Actions on Save" where you can select Reformat code, Optimize imports, Rearrange code, Run code cleanup, Run eslint --fix etc.
Comment: This should be the accepted answer at this stage. The macros approach works fine but this is the best option with the latest IntelliJ feature set.
Answer: If you have InteliJ Idea Community 2018.2 and above the steps are as fallows:

In the top menu you click: Edit > Macros > Start Macro Recordings
(you'll see a window lower right corner of your screen confirming
that macros are being recorded)
In the top menu you click: Code >
Reformat Code (you'll see the option being selected in the lower
right corner)
In the top menu you click: Code > Optimize Imports
(you'll see the option being selected in the lower right corner)
In the top menu you click: File > Save All
In the top menu you click: Edit > Macros > Stop Macro Recording
You name the macro: "Format Code, Organize Imports, Save"
In the top menu you clock: File > Settings. In the settings windows you click Keymap
In the search box on the right you search "save". You'll find Save All (Ctrl+S). Right click on it and select "Remove Ctrl+S"
Remove your search text from the box, press on the Collapse All button (Second button from the top left)
Go to macros, press on the arrow to expand your macros, find your saved macro and right click on it. Select Add Keyboard Shortcut, and press Ctrl+S and okay.

Restart your IDE and try it.
I know what you're going to say, the guys before me wrote the same thing. But I got confused using the steps above this post, and I wanted to write a dumb down version for people who have the latest version of the IDE.
Comment: Thanks. This works for intellij 2020.3 too!
Answer: Ctrl + Alt + L is format file (includes the two below)
Ctrl + Alt + O is optimize imports
Ctrl + Alt + I will fix indentation on a particular line
I usually run Ctrl + Alt + L a few times before committing my work.  I'd rather it do the cleanup/reformatting at my command instead of automatically.
Comment: Careful on Linux as `Ctrl + Alt + L` is commonly Lock Session. You'd need to remap one of the functions.
Comment: Replace Ctrl with Cmd for Mac
Comment: The Ctrl-Alt-L key can be unbound in Ubuntu.  https://stackoverflow.com/q/24908490/53897
Comment: This really doesn't answer the question at all.
Answer: If you're developing in Flutter, there's a new experimental option as of 5/1/2018 that allows you to format code on save.
Answer: I wound up rebinding the Reformat code... action to Ctrl-S, replacing the default binding for Save All.
It may sound crazy at first, but IntelliJ seems to save on virtually every action: running tests, building the project, even when closing an editor tab. I have a habit of hitting Ctrl-S pretty often, so this actually works quite well for me. It's certainly easier to type than the default bind for reformatting.
Answer:
IntellIJ 14 && 15: When you are checking in code in Commit changes dialog, tick the Reformat code checkbox, then IntelliJ will reformatting all the code that you are checking in.

Source: www.udemy.com/intellij-idea-secrets-double-your-coding-speed-in-2-hours
Comment: Beware that excessive promotion of one resource may be interpreted by the community as spam. You should post good, relevant answers, and if one or two happen to mention this course, that's fine - but if you're posting it in every answer, it's going to get flagged and deleted.
Comment: What did I said [here](http://stackoverflow.com/questions/3754333/what-is-the-shortcut-in-intellij-idea-to-find-method-functions/36825075#comment61221258_36825075)
Answer: For PyCharm/IntelliJ IDEA:

Install black.

$ pip install black

Locate your black installation folder.

On macOS / Linux / BSD:
$ which black
/usr/local/bin/black  # possible location

On Windows:
$ where black
%LocalAppData%\Programs\Python\Python36-32\Scripts\black.exe  # possible location

Note that if you are using a virtual environment detected by PyCharm, this is an unneeded step. In this case the path to black is $PyInterpreterDirectory$/black.

Open External tools in PyCharm/IntelliJ IDEA

On macOS: PyCharm -> Preferences -> Tools -> External Tools
On Windows / Linux / BSD: File -> Settings -> Tools -> External Tools

Click the + icon to add a new external tool with the following values:

Name: Black
Description: Black is the uncompromising Python code formatter.
Program: <install_location_from_step_2>
Arguments: "$FilePath$"

Format the currently opened file by selecting Tools -> External Tools -> black.

Alternatively, you can set a keyboard shortcut by navigating to Preferences or Settings -> Keymap -> External Tools -> External Tools - Black.

Optionally, run Black on every file save:

Make sure you have the File Watchers plugin installed.
Go to Preferences or Settings -> Tools -> File Watchers and click + to add a new watcher:
Name: Black
File type: Python
Scope: Project Files
Program: <install_location_from_step_2>
Arguments: $FilePath$
Output paths to refresh: $FilePath$
Working directory: $ProjectFileDir$

Uncheck "Auto-save edited files to trigger the watcher" in Advanced Options
To format Python files with Black, I followed this guide, which also uses File Watcher:
https://black.readthedocs.io/en/stable/editor_integration.html
Answer: Since version 2020.1, you can activate Run on save for files directly in the Preferences of the Prettier plugin:
Comment: IntelliJ is not only for JavaScript projects so this is not an answer
Comment: @Farid IntelliJ does support JavaScript projects though and so this answer is apparently helpful to other people. The question does not ask for a solution that covers all possible cases nor states a specific case/language.
Answer: I thought there was something like that in IntelliJ, but I can't find it.  The only clean-up that happens at save is that white space at the ends of lines is removed.  I thought I had to specify that behavior at one point, but I don't see anything related at this point.
Answer: If it's about Prettier, just use a File Watcher :
references => Tools => File Watchers => click + to add a new watcher => Prettier
https://prettier.io/docs/en/webstorm.html#running-prettier-on-save-using-file-watcher
Comment: Prettier is great but it doesn't work for languages/formats outside of the web. It'll format js, ts, css, json, etc. but is useless for C, C#, Java, Python, etc. - with the exception of some early attempts at plugins.

Intellij reformat on file save