Why is it often more expensive to repair and maintain than to buy new?

Question: What are the main factors and drivers that repairing and maintaining is often significantly more expensive than buying the good new?
Comment: This is very broad. Can you narrow to a specific good or type of goods? Something you have in mind?
Comment: This is broad, but a good question nonetheless. Would targeting it to a specific item type of item (car, appliance, furniture) make it more acceptable question?
Answer: Whether repairing or replacing is cheaper varies a lot between situations.

You wouldn't buy a new bike or car because of a flat tire.
Depending on the hole and your DIY abilities, replacing the tube or tire or patching are the usual ways to deal with this.
But putting in a replacement zipper into a well-worn jeans is a different situation as the repair starts by almost completely disassembling the jeans. So even a professional jeans sewing expert may need considerably more time to replace the zipper than sewing a completely new jeans. If then the expected increase in remaining lifetime isn't that much because of general wear, replacing the whole jeans may be the way to go.
In addition, if the zipper is never failing before the jeans is thrown away due to wear and tear, it was an overengineered waste of ressources.

Of course, two products with the same functionality may be more or less repair friendly, thus potentially shifting the rational, economic and ecological decision boundaries.

There are also often inherent trade-offs for the producer that affect repair friendliness:

repair friendly vs. ruggedness:   consider a mobile phone, gluing the case and soldering the battery vs. screwing on a lid over replaceable battery. The latter is clearly more repair friendly, but without additional effort, the former may be more rugged against falling, water and contact issues of the battery.
repair friendly vs. ease of assembling:    consider some household machine with the case being plastic and screwed vs. clicked on. The former is repair friendly, but the latter is more easily assembled in the factory.
spare parts: repair friendly design makes sense only if spare parts are produced and sold for the envisioned (enhanced) lifetime of the product.
This can be quite costly. Not only in terms of money, but there are likely to be also ecological trade-offs (which may improve with small series manufacturing/production on demand improving).
spare parts vs. product improvement: Supplying spare parts is easier/cheaper if your product stays the same over longer time/many units. While many changes in products are largely motivated by marketing without providing better functionality, there is also an imoprtant tradeoff here in case of improved functionality.
E.g. is it better to stick to the current fridge model in order to supply spare parts for longer, allowing for repair and increased lifetime - or is it better to discontinue the model and move on to a more energy saving next model?
repair-friendly design: (incl. using mostly standard parts). A product that has a given functionality and is as repair friendly as possible may not only be more expensive to produce, but already the development is probably more expensive as not-repair-friendly ideas have to be improved upon.
Of course, if repair-friendly design becomes more common, standard solutions will emerge and the state of the art in this respect will improve.
However, I'm told that universities around here do not even offer courses in safe design (as in product safety) for engineering students - despite safe design being a legal requirement for decades now.
Safety vs. ease of disassmbling: Where I am, certain types of safety measures must be attached in a manner that they cannot easily be disassembled or otherwise put out of action.
Also, the click-on case in the 2nd example may better from a product safety point of view if it cannot easily be taken off.
Legal risk: (I'm in the EU)
An additional thought may be (depending on legislation) that e.g. such cases that are not easily disassembled may give the manufacturer a bit more legal safety wrt. accidents during repair attempts: even if the manual says "do not attempt to repair", a case that is trivially taken off would be a foreseeable misuse and thus have the producer liable for safety/accidents.
Also, I just learned in a seminar about product safety legislation and in contrast to data services where GPPR over here make decided statements against vendor lockin, allowing repairs or merely handing out detailed plans of the product that make the users think they may repair it may place the manufacturer at higher risk in case of accidents.
This doesn't mean repair friendly cannot be done with acceptable legal risk, but it does mean that releasing (existing) information that would come handy for repair comes at surprisingly high cost for the producer: there is basically no possibility to say take this info at own risk - if released, it basically has to be in the form of a repair handbook that is safe for the average customer (or repair person).
(I've been interested in DIY labware projects for some time - and after that product safety regulation seminar I understand quite a bit better where the high prices for some not-too-complicated labware machinery comes from: the existing regulations are extremely unfavorable to anything that isn't a mass product)
Comment: @ChrisH: that is also a possibility - this is by no means meant as an exhaustive list of engineering/design trade-offs.
Comment: Rugged may actually be *more* repairable - but heavier, bigger and less desirable.  The material needed for screws to fit often adds toughness.  I have a cheap, tough, waterproof phone, and it's screwed together - but it's massive.
Comment: Yes, I'm in broad agreement, but posted my comment quickly before I could say so or vote up, as I had to go for my train.
Comment: BTW, regarding your last paragraph, I made a good start on the design for a spin coater (electronics, vacuum chuck etc.) before we found the money to buy one. That would have been open sourced if we'd finished it.
Answer: Costs and consumers shopping for low prices. Most "stuff" is made in massive quantities in factories where process and other types of engineers have refined the steps to produce an item. Each person on the floor needs to know only one small bit of the operation. Alternatively, to repair something, a capable service man needs to know all aspects of the item. Such knowledgeable service people are expensive to train, equip and require relatively high pay. So repairs cost more than manufacture of a new item generally.
Comment: This is basically what I would say, except I want to emphasize that building something is easy to entirely automate because it's the same thing every time. Every repair job is different and requires coming up with solutions.
Answer: It is a question of man hours used with technology against man ours (your time used in making repairs) without technology. If you worked in a factory you could make a hundred items in the time it would take you to repair one item. Even with a household sewing machine, you couldn't keep up with the speed of factory output. Everyone who works for a wage is in some way contributing to factory output. So any time that you spend repairing anything is going to be less productive than the time you spend at work. To make repairing "Pay" you need to corner a niche, and repair things that other people value and want to keep so much that they are willing to pay a bit more for them. Only that way can you make your time spent repairing, equal in value to time spent earning a wage.
Comment: I don't think this is true in general. There are cases where the repair effort is clearly much lower than the value added broken -> working product. But yes, there are also cases where repairing isn't worth while.
Comment: As stated above most electrical items are deliberately made not to be reparable, ostensibly for safety reasons. There is also the fact that the component parts are changed regularly so that new parts will not fit older machines. But looking at fabrics, repairing and redesigning can be more productive than buying new, and boutiques are starting up selling redesigned clothing. I do agree that in tiny things like darning a sock it probably is worthwhile.
Answer: Another element that other answers haven't touched on is Economic Production Quantity.
For many components in products, for example the metal casing of a washing machine, or any plastic injection moulded part, the machinery required to produce them takes a significant amount of set up time. This set up involves getting the mould out of storeage, installing it in the press or injection moulding machine, checking it all works.
The material that parts are made from could be only available by the tonne, sufficient to make a few thousand of components. It might be impossible to buy the material to make just one unit.
So production runs for some parts will be several thousand. Because the set up costs and material costs are spread out over several thousand, then one part might only cost $1. But if you were to 3D print, or otherwise just make one of that part it would cost $20.
If you were an artist making one discrete product, you might be willing to pay $20 for each component and £2,000 for the finished piece. But to mass produce a product in quantities of thousands then a lot of cost can be taken out due to manufacturing in bulk.
Another example is in logistics. In a factory a storeman will be given a list of parts to build a batch of products, they will wander round the warehouse locations grabbing each part. It takes approximately the same amount of time to visit each location whether the batch size is one unit or a hundred units. He still has to get paid, but if he's doing a batch of a hundred then the cost is spread out more thinly.
Comment: ... and this also applies to spare parts: in order to supply spare parts after the production of the new product ends, you'll either have to face the high unit costs of producing them on demand (including the cost of holding some required machinery/storing the mold/making a new mold), or you have to face storage costs of spare parts produced while the production was still running.
Answer: I'm a few years late to this discussion. There are lots of great answers here, but an underlying problem which humanity, given its creativity and ingenuity, ought to be able to solve. And companies that do, will earn loyalty from the consumers who are paying attention.
Here's the problem, very specific, but applicable in other circumstances. I buy canopies from Costco for events. Costco Business has reliably carried the same canopy for 3 years. The canopies currently cost $225. The canopies get damaged periodically, by wind mostly. The larger diameter leg is what consistently breaks. The cost of this replacement part is $140 for 2. Each canopy contains 4. So rather than buying replacement parts, I buy a new canopy and strip the broken one down for parts. But I only keep the outer legs. The rest goes in the landfill. The "rest" is made up of 1 broken part and around 200 unbroken parts.
I understand "why" the replacement leg cost so much to make. I don't understand why we're not coming up with better solutions.
Do you buy anything from a company that's conscientious about this issue?
Comment: Welcome to Sustainable Living and thank you for your answer. You say you understand why the replacement leg costs so much. Could you please explain this? The tent costs $225, but buying 4 legs separately would cost $280. Not even counting the costs for other materials, that is already quite a big difference.
Answer: Clothing, furniture, appliances are examples longterm investment that can be mitigated thru maintenance.  However real solution is finding industry uses for it when it's scrapped..... if clean, renewable energies are involved in manufacturing, it's environmental footprint is reduced.
Cotton is biodegradable.... or incinerate-able for power. So is wood.
Appliances made from steel, aluminum are recyclable.
Rubber and synthetic materials should be returned to stores whom have recycling programs.


how to find the class that will be executed when Android app is started?

Question: working on an Android App.  It is quite big and involved.  I need to find the class that will be executed when the App starts up, for example in Eclipse when it is run.  How can I find this class? Is there some standard?
Comment: Your main activity will be the first class to run...
Answer: Check your AndroidManifest.xml, it's located there with the flags:
<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Answer: From the docs:

When you create a new application using the Android SDK tools, the stub activity that's created for you automatically includes an intent filter that declares the activity responds to the "main" action and should be placed in the "launcher" category. The intent filter looks like this:

<activity android:name=".ExampleActivity" android:icon="@drawable/app_icon">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

And later:

The  element specifies that this is the "main" entry point to the application. The  element specifies that this activity should be listed in the system's application launcher (to allow users to launch this activity).
If you intend for your application to be self-contained and not allow other applications to activate its activities, then you don't need any other intent filters. Only one activity should have the "main" action and "launcher" category, as in the previous example.

In other words, the activity that has an intent filter with action = "android.intent.action.MAIN" and category = "android.intent.category.LAUNCHER" is the activity that runs first when uses presses you app icon.
Since your project is "quite big and involved", I suggest you get the basics - please read the docs about activities, manifest..
Answer: Look at your Manifest.xml file:
 <activity
  android:name=".LoginActivity"
 <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" /> <-LUNCHER ACTIVITY
  </intent-filter>
 </activity>

Answer: Look in the AndroidManifest.xml
The activty with action.MAIN and category.LAUNCHER will start first
Answer: Some pointers that might help you:

It's usually called MainActivity
If it isn't called MainActivity in your case, open AndroidManifest, press ctrl + F and search for "LAUNCHER" to see which class will start up first
Comment: This is not the class which runs first. Application is
Answer: look at the java codes. you should be albe to find classes there. I think it is in the src folder


Windows Application Guideline

Question: Is there a guideline for designing Windows Applications, whereas they specify font size and spacing, best screen resolution?
Comment: The first and second results on the first page for Google search provide the right answer to this question, as checked today.
Answer: Yes, of course MS has its own user interaction guidelines and they are available online: Windows User Experience Interaction Guidelines
Answer: It's worth looking out for an older version of the Windows guidelines - which had more actionable detail:
Here's a link to them in book form:
The Windows Interface Guidelines for Software Design
Scroll down for the Contents list...
Microsoft used to have these on their website - but I can't find them now.

Windows Application Guideline


Radial wave-functions and spherical harmonics of p-orbitals in a certain hypothesis

Question: I know that the s-orbitals of H atom are spherically symmetrical. But the p,d or f orbitals aren't. So, the H-atom needn't necessarily be spherically symmetrical, as the wave-function would be a linear combination of all the orbitals. But, in a certain hypothesis, if I assume the H-atom to be spherically symmetrical, what could I possibly comment on the specific orientations of $p_{x}$, $p_{y}$ and $p_{z}$ orbitals in space? The radial and angular wave-functions might/mightn't change for the p-orbitals, but how to comment on their spatial orientations? Can someone help me out in this?
Comment: Why take care of the $p$ orbitals of the hydrogen atoms ? It is like its $d$ and $f$ orbitals. They are empty. So why discuss about  their spatial orientation and of their linear combinations ?
Comment: Okay, but what about the excited states? Is it unnecessary altogether to look at $p$ or $d$ orbitals, or even $f$ orbitals in H atom?
Comment: Why take care of the excited states of the H atom in chemistry ? They last less than a nanosecond.
Answer: In "real life", the hydrogen atom has its only electron in the s orbital. And unless it gets to an excitated state, that's the only thing that matters (whether you're studying the energy of the atom or the bounds it can make in terms of energy or symmetry).
Nevertheless, the H atom is likely to have a spherical symmetry, so any of its p-orbitals will be orthogonal to the others, so their linear combination is likely to keep the overall spherical(-ish) symmetry of the atom.
Here is a representation of such orbitals :

(Reference)
Hope this helps!


Drawing, and Appending to a Double-Horizontal Line

Question: I know how to draw straight lines in C#, but I would like to draw a horizontal line, with two colors. Light blue on the top, and dark blue on the bottom. Also, how would I sort of... Append to that line? For example, every few seconds, that line will become bigger... like a ProgressBar. (btw, I'm not creating a ProgressBar, just using that as an example).
Here's the kind of line that I'd like to draw. I am aware that I can simply use PictureBox. But I want to start drawing!
Also, if there are other ways of drawing, than GDI or GDI+, could you list or link to those?

Thanks!
Answer: You can implement the onPaint event on any Control and then do the drawing manually on the passed graphics object.


Can you tp entities to other entities in java 1.16.1

Question: im trying to create a trident that when thrown will make salmon tp to it.
the example command is tp @e[type=husk] @e[type=snowball] this was the test but it didnt work with (@e[type=snowball]) being red. Am i doing something wrong or is it possible at all.
Answer: Look at the error message caused by @e[type=snowball].
Only one entity is allowed, but the provided selector allows more than one at position 0:

What you need to do is limit the number of entities returned to 1. So try the following instead:
@e[type=snowball,limit=1]

Learn more about these concepts on the Minecraft Wiki:

Target selector arguments
Answer: What should that command do if there is more than one snowball on the map? It doesn't make sense to teleport one entity to more than one, and Minecraft can't tell which snowball you mean, so it throws an error.
Do you want to ...
Teleport each husk to the snowball nearest to the command block?
/tp @e[type=husk] @e[type=snowball,sort=nearest,limit=1]

Teleport each husk to the nearest snowball to the husk?
/execute as @e[type=husk] at @s run tp @s @e[type=snowball,sort=nearest,limit=1]

Pick a random snowball and teleport all husks to it?
/tp @e[type=husk] @e[type=snowball,sort=random,limit=1]

Assume there is only ever one snowball, and cause unknown behavior if there turns out to be more than one?
/tp @e[type=husk] @e[type=snowball,limit=1]

Something else I haven't thought of?
You have to include limit=1 somewhere in the command to tell Minecraft to only pick one entity to try to teleport things to. At that point, it's a good idea to decide what should happen if there is more than one snowball (or trident in the non-hypothetical case) and modify the command accordingly.


App crashed in Beta on the device, but not in debug

Question: I've created a Beta ad hoc delivery profile, and when I press 'build and run' on the device in beta mode, my app crashes after I press a button.
However, when I use the app in debug mode (on the device) it works fine. It also works fine in the simulator and on the device in beta mode (when it's not connected to XCode)
Any ideas what's up here? It doesn't bother me too much since I can debug in debug mode...but I'm wondering when it comes to the submission process, if this will be a problem?
Thanks!
EDIT: Would this happen to be because I've got an entitlements file (dist.plist) with the option 'get-task-allow' unchecked? I tried checking this box but got an error "The executable was signed with invalid arguments"
Answer: There are many areas that can be the culprit.  You may have an #if or #ifdef DEBUG, or you could have (more likely) some source or xib that is not included in the Beta Target.
You should be looking in the log, whether during its run via Xcode or after when you plug the device back into your Mac and look at the log file using the Organizer window, for more details of the crash.  If it is related to clicking on a button, look at the path between the the button's actions set in the xib and the selector in your code. Sprinkle some NSLogs in there to help you out.
Comment: If you are using different targets, a missing file may be the culprit. If you have the same target for debugging and beta, the NSLog tip will help a lot
Answer: I have experienced this with applications that interact with other systems where timing is critical and debug mode affects the timing of the interaction with the other systems. Specifically when screen scraping an IBM mainframe but any time critical application may experience this.


Page Active/Deactive in wordpress

Question: How can Page or Post Active/Deactive in admin side so front side display or not in wordpress?
Answer: You can change status of any page or blog post in WP to "Draft". Then it disappears for the normal visitors.
Answer: You can Make check according to particular Page , Post Id, Making page as Draft is not the best way .You can make check for page url in header.php file If that particular page or post Id comes into url then automatically will be redirected to home page or the page you want .
Secondly You can also make a menu Where you will not display page in Menu.
Comment: Ok thanks that is done and also right posibility as make menu

Page Active/Deactive in wordpress


What should I write in "Member states of destination" on Schengen visa applications?

Question: I am traveling to Paris staying there for 5 days then flying to Spain and staying there for 10 days.
My understanding is that since Spain is where I am spending most of the time then I should apply for the visa in the spanish embassy.
But how about these fields in my case, How should I fill them?
"Member states of destination" & "Member state of first entry"...
Should they be "Spain" and "France" respectively?
Comment: One is plural and the other one is singular: you can only enter one state but you can visit more that one. So I imagine entry would be Spain, and member States would be Spain and France in your case.
Comment: I believe this one covers some of your questions...
http://travel.stackexchange.com/questions/13362/should-my-first-trip-be-to-the-country-which-issued-my-schengen-visa
Comment: Thanks. I saw this post before but it doesnt mention these fields in the visa application in specific.
Comment: Yes you are correct.
Comment: Seriously?!! no one filled a VISA application before?!!
Comment: Thanks Jo, My first entry is actually France. But yes, I finally figured out the information you stated from other forums.
Answer:
Member states of destination

is plural and

member state of first entry

is singular for a simple reason: you can only enter Schengen from one state but you can visit more that one member state whilst in the Area. So I imagine that in your case first entry would be France, and member destination states would be France and Spain.


Turn emoji back to previous default after upgraded to iOS 8.3

Question: Hello I just upgraded to iOS 8.3. My emoji is now default to kind of yellow colour, which is super annoying. Any ways I could set it back to previous default colour. Thank you!
Comment: hold your finger on the emoji, it will bring up other color options for many of the emoji
Answer: You can try holding down on the emoji you want and see if it brings up a menu to pick the skin color like this:

That feature is mainly only available on the more "human" looking emojis. Doing this will now set the default of that emoji to the color you chose, so I guess you could go through all of them and pick the one you want and they should stay as the new default instead of having to pick from the yellow one every time, but there isn't a way to "revert back" to 8.2 and earlier styles.
Comment: I know hold can change but should have a setting to set default colour : (. The current yellow looks sick. Thanks anyway!
Comment: @juanitofatas Once you set the color to send it once it will remember and that color will be the "default" the next time you open the Emoji keyboard.


Once food has been properly cooked is it absolutely safe?

Question: If you properly cook food (let's say in the oven for 2 hours) will there be no risk left? no pathogen will survive this?
Comment: Depends on what you consider "food". ;)
Comment: Some pathogens are more harmed by heat than others, some are obliterated at 80, 110. Some pathogens require large numbers to hurt you, a couple of tired E-Coli will not harm at all, but a mass of them is dangerous. generally you can boil water for 10 seconds at 100 degrees and it is considered sterilized, in fact that's how they sterilize orange juice, they pass it through a pipe and boil it for a minimum time, say 10 20 seconds.
Comment: Also depends on the elapsed time between cooking and eating.  Leaving cooked stuff in the refrigerator for a few weeks is probably not a good idea.  Nor is cooking stuff like meat that's started to smell...
Comment: You won't be able to eat the food at a temperature that is even close to reducing pathogens. So in any case, the time it spends cooling down will always be time which allows potential pathogens to grow.
Answer: No, no food is ever 100% safe, Prions for instance can survive anything short of incineration, spores can land on food in the transition from oven to wherever, some bacterial spore can survive high temprature, ect.
Answer: Oven does not sterilize!
High temperatures like the one you get in a normal oven (250 degrees Celsius) can kill a great deal of microorganisms but not all of them.
Also, consider that spores (including bacterial spores) can survive to extreme temperatures.
Lab-grade sterilization is obtained by high temperature, at high pressure and high humidity conditions. Have a look at this web page to get a glimpse.
So, even though you can reach high temperatures in a modern oven, you miss the high pressure and uniform humidity needed for a proper sterilization.
Also, as already mentioned by @John, it depends on what you mean for safe. 1) your food can be contaminated with toxic molecules and they may not be degraded by temperature alone, so even if you get a microbiologically clean food, that doesn't make it necessarily safe. 2) Many reactions occur during the cooking process, some of them may lead to accumulation of toxic products like acrylamide, in such a case, cooking make your food less "safe".
Here some literature on the topic:
http://www.annualreviews.org/doi/pdf/10.1146/annurev-food-041715-033144
http://science.sciencemag.org/content/301/5635/934
http://aem.asm.org/content/71/7/3556.full
http://www.sciencedirect.com/science/article/pii/S1878614611001164
https://www.readbyqxmd.com/read/16672493/high-pressure-mediated-survival-of-clostridium-botulinum-and-bacillus-amyloliquefaciens-endospores-at-high-temperature
Just to be clear, I didn't find any scientific paper describing any organism able to survive at 250 C. However 1) it has been shown that spores may survive to dry heat much better than wet heat and some microorganisms have been described to be thriving at more than 120 C. 2) The oven temperature is not the same of the food temperature, in many cases such a heat does not reach the "food core". 3) Unless you cook under a fume-hood, your food gets contaminated as soon you open the oven door.
Comment: Any refs for the claim that some microorganisms can survive 250°C even as spores?
Comment: I have one https://cals.arizona.edu/PLP/courses/plp329/sporeref.pdf  pg. 552, it's only about B. subtilis and it was tested only up to 160 C. I am checking for more...
Comment: -1 This paper gives the well known value of 120°C of wet heat (the one also used in cooking) needed to kill spores of Gram-positive bacteria in reasonable time. This is where the autoclaving temperature comes from.
Comment: To autoclave, you need pressure as well. Without it, you will not get any sterility. I assure you, I deal with microbiology all day long and I am doing it for more than 10 years. If you autoclave bacterial medium without setting the right pressure, you will see molds growing into perfectly sealed bottles in a few weeks. The same occurs if the humidity is too low. Temperature alone is not enough. Look at the plot on pg 552, dry heat for 1h at 160 C and still you don't kill all the spores.
Comment: @har-wradim:  250°C oven temperature does not mean  250°C food temperature, especially if you're cooking something large.  A turkey, for instance, is considered "done" when it reaches an internal temperature of about 75°C, which takes several hours.
Answer: No.
Staphylococcal food poisoning is super common.  The bacteria that cause it are killed by cooking but if they have a chance to grow and make their toxin before they are cooked, the toxin is not destroyed by cooking and can make you sick.  I think this type of food poisoning constitutes most cases where you throw up and have diarrhea about 6 hours after you eat but you rally within 2 days.
From linked source (CDC)

People who carry Staph can contaminate food if they don't wash their
  hands before touching it. Staph can also be found in unpasteurized
  milk and cheese products. Because Staph is salt tolerant, it can grow
  in salty foods like ham. As it multiplies in food, Staph produces
  toxins. Although Staph bacteria are easily killed by cooking, the
  toxins are resistant to heat and so cannot be destroyed by cooking.
  Foods at highest risk of transmitting Staph toxins are those that
  people handle and then do not cook. Examples are sliced meat,
  puddings, pastries, and sandwiches. Food contaminated with Staph toxin
  may not smell bad or look spoiled.
Answer: No for several reasons.
If poisonous bacteria previous got into the food, there could be poisons left over that cooking isn't guaranteed to get rid of.
Some bacteria pack themselves into spores when they are cooked. Spores are incredibly hard to destroy. You might consider irradiating them. A common way to counter this: cook food, let it cool (prompting the spores to unpack themselves), then cook it again.
Then you have the risk of "kitchen-to-table" contamination where the food gets contaminated after cooking and cooling due to poor hygiene practices.


hide the text inside select control

Question: How can I hide the part of the text written inside of the option?
I've tried the following:
<select name='what'>
   <option value='some value'>Value to be shown value to be hidden</option>
   ....
</select>

And here is the CSS.
.hide{ visibility : hidden; }

But it doesn't seem to work. I've also tried display:none instead of visibility:hidden but that doesn't work either.
P.S: Why I want to do this? I want to do this because I want the hidden text to be included in the search.
UPDATE I am well aware that it may be achieved using the html5 meta tags, but unfortunately that I can't use here as I am using Jquery plugin called Chosen and it doesn't support the search over meta tags.
Comment: You can't use html inside `` https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option "Permitted content Text with eventually escaped characters (like é)."
Comment: is the "value to be hidden" part the value of the option which you want to store and the "Value to be shown" the text of the option which you want to be visible?
Comment: @melc Sorry, I couldn't understand your comment?
Comment: Answer to his question is yes
Comment: of you use firebag, you'll see that the span tags are not supported inside option tag. You need to use something else to to that. Like storing that value in the name or other attribute of option tag. And if you want to show that value sometime you just use javascript to add the value from name to the html content of the option. Hope this help you!
Comment: But why you do this? What is the purpose of hiding this text?
Answer: In order to add extra data to your option, e.g. for search, you may use the value or extra attributes of the option element.
For example,
<option value="value to be hidden" data-meta="value to be hidden">Value to be shown</option>

HTML
<select>
    <option value="value to be hidden1" data-meta="value to be hidden11">Value to be shown1</option>
    <option value="value to be hidden2" data-meta="value to be hidden22">Value to be shown2</option>
    <option value="value to be hidden3" data-meta="value to be hidden33">Value to be shown3</option>
</select>

JS
$(document).ready(function(){
    $('select').change(function(){
       $('.output').html($('select option:selected').val()+'
'+
        $('select option:selected').data('meta'));
    });
});

http://jsfiddle.net/uHY5P/
You may introduce as many attributes as you want with the prefix "data-" and retrieve them by calling jQuery.data('yourCustomAttr')
Comment: i am very appreciate with your answer. really you have good knowledge.keep answer always and help others devlopers.
many many Thanks..
Answer: You can't do this. <option> tag cannot contain any other tags. Use Select2
Answer: It's been a while since you posted your question but it may help someone in the future. I went through exactly the same process in the past few days.
I needed to search for select options with or without special characters using jquery Chosen plugin (ver. 1.1.0).
I have a drop down with wine producers which includes names with foreign characters like Château Bénitey. In this case free text search should find the producer with "château bénitey" and "chateau benitey" keywords.
This is how I achieved it:
I used PHP to dynamically convert special characters to their equivalents eg. "â" => "a".
I created an extra attribute in <option> tags in html called data-search-text="Château Bénitey Chateau Benitey".
Then I patched Chosen plugin to read the data-search-text value instead of option text.
In SelectParser.prototype.add_option method I added a new property to store attribute values.
this.parsed.push({
    array_index: this.parsed.length,
    options_index: this.options_index,
    value: option.value,
    text: option.text,
    html: option.innerHTML,
    selected: option.selected,
    disabled: group_disabled === true ? group_disabled : option.disabled,
    group_array_index: group_position,
    classes: option.className,
    style: option.style.cssText, // extra comma ;)
    searchTextAttribute: option.getAttribute('data-search-text') // this is the line I added
});

Then I modified AbstractChosen.prototype.winnow_results method:
Replace:

option.search_match = this.search_string_match(option.search_text,
  regex);

With:
var textToSearch =  option.search_text;
if (option.searchTextAttribute) {
    textToSearch = option.searchTextAttribute;
}

option.search_match = this.search_string_match(textToSearch, regex);

I have multiple dropdowns in my advanced search so only the selects that have data-search-text attribute populated will behave that way.
I also had to remove the feature that highlights matched parts of option text as it was breaking it.
if (searchText.length) {
    startpos = option.search_text.search(zregex);
    text = option.search_text.substr(0, startpos + searchText.length) + '' + option.search_text.substr(startpos + searchText.length);
    option.search_text = text.substr(0, startpos) + '' + text.substr(startpos);
}

Make sure you initialise the Chosen plugin with the following setting, otherwise it will search from the beginning of search only and the converted text won't be matched.
$('.your-select').chosen({search_contains: true});

hide the text inside select control


Google Sheets - Dropdown list populates date in another field

Question: I have a header with "Status" and a simple dropdown that is Open, Closed.
I am trying to set the next header "Date Completed" with today's date.
Not sure where to look at establishing this kind of process.
https://docs.google.com/spreadsheets/d/12PNvyd9lAvrR1lg2pyMsy-CkJ-cgEu8y49xv9xIVyd4/edit?usp=sharing
Comment: Does this answer your question? [Insert current date to cell based on content in other cell](https://webapps.stackexchange.com/questions/88502/insert-current-date-to-cell-based-on-content-in-other-cell)
Comment: Welcome. Your scenario is not clear. Do you mean: when the dropdown value for a given row = "Completed", then you want the current date to be entered in Column B on that row. This requires an `OnEdit(e)` script. There are many (many, many) precedents for this. I have listed one here already.
Comment: "I am trying to set the next header "Date Completed" with today's date." Just to clarify something here for posterity... the date, when it is entered, will be "today's date". Over time, you want the date to remain fixed on the day that it was entered so that you have an accurate historical record of "when" the task was completed. This is the reason that 'today()' isn't helpful because the date would always change to "today's date", and there would be no record of the actual date that the task was completed. This is why you need a script like the one mentioned above.
Comment: I wasn't able to figure out how to read "Closed" and then set todays date.
Answer: This is an example of a script that watches for an edit to cell. The script is written as a "Simple" onEdit trigger
If the edit is "Closed", then the script inserts the date into the cell adjacent to the edited cell.
The script uses Event Objects to get the range and the value of the edited cell.
The desired value ("Closed") of the edited cell is described as a variable.
An If statement tests whether the edited value is equal to "Closed"; if this is true, then the script inserts the current date into the cell on the same row, one column to the right of the edited cell. The script uses offset(Row,Column) doc ref to define the new range.
The script includes two options for the date.

Option#1 (currently remmed out): inserts inserts the date; this means that you should format the cell/column to whatever format you require.
Option#2 formats the date within the code so that the date inserted into the cell is preformatted. You can edit the code to format the data in whatever way suits you.

function onEdit(e) {

  var evalValue = "Closed";
  var range = e.range;
  var editedvalue = e.value;

  if (editedvalue === evalValue){
    // the edited cell is equal to "Closed".
    // so make cell on same row and one cell to right = date.
    // Option#1 - format the cell/column however you like it
    // range.offset(0,1).setValue(new Date());
    // Option#2 - set the format in the code; you can additional formatting this this setting
    // refer "formatDate(date, timeZone, format)"
    // https://developers.google.com/apps-script/reference/utilities/utilities#formatdatedate,-timezone,-format
    var formattedDate = Utilities.formatDate(new Date(), "GMT+8", "yyyy-MM-dd HH:mm");
    range.offset(0,1).setValue(formattedDate);
  }
}


Show that the sum of two uniformly continuous functions is uniformly continuous in an arbitrary metric space

Question: I've seen the proof when you're talking about $\mathbb{R}$ and the metric is the absolute value function, but I'm trying to prove it for an arbitrary metric space. I figure the proof is pretty similar, for a given $\epsilon$, you choose $\delta$ to be the minimum of the $\delta$s required to make $d(f(x), f(y)) < \frac{\epsilon}{2}$ and $d(g(x), g(y) < \frac{\epsilon}{2}$ when $d(x, y) < \delta$. But then I don't know how to argue that $d(f+g(x), f+g(y)) \leq d(f(x), f(y)) + d(g(x), g(y))$. Any help?
Comment: You need some structure on the codomain of $f$ and $g$ in order to even _define_ $f+g,$ so we cannot be talking about an arbitrary metric codomain.  You need to settle that first.  After that, the most common property of the metric you'd need is translation-invariance (or some slightly weaker form), under which the same (or similar) proof as in $\mathbb{R}$ works.
Answer: EDITED:
After the comments of @Brian Moehring,
We assume that the distance is stable under translation and that both $f$ and $g$ target the same space,
$d(f(x)+a, f(y)+a)=d(f(x), f(y))$, So for every $x,y$ such that $d(x, y) < \delta$  we have,
$d(f(x)+g(x), f(y)+g(y)) \leq d(f(x)+g(x), f(y)+g(x))+d(f(y)+g(x), f(y)+g(y))\leq \frac{\epsilon}{2}+\frac{\epsilon}{2}=\epsilon$
Comment: To clarify:  Not every distance is stable under translation (i.e. translation-invariant) so it would be better to state "Assuming the distance is stable under [...]" rather than "We know that the distance is stable under [...]"  That said, absent any specific assumption relating $d$ and $+$ in the problem statement, we cannot prove anything, so this at least gives a good proof under that additional assumption.


Woocommerce thankyou page is not working after checkout

Question: Today I ran into an interesting issue. After payment thankyou page is not displayed. There is only white screen with menu. You can see it in the screenshot. thankyou page http://prntscr.com/ofpnuu
I tried to create a custom thankyou page and tried to redirect it from the function.php but nothing happened. Then I installed the plugin to create thankyou page but again nothing happened. I have run out of ideas. Can someone tell me how to solve this issue.
Answer: Use the hook below to redirect to the thank you page. Create a thank you page and redirect to that url...
Check the code below:
<code>add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' );
function wc_custom_redirect_after_purchase() {
  global $wp;
  if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
    wp_redirect( 'http://www.yoururl.com/your-page/' );
    exit;
  }
}
</code>
Comment: Yep! I've used this hook for creating redirect. But and here is my test page: https://www.nano-jewelry.co.il/thank-you-page-test/ As you can see it works. But when customer bought some item this page doesnt work( Instead of it apeears broken page like on screenshot above.


'Year Obtained from education' on CV meaning

Question: So I am filling out a CV and answering about my education, when it comes up 'year obtained' I have never come across this on a CV before and if I have it hasn't been worded this way. Could someone help me? I am confused about whether it asking me the year I started or left,
Thank you.
Answer: "Year obtained" refers to the year that you received your degree or certification, when you completed your course of education. If you never completed the course, I suppose you could put your last year, but be careful that you don't misrepresent yourself as having a qualification that you didn't complete.


Do desk rejects happen after one and half months?

Question: I submitted a paper to a math journal and after one and half months (the status showed "under review") it was rejected without any report. Does this mean it was a desk rejection?
Comment: Not sure what kind of answer you're looking for, but the brief answer is "yes".
Comment: If this is something that happened to you right now, also keep in mind that the preceding one and a half months include new years, christmas and thanksgiving, which might simply have delayed things compared to normal.
Answer: I think this is not usual, but if the editor has trouble finding referees this can make them decide to desk reject.
I've been waiting almost two months for the editor to assign reviewers to one of my papers and I'm expecting a desk rejection at some point if they don't manage to find reviewers. The peer-review crisis is probably making this problem more common.
Comment: An apparent case of desk reject after failing to find referees can actually be found in [one of OP's earlier questions](https://academia.stackexchange.com/q/196462/17254). One and a half months over the holidays seems too short a period to give up on though, so the comment about a quick expert's opinion seems more likely IMO.


How to Migrate Infopath XML form library to Powerapps

Question: I want to create PowerApps form for one of my InfoPath forms library. How can I do that. How we can convert XML form library to SharePoint list? Right now InfoPath form have a lot of attachment fields where documents can be uploaded and it exceeds limit of 5MB hence we want to move this to PowerApps.
Answer: There is no direct way to migrate infopath form to power apps or convert XML form library to SharePoint list.
It's necessary to re-create power app forms.
More information for your reference:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/transform-infopath
Comment: How can i add multiple attachment controls in a PowerApp form same like infopath form where multiple files can be attached in separate fields using separate controls.
Comment: Currently, within PowerApps, we could only add single one Attachments control within the Edit form.Actually, if you want to upload multiple files to one record of your SP list as attachments, you could add/upload multiple files within the single one Attachments control.
Comment: Thanks for your response. I believe then my requirement is not possible with PowerApps. I tried using multiple attachment controls in new form by copying attachment data card, but there seems to be no way to display documents in edit form in respective sections as they are getting stored in backend item in one field only. Is there any other alternative you can suggest for achieving this functionality so that we can submit and show files in individual sections of the form?
Answer: A little bit late on a response here, but wanted to chime in anyway.
As others have noted, the common approach is to more or less convert the form manually. You'll have challenges in recreating repeating sections and tables, translating InfoPath rules (and code behind) to Power FX, and more.
Regarding your specific challenge with attachments, you could do this if your form was backed by Dataverse instead of a SharePoint list...you can have multiple File data type columns in a Dataverse entity and I'm not personally aware of any limit.  We've successfully converted forms that had several separate attachment controls in them.
Another option would be to setup a separate source (say Azure Blob storage) to store your attachments separate from the form data.  You're moving away from the new/edit form paradigm, but that's frankly where a lot of the InfoPath form migrations end up anyway because of the types of challenges you're trying to overcome.
Disclaimer: I'm the CTO at Kudzu Software, so the following is a bit of product pitch.
Kudzu has a SaaS platform that among other things can convert InfoPath forms to Power Apps, our own runtime hosted in a SharePoint-native wrapper, or K2 SmartForms.  We can also convert PDFs of all types, imaged forms, and other source form types.


Is this metonym or synecdoche?

Question: I think that in the phrase, "the Cabinet conferred with the president," Cabinet is an example of a metonym. The answer book for a sample test I'm taking says it's a synecdoche. I thought I had finally figured out the difference. Help!
Comment: The belief that synecdoches are a subset of metonyms seems logical. I wish I could access the whole of  "Serial metonymy: A study of reference-based polysemisation". [Journal of Historical Pragmatics, 2:2, 245-272.] by Nerlich, B. and Clarke, D. D. (2001). But we may deduce from the title that the theories are neither simple nor finalised.
Answer: Both metonym and synectoche are figures of speech used in rhetoric. "The Cabinet" in your example is a "metonym".

They're not the same thing, though metonymy is often interpreted so widely that synecdoche can be regarded as a special case of it.
  Let's take synecdoche first (which is pronounced as /sɪˈnɛkdəkɪ/ Help with IPA, by the way). You use this when you speak of a part of something but mean the whole thing. When Patrick O'Brian has Captain Jack Aubrey tell his first lieutenant to "let the hands go to dinner" he's employing synecdoche, because he's using a part (the hand) for the whole man. You can also reverse the whole and the part, so using a word for something when you only mean part of it. This often comes up in sport: a commentator might say that "The West Indies has lost to England" when he means that the West Indian team has lost to the English one. America is often used as synecdoche in this second sense, as the word refers to the whole continent but is frequently applied to a part of it, the USA.
  Metonymy is similar, but uses something more generally or loosely associated with a concept to stand in for it. When Americans speak of the Oval Office, for example, they are really referring to the activity within it, the position or function of the President. It's a linked term, and so a metonym. British writers refer similarly to the Crown, when they're really discussing the powers, authority and responsibilities of the monarchy, which is symbolised by the crown. The difference between synecdoche and metonymy is that in metonymy the word you employ is linked to the concept you are really talking about, but isn't actually a part of it. Another example is the turf for horse racing. But the distinction isn't always obvious and often can't be rigorously applied, and many people use metonymy to mean both. http://www.worldwidewords.org/qa/qa-syn1.htm
Comment: The "let the hands go to dinner" example is poor because it's not actually using "hand" as a metonym. Rather, one of the definitions of "hand" is a manual labourer, especially on a ship. Yes, that definition probably came about by metonymy but, nowadays, it's just one of the literal meanings of the word. A better example would be the ship's cook saying that he has a hundred hungry mouths to feed.
Comment: As Edwin comments on another answer, that is the "is a dead metaphor a metaphor?" debate. Which is itself an example of the "is a fundamentally interminable debate a debate?" debate ;-)
Answer: It's really a terrifically awkward example, because sense I:

The "small chamber, private room" (SOED 'cabinet' I.3)

in which small groups of decision-makers typically met, gave rise to the political meaning of the word, sense II:

"the chamber in which the inner circle of a government meet" (SOED 'cabinet' II.7), or
"a committee of senior ministers ..." (SOED 'cabinet' II.8), or
"a meeting of a Cabinet" (SOED 'cabinet' II.9).

So the textbook seems to be asking you to conclude that the 'real' meaning of 'cabinet' is 'small room', and that the political meaning of the word has arisen figuratively (because the room contains the people: so referring to the people as though they were the room is the part/whole/container figurative trope).
But that's assuming that the 'literal' meaning of "the Cabinet conferred with the president" is "the small room conferred with the president". I don't think that's the case; the political meaning of the word dates from the early 17th century (according to the SOED), so I think it's been part of the English language for more than long enough now that the figurative nature of the meaning has all but disappeared - particularly because the use of 'cabinet' to mean 'small room' is now archaic.
To back this up, the SOED says that the political meaning is usually with a capital 'C' (whereas the cupboard/room meaning is not). And the example uses a capital 'C'. So it seems safe to assert that the political meaning of the word is the 'literal' meaning in this sentence.
But even if we're sure we're using the political meaning, it can still be the room in which the people meet, the committee itself (or perhaps the people who are members of that committee), or a meeting of the committee:

If, in your example, we take 'Cabinet' (a committee - SOED II.8) to mean the group of people who are the members of that committee, then it's synecdoche if we consider the people who compose that committee to be the constituent parts of that committee, in the same sense that the fingers are constituent parts of the hand. If we don't consider the individual people to be the constituent parts which compose the committee - if 'Cabinet' is more like a title than a collection of individuals - then it's metonymy.
If 'Cabinet' means the room in which the committee meets (SOED II.7), then it's metonymy because the room symbolises the people - or maybe the room symbolises the committee - metonymy either way ... unless we use the Quintillian definition of synecdoche which includes the substitution of 'the container for the contained', so then the room would be the container and the people/committee meeting within the room would be contained by it, so then our figure of speech would be synecdoche. The Du Marsais definition of synecdoche doesn't allow 'container for contained', so if we're using that definition then we're back to metonymy.
If, in the example, the committee itself (SOED II.8), as a whole, as a singular entity, is conferring with the president, then it's not figurative language at all.
If 'Cabinet' is meant in the sense of 'this particular meeting of the Cabinet' (SOED II.9) then it's arguably metonymy, because the meeting represents the committee or the people who are members of the committee.

tl;dr: it's debatable. The authors could hardly have chosen a worse example. Couldn't they just have used a "White House" example?
Comment: This is the 'Is a dead metaphor a metaphor?' debate.
Answer: From the following partial etymology

Cabinet: a body of persons, usually a limited number, of the ministers
  of state of a country, 1630; a secret store-house, hence, its
  contents. Examples: cabinet of animal functions, 1667; of my secret
  thoughts, 1549; of his secret will, 1634. {Dictionary of Collective
  Nouns and Group Terms.}

it is seen that the term was first used for the usual meeting place, then for the people attending the meeting. This is metonymy, not synecdoche. Interestingly, 'church' has made the reverse metonymic transition.
Comment: I call "cabinet" simply an uncountable noun, much as the word "committee" is an uncountable noun which takes a singular verb, at least in AE. Metonymic comparisons involve taking a word which is beyond (i.e., meta/meto) the name (i.e., nym) and using it to substitute for the name. Example: The crown issued a decree. Or, The badge caught me doing 65 in a 35 zone. Or, My blood, sweat, and tears went into that project. Or, His blood be upon us and our children. In the examples, the implied referent is, respectively, the king, the cop, hard work or labor, and the murder of an innocent man. Don
Comment: There can be c/Cabinets even in the sense being used here, and committees. Though metonyms are usually non-count, this is by no means a rigid requirement. Thus 'a dish' and 'dishes' meaning 'the course/s actually (the first dish was quite a surprise) or notionally (lobster thermidor is one of my favourite dishes) coming on a plate / plates'.
Comment: You've given me something to think about. The differences and similarities between synecdoche and metonymy have caused no little consternation among some folks, to the point where they use the terms interchangeably. That's OK, I guess. When I think about it, the word "dish" as you've used it could very well be an example of synecdoche, since a literal dish is a part of the whole, which contains both dish and victuals! "Gimme that dish" could mean "Give me that plate/saucer, cup" or "Give me the dish and the food on it." How would you 'splain "I'll have the blue-plate special, please"? Don
Comment: The fact is that the terms are ill-defined. A dish is not part of a course in the same way that a sail is part of a boat, but both the dish (crockery) and the serving are parts of what is placed on the table. It's pointless trying to work out which usage is correct; someone has to pronounce on the matter.

Is this metonym or synecdoche?


what kind of thing would nulify a criminal trespass warning

Question: I live in Atlanta, Ga. One of my neighbors was recently taken to jail for a criminal trespass. He entered the property and was there for about two hours the police were called. what is the law on such an event in my state?
Comment: The Georgia criminal trespass statute is fairly wrong.  Defense against being charged would be that an element of the charge does not apply.  Nothing was damaged, no unlawful purpose, etc.   Also, he wasn't warned, he was arrested.
Answer: Based on GA's Title 16 Chapter 7 Article 2 Part 1, the owner of the property could have alleged your neighbor damaged the property, and the damage was valued at $500 or less or your neighbor was allegedly using the property without the consent of the property's owner. Whether the allegations at the time of the event were true or made up, we don't know. However, the property owner (where your neighbor was) had the authority to initiate, call the cops, and file charges.


Walking Dead App: Can't get out the pharmacy alive

Question: I am stuck in the pharmacy. No matter what decision I make, I die. If I save Carly I die. If I save Doug I die. Always the same way. They run, I try to save Clementine, she is saved, the father opens the door. I die every time, then he closes it. Game over. I've played at least seven times with the same result. I am so sick of seeing the same scene over and over. What do I do?
Answer: Shortly after Larry punches you, Kenny returns and saves you. This happens regardless of your actions (but Kenny's dialogue and attitude change if you disagreed with him earlier).
You should not get a game over at this stage unless you're just reloading as soon as Larry hits you.


Camera Slow To Respond When Trying To Take A Photo | Nikon D5300

Question: I have a Nikon D5300. When I try to take a photo (I reset all settings to factory settings) and hold down the button to focus or just a quick snap, there is a long delay in the camera finishing to take the photo, if that makes sense. The photo turns out incredibly blurry and if I move my camera from the point I'm focusing on before it finishes, the photo turns out like I've moved the camera before it took the photo. I know that sounds redundant, but I'm not quite sure how else to explain it. I am in my apartment with a normal amount of lighting (all the lights are on). Is there something I'm missing?
Comment: Please post one of your photos, along with the shutter speed, aperture and ISO that you/the camera chose for the photo - you can see these details from any reasonable photo viewer.
Comment: Also, what mode is the camera in?
Comment: "normal amount of [indoor] lighting" probably looks bright to human eyes (because we have fantastic ability to adapt), but not particularly bright to the camera, compared to an outdoors sunlit scene for example. It sounds like the camera is using a slow shutter speed to compensate for the low light levels. What result do you get when you use flash?
Answer: The amount of time the camera sensor remains open to light is governed by the Shutter speed that you have selected. To be able to adjust the shutter speed of your camera, you need to put it in either Shutter Priority Mode (S on the mode dial) or Manual Mode (M on the mode dial). If the photo is getting a lot blurry even with very little movement, it's likely that your shutter speed is set very low; something like 1second or below. Try increasing it to 1/50 or more. If you have a long lens (a zoom lens like 70-200mm), you might need to increase your shutter speed even more to get sharper results.
Keep in mind though that increasing your shutter speed will reduce the amount of light coming into the sensor and you will have to bump up the Aperture (go towards a lower number like f5.6, f4.5, f3.5 ) to compensate.
Answer: I have the same camera as you, and it was experiencing the same problem. Then I realised that the exposure delay mode was on. Make sure it's off and you will get quicker photos.
Answer: You probably have set your camera in Aperture priority mode, and selected a very small aperture. This lets the automatic select a long exposure time to ensure a proper exposure.
Change the aperture to a more "sane" value, or select another mode, like "P" (full-auto) or "S" (where you set the shutter time and the camera determines the aperture for you).
Comment: I see no real evidence the camera is in aperture priority.
Answer: It really sounds like the camera is using a long shutter-speed.
First, check the Mode-Dial. It is is not set to Auto or P, then the exposure depends on the parameters you have dialed. Move the dial to P and see if it solves your problem. If it does, good but  you may want to learn about the Exposure Triangle if you want to take control of your camera and be more creative.
If automatic exposure still gives you a dark image, then you may have dialed Exposure Compensation up. That will give you a blurry but very bright image. To reset it, press the +/- button while turning the dial until the EC indicator is at 0.
The important thing to know is that even though you did not choose a slow-shutter speed (which is what you can do in S and M modes), the camera can still chose a slow one if you select too small aperture (which you can do in A mode). Finally, there is also ISO. In Auto mode, it is set automatically by default but in other modes it is fixed by default, although you can make it Auto or better, simply raise it to the needed level. In any case, the camera reports what shutter-speed will be used in the status line of viewfinder, so if you see 60 or a larger number (meaning 1/60s or a faster shutter-speed) than there should be little blur. If you see the number followed by a quote such as 8', then that is an eight second exposure which is way too long.


"Network error: Connection refused" in Putty when I'm trying to connect to my remote home Ubuntu server

Question: I just set up a linux home server using http://linuxhomeserverguide.com/. I can connect to it from my desktop PC at home via putty using a local ip like 192.168.1.2 (just an example ip), but I want to connect to it via my public ip so I can connect to it from my work office. When I try to establish a connection to the public ip with port 22, i get that error "Network error: Connection refused". Did I set it up wrong? I forwarded port 80 to the server and can ping the ip address so it's not a network connection issue. Thanks in advance
Answer: You have to forward the port 22 to your home server. Port 80 is the standard port of an webserver like Apache.
You can ping your public IP without to forward any port.
Comment: THANK YOU!!! I have not found this solution anywhere but here. Thanks this works.
Comment: I have another problem and I was wondering if you knew the answer to this as well: When I try to login with my username to my home server via winSCP I get an error Permission Denied when I try to edit a file in it. But I'm the owner of the pc and the server why am I being denied permission? Thank you.
Comment: If you want to edit files you need sudo


CPU fan support for Apple iMac

Question: Using Ubuntu 18 (Linux 4.15.0-72-generic) on a mid 2010 iMac 27", I found  that the CPU fan always runs on the slow 940rpm regardless of the CPU temperature. Hardware support is great for that machine, only fan and display back light control support seem to be missing.
I wrote own code to control the fans, but I have the feeling that I am just missing something here. Is there anything more "standard" or "straight-forward", like just configuring target temperature and fans?
Answer: Until a more "standard" or "straight-forward" way is posted, feel free to clone my code from https://github.com/merlinsenger/applefand

CPU fan support for Apple iMac


It's possible to make a program that shows FPS (frame per second) in Python?

Question: I was wondering...
It's possible to do it?
A simple console command based program that shows how are your FPS, for your currently running game/program?
Answer: Short answer: Yes.
Long answer: Beside that it is much simpler to gather statistics when you have hooks inside the measured program, it is possible also to hook on lower level: directly to DirectX or OpenGL. Start your discovery from some existing posts. They are in C++ but that's another deal: you can use SWIG to interop between Python and C/C++.
As a proof. There is famous Fraps applications that does what you say.
Answer: Short answer: No.
Long answer: Not without knowing the internals of the application, and without the application having the appropriate hooks to perform such a measurement.
Answer: As long as you have the available bindings/hooks to read what that application is doing through whatever library it uses, yes.
Those counters are normally implemented as queries to a program drawing through OpenGL (or directX).
If it's an OGL app, pyOpenGL provides a decent amount of functionality, might be worth your time looking into it. I have no experience with directX, but I assume you might find similar bindings.
http://www.cs.man.ac.uk/~toby/frameratedisplayer.htm if you want a simple example to look at that does just that (assuming you're ok puzzling out very little C syntax)


It is safe to have a swap partition on the SSD?

Question: As I'm planning to buy an SSD and replace my old mechanical hard drive, I've heard rumors that having swap partition can decrease the life of SSD. So is this true? Or can I still have a swap partition on my SSD?
Comment: To some extent it *was* true when SSDs just came out. SSDs generally have lower lifetime ( in terms of writes to disk). So if your machine uses swap a lot - that is a lot of writes - that decreases SSD life expectancy. However, technology has become better over the years, so I'd suspect nowadays have just as good life expectancy as HDD in terms of writes.  That's generally what the discussion comes down to - writes/reads to SSD and how agressively your machine uses swap. Of course, if you have good amount of RAM, small swap partition or swap file are good enough.
Answer: TL;DR: yes, it's OK to have swap on SSD, and swap partition is only one of many factors that may ( not necessarily will ) decrease SSD lifespan
Let's address the elephant in the room first: beginning with 18.04 release Ubuntu uses swap file instead of full partition ( see release notes ). So you won't have swap partition in the first place unless you yourself make one.
Now back to the topic. To some extent it was true that having swap partition may decrease SSD life when SSDs just came out. This has to do with the amount of writes that SSD can withstand and how aggressively your OS uses swap. To quote Wikipedia article on the topic:

If a particular block was programmed and erased repeatedly without writing to any other blocks, that block would wear out before all the other blocks — thereby prematurely ending the life of the SSD

So if your machine uses swap a lot - that is a lot of writes to that particular area of the drive - that decreases SSD life expectancy, even though other parts may be good. Note also that life of an SSD depends also on the particular technology used - cheaper drives use less reliable flash storage in general, and obviously more expensive - last longer with better flash storage. Other things affect SSD lifespan such as:

power outages and spikes
hibernation ( which saves a lot of RAM contents to disk )
temperature
if your SSD will be in datacenter environment, there's a potential that a lot of writes to log files can have an effect of lifespan, which I am guessing is why Debian suggests <code>/var/log</code> to be in persistent ramdisk.

ZDnet cites an article on the research performed by a professor at University of Toronto and Google, according to which one of the key conclusions is "SSD age, not usage, affects reliability." In other words, if this study is correct, even with high usage swap it's not going to drastically affect SSD reliability. Among other things, swap's primary purpose is to free up RAM so that more RAM is available to new processes. Well, with low swappiness setting and high RAM amounts nowadays, swap is used less and less, so it won't contribute as much to the lifetime of SSD.
It's also worth noting that swap partitions support TRIM according to answer on our fellow SO site Unix&Linux, which also plays a role in wear leveling - swap is not just wearing out SSD, but also has ability to engage SSD's built-in wear leveling mechanisms.
In conclusion, yes, it's OK to have swap partition and swap file, because:

SSD life depends on multiple actors
having swap or swap partition is still necessary to free up RAM memory that processes need
with larger RAM sizes swap is used less and less nowadays, hence less worry about swap reads and writes contributing to wear

See also:

Is it still bad to use swap on a modern SSD?
Does bigger capacity SSD have longer life due to wear leveling?
Answer: It's not rumor.  Writing ANYTHING on SSD decreases the life of SSD.
But current life of SSD is reasonably long.
For example, the 256GB Toshiba nvme my own gaming laptop wears like 2.0x% a year, which means I can use it for 50 years before it wears out all NAND flash cycles.  And I use hibernate a lot the first several months, which should impacts the life more than swap partition.
Also, my new WD Black 1TB nvme 3D TLC at work, with active android development(100GB repository after build-all), also wears less than 1%(I guess it's around 0.7%) after 3 months usage.
It totally depends how you use your drive.
The best way is that you just use swap partition normally, for several days or weeks, re-assess the wearing level using smart tools, and decide how you want to use it after.
Comment: What I mean is, **a)** is there any reason to assume that the "wear level" increases at a constant rate, and **b)** even counting out unrelated failure modes, would the drive still be practically usable at a wear level approaching 100%?
Comment: "which means I can use it for 50 years" – are you sure this calculation makes sense?
Comment: I bought the laptop in 2017 oct, and in oct 2018 it has just passed 2%, so at wearing level's point of view, it could last 50 years.  However we know in reality the hardware as a whole won't last that long.
Comment: 1. From industrial experiences, if the task type and the percentage of space remains at same level, than the rate will be roughly the same. 2. wearing level is not optimistic estimation but strict lab verification.  The quality of NAND will become unstable "after" wearing level is 100%.
Comment: I got a cheap old workstation with a 160GB SSD when my company threw it away. It was probably bought in 2009 or 2012 but when I checked the SSD I saw that it can be used for at least 10 years with the current data writing rate. Of course newer SSDs have much better wear-leveling algorithm as well as better write cycle, so it'll last a lot longer


Remove control characters from PHP string

Question: How can I remove control characters like STX from a PHP string? I played around with
preg_replace("/[^a-zA-Z0-9 .\-_;!:?äÄöÖüÜß<>='\"]/","",$pString)

but found that it removed way to much. Is there a way to remove only
control chars?
Comment: The following links might help you :
[ASCII Characters Table](http://web.cs.mun.ca/~michael/c/ascii-table.html)[POSIX refrence](http://www.regular-expressions.info/posixbrackets.html)[Regular expressions](http://w3.pppl.gov/info/grep/Regular_Expressions.html)
Answer: If you mean by control characters the first 32 ascii characters and \x7F (that includes the carriage return, etc!), then this will work:
preg_replace('/[\x00-\x1F\x7F]/', '', $input);

(Note the single quotes: with double quotes the use of \x00 causes a parse error, somehow.)
The line feed and carriage return (often written \r and \n) may be saved from removal like so:
preg_replace('/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F]/', '', $input);

I must say that I think Bobby's answer is better, in the sense that [:cntrl:] better conveys what the code does than [\x00-\x1F\x7F].
WARNING: ereg_replace is deprecated in PHP >= 5.3.0 and removed in PHP >= 7.0.0!, please use preg_replace instead of ereg_replace:
preg_replace('/[[:cntrl:]]/', '', $input);

Comment: Additionally, preg_replace('/[[:cntrl:]]/', '', $input); worked for me just fine (php 5.2.6).
Comment: sadly ereg_replace is deprecated in PHP 5.3 and the mb version is slower than preg_replace. There is a slightly cleaner way to do this with preg_replace, and in my testing it is very slightly faster (1% faster when dealing with hundreds of thousands of items) than the one above:

preg_replace('/[\p{Cc}]/', '', $input);
Comment: Not that you also may want to save tabs "\t".  I found this question because I was getting \x1D in my database.
Comment: not working for me, this string >>"Rua Enette Dubard, 806 - Loja 2" is converted to this >> "Rua Eee Dubad, 806 - Loja 2"  and carriage return char is still there.
Comment: Check this for why preg_replace('/[[:cntrl:]]/', '', $input); woks:
 http://stackoverflow.com/questions/475159/php-regex-what-is-class-at-offset-0
Comment: For sanitising console input the first preg_replace worked but not the second (which I thought was just an extension of the first)
Answer: For Unicode input, this will remove all control characters, unassigned, private use, formatting and surrogate code points (that are not also space characters, such as tab, new line) from your input text. I use this to remove all non-printable characters from my input.
<?php
$clean = preg_replace('/[^\PC\s]/u', '', $input);

for more info on \p{C} see http://www.regular-expressions.info/unicode.html#category
Comment: Hi @ChrisRosillo, we use the inverse form of `\p{C}` which is `\PC`, so where `\p{C}` matches control characters, \PC matches everything that isn't a control character. Then we use a negated character class `[^..]` to say match/replace anything "not [ not a control character or space ]". So it is kind of a double negative.
Comment: This is exactly what you need when sending user input to the Authorize.net API. In case anyone else is having invalid XML character errors.
Comment: @syl.fabre about the brackets: "If only one letter is specified with \p or \P, it includes all the properties that start with that letter. In this case, in the absence of negation, the curly brackets in the escape sequence are optional"
Comment: Why do you use `\PC` instead of `\p{C}`?
Comment: We have to use a negated character class to avoid removing spaces (since they are considered invisible), which means we need to use the inverse form of `\p{C}`
Comment: In stupid people terms (yeah, that's me) can someone kindly explain how this works. It does work, I know I've implemented it with extensive unit test coverage, however when I read it back with my current understanding it doesn't make sense.

The way I understand it is that it looks like it should replace anything that's not a control character or a white space with nothing? i.e. you'd end up with only the control characters and white space remaining...?

Thanks in advance!
Comment: You are a godsend. Having no idea about regex, this was the only one that worked in removing an obscure newline character that I've searched for in ages.
Answer: PHP does support POSIX-Classes so you can use [:cntrl:] instead of some fancy character-magic-stuff:
ereg_replace("[:cntrl:]", "", $pString);

Edit:
A extra pair of square brackets might be needed in 5.3.
ereg_replace("[[:cntrl:]]", "", $pString);

Comment: As `ereg_replace` is removed in PHP 7.0, for PHP > 7.0 it should be: `preg_replace("/[[:cntrl:]]/", "", $input);`
Comment: PHP does support POSIX, using the ereg functions istead of preg: http://nl2.php.net/manual/en/book.regex.php
Comment: In my testing, this only worked when adding an extra square bracket to the statement like so: ereg_replace("[[:cntrl:]]", "", $pString);
PHP 5.3.5.
Answer: TLDR Answer
Use this Regex...
/[^\PCc^\PCn^\PCs]/u

Like this...
$text = preg_replace('/[^\PCc^\PCn^\PCs]/u', '', $text);

TLDR Explanation

^\PCc : Do not match control characters.
^\PCn : Do not match unassigned characters.
^\PCs : Do not match UTF-8-invalid characters.

Working Demo
Simple demo to demonstrate: IDEOne Demo
$text = "\u{0019}hello";
print($text . "\n\n");
$text = preg_replace('/[^\PCc^\PCn^\PCs]/u', '', $text);
print($text);

Output:
(-Broken-Character)hello
hello

Alternatives

^\PC : Match only visible characters.  Do not match any invisible characters.
^\PCc : Match only non-control characters.  Do not match any control characters.
^\PCc^\PCn : Match only non-control characters that have been assigned.  Do not match any control or unassigned characters.
^\PCc^\PCn^\PCs :  Match only non-control characters that have been assigned and are UTF-8 valid.  Do not match any control, unassigned, or UTF-8-invalid characters.
^\PCc^\PCn^\PCs^\PCf :  Match only non-control, non-formatting characters that have been assigned and are UTF-8 valid.  Do not match any control, unassigned, formatting, or UTF-8-invalid characters.

Source and Explanation
Take a look at the Unicode Character Properties available that can be used to test within a regex.  You should be able to use these regexes in Microsoft .NET, JavaScript, Python, Java, PHP, Ruby, Perl, Golang, and even Adobe.  Knowing Unicode character classes is very transferable knowledge, so I recommend using it!
This regex will match anything visible, given in both its short-hand and long-hand form...
\PL\PM\PN\PP\PS\PZ
\PLetter\PMark\PNumber\PPunctuation\PSymbol\PSeparator

Normally, \p indicates that it's something we want to match and we use \P (capitalized) to indicate something that does not match.  But PHP doesn't have this functionality, so we need to use ^ in the regex to do a manual negation.
A simpler regex then would be ^\PC, but this might be too restrictive in deleting invisible formatting.  You may want to look closely and see what's best, but one of the alternatives should fit your needs.
All Matchable Unicode Character Sets
If you want to know any other character sets available, check out regular-expressions.info...

\PL or \PLetter: any kind of letter from any language.

\PLl or \PLowercase_Letter: a lowercase letter that has an uppercase variant.
\PLu or \PUppercase_Letter: an uppercase letter that has a lowercase variant.
\PLt or \PTitlecase_Letter: a letter that appears at the start of a word when only the first letter of the word is capitalized.
\PL& or \PCased_Letter: a letter that exists in lowercase and uppercase variants (combination of Ll, Lu and Lt).
\PLm or \PModifier_Letter: a special character that is used like a letter.
\PLo or \POther_Letter: a letter or ideograph that does not have lowercase and uppercase

\PM or \PMark: a character intended to be combined with another character (e.g. accents, umlauts, enclosing boxes, etc.).

\PMn or \PNon_Spacing_Mark: a character intended to be combined with another
character without taking up extra space (e.g. accents, umlauts, etc.).
\PMc or \PSpacing_Combining_Mark: a character intended to be combined with another character that takes up extra space (vowel signs in many Eastern languages).
\PMe or \PEnclosing_Mark: a character that encloses the character it is combined with (circle, square, keycap, etc.).

\PZ or \PSeparator: any kind of whitespace or invisible separator.

\PZs or \PSpace_Separator: a whitespace character that is invisible, but does take up space.
\PZl or \PLine_Separator: line separator character U+2028.
\PZp or \PParagraph_Separator: paragraph separator character U+2029.

\PS or \PSymbol: math symbols, currency signs, dingbats, box-drawing characters, etc.

\PSm or \PMath_Symbol: any mathematical symbol.
\PSc or \PCurrency_Symbol: any currency sign.
\PSk or \PModifier_Symbol: a combining character (mark) as a full character on its own.
\PSo or \POther_Symbol: various symbols that are not math symbols, currency signs, or combining characters.

\PN or \PNumber: any kind of numeric character in any script.

\PNd or \PDecimal_Digit_Number: a digit zero through nine in any script except ideographic scripts.
\PNl or \PLetter_Number: a number that looks like a letter, such as a Roman numeral.
\PNo or \POther_Number: a superscript or subscript digit, or a number that is not a digit 0–9 (excluding numbers from ideographic scripts).

\PP or \PPunctuation: any kind of punctuation character.

\PPd or \PDash_Punctuation: any kind of hyphen or dash.
\PPs or \POpen_Punctuation: any kind of opening bracket.
\PPe or \PClose_Punctuation: any kind of closing bracket.
\PPi or \PInitial_Punctuation: any kind of opening quote.
\PPf or \PFinal_Punctuation: any kind of closing quote.
\PPc or \PConnector_Punctuation: a punctuation character such as an underscore that connects words.
\PPo or \POther_Punctuation: any kind of punctuation character that is not a dash, bracket, quote or connector.

\PC or \POther: invisible control characters and unused code points.

\PCc or \PControl: an ASCII or Latin-1 control character: 0x00–0x1F and 0x7F–0x9F.
\PCf or \PFormat: invisible formatting indicator.
\PCo or \PPrivate_Use: any code point reserved for private use.
\PCs or \PSurrogate: one half of a surrogate pair in UTF-16 encoding.
\PCn or \PUnassigned: any code point to which no character has been assigned.
Answer: To keep the control characters but make them compatible for JSON, I had to to
$str = preg_replace(
    array(
        '/\x00/', '/\x01/', '/\x02/', '/\x03/', '/\x04/',
        '/\x05/', '/\x06/', '/\x07/', '/\x08/', '/\x09/', '/\x0A/',
        '/\x0B/','/\x0C/','/\x0D/', '/\x0E/', '/\x0F/', '/\x10/', '/\x11/',
        '/\x12/','/\x13/','/\x14/','/\x15/', '/\x16/', '/\x17/', '/\x18/',
        '/\x19/','/\x1A/','/\x1B/','/\x1C/','/\x1D/', '/\x1E/', '/\x1F/'
    ),
    array(
        "\u0000", "\u0001", "\u0002", "\u0003", "\u0004",
        "\u0005", "\u0006", "\u0007", "\u0008", "\u0009", "\u000A",
        "\u000B", "\u000C", "\u000D", "\u000E", "\u000F", "\u0010", "\u0011",
        "\u0012", "\u0013", "\u0014", "\u0015", "\u0016", "\u0017", "\u0018",
        "\u0019", "\u001A", "\u001B", "\u001C", "\u001D", "\u001E", "\u001F"
    ),
    $str
);

(The JSON rules state: "All Unicode characters may be placed within the quotation marks except for the characters that must be escaped: quotation mark, reverse solidus, and the control characters (U+0000 through U+001F).")
Answer: regex free method
If you are only zapping the control characters I'm familiar with (those under 32 and 127), try this out:
 for($control = 0; $control < 32; $control++) {
     $pString = str_replace(chr($control), "", $pString;
 }

$pString = str_replace(chr(127), "", $pString;

The loop gets rid of all but DEL, which we just add to the end.
I'm thinking this will be a lot less stressful on you and the script then dealing with regex and the regex library.
Updated regex free method
Just for kicks, I came up with another way to do it. This one does it using an array of control characters:
$ctrls = range(chr(0), chr(31));
$ctrls[] = chr(127);

$clean_string = str_replace($ctrls, "", $string);

Comment: ereg_replace is deprecated from php 5.3.0
Comment: How is this less "stressful" than ereg_replace("[:cntrl:]", "", $pString); ? Using ereg, the PHP interpreter will probably compile more efficient intermediate code than it would using that for loop anyway.


Which quantities are Lorentz-Invariable and which are not?

Question: The only physical constant I know for sure is Lorentz-Invariant is electric charge.  I am curious to know if there are others even if it's not possible to make an exhaustive list.
Comment: If you are worried for a particular "cosntant", do a Lorenz transformation to the inertia frame and check. the value
Comment: Possible duplicate by OP: https://physics.stackexchange.com/q/526037/2451
Comment: Hi Derek Seabrooke. Welcome to Phys.SE. Please don't repost a closed question in a new entry. Instead, you are supposed to edit the original question within the original entry.
Answer: All physical constants are "invariant" in the sense that all observers agree on their values. But we do not call things like Planck's constant or Boltzmann's constant "Lorentz invariants".
Here are some examples besides charge of Lorentz-invariant quantities that are dynamical, kinematical, or geometrical:

The speed of light. It's the invariant magnitude of every object's four-velocity.
Masses of elementary particles (and more complicated systems). Mass is the invariant magnitude of the energy-momentum four-vector. (I hope that you did not get taught the confusing and obsolete concept of "relativistic mass"!)
The spacetime interval between any two points in Minkowski spacetime.
The difference of the squares of the electric and magnetic field strengths at any point in spacetime.
The value of the Higgs field at any point in spacetime.
The scalar product of any two four-vectors.

As you can see, there are lots of examples.
The best way to understand what transforms and what doesn't under Lorentz transformations is to learn physics written in "manifestly covariant" form using four-vectors, four-tensors, etc. If a quantity doesn't have an index, or if all indices in an expression are contracted, then it is manifestly a Lorentz invariant.
Comment: your edit covers me +1
Comment: @annav I didn't mean to pre-empt you.
Comment: Come on, the point is to see the concepts expressed without danger of deletion (they often delete comments),  and you did.


Rules of thumb for minimum sample size for multiple regression

Question: Within the context of a research proposal in the social sciences, I was asked the following question:

I have always gone by 100 + m (where m
is the number of predictors) when
determining minimum sample size for
multiple regression. Is this
appropriate?

I get similar questions a lot, often with different rules of thumb.
I've also read such rules of thumb quite a lot in various textbooks.
I sometimes wonder whether popularity of a rule in terms of citations is based on how low the standard is set.
However, I'm also aware of the value of good heuristics in simplifying decision making.
Questions:

What is the utility of simple rules of thumb for minimum sample sizes within the context of applied researchers designing research studies?
Would you suggest an alternative rule of thumb for minimum sample size for multiple regression?
Alternatively, what alternative strategies would you suggest for determining minimum sample size for multiple regression? In particular, it would be good if value is assigned to the degree to which any strategy can readily be applied by a non-statistician.
Answer: I'm not a fan of simple formulas for generating minimum sample sizes.
At the very least, any formula should consider effect size and the questions of interest.
And the difference between either side of a cut-off is minimal.
Sample size as optimisation problem

Bigger samples are better.
Sample size is often determined by pragmatic considerations.
Sample size should be seen as one consideration in an optimisation problem where the cost in time, money, effort, and so on of obtaining additional participants is weighed against the benefits of having additional participants.

A Rough Rule of Thumb
In terms of very rough rules of thumb within the typical context of observational psychological studies involving things like ability tests, attitude scales, personality measures, and so forth, I sometimes think of:

n=100 as adequate
n=200 as good
n=400+ as great

These rules of thumb are grounded in the 95% confidence intervals associated with correlations at these respective levels and the degree of precision that I'd like to theoretically understand the relations of interest.
However, it is only a heuristic.
G Power 3

I typically use G-Power 3 to calculate power based on various assumptions
see my post.
See this tutorial from the G Power 3 site specific to multiple regression
The Power Primer is also a useful tool for applied researchers.

Multiple Regression tests multiple hypotheses

Any power analysis question requires consideration of effect sizes.
Power analysis for multiple regression is made more complicated by the fact that there are multiple effects including the overall r-squared and one for each individual coefficient.
Furthermore, most studies include more than one multiple regression.
For me, this is further reason to rely more on general heuristics, and thinking about the minimal effect size that you want to detect.
In relation to multiple regression, I'll often think more in terms of the degree of precision in estimating the underlying correlation matrix.

Accuracy in Parameter Estimation
I also like Ken Kelley and colleagues' discussion of Accuracy in Parameter Estimation.

See Ken Kelley's website for publications
As mentioned by @Dmitrij, Kelley and Maxwell (2003) FREE PDF have a useful article.
Ken Kelley developed the MBESS package in R to perform analyses relating sample size to precision in parameter estimation.
Answer: I don't prefer to think of this as a power issue, but rather ask the question "how large should $n$ be so that the apparent $R^2$ can be trusted"?  One way to approach that is to consider the ratio or difference between $R^2$ and $R_{adj}^{2}$, the latter being the adjusted $R^2$ given by $1 - (1 - R^{2})\frac{n-1}{n-p-1}$ and forming a more unbiased estimate of "true" $R^2$.
Some R code can be used to solve for the factor of $p$ that $n-1$ should be such that $R_{adj}^{2}$ is only a factor $k$ smaller than $R^2$ or is only smaller by $k$.
require(Hmisc)
dop <- function(k, type) {
  z <- list()
  R2 <- seq(.01, .99, by=.01)
  for(a in k) z[[as.character(a)]] <-
    list(R2=R2, pfact=if(type=='relative') ((1/R2) - a) / (1 - a) else
         (1 - R2 + a) /  a)
  labcurve(z, pl=TRUE, ylim=c(0,100), adj=0, offset=3,
           xlab=expression(R^2), ylab=expression(paste('Multiple of ',p)))
}
par(mfrow=c(1,2))
dop(c(.9, .95, .975), 'relative')
dop(c(.075, .05, .04, .025, .02, .01), 'absolute')

Legend: Degradation in $R^{2}$ that achieves a relative drop from $R^{2}$ to $R^{2}_{adj}$ by a the indicated relative factor (left panel, 3 factors) or absolute difference (right panel, 6 decrements).
If anyone has seen this already in print please let me know.
Comment: Thanks for the reference.  @gung that's a good question.  One (weak) answer is that in some types of models we don't have an $R^{2}_{adj}$, and we also don't have an adjusted index if any variable selection has been done.  But the main idea is that if $R^2$ is unbiased, other indexes of predictive discrimination such as rank correlation measures are likely to be unbiased also due to adequacy of the sample size and minimum overfitting.
Comment: +1. I suspect I'm missing something rather fundamental & obvious, but why should we use the ability of $\hat R^2$ to estimate $R^2$ as the criterion? We already have access to $R^2_{adj}$, even if $N$ is low. Is there a way to explain why this is the right way to think about the minimally adequate $N$ outside of the fact that it makes $\hat R^2$ a better estimate of $R^2$?
Comment: @FrankHarrell: look [here](http://www.sciencedirect.com/science/article/pii/0304407687900273) the author seems to be using the plots 260-263 in much the same way as the ones in your post above.
Answer: (+1) for indeed a crucial, in my opinion, question.
In macro-econometrics you usually have much smaller sample sizes than in micro, financial or sociological experiments. A researcher feels quite well when on can provide at least feasible estimations. My personal least possible rule of thumb is $4\cdot m$ ($4$ degrees of freedom on one estimated parameter). In other applied fields of studies you usually are more lucky with data (if it is not too expensive, just collect more data points) and you may ask what is the optimal size of a sample (not just minimum value for such). The latter issue comes from the fact that more low quality (noisy) data is not better than smaller sample of high quality ones.
Most of the sample sizes are linked to the power of tests for the hypothesis you are going to test after you fit the multiple regression model.
There is a nice calculator that could be useful for multiple regression models and some formula behind the scenes. I think such a-priory calculator could be easily applied by non-statistician.
Probably K.Kelley and S.E.Maxwell article may be useful to answer the other questions, but I need more time first to study the problem.
Comment: First link is broken -- is it now (?): https://www.danielsoper.com/statcalc/calculator.aspx?id=9 and the 2nd https://www.danielsoper.com/statcalc/formulas.aspx?id=9
Answer: Your rule of thumb is not particularly good if $m$ is very large.  Take $m=500$: your rule says its ok to fit $500$ variables with only $600$ observations.  I hardly think so!
For multiple regression, you have some theory to suggest a minimum sample size.  If you are going to be using ordinary least squares, then one of the assumptions you require is that the "true residuals" be independent.  Now when you fit a least squares model to $m$ variables, you are imposing $m+1$ linear constraints on your empirical residuals (given by the least squares or "normal" equations).  This implies that the empirical residuals are not independent - once we know $n-m-1$ of them, the remaining $m+1$ can be deduced, where $n$ is the sample size.  So we have a violation of this assumption.  Now the order of the dependence is $O\left(\frac{m+1}{n}\right)$.  Hence if you choose $n=k(m+1)$ for some number $k$, then the order is given by $O\left(\frac{1}{k}\right)$.  So by choosing $k$, you are choosing how much dependence you are willing to tolerate.  I choose $k$ in much the same way you do for applying the "central limit theorem" - $10-20$ is good, and we have the "stats counting" rule $30\equiv\infty$ (i.e. the statistician's counting system is $1,2,\dots,26,27,28,29,\infty$).
Comment: You say 10 to 20 is good, but would this also depend on the size of the error variance (possibly relative to other things)? For example, suppose there was just one predictor variable. If it was known that the error variance was really tiny, then it seems that 3 or 4 data points might be enough to reliably estimate the slope and intercept. On the other hand, if it was known that the error variance was huge, then even 50 data points might be inadequate. Am I misunderstanding something?
Comment: Could you please provide any reference for your suggested equation `n=k(m+1)`?
Answer: In Psychology:
Green (1991) indicates that $N > 50 + 8m$ (where m is the number of independent variables) is needed for testing multiple correlation and $N > 104 + m$ for testing individual predictors.
Other rules that can be used are...
Harris (1985) says that the number of participants should exceed the number of predictors by at least $50$.
Van Voorhis & Morgan (2007) (pdf) using 6 or more predictors the absolute minimum of participants should be $10$. Though it is better to go for $30$ participants per variable.
Comment: What are the full citations for the references Green (1991) and Harris (1985)?
Comment: Your first 'rule' doesn't have m in it.
Comment: His first rule of thumb is written as `N = 50 + 8 m`, though it was questioned whether the term 50 is indeed needed
Comment: I have added a new and more complex rule of thumb that takes into account the effect size of the sample. This was also presented by Green (1991).
Answer: I agree that power calculators are useful, especially to see the effect of different factors on the power. In that sense, calculators that include more input information are much better. For linear regression, I like the regression calculator here which includes factors such as error in Xs, correlation between Xs, and more.
Answer: I have found this rather recent paper (2015) assessing that just 2 observations per variable are enough, as long as our interest is on the accuracy of estimated regression coefficients and standard errors (and on the empirical coverage of the resulting confidence intervals) and we use the adjusted $R^2$:
(pdf)
Of course, as also acknowledged by the paper, (relative) unbiasedness does not necessarily imply having enough statistical power. However, power and sample size calculations are typically made by specifying the expected effects; in the case of multiple regression, this implies an hypothesis on the value of regression coefficients or on the correlation matrix between the regressors and the outcome must be made. In practice, it depends on the strength of the correlation of regressors with the outcome and between themselves (obviously, the stronger the better for the correlation with the outcome, while things get worse with multicollinearity). For example, in the extreme case of two perfectly collinear variables, you can't perform the regression regardless of the number of observations, and even with only 2 covariates.