Why do we wake up when we die in our dreams?

Question: A lot of people had some experience with dying in their dreams. They all confirm they remember the whole story until the precise moment of death and it is the death itself what woke them up - not being nervous, scared or shocked (I remember myself dying peacefully in bed in one of my dreams, no fighting or falling involved).
I have never met anyone who continued dreaming after dying - although some religious people should be deeply convinced that the death is not the end of their story. It also quite a common plot of novels or movies: the main character dies and appears in some kind of "afterworld" - I have never met anyone with this experience, though.
Is it caused by the fact that our brain just does not know what happens next when it is all over?
Or is the moment of death such a "low-level" shock for our minds, that it just "reboots"?
Comment: Welcome to CogSci and thanks for the interesting question. Can you give a reference to your claim that death always means the end of a dream?
Comment: Well I've died in a dream and didn't wake up, and I'm an atheist. I just recognized on some level that it was a dream, didn't want to stop/wake, and experienced pretty close to nothingness for a few moments.
Comment: @Christiaan I am no scientist, so I can give no better reference than my personal experience and experience of my friends, unfortunately.
Comment: I recently had a weird dream where I died but the dream still continued. I was a ghost like thing in the dream and I could see how my death affected people around me.
Comment: I have had an experience where I continued dreaming after dying. It was so stressful while dying. there was just one question in my mind. what now?will I exist? and then I was in a numb place at zero level some where and after wards i saw myself climbing stairs at someplace.
Answer: When you dream you're in REM sleep (rapid eye movement). REM sleep is only slightly more "deep" than stage 1 of non-REM which means it's not that hard to wake you up in the first place.
Dying in a dream is a stressful event, which causes your brain to release adrenaline. You can't sleep and have an adrenaline rush at the same time so you wake up.
These dreams where you die and wake up are usually more memorable due to the fact that you wake up whereas most people don't remember 95% of their dreams.
Sources:
Adrenalin:
"Being particularly scary or threatening, nightmares can provoke 'fight and flight' responses, and the release of adrenalin whilst we are still asleep. Once you awaken from a nightmare it may then take a little time to come down from this elevated state, preventing you from being able to get back to sleep as easily or quickly."
https://www.youtube.com/watch?v=9TZOiC23CpI&feature=youtu.be
Profeso Colin Espie, Director of the Sleep Centre at the University of Glasgow and co-founder of Sleepio
Forgetting Dreams:
"We forget almost all dreams soon after waking up. Our forgetfulness is generally attributed to neurochemical conditions in the brain that occur during REM sleep, a phase of sleep characterized by rapid eye movements and dreaming. But that may not be the whole story.
Perhaps the most compelling explanation is the absence of the hormone norepinephrine in the cerebral cortex, a brain region that plays a key role in memory, thought, language and consciousness. A study published in 2002 in the American Journal of Psychiatry supports the theory that the presence of norepinephrine enhances memory in humans, although its role in learning and recall remains controversial."
http://www.scientificamerican.com/article/why-do-memories-of-vivid-dreams/
"At least 95% of all dreams are not remembered. Certain brain chemicals necessary for converting short-term memories into long-term ones are suppressed during REM sleep. Unless a dream is particularly vivid and if one wakes during or immediately after it, the content of the dream is not remembered"
Hobson, J.A.; McCarly, R.W. (1977). "The brain as a dream-state generator: An activation-synthesis hypothesis of the dream process". American Journal of Psychiatry 134 (12): 1335–1348.
Comment: Interesting. So part of your answer is [silent evidence](http://johnaugust.com/2007/silent-evidence) in the sense that there may be dreams where we continue dreaming after in-dream death, but we don't remember it?


does anybody knows a good currency widget for ubuntu 14.10

Question: I would like to use an easy and small currency widget on ubuntu 14.10. Pref. one that can be minimized near the power, system settings and network bar.
Does anybody knows a good one?
I am enjoying a lot with ubuntu, although I am still a beginner after 1 years.
Answer: Ubuntu Software Center has only one Currency Converter and it only converts to and from Euro: KEuroCalc
But you can also use a multi-feature calculator like Qalculate to do the job (although it can only be added to Unity Launcher, and not the Top Panel or SysTray.
The application downloads the latest currency rates, and then  all you need is to type in something like GBP 1 to USD and press Enter to convert.
More info here: http://www.maketecheasier.com/qalculate-powerful-calculator-for-linux


Prestashop - give user ability to upload custom image for product

Question: How can this be achieved in Prestashop version 1.4.7?
Answer: You have to add personalization to the product.
In BO edit product, choose 6th tab (personalization, customize - i don't know how its on english - i have polish version) and then add one field Files Type and click update.
Then give this field name, choose is this field is required and save all.
I thinkg that should be enought
Answer: I know its bit of late but here is my answer
go to Products page under Catalog option and select edit product, then click on Customization and Select File Type or Text Type to upload an image and its description directly from prestashop.


Xcode 9.2 / iOS 11 / Can't find folder

Question: Apple recently demanded I upgrade my iPhone to the latest iOS version (11.2), and, as usual, Xcode then refused to connect to it unless I upgraded Xcode, which, of course, I could only do, if I upgraded my version of Mac OS.
So, after wasting half a day downloading and installing updates, I'm now on Xcode 9.2, and my code, which built beautifully before, fails to build with an error of:
    ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/
Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk/
Developer/Library/Frameworks'

(Note: I've added spaces in that folder path myself, to make it readable here.)
The error message is true though.
If I attempt to go into that folder, I can get as far as the iPhoneOS11.2.sdk folder, then there's no Developer sub-folder in it.

I have Googled this problem, and lots of people recommend checking your "Library Search Paths" and "Framework Search Path" settings...  but in my case, both of these were blank.  I didn't have any folders specified in my build settings.
Interestingly, in that screenshot above, I noticed that the System folder does have a Library\Frameworks subfolder so (out of desperation) I copied the System folder into a folder called Developer.
Ridiculously, this seems to have fixed the problem, but surely I'm missing something here...
Has anyone else had this problem, specifically since upgrading Xcode ?
After making this change to the folder structure, I did still have 1 other error.  Xcode was now complaining that:
embedded dylibs/frameworks are only supported on iOS 8.0 and later

Again, this error hadn't appeared before I upgraded Xcode, but the fix was to change the iOS Deployment Target in my "Project" build settings and in each of the Target build settings.

What really bugs me about Xcode is that I don't want/need any of the new iOS 11 functionality.  This is a legacy in-house app, which we've been using since iOS 7.  This stuff should just build, after an Xcode update, but with each release, we get new problems, as obscure as the ones highlighted here.
This Xcode stuff is truly terrible...  please can I go back to my warm-and-cosy Microsoft environment now...?
Answer: You can use your old Xcode to support 11.2
To support you need to run below command:

sudo ln -s PATH_OF_NEW_XCODE_DEVICESupport_TO_11.2 PATH_OF_EXISTING_XCODE_DEVICESupport

Example:

sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/11.0 /Applications/Xcode821.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport

Comment: Thanks for this advice.  But seriously, if you don't do this, Xcode thinks "directory not found" is a good error message to help developers get around this issue ?  This stuff is dreadful...
Comment: Try to create New App in New Xcode and If it works fine then your project may be having some Build Settings problem

Xcode 9.2 / iOS 11 / Can't find folder


Is life feasible in an inhospitable binary system?

Question: There is a planet orbiting a binary system inside the Goldilocks zone. The problem is that the binary system is of a violent kind. It either regularly explodes and sterilizes a portion of the planet's surface (recurrent nova) or constantly bombards the planet with X-rays (X-ray binary).
Can carbon-based life survive in these conditions?
Comment: The recurrent nova link provided suggests an increase in output for the star averaging _ten millionfold_.  The minimum example there was 1.5 million times the output.  Using earth as an example, the average square metre receives 21.6 MJ per day.  So it would receive 30 TJ/day.  At that point, we need to switch to nuclear weapon equivalents - that's 0.24kT per square metre, for the duration of the nova.  At the very least, the seas would boil to their bottoms and the land would be scythed to bedrock.  This seems impossible for life to survive.
Comment: Do you want to know about basic, monocellular life or more evolved one?
Comment: The evolved one, please.
Comment: It's a little like the "The Three-Body Problem" written by Liu Cixin. Through I don't know about scientific basics, you may find some relative ideas in this book
Comment: @Anton Lioznov
"The Three-Body Problem" is about a planet with an upredictable orbit that often leaves the Goldilocks zone, its not related to the question.
Comment: Native carbon-based life or any carbon-based life? I think something could certainly move in and survive but whether that would be feasible or not depends in part on details outside the scope of the planet in question.
Comment: In my opinion it could be possible but extremely rare. Firstly we need to defined the timescale we are talking here. Are those eruptions that much common? One thing other comments don't take into account is that every eruptions don't necessarly hit the planet. So based on the timescale we are talking and based on the distance you can already have a good idea of how much and how often your planet is being sterilized. Secondly which kind of planet? Is it massive, with a dense atmosphere (if so it has a pretty strong magnetic field)? This criteria is really important because if it has no magnetic
Comment: @ohpif - the link provided by the OP makes it clear that recurrent novae are non-directional.  The sun brightens by a hundred million times, and stays that way for a few weeks, at an interval measured in decades.  A magnetic field doesn't matter.  An atmosphere doesn't matter (and would, in fact, be erased by that).
Answer: It needs to be calmer
You said yourself that the novas regularly sterilize part of the planet (I assume the suns-facing side).  Unless this event occurs very infrequently (like, once per tens of millions of years), you will not have any life on the planet.
For life to exist, it needs an environment it can survive in long enough to reproduce and evolve.  If single-celled organisms happen to appear, they will have to be lucky enough to not get blasted for the millions of years it takes them to spread around the planet, or else one nova can be a 100% extinction event.
Even if they make it past that point, regularly Thanos-ing the planet will make it very, very difficult for any form of intelligent life to develop, civilize, and advance.  This further highlights the requirement for such an event to be extremely rare.  Life on Earth, let alone Humanity, would never be able to get to this point if half of the Earth got set back to 4 billion B.C.E every thousand years.  And this isn't even acknowledging the constant X-Ray bath, which would be constantly turning genetic code to Swiss cheese and giving everything cancer.
EDIT: As @jdunlop pointed out, recurrent novas are not an instant burst that would sterilize half the planet, but are in fact a sustained brightness increase of, according to your Wikipedia article, 8.6 magnitudes (400,000,000x), for days or weeks.  So, all life, not half of all life, would be sterilized.  This means your proposed planet is not almost uninhabitable, it is entirely uninhabitable.  Every time this happens the planet's surface would melt and maybe vaporize.
Comment: Nice use of "Thanos" as a verb, though this is actually worse than Thanos, because rather than all of the disappeared being randomly distributed amongst the population, it's literally every living thing (and probably most structures) on one entire hemisphere.  Anything resembling a civilization would be impossible under those conditions.
Comment: Not the sun-facing side - per the recurrent novae link provided by the OP, the star flares its output by a factor of about ten million - and keeps doing so for weeks.  This would annihilate _everything_ on the planet (if not the planet itself).
Comment: @jdunlop This is a good point, I will update my answer.
Answer: Maybe.
If life evolved under those recurring conditions, it is possible that it can adapt to them, in the same way some life forms have adapted to thrive when exposed to oxygen, which is otherwise toxic for others.
Even on our planet we keep finding life forms where we would not expect them to be, so we cannot exclude that what we deem unfit for life actually is totally fit for a life adapted to it.
Comment: You make a point, but I wonder how often those explosions occur? Every century and I can't suspend my disbelief enough (can a single-cell life form evolve a resistance to hemisphere-sterilizing radiation?). Even every millennium stretches my credulity... but every million years? Now I can believe life would form. But now we're Chicxulub-meteor rare. I'm having trouble buying into becoming resistant to an ELE. The explosions would have to be at just the right frequency with a hounding good amount of luck.
Comment: @JBH, at the century level, that's plenty of time for life (or proto-life) to migrate from the unharmed side of the planet.  Even the slowest oceanic circulation on Earth (the North Atlantic Deep Water traveling around South America to rise in the north Pacific) only takes a thousand years; the surface currents move much faster.  (And thousands of meters of water makes for an incredibly good radiation shield -- expect early life to evolve in the depths, then migrate to the shallows as it gains radiation resistance.)
Comment: @Mark I understand your point... I'm simply not convinced that wiping out 50% of life, which will happen on different parts of the planet over time, will permit any meaningful evolution.
Comment: @Mark [Recurrent nova](https://en.wikipedia.org/wiki/Nova#Recurrent_novae), it turns out, are not single-moment burst events, they last for days.  In other words, it doesn't wipe half the planet, it wipes the *entire* planet.
Answer: Hydrothermal Vents
Complex life exists in the deep sea. Half a dozen miles of salt water should provide insulation from the radiation storms. To quote my earlier answer:

There are already ecosystems on Earth that are separated from the sun. For example tube worms feed off the energy released by hydrothermal vents.

Of course a tube worm cannot snatch a human out of its shoes. But it's not just tubeworms down here. Look closer -- there is a ghost crab and some small orange Pokemon hiding in there.

Your Night Land Monsters have as the bottom of their food chain something akin to smokers. I leave it to your imagination how the smokers got so close to the surface that the denizens ever encounter humans.
Answer: Deep life
I am thinking of earth before the ozone layer formed.  It was a rough place topside.  Down by the black smokers in the deep ocean it was comparatively placid.  Less hard radiation, water to moderate the temperature, a steady supply of tasty sulfur and iron carried up from the energetic depths by the water cycle.  It was not until things really got started in the ocean and ozone could block the UV that Earth life could get going on dry land.
Minerals are good protection against radiation.  In your world the crust plays the role that the oceans did on earth.  Deep in your inhospitable world, life is sheltered from the hard rays.  Life forms are treated to tasty energy-rich molecules generated on the surface by the radiation and transported to the depths by the water cycle.
Answer: Life can survive using a couple of methods of coping with increased radiation. First off, radioresistance varies across organisms and can be quite high. Look at some of the pictures of how the wildlife around Chernobyl has rebounded despite the radiation. Since radiation causes cellular damage, repairing the damage quickly is one such method of how an organism can adapt to handle higher radiation amounts. Another method would be the evolution of shielding. Lifeforms inside thick exoskeletons are potentially less likely to be effected by external radiation. Molting after being hit by radiation could allow organisms to avoid most of the negative effects. A combination of these two factors could easily give you organisms capable of thriving in such an environment.
One issue such a planet would face is the rate of exposure. Too long between exposures can be just as bad as too short. But a short time between radiation pulses is only an issue for lifeforms which have not adapted over time to resist it. In order to adapt to radiation, organisms must be exposed to it often enough to kill off the less resistant offspring and allow the more resistant offspring to procreate, but if the periods between exposure events are too long, less resistant organisms will thrive and weaken the genetics of a species. If such exposure is predictably cyclical, then organisms could hibernate underground during the radiation storms.
If we have the initial organisms on your planet evolve in the deep oceans, then over time those which adapt a slightly higher radioresistance will move into shallower water. Higher radiation means more mutations, until organisms develop genetics, or biological defenses, capable of resisting harmful mutations. The process continues, with organisms adapting to enable their expansion into previously inaccessible niches. Perhaps one of these organisms evolves a thick shell to protect itself and is the mother to a new evolutionary line which branches into thousands of new species. Maybe plants evolve extra bark or a thick canopy which is rapidly replaced after a large radiation dose. Look at how plants have evolved to deal with wildfires as an example.
As long as the ancestor organisms evolve a resistance to high radiation, that trait can be passed on to their offspring. Wait a few billion years and you will have a world full of organisms perfectly adapted for their radiation soaked environment. An environment deadly to a human being could just be another day in the life for your planet's natives.
Answer: Mutant Tardigrades
Extremophile life is real. If life evolved in that planet, it most probably is extremophile organisms, who are able to enter a cyst state to survive the extreme heat and whose bodies aren't suceptible to x-ray radiation.
Earth's Tardigrades already to this:

Tardigrades Can Survive X-Ray Bombardment by Deploying a Protein Shield (ref)
A study in 2016 discovered that a protein unique to tardigrades called Dsup (damage suppressor) could suppress X-ray-induced DNA damage in human cells by approximately 40 percent.

As for the sterelizing heat, picture ants walking inside a working microwave oven without getting cooked. They are too small to properly capture and keep the heat.
Answer: So, you have the surface constantly bathed in x-rays, and the surface is regularly obliterated by its star.
First off, the planet is constantly bombarded by x-ray radiation. I think this is the lesser problem, as with the right adaptions, life could thrive in the high radiation environment, although the life would probably have to originate underground and evolve the x-ray resistance later. How about these organisms have exoskeletons to shield themselves from radiation, or how about there is lots of lead on the planet, which the animals could use to cover themselves, a biological lead apron. The plants could even use the x-ray radiation to their advantage, maybe they can harness the x-rays to use along side light energy. There are many possibilities.
Now, the bigger problem(in my eyes) is that the planets surface is wiped clean every couple years. Now assuming the whole surface is wiped out, and not just one hemisphere, and lets assume the pessimistic, that it happens every 2 years(the most frequent ones happen every 1 year). How about some sort of hibernation. Some animals on earth hibernate during the winter months and emerge in the summer. Animals on this planet could go deep down, hibernate, and reemerge when the nova is done. The plants meanwhile could maybe have very deep roots and embed seed pods underground, which could sprout back up after the nova along with the animals. Or maybe they have some completely different way of surviving through the apocalypses that happens every couple of years. Again, many possibilities.
All in all, I think carbon-based life seems probable on this planet, although it would need the right adaptations.
Answer: Yes, up to a point.
Water is good protection. It has high heat capacity and blocks much hard radiation. Because it has a maximum density at 4C and because ice floats on water, it takes a very long time for surface heat to reach the depths. Many miles of deep if you need it.
Life evolved in the oceans. The Chixulub impact didn't have nearly such catastrophic impact on marine life as it did on terrestrial life.
So, because of more frequent catastrophic upheavals, life on this world never loses its ability to survive deep in the oceans. When it gets too cold, or too hot, or too "hot" with radiation, everything dives into the ocean and swims down out of harm's way while the terrestrial environment gets a big reset. Depending on timescales, life may need to go into deep hibernation down there. Life will have evolved senses to sense the approach of the hot or cold, and the easing of such that will allow emergence from hibernation.
The situation of the "spiders" in Vernor Vinge's A Deepness in the Sky is almost exactly like this. Their star regularly flares and gives the terrestrial environment a brief hurricane of steam, then slowly cools down, and down, and down, until they have to hibernate deep underground for ~200 years until the next flare.  (Reasons = Spoilers). Oh, and they've acquired a technological civilisation, and they're starting to think about breaking with the natural cycles which  nature and evolution  imposed on them.


get original creation date of html file

Question: Can I find the creation/last modified date of an html file? For example, I would like to know when some index.html file from some website was created, not when I downloaded it.
Comment: For UNIX/Linux creation date is not part of the file definition
Comment: For static HTML pages backed by files, the `Last-Modified` header in the HTTP response usually reflects the last modification time.
Answer: Most browsers don't do anything special to set the time stamp on a downloaded file, so the file ends up being dated from the download. Download managers usually change the downloaded file's modification time to match the Last-Modified header sent by the server. With command line tools, use wget or curl -R to set the file's modification time to the time sent by the server (and wget --no-use-server-timestamps or curl to set it to the download time).
The server will generally set the Last-Modified header to the time the file was last modified, if the content of the URL is stored as a file. In these days of dynamically-generated content, that's not so common anymore. There's no way to get the creation date; most filesystems don't even record it.

get original creation date of html file


Which is the Electrolyse Reaction?

Question: $$\ce{NaOH +H2O->H2 +O2 +NaOH}$$
We know that $\ce{H+}$ and $\ce{OH-}$ go  to the cathode and anode, but how can I write the total reaction?
Is it: $$\ce{2NaOH +2H2O->2H2 +O2 +2NaOH}$$
I've put NaOH both sides because if the mass of NaOH is given, how can I find the mass of H2 for example?
Comment: Why would you need to write $\ce{NaOH}$ on both sides?
Comment: Because if I'm given the mass of NaOH, how should I find the mass of other substances?
Answer: Electrolyse of water is a redox reaction, meaning that there is a transfer of electrons between atoms. Now, every redox reaction can be written as a combination of 2 half-equations. One half-equation shows one species getting oxidised (losing electrons) and the other half-equation shows the other species getting reduced (gaining electrons). When you combine these two half-equations you get the overall reaction, which is what you are asking for. Here is guide that should help you find the overall equation of any redox equation, not just this one example.
Step 1: Determine what species gets oxidised and species gets reduced
Now, what I think the reaction you are trying to describe is the electrolyse of water. Correct me if I am wrong. If that is the case, there is no need for $\ce{NaOH}$ in the equation as it appears on both side, meaning that they cancel each other out (also $\ce{NaOH}$ has nothing to do with electrolyse of water). Secondly, it is $\ce{H2O}$ that gets oxidised and reduced, not $\ce{H+}$ and $\ce{OH-}$.
Step 2: Determine  half-equations
These can be easily found by using your table of standard reduction potentials. Oxidation half-equation: $$\ce{2H2O -> O2 + 4H+ + 4e-}$$
Reduction half-equation: $$\ce{2H2O + 2e- -> H2 +2OH-}$$
Step 3: Balance each equation so that there is the same number of electrons
We can't immediately add the half-equations as the electrons won't cancel each other out. This means that we need to multiply the reduction half-equation by 2:$$\ce{4H2O + 4e- -> 2H2 +4OH-}$$
Step 4: Add the half-equations
When you add each half-equation, you get: $$\ce{6H2O   -> 2H2 + O2 + 4H+ + 4OH-}$$ The $\ce{H+}$ and $\ce{OH-}$ combine to form water which then cancel out with the water the other side. Therefore the overall reaction is: $$\ce{2H2O  -> 2H2 + O2}$$
Comment: What if I am given the mass of NaOH, how am I supposed to find the mass of other elements?
Comment: I do not understand what you mean. How is NaOH related to the electrolysis of water? Can you explain your problem in more detail?

Which is the Electrolyse Reaction?


Can't update record

Question: I'm trying to sync three scripts together to get cross domain profile editing working. The scripts are WordPress, BuddyPress, & JamRoom.
The code I'm using go to the test domain, get the profile's information from a php call that returns JSON, and then the JSON can be pushed to the WordPress/BuddyPress database.
The only problem is that I'm a front end developer wearing a backend's hat, so I'm learning as I go.
How can I check to see if the user_id already has entries under field_id (value 1 & 2) that have filled in values? And if that exists, simply update the entries. If it doesn't exist, simply create them.
Code I'm working with
http://pastie.org/private/zivzakqyhzcbn3wkdfa6w
Columns I'm working with
<code>id,field_id,user_id,"value","last_updated"
</code>
1,1,1,"admin","2011-03-07 00:35:52"
9,1,2,"YouRock","2011-03-07 01:11:32"
Answer: Assuming that id is key, use a ON DUPLICATE KEY UPDATE-statement
Comment: No, but you may create a key of it.

Can't update record


Contacts with Multiple Accounts /Multiple Email addresses

Question: I have a user requirement where a contact may need to be associated to multiple Accounts and store multiple email addresses based on the Accounts they are working for.
For Example, Joe Blogs who works as a contractor starts work with Company A, then works with Company B, and then works with Company C. Joe has multiple email addresses for each different account - firstname.lastname@example.com, email@example.com and email@example.com.
I am using the new SF Feature, Contacts with Multiple /Related Accounts which is great, but I need a way to store multiple emails for the contacts based on the company that they are with.
Also, I would like to be able to integrate Salesforce for Outlook, so that when a Sales person can send an email to any email address that joe has (firstname.lastname@example.com, email@example.com etc.) and the email will be mapped to Joe's contact record in Salesforce. (Ideally, I would like to have one Contact record for Joe in Salesforce). Any ideas, either using the new feature or without using the new feature?
Answer: You can create a custom email field on the Account Contact Relationship, that way you'll have a unique email for that specific relationship. Go to:
Setup>Accounts>Account Contact Relationships>Fields
and create a new field


How to use ionicons in photoshop like font awesome?

Question: Can we use ionicons like we use font awesome? or is there any workaround. Currently, they have the option to download SVG's but they are not opening in photoshop for me (I am using cs6).
Comment: Do [these answers](https://graphicdesign.stackexchange.com/questions/27254/font-awesome-as-photoshop-custom-shape-set/27281#27281) begin to answer your question?
Comment: How do we use font awesome in PS cs 6? I have no recollection of what the svg support was pre CC. I could've sworn you could open svg's but PS would rasterize them... But I guess not? — I personally use [IconJar](https://geticonjar.com/) (Mac only). You can drag icons from IconJar to the application... but that is no different than dragging/opening .svg files in PS.
Answer: Don't open an SVG in Photoshop - that will rasterize it. In some instances I've found that Photoshop can have problems rasterizing an SVG, especially a complex one.
Instead try placing the SVG using File > Place linked/embedded, or drag and drop the file into an existing document, where it will be converted into a Smart Object, and will remain a vector image. This certainly works in Photoshop CC. I don't have a copy of CS6 to test it.
If this still causes problems, perhaps try opening the SVG in Illustrator, and save as an AI file, then place the AI file as a Smart Object in a Photoshop document.
Comment: Yeah, I was doing the same. Open in illustrator and then drag into photoshop as a smart object. Not an efficient solution like font-awesome we use but it works. thanks
Comment: @AamirShahzad, you still haven't told us how you use font awesome in cs6. Dude, cs6/cc was released like 8 years ago. I can't remember further than 24hours you think I remember how things worked I cs6? :) Like I think I maybe had an extension for fontawesome. But if you use it as a font, you could probably use like iconmoon.io to convert any icon pack into a font... though I'm not s sure that would make it any easier than just converting the files to png once and just dragging them in on demand..
Comment: @Joonas this is how you use font awesome. https://knackforge.com/blog/manoj/how-use-font-awesome-icons-adobe-photoshop
Comment: Yea, svg's converted into a font using iconmoon would work the same way.


jQuery variable increment ++ not working in script

Question: I have this jQuery function that switches between different status messages (p elements) with ID's ranging from status_0 to status_5:
setTimeout(function() {
    var next_status;

    if (current_status < 5) {
        next_status = current_status++;
    } else {
        next_status = 0;
    }

    $(".status_visible").fadeOut("fast", function() {
        $("#status_"+next_status).fadeIn("fast");
    });

    //alert(next_status);

    change_status();
}, 10000);

My problem is that to start with, current_status definitely equals 0, but when it gets to my increment part, it comes out as 0 still! I tried this with a simple next_status = current_status + 1, which returned 01 instead of 1 (concatenated them), so I tried next_status = current_status++ and it returned 0 still.
Can anybody put me straight here please :)
Comment: In addition to the pre-incrementing operator suggested by Huang Tao, you could replace the entire if/else with `next_status = ++current_status % 5`
Comment: @amnotiam: thanks for that, that's really helpful, and interesting.
Answer: next_status = ++ current_status;

Answer: The expression current_status++ means, "increment current_status, and evaluate to the old value of current_status," that is, use current_status, and then increment it after you note its value.
You want, ++current_status, which means, "increment current_status, and evaluate to the new value."
Answer: is your timeout method "setTimeout" going to be called multiple times? If so , you need to pass your counter as a parameter with global scope, otherwise it will be reset each time.


Second Monitor Not Detected After HDMI unplugged and plugged back in

Question: I'm using Ubuntu 14.04 on a Toshiba S55-B5289 laptop. I've been using a second monitor with the laptop since I got it, and it's basically been plug-and-play. I connect the monitor via HDMI, and usually it just fires right up. Last night, I unplugged the monitor to take the computer upstairs. I noticed it was still behaving as if the second monitor was there. So I logged out and logged back in--problem solved. Today, I plug the monitor back in, and Ubuntu doesn't detect it. I've spent the last half hour unplugging, plugging back in, restarting, tweaking settings, and browsing forums without much luck. Most of the tips seem to have to do with getting a second monitor working in the first place. It was working yesterday. But now the laptop just doesn't seem to notice it's there.
Comment: I just learned this trick which helped with some of my multiple monitor issues:  connect both monitors, then repeatedly press magic-p to cycle through different configurations.
Comment: magic-p? Can't say I know what that is.
Comment: "Magic" = "windows" key on most keyboards.  Also called super
Comment: Gotcha. When I git magic-p, I just see a list of numbers/letters pop up on my shortcuts bar.
Comment: Odd.  It cycles through 3 or 4 different monitor configs for me.  Sorry it didn't help.
Comment: Thanks for the tip! It might work if the second monitor were being detected. At the moment, Ubuntu doesn't even appear to notice that the second monitor is there.
Comment: Check the similar question that was answered (but not accepted) here: http://askubuntu.com/questions/874506/hdmi-monitor-not-detected-by-laptop-after-unplugging-and-plugging-back-in/876684#876684
Answer: Some system updates came out today, and I applied those using Synaptic Package Manager. After the update and another reboot, the dual-monitor system is working again. I don't see anything in the updates that appear to have anything to do with display, but my guess is that maybe running the updates flushed out whatever the disconnect was that was keeping the second monitor from being picked up.
Comment: To avoid this problem in the future, could you post your `monitors.xml` to http://paste.ubuntu.com as I've got a hunch the problem is somewhere in there...  ;-)
Comment: http://paste.ubuntu.com/10819346/
Comment: As I suspected...  I'll start answering in a few minutes.
Comment: any feed-back???
Answer: As I suspected, this was no fluke: Your monitors.xml contained an erroneous configuration without HDMI.
Here is the corrected version that only contains one single configuration (the original that worked without any problems)
Now

Replace your existing version with my corrected one
Keep a back-up of the corrected  just in case this ever happens again…
Comment: Not sure I understand. I can see that mine had the configuration repeated, but there _was_ an HDMI configuration in it.  Your version deleted the repeated info, but it didn't add anything. Or am I missing something?
Comment: As you can see from my answer, I'm not currently having the problem. I wasn't having the problem when you submitted your answer. I can't confirm that this solves it. The problem was solved for me when I ran new updates. If/when it happens again, I will try your solution. If it works, I'll mark your answer as correct.
Comment: Fair enough!  ;-)  Please delete all comments as they've been incorporated into the answer anyway...
Answer: By sheer coincidence I had a similar problem right here with this computer only yesterday.  Believing in trying the simplest solution first I applied a thin layer of CAIG DeOxit D100L to both ends and that fixed it.  I recommend it to all my friends.
I gave a vial of this to my girlfriend two years ago, and of all the gifts I've given her for birthdays, holidays, and anniversaries, I'm sorry to say this is what she uses the most.  A few months ago she "fixed" her daughter's iphone when it refused to charge merely dabbing this on the charger plug.  When her 14 year old daughter asked how that fixed it, my girlfriend's response was "It's Magic".
So you see, while this is not the same magic recommended by another, it is a useful tool necessary in any geek's arsenal, and it is available online.
Comment: I appreciate the tip. The cable/monitor work fine when plugged into another computer. Do you think this is still a possible solution?
Comment: If the cable and monitor worked with another computer, but previously worked fine with the original computer, then the problem exists in the original computer.  DeOxit might fix it, if it is only the connection.  I carry a vial of deoxit in my fanny pack at all times.  Let me give you a quick example.  The last time I mailed a package at the post office, the scanner stopped working and the clerk could not shift machines.  With the line getting longer and the clerk consenting, I fixed the scanner with my deoxit, right there.  He took note of it to buy some himself.


Run Program on Startup?

Question: How is it possible to have an executable run automatically on startup? Is it possible by having a shortcut to the .exe in the startup folder in the All programs section of the start menu? If that is correct, what is the full directory of the startup folder?
Comment: What version of Windows?
Comment: I suppose Windows 7. If not it would be equally interesting to know about windows xp and vista also.
Comment: Im sorry if this is amateurish, but would it be possible for an explanation of how to use the following code?

 Private Const cPGM = "C:\VB Forum\startup\TestStartup.exe"

   Dim oShell As IWshShell_Class
   Set oShell = New IWshShell_Class
   oShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\MyVBApp", _
                   cPGM, "REG_SZ"

thanks for your patience
Comment: that will set a registry key that allows "C:\VB Forum\startup\TestStartup.exe" to run at startup
Answer: There are many options, the Startup folder being only one of them.
A detailed guide is available here: http://oreilly.com/pub/a/oreilly/windows/ron/startup_0401.html
The most popular option these days is the registry - see the guide link above for details.
Comment: That's the answer. You don't need to look any further.
Answer: The preferred way is to create a registry entry, such as in HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run.  The key needs to be of type REG_SZ (0-terminated string) and contain a unique name as Name and the program's full executable path as Data.
Comment: I disagree. The registry has less transparency to the average user than the startup folder. Users don't generally like it when programs add startup items of dubious necessity.
Answer: Yet another method is to use the task scheduler found under accessories/system tools.  Create a task that launches the program at startup.
Answer: C:\Users\YOURUSERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Comment: Be wary of non-English versions here!! There are known ways to get special folders under Windows.
Comment: I notices the tags didn't include a tag for any programming language so I assumed he just wanted a path. I think maybe his question if not asking for code example should be placed on superuser instead.
Comment: You should still use the environment variables. `%AppData%\Microsoft\Windows\Start Menu\Programs\Startup`
Answer: the simpliest way is to create a shortcut and to drag it it Startup folder (drag over start button, programs, start and drop it there)
If you want to see the path, just r-click on startup folder and select open

Run Program on Startup?


Should I be worried if my EIN application form and EIN are publicly available online?

Question: Some time ago, I sent a Form SS-4 (Application for Employer Identification Number) to the IRS, and later received a reply from the IRS containing the EIN. Recently, I discovered that the Form SS-4 I sent and the IRS' reply are somehow publicly available as a PDF download if one searches hard enough using a search engine. The form contains my full name, my EIN, and my signature. I used a third-party's address as my mailing address, so my home address is not leaked. Is this a cause for concern in terms of privacy, identity theft, etc.?
Comment: Can you be more specific about where this "publicly available" document is found?
Answer: It's not a cause for concern in the sense that there's no way you can keep your EIN secret since there's many government entities (states, and FCC for example) that will provide your EIN to others if you're registered to do business with them or need them for licensing. Apparently tax fraud happens where people steal someone's EIN but all you can do is then try to prove to the IRS that you aren't responsible. Business EIN Tax Fraud
Your signature, I guess that might be something someone could copy but realistically, I don't think that the vast majority of places that accept signatures actually have a handwriting expert to verify that the signature is legit so a criminal could just make up a signature out of thin air.  In the modern age of digital signatures (and rubber stamps) it's really hard to tell if a signature is legit or not just by looking at it. It's more like if someone uses a signature without authorization, it can be used as evidence of fraud against them at some future point in time. After whatever crime occurred.


Laptop screen brightness irritates me at night

Question: When I am using my laptop at night, the laptop light irritates me, despite the fact that my laptop brightness is normal. Please tell me how to overcome this problem.
Comment: What operating system (and what laptop model) are you using?
Answer: In Windows 10 Settings, for controlling the brightness of your device. Go to "Settings" and then select "System". Now under "Display", you will find a "Change Brightness" slider at the top. Move that slider to adjust the brightness of your device.
If your device comes with sensors capable of light intensity detection, then you might also see "Change brightness automatically when lighting changes" checkbox below the slider. Enable this Adaptive Brightness feature if you want the brightness to be automatically adjusted.
Another simple solution may to get a tinted sheet of Plexiglas or something to put in front of the screen to make it dimmer.
See also: http://forum.notebookreview.com/threads/how-to-decrease-laptop-led-backlight-screen-to-its-minimum.433375/
Answer: There is an application called F.lux, which reduces blue light and irritation to eyes during the evening.  It is available on most platforms, including phones and tablets.
EDIT:  This program can be set up to individual preferences.  For instance, you can change the warmth of the light depending on your own preferences.  As well, it has the ability to change states depending on your timezone's sunrise/sunset times, how quickly the changes occur, and even the ability to expand the range to warmer colors than is typically available directly from a base install [although this requires a restart of your system].  All in all, I find this has more features and customizations than other offerings, be they OS or other software.
Answer: If you've set the brightness to lowest and the screen is still too bright for you, there are many dimmer programs you can download for free. (PangoBright, for example, allows you to dim the screen up to 20% and also change the hue. If 20% is still too bright, you can use it together with another dimmer.) Do some searching on screen dimmers and see what works best for you.
Answer: I take it that you already reduced the brightness of the screen as much as possible as well as chose a pleasant dark desktop theme. Your remaining options are:

Turn the ambient light on in the room (will make your pupils contracting and therefore will make your eyes less sensitive to the laptop light).
Put some grey filter in front of your screen. Experiment with grey plastic foil.
Put some grey filter in front of your eyes. Use some kind of very light sun glasses.


I can no longer completely turn off the screen by decreasing the screen brightness to zero in 16.04

Question: Sorry if this is vague and not nearly as technical as most other questions here, but I'm a pretty new ubuntu convert. When I'm in hurry I've been turning off my screen just by holding fn and f8 to decrease my screen brightness to the lowest setting which used to completely turn the screen off, however after updating to 16.04 the lowest brigtness setting doesn't completely turn the screen off, is there any way to return the lowest brigtness setting to being a completely off state?
Answer: you can try the command line

sleep 0.2s && xset dpms force off

and press enter to have it display again.
you can write it into a script and put just have it launch from a desktop icon then you can click the icon and your screen will turn off then move your mouse/trackpad or press enter and your screen will display again.


Iteration on CSS class array and Toggle class on click

Question: I have this code
The problem is I need to toggle class on click. I have classes
.col

.col-1 / .col-2 / col-3 etc.

and I need to apply on click to the right .col-1 / col-2 an expand class, so it would like
.col .col-1 .col-1--expand
.col .col-2 .col-2--expand

Before I had this on hover in CSS and it works, but make it on click is little problematic. I searched whole day Javascript and jQuery cases, but I haven't found any right solution to it.
What I learned, I must use forEach function in Javascript, but a solution in jQuery is also what I want.
I tried something like this on my project, but I'm still bad at Javascript :(
if (document.querySelector('.slider__col')) {
const expandElement = element.querySelectorAll('.slider__col')
expandElement.forEach(element => {
    element.addEventListener('click', function() {
        element.classList.toggle("");
    })
})

Answer: You can use a regular expression to match element classes and toggle the expand class on that element when clicked.
var matched = this.className.match(/col-\d{1,2}/);

This will find any classes in your element's class attribute that contains col- followed by any numbers up to two digits so you can cater for 1-99.
matched.length && (matched = matched.pop())

.match() returns an array of matches so you can determine if any matches were found and pop the first match off of the array.
var expandClass = matched + '--expand';

Because you're matching, for example, col-1 you can use this string and append --expand to make col-1--expand.
$(this).toggleClass(expandClass);

You can use jQuery's toggleClass to add/remove the expandClass depending on the class's presence. See col-3 for demonstration.

$(document).on('click', '.col', function () {
  var matched = this.className.match(/col-\d{1,2}/);
  if (matched.length && (matched = matched.pop())) {
    var expandClass = matched + '--expand';
    $(this).toggleClass(expandClass);
  }
});
.col {
  background-color: blue;
  color: white;
  padding: .25rem 1rem;
  margin: .25rem 0;
}

.col-1--expand,
.col-2--expand,
.col-3--expand,
.col-4--expand,
.col-5--expand,
.col-6--expand {
  background-color: green;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

1

2

3

4

5

6

Comment: Guess we were both working on an answer! ^^ Nice, I love the regex addition.
Comment: Worked for me, very thanks for help and explanation!
Answer: Welcome to StackOverflow! Since you want a solution in jQuery, let me give you some guidance.
1. The forEach function is in jQuery available as the
   .each() method. Making your code:
// Select your classes, for each of them run a function
$('.col-1').each(function() { });

2. To make something happen on a click, jQuery has a .click() method available, it will call a function on click. Making your code:
$('.col-1').each(function() {
    // Click method:
    $(this).click(function() { } );
});

// Or just do:
$('.col-1').click(function() { });

jQuery does not need a loop and can bind the click method to all classes by itself. There are cases where it still might be useful, but let's keep it basic for now and get your code working!
3. Adding the new CSS class. In jQuery there are many methods you can use for it. In this case you are probably looking for the .toggleClass() method. Other useful ones might me .addClass() and .removeClass(). Making your code:
$('.col-1').click(function() {
    $(this).toggleClass("col-1--expand");
});

// Or just add it:
$('.col-1').click(function() {
    $(this).addClass("col-1--expand");
});

Done, repeat for other classes where you want to do some magic. Next time try spending a day on the jQuery API Documentation. All the methods are there, with great examples included! Best of luck with it.
Comment: Thanks for explanation and help, I will do good research on this site starting from now.


Is a buffer stage needed in this signal chain?

Question: I am designing a signal chain that includes a 4 pole cascade Sallen-Key filter based on the AD8034. The circuit will be used to shape tail pulses (~10ns rise time, ~50us decay) into gaussians. The filter design is taken directly from page 20 of the AD8034 datasheet. I would like to include two AD8009 gain stages before the filter as shown in the schematic below. Is a buffer stage separating the AD8009 from the AD8034 necessary in this case?
Comment: I don't see why you would need one? Pin 3 of U7A draws no current, so what is the buffer for?
Comment: Some of your resistor values are very low. My rough rule: If an opamp is driving less than 1k impedance, I make sure that the opamp can drive the output to the expected voltage.
Comment: @Mattman944 Are refering to the feedback resistors on the AD8009s? I got these values from the datasheet for G = +10 (page 2 of datasheet).
Comment: The AD8009 is OK, it is a video amp, much more powerful than a normal opamp. The AD8034 is more of a normal opamp and it has 100 ohm loads that I don't see any reason for.
Answer: The purpose of a buffer stage is to prevent the current drawn by the next stage from affecting the voltage output of the previous stage, i.e. to bridge a high-impedance output to a low-impedance input.
The inputs of U7 AD8034 have very high impedance - at least at DC. For AC, I guess working it out would require some complex calculations I'm not familiar with. The input capacitance as specified as "a few pF". Adding a buffer stage would have the same capacitance in the buffer stage so it wouldn't improve anything, anyway.
In fact, if you look at how the circuit is constructed, U7A is a buffer stage!


How long do I charge the battery for a "Power Grinder" brand rotary tool?

Question: I was given a "Power Grinder" brand(made in China) rotary tool, and its cordless. I've plugged it into the charger, and the red light came on, and is still on 6 hrs. later. The tool works, but I don't know if its fully charged. It didn't come with any sort of manual, or instructions. I searched for a manual online, but couldn't even get the tool to come up in the results. I don't know if I'm damaging the battery, or if it actually takes this long to charge. Any help is much appreciated! Thanks, Mark]1
Comment: A free tool may have a battery that is not capable of fully charging rechargeable battery's have a limited life no matter what type. Several will gain a deeper charge by fully discharging and recharging several times, if the battery gets warm in recharge unplug let cool and try to top off the charge, heat kills rechargeables.
Answer:
It's normal for a battery to self-discharge over several months.
It's normal for a cheap tool (Black & Decker tier) to take 12-18 hours to fully charge.
What damages such tools is being left on the charger for days and days.

The reason is because their charger is not using "everything we know about batteries". By contrast, a Tesla supercharger can calibrate charge rates to take a Tesla Model 3 from 25% to 75% in 25 minutes at a rate that would take another Tesla from 90% to "fiery explosion".  Most batteries want a bulk charge rate in the middle of their range to about 85% and a low current taper charge near the end of cycle.
In the case of cheap chargers, rather than shift gears from "bulk slam-charge" to "low taper" to "maintain", the cheap charger simply does the taper charge continuously!
Which makes the charge comically slow.  But results in de minimus risk to the battery.
Note that it doesn't transition to a maintenance charge either; that's why you can't leave it on charger indefinitely.
Comment: @SolarMike Is there a "not" missing from your last comment?
Comment: Leaving the battery discharged for long periods is also damaging the battery.
Comment: @SolarMike Not for NiCd or NiFe, which is what most cheapie tools are.
Comment: Someone gave a tool with nicads in it - not been used in several years and battery is stuffed... so experience seems to say batteries should be left discharged for long periods.


Mix CATextLayer and CAScrollLayer

Question: I need a scrollable CATextLayer to display a NSAttributedString.
Is there any way to mix both layers, or to add a scroll to CATextLayer or to display text in a CAScrollLayer?
Sorry if the question isn't very exact.
Thanks!
EDIT: I haven't seen that the CALayer is scrollable.
Sorry!
Answer: Try adding this to your example to scroll the layer programmatically:
<code>- (void)scroll {
    [scrollLayer scrollToPoint:scrollPoint];
    scrollPoint.x += 10;
    [self performSelector:_cmd withObject:nil afterDelay:0.1];
}
</code>
and add this at the end of the initialize method:
<code>scrollPoint = CGPointMake(0, 0);
[self scroll];
</code>
Answer: CALayer (and CATextLayer) can be scrolled

Mix CATextLayer and CAScrollLayer


self-encoded QR barcode?

Question: I was wondering if it's possible to create a QR in some file format, say png, then encode the png in QR, such that the resulting QR is the same one you started with?
Comment: https://www.quaxio.com/qrquine/ a `*.js` file that QR-encodes itself
Comment: @darw: Perfection. Not exactly what I asked, but definitely what I was going for :)
Answer: I don't think so. Each QR code needs to encode the original data along with variable amounts of redundancy.
So to encode the original QR code, you need the encode the same amount of information and additional redundancies, which means the result can't be the same since it encodes more information.
Answer: There are different sizes of QR codes ranging from 21x21 to 177x177. They can hold anywhere from 152 to around 31,000 data bits. Unfortunately, even using 1 bit per "pixel", the amount of data a code can hold never reaches the number of bits required to store it.
There are sizes, though for which it is not far off. I imagine some simple compression algorithm, or maybe even ignoring common parts like the calibration areas could get to a point where you can store some representation of it in itself. It is feasible to me that you could find a way to store a qr code of some size as a qr code of the same size.
The problem then is constructing a code which creates itself. With different error correction options, there is room to fudge a few pixels around, which helps the probability that such a thing is possible, but it would still take a fair bit of magic. Perhaps some sort of genetic algorithm could do better than brute force, but you may need to read the full spec and build one cleverly by hand. The search space is pretty big.
Answer: A QR code can contain max. 4296 characters. I assume this is unicode, and that two bytes are used to represent one character. This means that a QR code can contain a maximum of 7089 bytes, which is enough to store a small image (like a small qr code).
The only issue here, is that most QR readers expect qr-codes to contain text (not image data).
Comment: qrencode -o newQR.png \`cat originalQR.png\`
works on linux, but I haven't tried to decode it to see if it puts out uncorrupted png data. freespace's answer suggest it wouldn't...
Comment: Not unicode, QR code can store up to 2953 bytes. 4296 is alphanumeric only (less then 8 bits per char).
Answer: As freespace mentioned, it's not possible to encode an image in that same image itself, for several reasons.
I have created a QR Code which contains an URL which contains (again) the original image:
http://qr.ai/qqq
I really think that's the closest you can get.
Comment: Including the contents of the link would make this answer useful

self-encoded QR barcode?


Occupation of Iran in World War 2

Question: During World War 2, British, Russian, and American forces attacked and occupied Iran. Why did they occupy Iran? Why Hitler did not try to stop them?
Comment: have you looked at a map lately? How'd the Germans even get there with a meaningful force to affect that attempt to stop the British and Americans already in place before the war, or the Soviets who have a large land border with the area?
Comment: they lacked the range, plus would have to fly a long way through hostile airspace to get there... Turkey, Iraq, Syria, Transjordan, all were solidly in the hands of the allies.
Comment: @VKaren-Pahlav: In 1940 the operational range of the ME-109, Germany's only first-line fighter, was barely from Calais to London. That the Spitfire and Hurricane both  had double the operational range was a significant factor in the Battle of Britain.
Comment: @PieterGeerkens: Actually, the operational range of the E-series Bf-109 (800km) *exceeded* that of the contemporary Mk I Spitfire, and was sufficient to make the trip Calais - London and back... *twice*. However, the Bf-109's didn't *take off* at Calais, had to group up with the bombers, and *then* fly to Britain, while the Spitfires and Hurricanes were operating over their own airbases, giving the RAF the endurance advantage. But yes, supporting Iran was just not on the table, neither technically nor strategically.
Comment: @jwenting: Germany had a very powerful air force; they could use their air force.
Comment: @jwenting: I am convinced; but Iran and Nazi Germany had very good relations since Iranians are Aryans dependents. Only if Hitler would station some of its forces in Iran or provide Iran with military equipment and educating Iranians how to use them, Germany would stop invasion of Iran and Germany could win World war 2.
Answer: The Invasion of Iran was carried out by British and Commonwealth forces in the south, and Soviet forces in the north. The Shah of Iran was forced to abdicate, and the new Iranian government under his son was obliged to adopt a pro-Allied stance. For the remainder of the war, Iran was occupied by Soviets in the north and British forces in the south. The occupation continued until 1946.
Why Was Iran Occupied?
It is naive to claim that Iran had nothing to do with "their war". Iran was of great strategic importance to the Allied war effort; the Allies would not tolerate a pro-German Iran.
Iran however, have a history of business with Germany, and when WW2 began, the Iranian government sought to pursue a policy of neutrality. Unfortunately, that failed to reassure the Allies. Therefore between July and August 1941, Britain issued two ultimatums demanding Germans be expelled from Iran. The Iranians refused, and the Allied invasion began on 25 August.
The main motivations of the Allies were:

Securing a vital supply route into Russia: the Persian Corridor enabled massive movements of supplies through to both the Soviet Union as well as Middle Eastern British forces. Some 30% of Lend-Lease shipments to the Soviets were made through this route.
Safeguarding Iranian oil supplies: the British Anglo-Iranian Oil Company refinery in Iran was a significant part of the Allied war effort; conversely, it was crucial to deny oil to the German army.

Why Didn't Hitler Try to Stop it?
I'm not really sure what you expect Hitler to do. Axis forces were separated from Iran by Turkey, the Soviet Union, and British controlled Iraq. In contrast, the Allies had sizeable forces already deployed around Iran. Unfortunately, Nazi Germany had no success in developing a mass teleportation device.
Even if Hitler tried to do anything, there is nothing he could do to materially change the military situation on the ground. So no, it would not have given him "a good chance of winning the war". Even if Iran threw itself behind Nazi Germany, the military balance of power in the region was so tilted against them that it would have been little more than a rerun of what had only just happened to Iraq.
Why Weren't the Allies Questioned in Court?
I'm not sure how you imagined that could possibly happen. Or in what court that could possibly happen.
No court had jurisdiction over the Allies. None of the Allies would have agreed with your claim that it is a "crime", much less allowed Iran to take them to any court over it. And most importantly, as victors of the bloodiest war in human history, the Allies of 1945 could hardly be compelled otherwise. Even the International Court of Justice would have required their consent to have jurisdiction.
In any case, the international law prescript against the use of force in international conflicts was a development since 1945. And even now great powers still discard them at will, as evidenced by recent news. It isn't as though there actually is an international police who would come around and take you to trial.
Comment: The comment section is not a discussion board. For discussion please use the official History chat room, The Time Machine, found here: http://chat.stackexchange.com/rooms/1560/the-time-machine
Comment: The allies also could not tolerate a neutral iceland  :)    It was a world war.. . everyone was fighting for survival....
Answer: The allied forces , Britain , Russia specially and France had always a bad record in Iran and that has nothing to do with GERMANY. Iran had always good relations with Germany much before Hitler, Check for Wassmus of Persian in google. Iran did not have any sympathy for Nazi racism. They cared about protecting their jews which was the largest in Middle East then. Iran told Hitler that Iranian jews were assimilated Iranian of Aryan descendents and that he can't touch them. Iran gained a special status for it jewish population. Meanwhile Reza shah after cyrus the great is very popular among jews, because jewish organisations and rights improved under him and his son. His secular policy intended to include and unify all Iranians of any tribe or religion or ethnicity together. Reza Shah benefited from German engineers who unlike Brits were not involved in looting Iran and its resources. German engineers did a good assistance.  Brits and Russians did not respect Iran's neutrality just because Brits wanted to secure Abad oil field through BP, then called Anglo Iranian company. Reza shah did not like Brits dirty politics of dividing Iran and its Darcy oil contract under Qajar. Russia was always wishing to occupy and separate lands from Iran. It was peter great wish to put his boots in warm waters (Persian Gulf).
Comment: This answer would benefit from sources and paragraphing.

Occupation of Iran in World War 2


Is there any particular reason why Faraday's and Ampère's laws are valid?

Question: I know that the Maxwell equations are usually the explanation for all electromagnetic phenomena, but I would like to know why those are valid, if there is any reason for them.
Answer: Maxwell's equations can be derived from the following considerations:

The theory must respect the principle of relativity (no inertial frame is distinguished from another).
It is a theory involving continuous entities called fields, with matter-like entities called charges, and it is as simple as possible.
The charge property is invariant between inertial frames.
The theory involves a force which does not change the rest mass of the things on which the force acts.

Within these constraints there is little room for manoeuvre left, and Maxwell's equations are pretty much the simplest possibility you can find.
We respect (1) by using 4-vector and tensor notation throughout.
We respect (2) by not introducing things like non-linearity, and preferring tensors of low rank.
We respect (3) be asserting it.
We respect (4) by using an antisymmetric tensor for the field tensor, and making the force from the product of this with a 4-current.
Another way to proceed is to use a Lagrangian method, and again Maxwell's equations are pretty much the simplest field equations that respect items 1-4. (I say "pretty much" because there is not always a completely clear way to determine which theory is simpler than another.)
I assume from the question that you may not be familiar with tensor methods, but I hope the above nevertheless gives some flavour of the ideas. But no theory in physics can be derived in full, like a proof; rather we look for elegant and coherent sets of ideas, and then use empirical observations to discover whether the ideas describe the physical world correctly.
Comment: Why on Earth did this get downvoted? Andrew quite correctly points out that when you require the equations to be Lorentz covariant Maxwell's equations pretty much fall into place.
Comment: Did not downvote, but this answer gives more motivation than justification. Aaron Stevens is the more appropriate answer. I like that both are here!
Answer: They have been experimentally validated. Therefore, we take them to be true until an experiment invalidates them.
Measuring magnetic fields around wires, the validation of the behavior of inductors in circuits, and the successful description of EM waves are just a few experimental validations.
Comment: Of course, I'm not saying they are invalid, but maybe there is a deeper reason for their validity. Like we also dont just say things fall down, but we use gravity to explain them falling down.


Can I cast Mizzium Mortars for its alternate cost with Fires of Invention?

Question: Can I cast Mizzium Mortars for its alternate cost with Fires of Invention?
Comment: Have you read the Gatherer rulings on Mizzium Mortars?
Answer: The Gatherer page for Fires of Invention says (emphasis mine):

You may choose to pay the mana cost or an alternative cost for spells you cast, even if their converted mana cost is less than or equal to the number of lands you control.

as well as

If you cast a card "without paying its mana cost," you can't choose to cast it for any alternative costs. You can, however, pay additional costs. If the card has any mandatory additional costs (such as that of Fling), you must pay those to cast the card.

So yes, you can cast an overloaded Mortars, but the Fires will not help you to pay for it.
Answer: Both "without paying mana cost" and "Overload" are alternative costs, and when you cast a spell, you can only choose 1 alternative cost to use. So you can either cast Mizzium Mortars for free, or you can cast it by paying its Overload cost and getting the Overload benefit. But you can't do both.

118.9. Some spells have alternative costs. An alternative cost is a cost listed in a spell's text, or applied to it from another effect, that its controller may pay rather than paying the spell's mana cost. Alternative costs are usually phrased, "You may [action] rather than pay [this object's] mana cost," or "You may cast [this object] without paying its mana cost." Note that some alternative costs are listed in keywords; see rule 702.

702.95. Overload

702.95a Overload is a keyword that represents two static abilities that function while the spell with overload is on the stack. Overload [cost] means "You may choose to pay [cost] rather than pay this spell's mana cost" and "If you chose to pay this spell's overload cost, change its text by replacing all instances of the word 'target' with the word 'each.'" Casting a spell using its overload ability follows the rules for paying alternative costs in rules 601.2b and 601.2f–h.

118.9a Only one alternative cost can be applied to any one spell as it's being cast. The controller of the spell announces their intentions to pay that cost as described in rule 601.2b.


Computer does not boot from DVD

Question: I'm new to Ubuntu.
My OS is XP service pack 3.
I downloaded Ubuntu 12.04.3 32bit ISO file.
I burnt it to a DVD.
I put the DVD in my DVD drive and rebooted the computer.
The install routine does not start and the computer boots to my XP desktop.
I assumed the installer would automatically start.
Do I need to go into the BIOS and tell computer to boot from the DVD with the ISO file?
Answer: Yes,you have to go into the bios,and change the boot order first priority to DVD drive.You can enter into the bios by pressing F2 on startup.This key varies according to your device manufacturer's.

Computer does not boot from DVD


Would a plant need light if the chemicals gained by photosynthesis were given through the roots or as a foliar spray?

Question: If you took the chemicals a plant gains through photosynthesis and put it through the plants' roots or by injection, or used as a foliar application for intake through the stomata, would the plant need light? If not, how would it respond to the treatment?
Comment: Are you suggesting that someone would artificially supply a plant with sugar, proteins, lipids, etc. via the roots?  Isn't that sort of like putting a plant on a feeding tube?
Comment: Yes. Would it work?
Comment: This approach can be used to culture mycorrhizae http://www.jstor.org/stable/3760183
Comment: There are a couple autotrophic plants that parasitize other plants that kind of do this already. But you probably couldn't do it to any plant. But you could do it to some
Answer: Not exactly the same thing, but a species of algae has been genetically altered to allow it to  uptake glucose, bypassing the need for photosynthesis: http://www.unisci.com/stories/20012/0615013.htm
Answer: I doubt this would work for the vast majority of plants.  I think it would cause root rot as the microorganisms in the soil would out-compete the plant.  Also the transport systems of the plant might not be efficient in this direction.
I mean might there be a plant somewhere where this might work?  Sure.  Fungi that grow in the dark would be a lot like such plants, so its biologically possible.  There might be a primitive plant that doesn't need its chloroplast to be active to live.  I've never heard of one and wikipedia is not helping here...
Comment: http://en.wikipedia.org/wiki/Monotropa_uniflora


Preventing form resubmission on contact form plugin

Question: I've built a "get a quote" plugin for a client; basically a contact form with some extra fields and and some math.
This form is embedded in a landing page and upon submitting it is replaced with a graphic that says "Thank you, we'll be in touch with a quote soon".
For that I use the following structure:

  <?php if( !isset( $submission_message ) || $submission_message == '' ): ?>
    <?php include('form.php'); ?>
  <?php endif; ?>
  <?php if( isset( $submission_message ) || $submission_message != '' ): ?>

Thank You!

<?php echo $submission_message; ?>

  <?php endif; ?>

I assumed that bringing in the contact form via the include statement would turn off the form-resubmission issue, but it didn't.
I did some research and found out that I'd have to implement a post/redirect/get pattern, but I would like to avoid a full redirect, i.e. avoid sending the user to a completely different page. Instead I want to hide the form and display the "thank you"-message instead.
I've seen this implemented on other websites, but have no idea how to continue here.
Answer: You can setup a wp_nonce_field to act as a single use token. You can then wp_verify_nonce to make sure the action requested matches the token.
A more ideal way is to just use an AJAX solution and submit + respond using javascript. That will allow you to stay on the page and show/hide elements required without needing the server to re-render the page.


U.K. Travel valid visa

Question: I have a valid UK c visa with multiple entries valid from 26/05/2009 and till 26/05/2019. I have travelled to UK on business three times and stayed for a total of 15 days till now. I plan to visit UK for a short trip from 12/05/2019 till 17/05/2019. Can I use my existing visa for tourism?
Answer: Yes. It is equivalent to a Standard Visitor visa, which replaced the various separate visit types several years ago. https://www.gov.uk/standard-visitor-visa
Bring the same documents with you that you'd need to apply for a visa, to show to officers at the UK border, if asked. https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/549692/Visitor_Supporting_Documents_Guide_-_English_version.pdf

U.K. Travel valid visa


Select bootstrap capacitor value too high

Question: What happen if we choose bootstrap capacitor value too high in high side gate driver applications? Can it be harmful for MOSFET/IGBT or it is just not important?
Comment: Startup behavior would be of primary concern.
Answer: The only drawbacks which came into my mind:

it takes longer to charge it up after startup
You need a capacitor with low ESR if you need to utilize the whole voltage for the switch drive. The ESR will have a voltage drop in it during charging up the high-side gate, plus it slows down the process. You need a cap where it will not be the bottleneck in your design.
a large cap has lower self resonance frequency. You want that your capacitor behaves as a capacitor at the switching frequency and its first few harmonics.
more expensive

Increasing the bootstrap cap well beyond the gate cap - it might be better to think in sum of charges, but saying cap is easier - will not give you much. As long as the voltage after the charge sharing process is close enough to the supply you will gain nothing from a bigger cap.
Comment: @Ata likely what's happening is since the bootstrap capacitor is taking a while to charge, in the beginning the IGBT may be partially turning on (operating in the linear region) and this is not good. This will generate large losses across the IGBT and cause it to fail.
Comment: Thanks for your reply. In my BLDC application, VBus=420V and carrier frequency is 16KHz. I chose 220uF/25V bootstrap capacitor for high side gate driving. Usually driver and motor work fine. But sometimes when i power on, before rotating motor, one of the IGBT legs fails and damages. Is it possible that it is because of high value of bootstrap capacitor?


If you switch an interface's vlan does it stop traffic?

Question: I'm configuring a cisco catalyst switch and I want to change the vlan for the all of the ports on the switch away from the default vlan 1. I know how to change a vlan on an interface, I want to know if the traffic will be stopped when I do the switch and if this is something I am able to do while the switch is live.
Answer: The answer is Yes and No. You can make the changes, BUT hosts and devices won't be able to communicate with each other until and unless the ports they're connected to are members of the same VLAN. So if hosts 1 and 2 are connected to ports 1 and 2 in VLAN 1 and you make port 1 a member of VLAN 2 then hosts 1 and 2 won't be able to communicate until you make port 2 a member of VLAN 2.
Comment: And if you're making the same change to all ports, you could use an "interface range" command to make the change on all ports in a single command, to minimize the downtime any clients would see.


Method of using previous scenes in ending credit

Question: This is the ending credit for the game Final Fantasy 7 Remake. The ending credit uses clips from the cutscenes in the game. I've seen this kind of method of using part of the flim in the ending credit in other movies too. Is there a name for this method?
Comment: Whilst this question could related to TV shows and movies, your example of a game is off-topic (I assume). Do you have an example of one of the former you can update your question with?
Comment: Not everything has a name, it is what it is: adding scenes from the movie to the credits to make it less dull. Many times I see it taken a step further, they put scenes that were cut from the movie, i.e. the viewer will get to see "new" scenes if they'll watch all the credits. There're no set rules for this, or even a "norm" that's really up to each movie provider and the people behind it.
Comment: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Answer: Sounds like a montage in the end credits.
TV Tropes calls this a Credits Montage:

Credits Montage
The credits are rolling! Wasn't that a great show? Let's all reflect
on the great moments we just watched... ah, here they come now, and
they brought a stirring, victorious musical track, too!
In short; the credit sequences of TV shows, movies or video games
include a montage of stills or clips from earlier in the show.


adelic quadratic forms

Question: The classification of quadratic forms over local and global fields is well understood.  But what about quadratic forms over adele rings?  Let G = GL(n,A), where A is the adele ring of a global field F.  Let S be the set of symmetric matrices in G.  Let G act on S by g * s = g s (transpose g).  What are the orbits?  Even for n = 1 and F = Q, not every orbit contains a rational point.
Comment: Dear Jeff, got your reply to my email. The best bet is for you to post your own answer, perhaps with nothing more than the references you found, as I missed the point of your query. That way, your new answer pushes this thread to the front of the "Active" sort.
Answer: EDIT: I have never seen this one, but it is said to cover some of the same ground as Kneser (1961): A. Weil, Sur la theorie des formes quadratiques (1962).
ORIGINAL: I did not notice this earlier...for what it may be worth, the introduction of adeles into the consideration of quadratic forms may well originate with Martin Kneser, Darstellungsmasse indefiniter quadratische Formen, Math. Z. volume 77 (1961) pp 188-194. Also MR0140487.
Similar in spirit, Rainer Schulze-Pillot,  Darstellungsmasse von Spinorgeschlectern tern$\ddot{a}$rer quadratische Fromen, J. Reine Angew. Math. vol. 352 (1984), pp 114-132. Also MR758697.
Comment: As far as I can tell, these references discuss quadratic forms defined over global fields.  Adelic techniques are used to study them.  I am interested in quadratic forms defined over adele rings.  What are the equivalence classes?  For GL(1), we are talking about the idele class group mod squares of ideles.  This is a nontrivial quotient.
Comment: You do have a point...

adelic quadratic forms


how to achieve slerp in the graph editor

Question: i have keyframed an objects rotation, im using quaternion rotation mode cuz i wanna avoid gimbal lock, however a new issue arises.
i need there to be proper linear interpolation between these keyframes, selecting linear interpolation mode wont do the trick if im using quaternion rotations.
i figured there must be some code involved, im not very good at coding, but is there a function somewhere in the API that would make this possible, or am i down the wrong path?
Answer: For emphasis that you can control the individual rotation components, I keyframed both w and x of the quaternion rotations and gave them different interpolations. For completeness, I also included easing for the x rotation. Since I keyframed two components, there are two fcurves in obj.animation_data.action.fcurves. The 0th index belongs to w and the 1st to x. The keyframe points are extracted from an fcurve using fcurve.keyframe_points. For interpolating/easing between two keyframes, you only need to set the interpolation/easing for the first of those two keyframes, which is why I only use pts[0] and not both pts[0] and pts[1].
import bpy

# keyframe the object
obj = bpy.context.object
bpy.context.object.rotation_quaternion.w = 0
bpy.context.object.rotation_quaternion.x = 0
obj.keyframe_insert("rotation_quaternion", frame = 1)
bpy.context.object.rotation_quaternion.w = 1
bpy.context.object.rotation_quaternion.x = 1
obj.keyframe_insert("rotation_quaternion", frame = 100)

# get the interpolation curves
fcurves = obj.animation_data.action.fcurves

# get the keyframe points of w
fcurve = fcurves[0]
pts = fcurve.keyframe_points

# interpolation = 'CONSTANT', 'LINEAR', 'BEZIER', 'SINE', 'QUAD', 'CUBIC', 'QUART', 'QUINT', 'EXPO', 'CIRC', 'BACK', 'BOUNCE', 'ELASTIC'
# easing = 'AUTO', 'EASE_IN', 'EASE_OUT', 'EASE_IN_OUT'

# set interpolation of w
pts[0].interpolation = 'LINEAR'

# set interpolation/easing of x
fcurve = fcurves[1]
pts = fcurve.keyframe_points
pts[0].interpolation = 'SINE'
pts[0].easing = 'EASE_IN'

If you don't care about the individual component keyframes, you can also just select the only the object in question, go into the fcurves editor, and set interpolation/easing for all the object's keyframes using
bpy.context.area.ui_type = "FCURVES"
bpy.ops.graph.interpolation_type(type = "BEZIER")
bpy.ops.graph.easing_type(type = "EASE_IN_OUT")
bpy.context.area.ui_type = "TEXT_EDITOR"


Would formatting my iMac fix my failing drive?

Question: I have been dealing with this problem for few months, I was using bootcamp on my iMac late 2013, and after a while its driver corrupted using too much disk space and slowing down. So I deleted it and created a new bootcamp partition but my problems didn't end there. Every time I shut down my computer its windows files would corrupt again making me redownload windows. And few days ago this corruption affected my main iMac drive too. I can repair the disk through disk utility because its giving me exit code 8, my internet recovery mode is giving me code -2002f and its startup is extremely slow ( only the part where you enter your password and log in) everything else is fine. Startup problem is the same problem i had with the bootcamp. I was getting black screens during startups. I wasn't able to delete my bootcamp partition until today because the disk utility didn't let me to do it. I deleted it through terminal and now I am dealing with my main drive corruption. I plan to sell this iMac very soon due to educational fees and I want to fix this before I sell it. I am currently trying to log into single user mode but its keep failing to mount disk0s2 and there is a small white circle with a cross on the screen. How can I fix this? Would formatting my iMac solve all my driver problems?
Answer: The 2013 iMac was offered with 1TB hard drive, Fusion drive, or SSD. The first two of these use mechanical spinning platter hard drives, which are expected to have a limited life before failing.
After six years, it's likely that the drive is failing, and so Erasing or repartitioning it won't help. Replacing the drive is possible, but "moderately difficult".
Comment: so should i just throw away my computer? I am erasing it right now and I really need some money for educational fees.
Comment: also i bought it in 2015 its been 3-4 years shouldn't that be early? I was able to log into internet recovery via my phones internet and now im deleting the main disk0s2, I hope this goes well before i sell it
Comment: You can certainly try erasing it and reinstalling the OS: however, something must have caused whatever 'corruption' occurred on both Windows and Mac partitions, which suggests a hardware problem.
Comment: you can always take it to an Apple Store or an Apple Authorized repair shop and get the drive replaced.


Why do all empires gang up on the player in Birth of the Federation?

Question: Why do all empires gang up on the player in Birth of the Federation?  Is there any action I'm doing to garner their wrath?  Is there any way this can be avoided?
Comment: @Xantec *Winning?*
Comment: what fun would it be if the computer didn't gang up on the player?
Comment: I think he meant this kind of fun http://df.magmawiki.com/index.php/DF2010:Losing
Answer: You can bend over backwards and keep ONE of them friendly, sometimes. But no, they'll attack you pretty quickly on most difficulty levels.
What I usually try to do is hunker in a corner, building up. Sometimes they'll give you enough space to get competitive. One time I did that though,  and eventually emerged to find out that the Borg had taken over the entire Galaxy =P. They must have spawned right near me, and just expanded in the other direction.
Comment: @ivo: Well, I was talking about giving them money and tech, but if bending over forwards works, run with it.
Comment: I'm not sure if that joke is really appropriate


What can I do with all this copper?

Question: In Terraria I've managed to equip myself in Silver Armor and all tools are silver or gold.  I also have a large stockpile of copper and iron bars.  I know I can use some ores for potions, but is there anything useful I can do with the bars besides sell them?  If I sell them, would it be better to craft them into items first?
Comment: Sell it, really there is no use for copper if you reach a certain part. For example Hardmode, I see copper, i think of it as dirt.
Answer: You can use copper to make watches and depth meters. Those stay relevant...until you make a GPS.
I'd say keep 25 bars on-hand, just in case (ease of mind etc etc etc), and sell the rest.
Comment: Watches are good for timers, which are good for triggering traps you setup for killing monsters/bosses.
Answer: A few items and accessories require copper ore and/or iron, but for the most part, copper is of dubious value. (Though usually so plentiful that anything you sell can be easily reacquired, if need be).
Copper ore is the most profitable item (as opposed to making something with it), as are all other ores except for Meteorite Ore (which should be sold as meteorite bars).
So sell with no regrets!
Answer: Crafting the summoning items for hardmode bosses requires 5 copper and 5 iron bars. The other ingredients may be farmed, but the metals cannot. Unless you are absolutely certain you don't want to fight hardmode bosses and reap the substantial rewards, you should hang on to your copper and iron.
Comment: @RavenDreamer or you could just put your copper in a chest. It's not like there's anything to lose by doing so.
Comment: Hell, make a trash bin out of iron if you hate low metals so much and put the copper in it, still going to be faster than scrounging a new world for copper.
Comment: Packrat ALL the things!
Comment: You can always plunder another world if need be.
Comment: @RavenDreamer if those things give you access to the sort of content you'd usually have to pay a fiver for, packrat the hell out of them.
Answer: In addition to what everyone else has said, you can also make two decorative items with copper, which for someone like me, means I need a lot of copper.
You can make copper chandeliers which are fairly cheap, but the biggest expense on my copper is making copper bricks. 1 ore per brick means that I'm farming up a whole lot of copper.
Answer: Hang on to all of the copper all the way through the game. IT can be used for bricks and Chandeliers, which are both nice looking blocks when creating a detailed build. If you're not interested in building, keep the copper until you have killed the Mech bosses and have a watch or gps, after that you won't need it.
Answer: Sell most of it. Once you get gold or molten armour sell all of it.
Comment: As mentioned in the other answers, there are uses for copper other than armor, most important of which are the summoning items, the 5 second timer, the depth meter, as well as the flamethrower

What can I do with all this copper?


Calibrating Gamecube C-stick

Question: I have gone through the default windows calibration menu like a gazillion times and everything works fine, except my c stick. It is always recognized as slightly to the left and any small movement is recognized as pushing the stick further than possible
Comment: If it's a real GameCube controller it should be self-calibrating. Make sure its centred when you plug it in. You can also recalibrate it by rotating the C-stick at full extension in a circle. Your problem may be with your adapter or driver.
Comment: Are you using your controller in Dolphin?
Answer: On a real GameCube, you could cause the various analog inputs to recalibrate by holding down X, Y and Start for 3 seconds. If the problem you're having is only within Dolphin, this should clear it up.

Calibrating Gamecube C-stick


How can i stop DC motor when button on remote is released?

Question: I am trying to control a motor using a remote with Arduino Mega. The motor turns on when I press the button on the remote but when I release the button, it continues to move. Does anyone know how to stop the motor spinning when I release the button on the remote?
Comment: IR remote? Those generally don't have the concept of button release.
Comment: do you actually have code to turn the motor off?   .... a lot of people assume that if the motor turns on when a button is pressed, that it will magically turn off when the button is released
Comment: share you sketch here.
Comment: You won't get answer more precise than Majenko's, until you share the code in question. Though it is a good answer.
Answer: For an infra-red remote control you generally can't. Those don't normally have the concept of button release.
Normally there are two kinds of buttons on a remote:

Burst code
Repeat code

The first sends a short burst of the same code. This allows for a function to be run once per button press.  The second sends the same code over and over again constantly until you release it.
For the repeat code buttons you can use that to your advantage.  You program your Arduino to run the motor for a short period. That period needs to be slightly longer than the time between each code reception. Then it can appear that it's responding to the release of the button.
For example, if your remote sends codes 5 times per second then whenever you receive a code you start the motor. If you haven't received a code for more than say 300ms then stop the motor.


Alternatives to neural networks for function approximation in Q learning?

Question: I want to know if there is anything other than neural networks (or Deep NNs) that I can effectively use to perform function approximation? I am asking this w.r.t to the use of approximators in Q learning with large state space.
Comment: Any parameterisable function does the trick.
Comment: @DavidIreland Any examples?
Actually, I am going to post my scenario specific question after 20 min (as I have to wait before posting another). I will give the link here. I request you to please also take a look on that, if possible. I have been asking small small questions and still stuck. So I decided to ask my scenario specific question finally.
Comment: @DavidIreland This is the link I said in the above comment. https://ai.stackexchange.com/questions/32472/scenario-specific-question-w-r-t-q-learning-and-deep-q-networks
Comment: It's a good idea to do a little bit of research before asking a question. Please, take a look at [How do I ask a good question?](https://ai.stackexchange.com/help/how-to-ask).
Comment: it looks like you're using a graph as the state, in which case I'd recommend looking at graph neural networks.
Answer: Any series approximation technique will regress on training data. Taylor Series approximation is a popular technique.
https://en.wikipedia.org/wiki/Taylor_series
Fourier series is also important in DSP and computing analog signals but  can be used to approximate functions where a higher term count yields more accuracy.
https://en.wikipedia.org/wiki/Fourier_series#:~:text=A%20Fourier%20series%20(%2F%CB%88f,be%20determined%20using%20harmonic%20analysis.
you can pick any degree of a polynomial and start regressing on data points for the coefficients but these term approximations show the calculus of choosing the degree of the approximator with respect to accuracy and other considerations such as if the data is even able to be modeled by a function (vertical line test) or if it needs to be transformed/mapped first.
To my understanding, Neural Networks have powerful generalization ability meaning they do well at modelling the function over a larger domain (including outside the trainning dataset as seen in cross-validation). To learn more on this I would suggest reading on the difference between neural networks and linear approximators.
I say this since any black box optimizer such as neural networks are equivalent to function approximators. Deep Learning is a subset of the study of function approximation but choosing what approximator is needed needs to be researched for each application.
Comment: One note of caution on the last paragraph: Deep Learning involves much more than function approximation. Topics like scalable system design, deployment, computational complexity and more don't fall cleanly into a "function approximator" perspective. This isn't a pedantic critique but a warning to anyone that might take that too seriously and then make reductive claims about the "nature of deep learning being nothing but function approximation."


Optimal design for a Database with recurring event

Question: I want to create a php calender application. What is the optimal database design for this software if I want to create normal, weekly, monthly and yearly events.
Comment: The optimal design is the one that perfectly meets your requirements and is as normalised as possible. What have you tried so far? What are your current thoughts? (We're not here to do all your work for you.)
Answer: I would just create an entry for each recurrence of the event, out to some horizon.  However, it means that you'll need another table that you can use to project out the dates if they scan past your horizon date.  I.e., you'll need an events table that contains one record for each occurrence of a repeated event (Jan 1, Jan 8, Jan 15, ... through December), and a table with each record available to seed future years (start date: Jan 1; repeat: 7; through: 2011) so that at the start of 2012 (or as soon as the user requests a view of a 2012+ month) you can generate the future events.
This has two big disadvantages:

Your database has data for a full year.  However, if adding a full year's worth of data ruins your performance, your system is probably underpowered.  (It seems a requirement that a calendar app be able to handle many years' worth of dates)
At the end of the event horizon, you need to generate the future dates for recurring events.

The advantages (IMO) that outweigh the disadvantages:

Easier math when displaying the calendar.  Using Tim's method, above, if the user loads Dec 18, 2011, how are you going to calculate which recurring events should be placed on that day?  You'll be forced to loop through EVERY recurring event every time you display a date.  The tradeoff is disadvantage #1, which I think is the better solution that having to redo these calculations.
You can edit specific instances of an event.  Using Tim's method, if a meeting occurred on a holiday and the user changed it to the previous day, how would you even do it?  Using the one-entry-per-event method described here, you could just modify that record for the event, easily moving single occurrences around in the calendar.
Answer: You could have a column in the EVENT table for RECURRENCE_STATUS which tracks 4 values, does not recur, weekly, monthly, yearly. The query of the day's events would be a union of those that are set to occur on that day and which do not recur with the set of those that do recur and whose initial date's difference from today is a modulo 0 for week, month, and a year differences.  The date-math calculations are a little more nuanced than that (because of the varying number of days in the month) but the structure should suffice.