Chirping in Kitchen - Always one minute apart

Question: So we've been getting this weird chirping noise in the kitchen. It's always just one chirp, and always a minute apart between chirps when I decided to time it. It first started yesterday in the morning, and then stopped later during the day, and today has started again, continuing on.
We don't have a smoke alarm in the kitchen, I've tried turning off the boiler and fridge, but the chirping carries on, and when I listen to where it's coming from, the sound seems to move.
Any help?
Comment: If you turn off all the circuit breakers does the chirping continue?
Comment: A bit more information: It always seems to start in the early morning, chirp for a few hours, then stop for the rest of the day. I just got back from work, and it started chirping at 6 in the morning.
Comment: Could it be a critter of some kind?  Do you have cicadas or crickets where you are?
Answer: Even though you do not have a smoke alarm in the kitchen I would suggest that you check for low battery condition in all of your smoke alarms in the home. If you have not done so in more than a year the general advice is to replace all the smoke alarm batteries with fresh new ones.
I had the chirp problem at my house and can attest to the fact that it can be difficult to locate the source of the chirp. I believe that the problem is that the chirp sound is one that easily bounces and echos around the house. In addition I have found that the sound duration is so short that our brain has difficulty performing the triangulation that it normally uses to find the source of sounds.
Comment: One would also hope that a "friend" has not installed an annoy-a-tron device for the sole purpose of driving you crazy!
Comment: Replace batteries *annually*? That seems rather excessive unless you are using cheapie batteries. A duracell should be good for at least 3-5 and a an energizer "lithium" for 10.   I have one chirping, I haven't changed it because  a ceiling was later retrofit.  It's behind the ceiling, they buried it.  The ceiling went in 15 years ago.
Comment: @Harper - Newer smoke detectors are designed with built-in ("10 year" but YMMV) batteries. But in my area at least, the advice was "change your clocks, change your smoke detector batteries" - i.e., **twice** a year. Most don't bother until they hear the chirp, which is one reason for the new built-in long-life batteries (the other reasons get into profit margins...). The detectors from years ago were designed with older alkaline batteries in mind, not the newer lithium and others, so longer life now is reasonable with good batteries. But a couple $ on batteries is very cheap insurance.
Comment: don't smoke detectors chirp every 35 seconds instead of every min?
Comment: The 5 to 10 year "life" of batteries is for when they are sitting in a drawer NOT connected to anything. Smoke alarms are powering up a small heated chamber, constantly draining a small amount of power from the batteries at all times. Once a year is the MINIMUM change-out time, twice per year (i.e. with the time changes as suggested) is the safest bet.
Comment: +1 on the difficulty of locating the source. There is something about the frequencies they use on the smoke detector chirps. I have been fooled by the echos of those things, swearing the sounds were coming from rooms or areas where there were no detectors. My theory is that rooms with carpet and furniture absorb the sound more, kitchens are almost all hard surfaces that make the sound bounce around more.


Football coaching

Question: I want to be football coach you know like football manager I want to know what should be my first step. well I don't play football in school or college and I am not that good but I like tactics and all
Answer: Being a coach doesn't require to be a good player at all.
The requirements to become a football coach vary, but a bachelor's degree in sport coaching education, physical education, or exercise and sports science is often required.
If you want to become a Pro Coach, then you will need to make bachelor's degree, more than likely. If you are in high school or college, my suggestion would be to "hunt" for a coach's assistant's place for the start, this would not require any degree.
but you would need skills like:

Understanding of the game
Being a good leader
Being very detail-oriented
Being an excellent communicator
Having physical stamina
Comment: Thanks for your help so I am thinking about to join local football club for some practice and understanding the game

Football coaching


Issues loading page with CocoaHTTPServer using a WiFi module

Question: I have a RN-171 WiFLy module (I'm very new to working with hardware, btw) and I need it to talk to an iPhone over WiFi.
To achieve that, I've chosen to host a web server on the iPhone using CocoaHTTPServer, set the RN-171 in Adhoc mode, join the network via the iPhone and then send requests to the iPhone server via the device.
The module works correctly when I try to load a page on my Mac (running on Apache). The device prints out *OPEN*, shows the returned HTML and then prints out *CLOSE*.
With the iPhone application, however, it simply hangs at *OPEN* for a while until it times out and then shows *CLOSE*. I've put a breakpoint in the application and can indeed see that it is hitting the iPhone server but for some reason the server is responding correctly.
I couldn't figure out the issue by stepping through the application but I'm guessing that the request isn't being closed or something.
<code>set dns name www.rovingnetworks.com
set ip host 0
set ip remote 80
set ip proto 18
set com remote GET$/server.php?value=
set sys auto 10
set option format 1
set uart mode 2
save
reboot
</code>
The above are the commands I'm entering into the device to try and get it to connect taken from manual. In my case, I'm setting the dns name to the iPhone IP and the remote string to the GET$/index.html?value= however I'm not having any luck.
Any ideas?
Answer: I was using Picocom to talk to the device. I set the options to convert linefeeds and carriage returns to CRLF and it worked correctly.


How to disconnect/disable MMC SD card

Question: I have non USB MMC/SD reader slot .
If a user inserts SD card, I want to be able to disconnect the SD card, or
Disable the reader. (in case I detect malicious card).
How can I do this?
With umount, I unmount it. Problem is it is very quick to return it to work.  I just click on its Icon In Thunar file manager UI. So I need solution that it takes longer to reactivate. Probably disable the reader.
I can see the storage sd card in /dev/mmcblk0p1.
The sd reader in /dev/mmcblk0
Comment: Would it be enough to unmount the partition(s) on the card, or would you want to turn off the power supply for the card and/or the card reader? (I know how to unmount, but I don't know how to turn off the current for the card and/or the card reader. I know also how to remove all information on a card by overwriting it with zeros.)
Comment: Remove information in card you mean to actually delete memory from the card? I dont want to touch memory in the card itself
Comment: I managed to do unmount. Problem is it is very quick to return it to action. I just click on its Icon In Thunar file manager UI. I also want to turn of reader.
Comment: Let us hope that someone who know how to turn off the card reader will see you question and answer.
Answer: You can unmount each partition with a command like this,
sudo umount /dev/mmcblk0pn  # general command, where n = partition number

sudo umount /dev/mmcblk0p1  # specific command (matching the question)

sudo umount /dev/mmcblk0*   # umounting 'everything on the card' at once

You can check that it is no longer mounted with
df

or
lsblk

I do not mean to delete the memory, only delete the data which might be infected  with malicious code from the memory, so that the memory is clean, only contains zero bytes. You can do that safely with mkusb.
After that you can create a fresh partition table and file systems with gparted in graphics mode or with more basic command line tools, fdisk and mkfs, in text mode. If you want a basic FAT32 file system, mkusb can do it directly (in graphic mode as well as in text mode).

You can turn off Thunar's automatic mounting according to the following link

Is Thunar cluttering your Desktop?

How to disconnect/disable MMC SD card


Default web app in tomcat

Question: Its been few days i've been searching for a solution.
My question is..I have to deploy a project in tomcat and make it as a default webapp. What I did is copied my war file and placed it in the tomcat/webapps folder. Started tomcat and changed the port to default. Now I can access my application at http://localhost/myapp .What i want is to see my application at http://localhost. How can I do this?
Comment: http://stackoverflow.com/questions/715506/tomcat-6-how-to-change-the-root-application/6093662#6093662
Comment: http://stackoverflow.com/questions/1363605/tomcat-base-url-redirection
Answer: I was able to do it by adding "Context" element with path="" attribute under Host in server.xml file.
            <Context path="" docBase="/usr/local/tomcat/mywebapps/myapplication">
                <WatchedResource>WEB-INF/web.xml</WatchedResource>
            </Context>

Note: I am using Tomcat 7. Also I had to move my webapp to different location than default webapps folder. I also deleted default webapps provided by tomcat. But this solution works even without deleting them.
Here are contents of my server.xml for reference. Hope this helps.
<?xml version='1.0' encoding='utf-8'?>

<Server port="8005" shutdown="SHUTDOWN">

    <Listener className="org.apache.catalina.core.AprLifecycleListener"
        SSLEngine="on" />

    <Listener className="org.apache.catalina.core.JasperListener" />

    <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
    <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

    <GlobalNamingResources>

        <Resource name="UserDatabase" auth="Container"
            type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved"
            factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
            pathname="conf/tomcat-users.xml" />
    </GlobalNamingResources>

    <Service name="Catalina">

        <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000"
            redirectPort="443" />

        <Connector port="8009" protocol="AJP/1.3" redirectPort="443" />

        <Engine name="Catalina" defaultHost="localhost">

            <Realm className="org.apache.catalina.realm.LockOutRealm">

                <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                    resourceName="UserDatabase" />
            </Realm>

            <Host name="localhost">

                <Valve className="org.apache.catalina.valves.AccessLogValve"
                    directory="logs" prefix="localhost_access_log." suffix=".txt"
                    pattern="%h %l %u %t "%r" %s %b" resolveHosts="false" />

                <Context path="" docBase="/usr/local/tomcat/mywebapps/myapplication">
                    <WatchedResource>WEB-INF/web.xml</WatchedResource>
                </Context>

            </Host>
        </Engine>
    </Service>
</Server>

Comment: wouldn't this approach deploy twice the application under webapps then? from [official Tomcat doc](http://tomcat.apache.org/tomcat-8.0-doc/config/host.html): "When using automatic deployment, the docBase defined by an XML Context file should be outside of the appBase directory. If this is not the case, difficulties may be experienced deploying the web application or the application may be deployed twice."
Answer: Delete the Tomcat/webapps/ROOT folder (if any), rename your WAR file to ROOT.war and restart.
Comment: I did, but I get the apache tomcat home page.
Comment: Then you're modifying or accessing the wrong Tomcat instance. Are you using an IDE or something?
Comment: Yes, I used netbeans IDE to deploy the project.
Comment: You should set context name to empty string or / in the project properties. I can't tell in detail how/where since I don't use Netbeans. Regardless, the answer works when leaving the IDE outside consideration and you do it exactly as mentioned in your question: copy the WAR and place in tomcat/webapps.
Comment: Yes, I did that and I am not using netbeans anymore. I close the netbeans and just the war file is used.
Comment: Then you're modifying or accessing the wrong Tomcat instance. Take a look in the webapps folder where you removed the `ROOT` folder and placed the `ROOT.war`. Did Tomcat expand the WAR upon startup? If not then it's definitely the wrong Tomcat instance which you're modifying and/or starting. If so, then there's probably a conflicting old one in the `Tomcat/work` folder which you should then remove.
Answer: you could rename your webapp to ROOT (the default app for tomcat), or you can use a web server that can handle domain names and redirects (like apache httpserver), and configure your site there.
The first approach is not very elegant, but quick and efficient though.
Answer: create index.html at webapps/ROOT with below.

    <meta http-equiv="refresh" content=0;URL="http://localhost/myapp">

Comment: This will only work for clients that are browsers (i.e. that load and parse HTML). Not for instance if you are using Python `urllib2` or `httplib2` or `requests` libraries).
Comment: As above, this is simply a web page, not a real redirect
Comment: Would you mind adding some information about why you think this is the best solution to the problem? (And not a server-side redirect). I don't think it is an answer, before I vote on it I'd like to hear your reasoning.

Default web app in tomcat


Braintree: test nonces are resulting in Payment Method Nonce is Invalid

Question: I am in the process of using the sandbox to test creating a new recurring billing subscription using a fake nonce but I keep getting an error indicating the
payment nonce is invalid, here is the object I am sending to the gateway.subscription.create method:
<code>{
  paymentMethodNonce: 'fake-valid-nonce',
  planId: 'ip19',
  price: 2.5,
  options: { startImmediately: true }
}
</code>
This is the error I am receiving when I make me call to gateway.subscription.create:
<code>[
  ValidationError {
    attribute: 'payment_method_nonce',
    code: '91925',
    message: 'Payment method nonce is invalid.'
  }
]
</code>
I am using the fake nonces listed in this article, https://developer.paypal.com/braintree/docs/reference/general/testing/node#nonce-fake-valid-nonce
I am passing the sandbox credentials when I make my initial connection but it seems like it is not honoring the fake nonce.
Answer: None of them have ever worked? They should work at least once. Otherwise, if you have a payment method in your vault, do something like braintree.PaymentMethodNonce.create('token').payment_method_nonce.nonce to generate a new nonce for server-side testing.
Answer: Payment method nonces can only be used in certain specific conditions. Fake nonces do not support these specific use cases. You need to use a payment method token to create a subscription or use a generated payment method nonce from the specific client workflows mentioned in the API reference.


Is Sharp Objects series completely based on the book or is it like GOT?

Question: I haven't read the book or seen the series but interested in them. I see from wiki the book is only 250+ pages. From some careful googling I see that story did not end with the season finale that aired recently which was 8th episode in the first season. I wonder if the series is faithful to the book or is it "based on" the book like GOT?
Comment: Define "faithful". There has never been an adaptation that **exactly** matches the book, as far as I know.
Comment: I would recommend changing the question to target major plot differences between book & show. And also remove any reference to GoT as it would make it primarily opinion based. Welcome New contributor
Answer: According to this article from Elite Daily there are few big changes compared to the novel.

No television show is perfectly faithful to the book, though some try.
  Game of Thrones, for example, stayed faithful in their debut season,
  but it was a 10-hour show adapting 800+ pages. Most novels are not as
  long, so to fill the 8-to-10 hour brief, extra scenes are added.
  That's especially the case in adaptations where the novel is told in
  the first person point of view and swaps to a third person POV with a
  camera. The Sharp Objects show vs. the book is a perfect example of
  this. With only 254 pages to work from to fill seven hours, there are
  changes all throughout the series.

The following are the changes made. I have compiled a list based on the article, but the article gives more context to how this changes may affect the work.

Camille works and lives in Chicago instead of St. Louis.
Camille's response at Natalie's funeral is different.
Third person perspective fleshes things out more, including Detective Willis is "nicer" in the novel by spending more time with the character.
The Addition of Calhoun Day.
Ending change: A girl from school turns up stangled, rather than the accidental discovery of the floor in the dollhouse. Camille also has a breakdown, wanting to cut herself again, but Frank interviens, while Amma happily admits to her crimes and her gang of friends willing to help her do it!


Best way to create a responsive prototype?

Question: Are there any platforms or tools to create a responsive prototype?
Answer: Actually most modern wireframing tools offer this option (in different ways).
Figma
Using constraints & "magic numbers" to build responsive layouts in Figma

Figma is great for building with responsive constraints — you can stretch your layouts and see how they will respond to changes in screen size. (If you're new to constraints in Figma, check out this beginner primer here.)

Axure
Adaptive Views - in Axure you basically just create different screens that trigger at certain breakpoints.

Adaptive views are alternate versions of pages designed for specific screen sizes. They allow you to create a page once and then rearrange, resize, and restyle its widgets to fit each screen size you intend to test it on.
  When you view the page in a web browser, the appropriate view for the browser dimensions will be shown automatically.
Answer: Adobe XD has some responsive features now that might help your design along. Here is the intro video from Adobe that will give you some insight: https://www.youtube.com/watch?v=BKvg8_8jv10


PC laptop without vents in the bottom?

Question: Is there a PC laptop without air vents in the bottom, just like the Macbooks? I've always found those lame; How am I supposed to use it on the top of my lap if I must keep the air vents clear? I actually moved to Mac just because of that. But I'd really like to know if there's a PC option. Thanks.
Comment: Please narrow down the options, providing a budget would be a good start. What kind of performance do you expect from this computer? Edit the question with a list of must haves and nice to haves and don't needs.
Answer: Well, the short answer is:
Yes
This list might help:
http://www.ultrabookreview.com/6520-fanless-ultrabooks/
It is a detailed list of laptops that are of a fanless design and would be more in line with what you are asking about.  However, without more details a proper recommendation is hard to give.
Disclaimer: This really isn't a proper answer either, but the question really isn't about hardware recommendations and more a general question that would be easily researched.
Comment: Actually this is (theoretically?) only a subset of all the laptops that the OP has to consider because one can also imagine the vents sitting on the side instead of the bottom.
Comment: There was no mention of side vents, so not included as part of my "answer."  There were a lot of things not mentioned and I'm not even sure that the OP is even looking for something specific, which I also noted.  Its a poor answer, I admit, but it was a poorer question.

PC laptop without vents in the bottom?


Strange behavior for macro parts on umbraco site

Question: Umbraco version: umbraco v 4.0.0 (Assembly version: 1.0.3327.20280)
Asp.Net: .Net framework 2.0
Windows server 2008 with IIs7
Sometimes when viewing a page with a contained macro, the macro part of that page is completely removed, not rendered, no error no nothing only a incomplete page. Loading the same page again, it's rendered correctly. This occurs very rarely.
When investigating more deeply I found out that this is somehow connected to the recycling of the application pool in which umbraco is running in. Setting the application pool to recycle itself every 1 minute I could reproduce the behavior more often than with the default recycling time but still not consistently after every recycling.
I was never able to reproduce the error when adding the umbDebugShowTrace=true, the page always renders correctly when having it set to true.
Has anyone got a clue about what can cause this or have anyone seen this before?
Note. It just not a particular page with a macro the got this behavior, every page on the site that have a macro on it acts like this when the problem occurs.
Answer: I can't replicate your issue - so I suggest you ask this question at our.umbraco.org
There is will get a bit more visibility by the Umbraco core team who may be aware of the issue.
If you have proper steps to reproduce the bug then submit it to the umbraco codeplex site so that it can get fixed.
T


How can you tell that the image in a plane mirror is a virtual image from the following ray diagram

Question: I'm working through some past papers and came across the question below and I've shown my ray diagrams as the red and blue lines. For the next question I would think that the image is virtual because light has not actually from the image. However the mark scheme says that it is because the two light rays don't join up in the plane mirror, but they do join up in my diagram. Is my diagram wrong and if so, why would the two rays of light not joining give the indication that the image is virtual?
Comment: It is just a matter of definition. Look in your script/book/notes, your teacher/prof somewhere defined what a virtual image is. The definition will probably contain "not joining" or "diverge", and you have to use this definition in your answer.
Answer: The actual physical light ray doesn't pass through the image so it is virtual.
Answer: Look for diverging rays which when back produced appear to emanate from a point although the light rays do not actually come from that point.
Another way of deciding is to put a screen where the image is supposed to be.
With a real image you will see the image on the screen but with a virtual image there will be no image visible on the screen.
So looking at your diagram those dashed lines are construction lines to show where the virtual image is located.
The full lines with arrows on them shown the direction in which the light travels.


Alternatives to Bayesian statistics when distributions are unknown

Question: In Bayesian statistics, with my variable is Gaussian distributed and I have a conjugate prior, I can solve the posterior analytically. I can still use MCMC in the case when things are non-Gaussian so long as I nominate a distribution. But what if I don't know what the appropriate distribution is? I am working with financial data which are known to be non-Gaussian (heavier tails and skewed relative to a Normal distribution). To the best of my knowledge, the exact distribution of financial data is still up for debate in academia. What would be an alternative if I don't want to make a strong assumption on how the data is distributed?
Comment: You might want a non-informative prior distribution. One choice might be a normal distribution with a mean that is near a plausible population mean and a huge standard deviation. Or a gamma distribution with very small shape and rate parameters. Then the posterior distribution will depend mainly on your data.
Comment: Following @BruceET's comment, John Kruschke's ["Bayesian Estimation Supersedes the t-test"](https://jkkweb.sitehost.iu.edu/articles/Kruschke2013JEPG.pdf) (BEST) paper used t-distributed priors for that purpose. (As a tangent, Kruschke is a member on here and once answered a question I had about that BEST paper!)
Comment: Thanks for your replies @BruceET and Dave, will have a read of that paper. I suppose I can choose a non-informative prior, but I'd still need to choose a likelihood distribution, which for a regression, it's likely going to be Gaussian?
Comment: Just list every computer program that can generate a probability distribution, give each one a prior of `2^-(number of bits+1)`, calculate the likelihood of the data for each one, then update. Simple!
Comment: @Acccumulation In practice, the assumptions that that prior distribution makes aren't worth having. (It assumes integers are _much_ more likely than reals, for instance, but most things you do stats on involve reals.)
Comment: @Acccumulation Even assuming you could do it in practice, you still have heavy dependence on the choice of computer/programming language. Unfortunately, that issue is not going to go away (I think Hutter around 2016 had a discussion of that).
Answer: If the distribution of the data is unknown, the Bayesian way of handling this uncertainty is to put a prior on it. There exists a huge literature on Bayesian non-parametrics, including the Fundamentals of Nonparametric Bayesian inference by Ghosal and van der Vaart. The default priors in such settings are distributions on distributions, like Dirichlet processes. Check e.g. the webpage Tutorials on Bayesian Nonparametrics, maintained by Peter Orbanz. Here is a list of seminal papers given to our students.
Concerning MCMC, there exist MCMC algorithms that handle Bayesian nonparametrics as well. See e.g. this book by Dey et al. Check also the dirichlet-process tag on this forum.
A milder solution is to use Bayesian model averaging, that is, to list all (!) the plausible families that could fit the data, choose a reference prior on each, and use the posterior mixture for quantities of interest [common to all families].
Comment: Thanks @Xi'an, I have used GPs once before. I suppose I wasn't sure what to do when I can't nicely describe the priors and likelihood distributions.
Comment: @stevew I think you are placing too much emphasis on "correct" distributions; nothing is a correct distribution. There is no such thing as "exact distribution of financial data" (except in a simulation). You choose models based on features of your data that you believe are important to the analysis at hand. You can then evaluate these choices based on simulation or comparison to real world data fit. If you are not sure what features matter I would recommend Bayesian model averaging or non-parametrics as described here
Comment: @bdeonovic thanks for the tip!
Answer: From what you're saying is that you want something Bayesian, but you can't define the likelihood. For such cases there is approximate Bayesian computation (see abc), where in place of likelihood you use some summary statistics.
As a side note, for using proper Bayesian analysis you don't need to know the "exact" distribution. We nearly never do. You need to use some distribution that relatively well approximates the distribution of the data. This is how is it done in most of the statistics. We don't use Gaussian, Poisson, etc distributions because they are the exact distributions of the observed data, but they are good enough approximations for the purpose. Same you do with loss function, you don't use squared error because it has some deep meaning for your data, but because it works well enough.
Comment: @AccidentalStatistician: ABC requires a specific (generative) model as the distribution of the data (or of the summary statistic), hence one "knows" this distribution if not its density function.
Comment: To elaborate, ABC is used when you don't know the distribution of the data, but, given parameter values, you have a way to sample from it.
Comment: @Xi'an Yes, thanks, that was poorly worded. There are rare examples where you have the inverse cumulative distribution function for data generation, but the density function is what is required for MCMC.
Comment: Thanks everyone for your replies. I've never heard of `ABC` but from the description it sounded like it's what I'm after. Will read up on this. Thanks!
Answer: Although the other answers are ok, I think they might be overkill for yours or for many other problems.
Without changing the paradigm, if you know the distribution has heavier tails than Gaussian, you can fit t-distribution with either fixed heaviness of tails or with the heaviness of tails that are estimated from the data possibly with a prior information.
If a distribution is skewed and has heavier tails, you can fit a SHASH distribution which has four parameters parametrizing location, scale, skewness, and kurtosis of the distribution with the normal distribution as its special case.
Comment: I've never heard of SHASH so thanks for introducing it to me.
Answer: I suggest as alternative bootstrap based methods, which can be parametric and not, and works with very few assumptions and very few data (only 5-7 samples suffice); it works on non gaussian distributions and for many measures (eg., mean, etc). One can "rebuild" a distribution by bootstraping the mean, if it makes sense in the given context. The Davison1 is good for introducting the bootstrap in general.
Many papers were published on the volatility smile analysed throught bootstrap based methods [0].

https://scholar.google.com/scholar?q=bootstrap+volatility+smile
Davison, A.C. and Hinkley, D.V., 1997. Bootstrap methods and their application (No. 1). Cambridge university press.
The Non-parametric Bootstrap as a Bayesian Model
Comment: thanks for your reply. Not sure why this answer was voted down but I guess the only downside of this approach is speed. I'm actually using a neural network underneath all these Bayesian stuff so a bootstrapping approach might be too slow for me.
Comment: @stevew, The speed aspect needs to be actually measured. I guess you're using gpus for NN, you can do the same with bootstrap, and it can happen in parallel wiht the NN part (on different streams). If it helped or is informative, you can upvote.
Comment: I see. Thanks again!


Loki's Trickery card rss

Question: Suppose that players A, B, and C are in battle.
Players A and B each play the Loki's Trickery card (If you lose, steal 1 rage from the winning player ).
Player C wins the battle, but he has only 1 rage
What happens now ?
Which player will steal the 1 rage from Player C?
Answer: It depends on who started the pillage.
Starting with the pillaging player, go in turn order. The first player executes their Loki's Trickery effect and steals a rage. The second player now cannot do so.
Source.

Loki's Trickery card rss


Anti-nuclei production in particle accelerators

Question: Related to Why is Anti-deuterium so important in the search for dark matter?. If the detection of anti-helium in the cosmic rays would be a signature of dark matter, is it possible to measure any light anti-nuclei in particle acceleration collisions? What would be the probability of observing these light anti-nuclei?
Comment: Note that the answer to the question you reference states up front that it has nothing to do with dark matter, but instead the balance of matter and anti-matter in the universe. And, yes, anti-protons, the lightest anti-nuclei, are produced in particle accelerator collisions and studied. CERN is even making anti-hydrogen in (small) quantity...
Comment: Deuterium has a small binding energy (2.2 MeV), so it's unlikely to produce it (or anti-it) intact at any appreciable energy.
Comment: Hi Juanjo. Welcome to Phys.SE. I removed your last subquestion, as we prefer one subquestion per post.
Comment: I'm pretty sure that the first production of anti-helium was reported in a *Nature* paper by the STAR collaboration in about 2007 --- I remember where I was when I read it because the print version of the paper had an important figure with a very confusing printing error. I'll try to construct a proper answer later.
Answer: A lot of effort in analysis of LHC data goes into trying to find supersymmetric particles , unsuccessfully at the moment. There are theoretical models for dark matter which assuming supersymmetry is what the WIMPs are about derives a signal of antideuterons  from neutralino interactions, for example:

Antideuterons, ... As explained in Sect. II, they form
  when an antiproton and an antineutron merge together. The two antinucleons must be at rest with respect to each
  other in order for fusion to take place successfully.

....

On the other hand, supersymmetric ̄D's are manufactured at rest with respect to the Galaxy.  In neutralino annihilations, antinucleons are predominantly produced with low energies. This feature is further enhanced by their
  subsequent fusion into antideuterons, hence a fairly flat spectrum for supersymmetric antideuterium nuclei as shown
  in Sect. IV. Below a few GeV/n, secondary antideuterons are quite suppressed with respect to their supersymmetric
  partners. That low–energy suppression is orders of magnitude more effective for antideuterons than for antiprotons.
  This makes cosmic–ray antideuterons a much better probe of s
  upersymmetric dark matter than antiprotons

So one has to first verify that supersymmetry is true, that neutralinos exist, and have enough of them to annihilate into antiprotons and antineutrons so that they can bind into deuterium.
As there is no experimental discovery of supesymmetry in the current accelerators, this whole scheme is highly theoretical for dark matter, and certainly cannot be explored in a particle accelerator setting, unless with very low energy beams in the way antihydrogen is generated at CERN, but this will have no connection with dark matter. (Considering the difficulties of controlling neutral beams antideuterium will be much more difficult as it needs antineutrons).
Edit after further search:
In heavy ion collisions, light nuclei have been created in Alice experiment .

The measurement by ALICE comparing the mass-to-charge ratios in deuterons/antideuterons and in helium-3/antihelium-3 confirms the fundamental symmetry known as CPT in these light nuclei.

This demonstrates the antiparticle production possibility in the quark  gluon plasma, to explain antimatter creation in the early universe, not dark matter, as proposed by  neutralino interactions .
So the answer is, antideuterons and antiheliums have been seen in accelerators, but their observation is related to antimatter production, not dark matter. The proposal for dark matter comes from supersymmetric theories combined with hypothesis dark matter is neutralinos.
Comment: Thanks for the answer, but my question was more going in the direction of what is the reaction (maybe explained with a Feynman diagram) that produces anti-nuclei in an accelerator. In the thread [Why is Anti-deuterium so important in the search for dark matter?](https://physics.stackexchange.com/q/404400/) you explained that it is possible to produce anti-helium but the probability is very low coming from pair production, what about in a collision in an accelerator? What about with anti-deuterium  and heavier nuclei there?
Comment: within the standard model it is very small at the energies accessible to accelerators.  One would need quark gluon plasma energies,  and the combinatorics of getting the correct quarks and correct antiquarks to match up , in principle possible, would depress the probability, though as the strong interaction is involved it will not be simple feynman ( a huge multiplicity of them as gluons are self interacting) diagrams but lattice QCD or some other apprppriate theory. complicated https://arxiv.org/abs/1011.5612


Funny books about etymology in German language

Question: Are there funny German books about the etymology of words, like "Word perfect" by Susie Dent for English etymology, or "have you eaten your grandma" by Gyles Brandreth for English grammar?
Comment: Can you elaborate on the peculiar propreties you are looking for? I'm afraid they are too unknown for a typical German speaker to come up with proposals for counterparts. (I'm sure I never heard or read even the titles.)
Answer: There is "Der Dativ ist dem Genitiv sein Tod" by Sebastian Sick (Kiepenheuer & Witsch). "Funny" is, of course, in the eye of the beholder.
An excellent source, although not structured and rather a loose collection of articles than a book, is "Die Sprache" by Karl Kraus (Suhrkamp).
Answer: Kluge/Seebold, Pfeifer, or Duden's Herkunfts-, Fremdwörter-, Redensarten- and other Wörterbücher are recommended.
There are hundreds of books on "funny" etymology, because everyone can browse and collect tidbits from more serious publications and add their grane of salut.
I am not aware of one using long running prose to integrate etymologies into something of a narrative. Ideally, it would teach etymology by example in its historic context. It would be a detriment if it is exclusively about German, or English for that matter.
Indeed, the exposition of false friends and false cognates is a common pass-time among language learners and etymologists as such, so any dictionary of Dutch will do you good. See bijvoorbild "zum Beispiel", haha, always cracks me up. Actually though, the origins of both bild (German Bild) and Spiel (Dutch spel) are ultimately unknown.


attack signatures

Question: I am learning at school about attack signatures on web applications (basically OWASP), but I do not understand what they really are in this context. Can anybody give me some good references where I can better understand what they are and where they are used? Thanks!
Answer: Attack signatures in the context of network intrusion detection (especially in relation to web applications) are heuristics and data patterns that can be used to identify traffic that constitutes an attack.
For example, the regex pattern union\s+select could be used to (albeit very naively) detect SQL injection attacks. Another pattern might simply be 0x31303235343830303536, which is a value that Havij (a SQL injection tool) uses in its requests.
Signatures don't have to be related to application data. They could also be based upon packet flags, patterns of traffic (e.g. lots of unexpected DNS response packets), bad login attempts, etc.
These signatures combined can form the backbone of an Intrusion Detection System (IDS), which relies upon these patterns and heuristics in order to identify attacks and alert the administrator.
Comment: Thank you very much for the explanation. Can you recommend me some books/articles/websites where I can get more details on this subject and maybe some simple (very simple) implementations? I've already googled this, but couldn't find something concrete. I guess I might have not searched the right thing properly.

attack signatures


Lishem Yichud on Mitzvos

Question: Should Leshem Yichud be said before Mitzvos or not?
Comment: One must be sure not to speak during the action one is doing if he says Leshem Yihud, because one who pauses in the Yihud is like his life stopped BAR MINAN (Zohar that I heard from Rav Mutzafi).
Answer: (Disclaimer: The below is based on a שיעור I heard several months ago on the topic and may be biased but includes some useful information.)
Saying a paragraph preceding doing a מצוה to state one's intent accomplishes one or both of two things:

Ensuring that one has the correct
intent just in case מצוות צריכות
כוונה - mitzvos need [to be carried
out with] intent.

--  According to the Shulchan Aruch
Orach Chayim 60:4 they do:

י"א שאין מצות צריכות כוונה. וי"א שצריכות כוונה לצאת בעשיית אותה מצוה,
וכן הלכה.

Ensuring that one accesses the
desired metaphysical effects of מצוות
known as "כוונות", which are
interdependent across the spectrum of
commandments and cannot fully be
accessed consciously by the average
person because they are so esoteric. (See the text of the לשם ייחוד paragraph that appears in many סידורים.)

When it comes to the former, some have suggested, including the ריטב"א on פסחים ז עמוד ב that the mechanism ensuring and clarifying that we have intent to fulfill מצוות when we do is the recitation of a ברכה before doing them:

וכתב הרי"ט ז"ל וטעם זה שאמרו חז"ל לברך על המצוה עובר לעשייתן כדי שיתקדש תחלה בברכה ויגלה ויודיע שהוא עושה אותה מפני מצות השי"ת

And as far as the second reason goes, many have argued and held in the past that since the paragraph basically expresses the fact that we wish to access the very metaphysical forces that we consider ourselves unable to access, saying it either doesn't work or is more of a תפילה that our מצוות be effective in general and therefore is sufficient to be said once a day. This is the reason that a number of סידורים print it (or something like it) just once at some point toward the beginning of davening. E.g. The בעל התניא had it before ברוך שאמר; the "סידור וילנא" has it before putting on תפילין, etc.
For reasons of superfluity and the risk of casting aspersions on previous righteous generations who did not say it, the Noda' BiY'huda - Yoreh De'a 93 (first edition) proclaims in no unscathing terms that לשם ייחוד should not be recited. He endorses saying a brief formulation before active positive commandments that do not already have a ברכה attached (confirming the ריטב"א's logic above?) to the effect of "I am about to do what God commanded."
Ask your local competent legal and practical authority.
Comment: And of course the Beer Mayim Chaim and Reb Tzadok where both strong advocates as was SHLOM kLUGER ON THE MISNAGED SIDE OF SAYING THE LESHEM YICHUD
Comment: One should mention the highly controversial aspect of speaking of uniting components of God which at first glance lies in the face of traditional judaism as codified by R. Saada Gaon, Chovos Halevavos, Rambam, etc.
Comment: See Chavos Yair (210) who as a bit of a rant about the l'shem yichud.
Answer: It depends on the mitzva, I found that some sidurim brings leshem Yichud for some mitsvot that other sidurim don't. In any case there are places that it is not applicable like Havdala.
Comment: ...and tzedakah. You don't want the poor fellow to drop dead from hunger while you're busy concentrating on the deeper meaning of the mitzvah!
Answer: Al Pi Kabbala one should say Leshem Yihud for every Miswa (More BaEsba 1:1, Kaf HaHaim P. 1:1). However, Harav Dawid Yosef (Shu"t Oserot Yosef vol. 1 ) Paskens that saying Leshem Yihud prior to any Miswa is "MiMidat HaHassidut" (a stringency).
Comment: Do you say Leshem Yihud every time your parents ask you to pass the water?
Comment: If you say Wihi Noam by giving Sedaka (which the Hida says to do) I would assume that by Kivud Av Waem which is also Ben Adam Lahavero (as the Rambam and Hacham Ovadia Shalit"a hold) you should also say Wihi Noam. The only reason I am Mesupak by Kivud Av Waem is because there is a possible Hefsek which would be a problem because of a Hefsek by Leshem Yihud is a big problem according to the Zohar (as Hacham Musafi Shalit"a says).
Comment: Hacham Ovadia writes (Yabia Omer Yoreh Deah 6:29:5) that Miswot Ben Adam Lahavero don't need Kawana and the reason for Leshem Yihud Al Pi HaPshat is to fulfill Kawana in the Miswa but since Kivud Av WaEm is Ben Adam Lahavero it wouldn't necessitate Leshem Yihud.

Lishem Yichud on Mitzvos


Wormholes man made are real?

Question: Can we bend two points of spacetime in a way  we would create a wormhole ?Why havent we tried it yet?How much energy would we need to do it?
Comment: This appears to be a question about hypothetical engineering rather than astronomy/astrophysics
Comment: No, it would require matter with negative mass what was not found yet (and likely is a theoretical contradiction).
Answer: Short answer: We haven't because there is no imaginable way to do it with current technology nor with any vaguely plausible extension of it.
There are two fundamental problems and some technical ones:
Space is stiff. You can measure the stiffness of a material by measuring the energy that it takes to bend it.  Applying that same approach to measuring the "stiffness" of space, you find that it is far, far stiffer than the strongest steel. The energies that must be manipulated to bend space to produce a macroscopic wormhole are colossal. They far exceed what we can produce or might plausibly produce.
Secondly, wormholes are unstable. Very unstable. Even if a wormhole could somehow be created, it would snap shut faster than light could traverse it. There are theoretical ways to stabilize a wormhole, but they require the use of "exotic matter" -- matter with a very high negative mass -- and exotic matter has never been observed and we have no slightest clue how it might be produced. (The only reason that it's even considered is that our current theories don't actually say that exotic matter is impossible.)
Technical issues include the problem that the energies involved in warping space enough to produce a macroscopic wormhole would themselves produce gravitational effect which would probably destroy Earth, so it would likely need to be done in deep space. There is also theoretical work which suggests that either (a) wormholes can produce a quantum feedback that would destroy the universe or (b) wormholes are always a slower route to the other end than moving through empty space.
Note: If we ever develop a good theory of quantum gravity, this may all change. But today that's speculation piled on speculation.
Comment: Be careful before we go too far down the rabbit-hole discussing wormholes :-)
Comment: @Warrior If a stable wormhole could be created and if one end moves relative to the other (hard to avoid) the wormhole acts like a time machine.  If this happens, you wind up with closed time-like loops and QM suggests that one possible consequence is a runaway energy flow through the wormhole. This is taken by some to suggest that wormholes are impossible. (Others take it to mean that QM is not yet a complete theory.)  Me, I don't have an opinion!
Comment: What do you mean ""Quantum feedback which may destroy the universe?

Wormholes man made are real?


How can I get the raw download size of a request using Puppeteer?

Question: That is, the total amount of data downloaded across all resources (including video/media), similar to that returned by Chrome DevTools' Network tab.
Answer: There doesn't seem to be any way to do this as of January 2018 that works with all resource types (listening for the response event fails for videos), and that correctly counts compressed resources.
The best workaround seems to be to listen for the Network.dataReceived event, and process the event manually:
const resources = {};
page._client.on('Network.dataReceived', (event) => {
  const request = page._networkManager._requestIdToRequest.get(
    event.requestId
  );
  if (request && request.url().startsWith('data:')) {
    return;
  }
  const url = request.url();
  // encodedDataLength is supposed to be the amount of data received
  // over the wire, but it's often 0, so just use dataLength for consistency.
  // https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-dataReceived
  // const length = event.encodedDataLength > 0 ?
  //     event.encodedDataLength : event.dataLength;
  const length = event.dataLength;
  if (url in resources) {
    resources[url] += length;
  } else {
    resources[url] = length;
  }
});

// page.goto(...), etc.

// totalCompressedBytes is unavailable; see comment above
const totalUncompressedBytes = Object.values(resources).reduce((a, n) => a + n, 0);

Comment: doesn't work anymore: TypeError: Cannot read property '_requestIdToRequest' of undefined
Answer: The solution of @mjs works perfectly even in 2021. Just need to replace:
page._networkManager -> page._frameManager._networkManager
Full example that works for me:
const resources = {};
page._client.on('Network.dataReceived', (event) => {
  const request = page._frameManager._networkManager._requestIdToRequest.get(
    event.requestId
  );
  if (request && request.url().startsWith('data:')) {
    return;
  }
  const url = request.url();
  const length = event.dataLength;
  if (url in resources) {
    resources[url] += length;
  } else {
    resources[url] = length;
  }
});

await page.goto('https://stackoverflow.com/questions/48263345/how-can-i-get-the-raw-download-size-of-a-request-using-puppeteer');

const totalUncompressedBytes = Object.values(resources).reduce((a, n) => a + n, 0);
console.log(totalUncompressedBytes);

Comment: this does not work with puppeteer v20. _frameManager does not exist on page anymore.
Answer: If you are using puppeteer, you have server side node... Why not pipe the request through a stream, or streams and then calculate the content size?
Also there is https://github.com/watson/request-stats
Also you may want to call page.waitForNavigation as you may be wrestling with async timing issues
Answer: const imgaes_width = await page.$$eval('img', anchors => [].map.call(anchors, img => img.width));
const imgaes_height = await page.$$eval('img', anchors => [].map.call(anchors, img => img.height));

Comment: From Review:  Hi, please don't answer just with source code. Try to provide a nice description about how your solution works. See: [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer). Thanks


When a member achieves 10k rep, can they see who up/down votes questions/answers?

Question: Or does it take Mod status to view those reports?
Answer: Not even moderators can see who upvoted and downvoted posts. Only some employees can (community managers and developers).
Comment: Oh, OK thanks @Kevin
Comment: Sorry guys, I didn't see the other (same) question.
Comment: If I go to the profile of the user I suspect of downvoting my answer, won't I see the -1 in his/her/their/its recent reputation changes?
Comment: @user14111 - there are other tricks too. Most active voters report helps. Anonymous voting isn't very anonymous once someone starts exibiting voting patterns (like hitting specific users).
Comment: @user14111 No, you won't see the -1 in their profile. Neither will I. You can guess if you see their rep drop by 1 right when you get a downvote, but that's not necessarily accurate.


Why only harmonics allowed in the Casimir effect?

Question: My question is really a request for an intuitive explanation as to why only harmonic frequencies of photons allowed between two conduction plates.
Why do the plates have to be conductive?
And can real photons with unmatching frequencies exist between the two plates in the casimir experiment?
Comment: 1. try strumming a guitar. 2 lightly touch the strings half way down with one finger, while strumming. 3. etc.
Comment: just for interested readers , a good review of the effect and experiments https://arxiv.org/abs/quant-ph/0609145
Comment: @AndrewSteane interesting though, a guitar string (not being touched) has the appearance of a half wave between its two anchors. There's obviously a lot more going on with a vibrating string, but presumably a photon can't have half the wave-length of the plate distance.
Answer: Plates do not have to be conducting. Various dielectric materials can be used, and the Casimir force on the plates will depend on the characteristics of those materials such as dielectric constants.
But perfectly conducting plates are the simplest toy model, because perfect conductor means electric field is zero in and at the plates.
For two infinitely long perfectly conducting plates separated by distance $a$, relevant frequencies used in the Fourier expansion have to obey the relation (due to Maxwell equations and the mentioned boundary condition)
$$
\frac{\omega_n^2}{c^2} = \frac{n^2\pi^2}{a^2} + k_x^2 + k_y^2.
$$
So we can see allowed frequencies are harmonics only in 1D world, where there is no $k_x,k_y$. In 3D space, any frequency is allowed, due to the fact $k_x,k_y$ can have any real value.
Comment: I am not sure, but I don't think eigenfrequencies have to be limited to harmonics. Harmonics are multiples of some basic frequency. But eigenfrequencies depend on the shape of the cavity, and need not be multiples of anything. It's like in QT;  eigenvalues of Hamiltonian are multiples of some basic value (and thus form an arithmetic sequence) only in special case, such as 1D harmonic oscillator. In general, they are not.
Comment: Ok, so if i had a hollow ball of dielectric metirial, the point in the middle would be limited to harmonics in every direction in 3d space?
Comment: I see. Then what about photons that are not allined with the normal of the plates? Would they still be limited to harmonics depending on the angle of the approch?
Comment: Not harmonics, but frequencies $\omega_n$ obeying the relation above.


Unable to write to /dev/ttyUSB0 using fopen or php_serial.class.php

Question: I'm trying to rewrite this C script into PHP.(sample)
// send packet to network
tty_fd=open(buf50, O_RDWR | O_NOCTTY | O_SYNC);
write(tty_fd,&packet2send,34);
close(tty_fd);

This C script also reads data from /dev/ttyUSB0  in Hexadecimal but i'm having trouble with write(in php).
I've been able to successfully read, but I'm afraid writing isn't working - or I have been unable to see the content of what I write.
I've used fopen:
$request_packet_ok = dechex(ord("~")). " 02 ff ff 07 ff ab 2c 4d 65 73 73 61 67 65 20 43 43 20 23 31 2f 34 20 20 20 20 ff ff d2 d7 00 00 b5 7a\r"; //Means "Message CC #1/4" on the thermostat

$device = "/dev/ttyUSB0";

if (is_writable($device)) {
    echo "\n".'The file is writable'."\n";

    $fp =fopen($device, "w+");
    if( !$fp) {
        echo "Error";die();
    }

    while(true){

    echo "\n".'writing: '.$request_packet_ok;
    fwrite($fp, $request_packet_ok);
    $packet='';
    $var =  fread($fp, 35);
    for ($i=0; $i < strlen($var);$i++){
        $packet .=  dechex(ord( substr($var,$i,1) ) );
    }
    var_dump($packet);
}
fclose($fp);

i've also tried using the php_serial.class.php:
define('PACKET_SIZE_LIMIT',70);
$serial = new phpSerial;
$serial->deviceSet('/dev/ttyUSB0');
$serial->confBaudRate(19200);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("rts/cts");
$serial->deviceOpen();
$starttime = microtime(true);

$sof='~';
$packet = '';
$output = '';
while (true) {
    $read = $serial->readPort();
    if ($read) {

        while (strlen($output) < PACKET_SIZE_LIMIT){
            for($i = 0; $i <strlen($read);$i++){
                $each_char = substr($read,$i,$i+1);

                if ( strlen(dechex(ord($each_char))) != 2 ){
                    $output.= sprintf('%02d',dechex(ord($each_char)));
                }else{
                    $output.= dechex(ord($each_char));
                }

            }
             $read = $serial->readPort();
        }

        echo $output;

    }

}

$serial->deviceClose();

The purpose is to send messages to a thermostat using PHP rather than using C code.
Since I am able to Read the packets being sent by the antenna using php, I'm assuming I can access /dev/ttyUSB0 to write but for some reason, I can never see the content I had sent/write to the antenna (which sends the text message to the thermostat display - that doesn't happen). I also don't get any errors.. at all!
I'm looking to write to /dev/ttyUSB0 and then read what I wrote from it (to check that it works - as a test).
I am getting no permission denied, and the antenna looks like the image attached (plugged it to windows to show you, it needs to run on Ubuntu)

i have tried using the following commands to see the content at no avail (when I run the php code on that machine using root privileges):
screen /dev/ttyUSB0 19200
od -x < /dev/ttyUSB0

How can I send a message using php via /dev/ttyUSB0 and receive that very message? or at least have some sort of simple test to confirm that what was sent, can actually be read.
Comment: Are you sure your device is using rts/cts for flow control instead of "none"?
Comment: Yes, or that's what the software engineer says. is there a way to check?
Answer: In the C program you write(tty_fd,&packet2send,34); i. e. 34 bytes. In your PHP script you fwrite($fp, $request_packet_ok); where $request_packet_ok is a string of 105 Bytes. Obviously you are mistakenly sending the message in hexadecimal space-separated representation, while you should rather send it as raw bytes.


How to extend an outdoor single gang electrical box to a 2 gang electrical box

Question: I have a single gang electrical box on an outside wall of my home. I need to expand it so it can house two GFCI outlets on separate circuits. I have been looking for an extender with an opening in the back the size of a single gang box but have not found one. Does anyone know where I can buy one? If not, can I cut a hole in the back of a two-gang weatherproof box and mount that to the single gain box? Any suggestions would be appreciated!
Comment: Everything below is good information, but I didn't see the simple 'run a new circuit into a new box beside the old one'. Is that an option?
Answer:
so it can house two GFCI outlets on separate circuits

Frame challenge. If you literally need two receptacles, one on each of two GFCI protected circuits, there are two options that do not involve expanding the box at all. It may or may not be practical, but that is a separate issue:
Multi-Wire Branch Circuit (MWBC) with GFCI Breaker

Install a double-breaker GFCI. (Note: This may not be possible in an older panel.)
Run a /3 cable (12/3 for 20A, 14/3 or 12/3 for 15A) or two hots + neutral in conduit from the breaker to the outside box.
Install a weather-proof standard (not GFCI) duplex receptacle in the outside box.
Remove the tab on the hot side.
Connect the two hots to the hot side (one on top screw, one on bottom screw) and the neutral to the neutral side.

MWBC with Two GFCI Receptacles

Install a plain double-breaker.
Run a /3 cable (12/3 for 20A, 14/3 or 12/3 for 15A) or two hots + neutral in conduit from the breaker to an inside double-gang box.
Install two GFCI Duplex Receptacles in the box. Pigtail the neutral to feed the LINE side neutral and use a different hot wire for each LINE side hot.
Run 4 wires (plus ground if not metal conduit) to the outside box. This can be two cables or four individual wires in conduit. If it is four wires in conduit, make sure that the hots are clearly marked (different colors or colored tape near each end) and the neutrals are clearly marked (since most non-professionals won't bother getting gray wire, mark one of the white neutrals with colored tape).
Connect one pair of wires to each LOAD side.
Install a weather-proof standard (not GFCI) duplex receptacle in the outside box.
Remove the tabs on both the hot side and the neutral side.
Connect the two hots to the hot side (one on top screw, one on bottom screw) and the two neutrals to the neutral side.
Wires must be paired properly - i.e., LOAD side of one GFCI to top of outside, LOAD side of the other GFCI to bottom of outside.

There is a third option - run two separate circuits to two separate GFCI/receptacles and then bring LOAD from both of them to the outside box. The trick there is that even though they don't need to be a double-breaker (as necessary for a GFCI/breaker or makes sense for a new MWBC), they do need to be next to each other and handle-tied. In all three cases, double-breaker or handle-tie is critical to make sure that the next owner (who may not realize there are two circuits or an MWBC) always turns off power to everything in that outside box before doing any work on it.
In all of these cases, the outside receptacle must be marked GFCI Protected, and if it isn't really obvious, labeling the location of the GFCI device would be helpful for when there is a GFCI trip.
Comment: Sorry I deleted that because I thought you already covered it. I was proposing your second case but with non-MWBC from panel to GFCIs, so each GFCI would be fed its own hot/neutral on its own /2.  The breakers would need to be tied since they both serve the same receptacle.
Comment: @Harper-ReinstateUkraine Yeah, I thought of that option too. The trick there is the handle-tie - that gets a bit more confusing than a simple double-breaker. But if OP already has two separate circuits in mind and wired to near the destination then that makes sense. In all of these the GFCI will be inside and sticker needed.


Calculate the SNR of wav file?

Question: I am doing a project in which i have a "recorded voice". Now i have applied the noise reduction and get the "filtered voice". Now i want to calculate the SNR of recorded voice and filtered voice in matlab. I do not have pure voice for reference (As in all the previous post, pure signal is taken as reference in calculating SNR). I am confused how to do it. Please help !!
Answer: When you dont have the exact voice as a reference you can only go to estimate/measure the noise. Assuming you are facing white noise, the simplest thing is to look for either time-domain or frequency-domain parts of the signal, where no voice is present. In these parts there is only noise. Hence, if you measure the average signal power in these parts, you get the noise power P(noise). Then, you measure the overall signal power, which is P(voice) + P(noise). Finally, you can have
$$ SNR=\frac{P(voice)+P(noise)-P(noise)}{P(noise)} $$
Comment: But its difficult to implement this in matlab. I just want to prove that my noise reduction algorithm is working properly that's why I thought SNR is one of the way to prove it. If you could help in matlab code I would be grateful to you.
Comment: It is not difficult to proceed with Max's suggestion in Matlab, and agree that this would be the best you could do. There will be pauses between words in the time domain signal, so you could extract these samples to get the best estimate of your noise (the more you can get the better the estimate, assuming your noise is white as Max said and stationary). Ideally if you can make new test signals, either with a minimum noise voice recording and then add your own noise in Matlab, or record with no voice present and record again with the voice on the same hardware.
Comment: @SourabhGoel Then take a known sample of voice, add noise to it, and then remove it, and see how much noise is left when you subtract the original

Calculate the SNR of wav file?


Are engine block heaters common in Ottawa?

Question: I know it can get very cold in Ottawa in the winter. Are automobile engine block heaters common/necessary?  If I move a car from the US, would it need to be retrofitted?
Answer: There is no perfectly correct answer to this question. Block heaters aren't uncommon in Ottawa, but lots of cars don't have them and get along okay.
The last new car manual I read recommended that if you have a block heater you should use it only if the temperature was going to be below -18C, suggesting that they are 100% certain that a properly working car will start at temperatures above that. According to this Ottawa averages less than 20 days per year where the low temperature reaches -20C or below, so following the recommendation would mean you won't get a lot of use out of the block heater. My experience is that if you use synthetic oil and don't try to get more than a few years out of your battery you'll have little to worry about above -30C with a modern car, and in Ottawa it is rarely that cold. On the other hand, if you do see a <-30C morning you may feel very smart for having bought the block heater.
I think you wouldn't regret buying the block heater (and if you move somewhere further north block heaters become standard equipment) but if you don't buy it you'll rarely have difficulty in Ottawa since it isn't that cold. You sort of need to decide for yourself whether you prefer to feel perfectly safe that your car will start under all conditions or would be happier not spending the money.
Do buy snow tires, though.
Comment: _There is no perfectly correct answer to this question._ Actually, this is exactly the information I was looking for. Thanks!
Comment: I live in Saskatchewan, which is much colder, but I would have a block heater anywhere that temperatures get below -15 regularly.  A car may start without one, but it will start more easily with one, and warm up more quickly.  Also, contrary to the normal behaviour of many, it's best to only warm up your car for about 30-60 seconds, and then drive gently until the engine starts to warm up, to reduce unnecessary wear and fuel consumption.  (I tend to keep the heater on a lower fan speed setting and ease it up as the temperature gauge goes up.  This speeds up how fast the engine warms up.)


What's the difference between an inverted index and a plain old index?

Question: In software engineering we create indexes all the time (e.g., in databases) but I also hear a lot of people talk about inverted indices. Is there something fundamentally different between the two? They sound like the same thing.
Comment: @guidoism What everyone failed to mention (though normalocity partially describes it by examples and lovesh is pretty much on the button) is that inverted indexes "invert" the basic data to be more efficient (e.g. swap keys/data to search from different perspective or ordering alphabetically/numerically to allow fast search algorithms), whereas a standard index stores data as it finds it. The "backward/forward" references and literal meaning of the word "invert" do not apply here, instead it refers to inversion of data to produce an efficient format specific to the task at hand.
Comment: http://en.wikipedia.org/wiki/Inverted_index
Comment: To clarify, you're asking: what's different about a normal index (http://en.wikipedia.org/wiki/Index_%28database%29) that breaks down a table based on data that already exist in that table? Is that correct?
Answer: One common use is "...to allow fast full-text searching."
The two types denote directionality. One takes you forward through the index, and the other takes you backward (the inverse) through the index.  That's it. There's no mystery to uncover here. Otherwise the two types are identical, it's just a question of what information you have, and as a result what information you're trying to find.
To address your inquiry, I don't think there's actually a way to know why the use is what it is today. The only reason it's important to define which is forward and which one is inverted is so that we can all have a conversation about them, and everyone knows which direction we're talking about. Think about the terms "left" and "right": they are relative. Which is which doesn't matter, except that everyone needs to agree which one is "left" and which one is "right" in order for the words to have meaning. If, as a culture, we decided to flip left and right, then you'd have the same issue figuring out what a "right turn" vs a "left turn" is since the agreed upon meaning had changed. However, the naming is arbitrary, so which one is which (in and of itself) doesn't matter - what matters is that we all agree on the meaning.
In your comment where you ask, "please don't just define the terms", you're missing the point, and I think you're just getting hung up on the wording when there is absolutely no difference between them.

For the benefit of future readers, I will now provide several "forward" and "inverted" index examples:
Example 1: Web search
If you're thinking that the inverse of an index is something like the inverse of a function in mathematics, where the inverse is a special thing that has a different form, then you're mistaken: that's not the case here.
In a search engine you have a list of documents (pages on web sites), where you enter some keywords and get results back.
A forward index (or just index) is the list of documents, and which words appear in them. In the web search example, Google crawls the web, building the list of documents, figuring out which words appear in each page.
The inverted index is the list of words, and the documents in which they appear. In the web search example, you provide the list of words (your search query), and Google produces the documents (search result links).
They are both indexes - it's just a question of which direction you're going. Forward is from documents->to->words, inverted is from words->to->documents.

Example 2: DNS
Another example is a DNS lookup (which takes a host name, and returns an IP address) and a reverse lookup (which takes an IP address, and gives you the host name).

Example 3: A book
The index in the back of a book is actually an inverted index, as defined by the examples above - a list of words, and where to find them in the book. In a book, the table of contents is like a forward index: it's a list of documents (chapters) which the book contains, except instead of listing the words in those sections, the table of contents just gives a name/general description of what's contained in those documents (chapters).

Example 4: Your cell phone
The forward index in your cell phone is your list of contacts, and which phone numbers (cell, home, work) are associated with those contacts. The inverted index is what allows you to manually enter a phone number, and when you hit "dial" you see the person's name, rather than the number, because your phone has taken the phone number and found you the contact associated with it.
Comment: thank you for your time. but your answer is still uninformative. As I mentioned in my bounty request, I DO understand what the terms involved mean and why they arise. My question was: "why did the people who named inverted indexes call them inverted when we have a long standing tradition which calls them just plain indexes? For example, indexes at the end of books, as you point out, are actually inverted. Going by historical perspective, the indexes at the end of books came before web indexes. Then why invert tradition?". My guess is that it was just one of those things that just happened...
Comment: @jefflunt just wondering on why should the forward indexing be used. I am particularly talking about the web search example here. So if google, as part of the forward indexing does the _list of documents <-> words in them_ , and ultimately uses the _list of words <-> list of documents_ in their search, why do the _list of documents <-> words in them_ ? In other words, my question is: One cannot ask google what words are there in a particular page(document) or is mainly going to ask where do the keywords he/she is looking for occurs in the pages. Then why do forward indexing?
Comment: So in context of Relational database there's no inverted index? or those indexes are actually 'inverted index' . Problems with "agreeable" terms in literature is ignorance/mistake/deliberation by few pioneers or corps who start different agreement and part of community follow that nomenclature. Everyone gets confused after sometime. I'm sure there are many terms in software that were originally meant to be lets say A but different community deliberately or mistakenly takes it as A' or B, syntactically off course. It still confuse the hell out of new learner.
Comment: "I don't think it's possible to know why without conducting a historical examination of the use of the terms" -- I'd have hoped someone _would_ conduct such a historical examination and give an answer. :-) Because this being opposite to the common-language meaning of "index" is surprising. (One possible answer is that when the phrase "inverted index" was first thought of, the phrase "index" was already being for some "index" inverted wrt "inverted index", i.e., inverted wrt the real-life meaning of "index". In that case, it would be useful to know why the forward "index" got the strange name.)
Comment: @Roylee - I've not read that white paper. I think what you're asking is, "Do you update the inverted index when updating the forward index?" If that's your question, then the answer is yes.
Comment: @Roylee - either way, I think the answer is the same. The directionality isn't important, and both sides of the index should match one another. I'm sorry - I'm not sure I'm actually answering your question.
Comment: @nir I agree - it seems to me that by the definition of 'inverted index', standard indexes on RDBMS columns are inverted indexes, because you use the column values to give you a list of rows in which they appear. I think the confusion arises because the index that the 'inverted index' is the inversion of is not what one usually thinks of as 'index' but rather a straightforward list of documents/pages and the words they contain.
Comment: Yup, and I read that part of your post. My examples are more for the benefit of future readers of your question.
Comment: As far as trying to answer the "why" question, I addressed that in my second and third paragraphs. Simply put, I don't think it's possible to know why without conducting a historical examination of the use of the terms, and how that use changed. I've also (just now) made a few adjustments to my original answer that reflect these comments.
Comment: Pointing out the traditional use is valid only if you are arguing which one people "should" use now, but it doesn't help you know why one was chosen over the other, or why it was flipped on its head at some later time. The naming is arbitrary, and has no meaning in and of itself, and therefore, there is no answer to "why". The only purpose of the naming is to facilitate conversation about the two concepts, such that when a person says "inverted" or "forward" we all have the same concept in mind.
Comment: I won't be awarding you the bounty since you didn't really answer the why part, but you should be getting half of the bounty anyway (since yours is the highest voted answer). And I think you deserve it too, since going by all the other answers on this page you seem to be the only person who is atleast getting the intent of the question :) And again, thank you for your time.
Comment: How is the TOC of a book a forward index and the Index at the back a reverse index? In both cases we are searching for a word (or words), and we get the page number as the result, right? So they can't be different. Either both are forward, or both inverted. My thought is they are both inverted indices.
Comment: @jefflunt, in Google's white-paper: `the anatomy of large scale hypertextual web search engine`, it mentioned about forward index/inverted index, in a context of implementing search engine indexing, do we remove entries from forward index file after we have taken its information to forge inverted index?
Comment: @jefflunt Forgive me for my lack of clarity.  Its actually "Do you remove forward index, when the inverted index has updated?"
Comment: People tend to get caught up on "forward" verses "inverted" when thinking about inverted indices rather than realizing that the difference between regular indices and inverted indices does not involve a mathematical inversion of the query process, but instead a different indexing algorithm. Take a look at @Bery answer as it actually does spell out the algorithm known as "inverted index" rather than just trying to explain what the inverse of a forward index would look like.
Answer: They called it inverted just because there is already a forward index. Take the example of search engine, it composed by two parts: the first part is "web crawler and parser" which build a index from document to word, the second part is search database which build a index from word to document. Because of the first index exist, we naturally call the second index as inverted index.
If you name the TOC (Table of Content) of a book as index, then you should call the index at the end of book as "inverted index". Or, in other side, you can call the TOC as inverted index.
Comment: This should be the accepted answer as it answers the question why we call an index "inverted" even if it is just what everybody thinks of a  "normal index". A SQL b-tree index stores for each word a pointer to all rows ("documents") containing it. There we call it "index". But in search engines we suddenly call this exact same procedure "inverted index". Not because it's fundamentally different, but because we first created a "forward index" (split text) and then "inverse" it. So, all in all, the name "inverse" comes from the process of creating it, not from the final structure of the index.
Comment: I agree with @FooBar. This answer should be chosen as the right answer.

It answered why we invent a new term `inverted index`   even though all normal index in our life are already used as `inverted`.
Comment: @xeranic thanks for the insights. Quick question: Is it practical to remove entries from forward index file after inverted index is built from it?
Answer: typically when speaking about index, you mean some added calculations or stored results of procedures which have been done in order to speed up application (e.g. MySQL or other RDBMS Consult MySQL the docs). Indexing can also be related to caching etc.
Inverted index creates file with structure that is primarily intender for (fulltext) searching.
Inverted index consists of two main files:

Vocabulary
Occurences

In vocabulary are common words extracted from text (of course after filtering blacklist words like pronouns). The occurences file holds the connection between words and documents (word1 appears in doc1 and doc2, not in doc3). It is represented in a form of a matrix.

In the above image is shown the process of creating the two files mentioned.
If you are further interester in this problematic I can recommend you a great book written by Ricardo Yated - Modern Information Retrieval (See it on Amazon) - about page 200 I think.
Hope it helps :-)
Comment: This is a very good answer as it explains what an inverted index really is. It gets past the idea of forward indexing and inverse indexing which is different from the algorithm that is used for a search capability that is enabled by creating and inverted index.
Comment: I like this answer best of all the ones here.
I'll also add that you can think of an inverted index as a de-normalized index. A single index can reference multiple fields or entities, letting you search many things in a single lookup (very useful for search engines).
Answer: normalocity has already wonderfully differentiated between a forward and an inverted index but for the question of why one is called a forward index and the other an inverted index, maybe this is why they are called that way---
Taking example of search engine crawling and indexing (or building index for a book), a forward index can be built simultaneously while you are crawling the web pages(or reading the book) or going forward. So if you have 10 webpages to crawl(or 10 chapters in a book) you can crawl the first webpage(read the first chapter) and then make a list of words which appear in the webpage(words which appear in the chapter) and continue this process for other webpages(other chapters) so by the time you have crawled all the 10 webpages(read all 10 chapters) your forward index is complete with each webpage(chapter) pointing to a list of words it contains.
But to make an inverted index you have to crawl all the 10 webpages(read the 10 chapters) and and then take each word from each documents list and figure out which documents contain that word. So this is like going backward once you have crawled the webpages(read chapters of the book). So its called an inverted index.
This is just my speculation.
Answer: The term "Inverted Word Index" refers to the change in relationship of
a single-document containing many-words, to each unique word containing
(or identifying) a list of many-documents. This is effectively taking a One-to-Many Relationship (Docs to Words) and Inverting (or reversing) it such that a new "Inverted" One-to-Many Relationship now exists, which is each-unique-word relating to Many-Documents (i.e., all that contain that word). It's origin really is that simple, and the term "inverted index" was used to describe manual indexes of the same type long before computers and electronic high-speed indexing even existed (yes, admittedly, I'm an old, geezer programmer, almost old enough to have considered Grace Hopper a "sweet young lady" age appropriate for courting back when COBOL was a shiny new language). Please don't discard us geezers just yet, as we may occasionally provide a useful, and possibly even valuable, historical tid-bit or two - when our personal RAM is still working, that is. [grin]
Answer: There are many types of index. For example, B-tree, R-tree, hash... For different purposes, we must choose correct index.
Inverted index is a special one. Inverted index usually used in full text search engine. Use inverted index we can find out a word's locate in a document(or documents set) as fast as possible. Think about the limit of memory and cpu, other index can't finish this job.
You can read lucene document for more details. It's a open source search engine.  http://lucene.apache.org/java/docs/index.html
Answer: in inverted indexes, we have the following form:
word1-> list of docs it occurs in (sorted order)
word2-> list of docs it occurs in (sorted order)
It is very useful for search engine query processing as it allows us to find docs that word occurs in .
You can use supervised machine learing to build this inverted index.
Comment: That sounds like an index to me, what's inverted about it?
Comment: @guidoism An inverted index is the inversion of a forward index. a forward index stores a list of words for each doc.  Eg Doc->w1,w2
Comment: I still don't find any difference between Forward and Inverted index (in terms of how it works, leave the naming bit). Both to me, looks like an index that maps a field to a bunch of document ids. This is how I understood how the oracle btree (otherwise referred to forward index) organises the data. I don't see any difference to the inverted index's principles. Mapping a Doc -> w1, w2, w3 looks like an inefficient proposition to me in terms of search. Wonder why is this in the first place? That leaves me back to square one. :-).
Comment: @Programmer  Quick question: Is it practical to remove entries from forward index file after inverted index is built from it?
Answer: One more difference:
Handling updates with the inverted index are expensive in comparison with forward index.
Forward index handles updates easily by reflecting the changes only in the corresponding document index, whereas in the inverted index, the same change has to reflect in multiple positions across the inverted index.
Answer: The way to interpret is based on  "what points to what".
Example, An entity has many attributes.We first need to have the entity at hand to be able to find what attributes it has.
A practical example is that in a search engine , in its ingress/ web crawler phase, it first crawls and has access to a webpage. Webpage here is the entity. The index that it would create  to map a webpage to the different words it has is a forward index. The mapping would be , document -> words
To facilitate the lookup from an attribute to the entity , we need a inverted index. In my example it would be the mapping of words -> webpage documents.


Are there any creatures based on breath or air, and specifically stealing these if possible?

Question: I'm sure we've all heard of the myth of cats stealing babies' breath, but I'm looking for more than that.  I've heard of two other myths as well, the Boo Hag off Gullah culture and mice in some Chinese myths, but other than that I can't find much of anything.
Answer: The generic name for this would be Night Hag. There is sleep paralysis related folklore worldwide, some of which gave birth to what developed into the modern concept of the nightmare. I could not find any solid reference for the cat story.
Your mice can be found there:

In Eastern Chinese folklore, it is thought that a mouse can steal human breath at night. Human breath strengthens the mouse, allowing it longevity and the ability to briefly become human at night, in a similar fashion to fox spirits. The mouse sits near the person's face or under their nostrils

Some more samples:

In Scandinavian folklore, sleep paralysis is caused by a mare, a supernatural creature related to incubi and succubi. The mare is a damned woman, who is cursed and her body is carried mysteriously during sleep and without her noticing. In this state, she visits villagers to sit on their rib cages while they are asleep, causing them to experience nightmares.
In many parts of the Southern United States, the phenomenon is known as a hag, and the event is said to portend an approaching tragedy or accident
In Brazil, there is a legend about a mythological being called the pisadeira ("she who steps"). She is described as a tall, skinny old woman, with long dirty nails in dried toes, white tangled hair, a long nose, staring red eyes, and greenish teeth on her evil laugh. She lives over the roofs, waiting to step on the chest of those who sleep with a full stomach

Reference:
https://en.wikipedia.org/wiki/Night_hag
https://en.wikipedia.org/wiki/Boo_Hag
Comment: I've seen those links, but are those the only myths?  I was looking for other things that steal breath as well, not just the sleep paralysis related ones.


How can I get confidence intervals for fixed effects using the rlmer function (robustlmm package)?

Question: I need to fit a linear mixed model but my dependent variable is right-skewed with some big outliers. Thus I used the rlmer function of the robustlmm package. it works quite nicely, however what I am missing now is confidence intervals for the fixed effects. Is anyone working with this package and has some tips for me? Otherwise I would also be interested in other packages to fit robust linear mixed models.
Answer:
Wald confidence intervals: these assume that the sampling distribution of the parameters is multivariate Normal (a much weaker assumption than that the conditional distribution of the residuals is Normal). They are relatively easily to compute (for the fixed-effects parameters) by extracting the parameter values (fixef()) and the standard errors (sqrt(diag(vcov()))) and computing $\beta \pm z \cdot \sigma$ ...

Example:
library(robustlmm)
r <- rlmer(Reaction ~ Days + (1|Subject), sleepstudy)

confint.rlmerMod <- function(object,parm,level=0.95) {
     beta <- fixef(object)
     if (missing(parm)) parm <- names(beta)
     se <- sqrt(diag(vcov(object)))
     z <- qnorm((1+level)/2)
     ctab <- cbind(beta-z*se,beta+z*se)
     colnames(ctab) <- stats:::format.perc(c((1-level)/2,(1+level)/2),
                                           digits=3)
     return(ctab[parm,])
 }
 confint(r)
 ##                  2.5 %    97.5 %
 ## (Intercept) 235.575485 269.27845
 ## Days          9.211197  12.04305

if you think the Wald intervals are likely to be nonsymmetric on the original scale, it might be possible to compute confidence intervals on another scale, e.g. the log scale, and back-transform.
I don't think that profile likelihood confidence intervals are an option; at the very least you'd have to follow through the theory for robust linear models and see if there was a robust-likelihood analogue that followed the same asymptotic theory.
the same problem applies for parametric bootstrapping.
nonparametric bootstrapping is a possibility.  See e.g. Confidence intervals on predictions for a non-linear mixed model (nlme) , Non-linear mixed model (nlme) with nested random effect, do not know how to include nested random effect when bootstrapping
Comment: see edits.  A non-symmetric response distribution doesn't imply that the Wald CIs are bad ...
Comment: I think that some generic reference to Wald confidence intervals would be sufficient ...
Comment: Thank you for your answer. I already did that myself, but I am not so happy with Wald confidence intervals in this situation, as the normality assumption is obviously violated and my distribution is not symmetric...
Comment: Thank you for expanding your answer! I was also thinking about bootstrapping, but I was/am unsure how to do that correctly in this situation, incorporating the random effects etc. I will have a closer look at your links and see if I manage! It would be interesting also for comparison with the Wald confidence intervals.     About your suggestion to calculate the CIs on another scale: There I see the problem with the interpretation. The model is for a surgery trial and the surgeons need to be able to interpret the results - many of them do not have an in-depth knowledge about statistics.
Comment: Hi all! @BenBolker, I am using robustlmm and I will use your code to calculate confidence intervals. I was wondering if I have to give some specific reference if I use your method to calculate the confidence intervals since I am not using any package. By the way, I read a lot of comments from you everywhere, and I have to tell you THANK YOU VERY MUCH for sharing your knowledge.
Comment: One last doubt, if possible @BenBolker. What could I cite to say that confidence intervals are more reliable than p-values using robust linear mixed-effect models? Or I don't need to justify that?
Answer: It is also now possible to obtain confidence intervals of rlmerMod objects using the effects package.
Example:
library(robustlmm)
library(effects)

r <- rlmer(Reaction ~ Days + (1|Subject), sleepstudy)
as.data.frame(effect("Days",r))

###   Days      fit       se    lower    upper
###      0 252.4270 8.597854 235.4601 269.3938
###      2 273.6812 8.161895 257.5747 289.7877
###      4 294.9355 7.967757 279.2120 310.6589
###      7 326.8168 8.161895 310.7103 342.9234
###      9 348.0711 8.597854 331.1042 365.0379

Comment: one doubt, How should I specified in this package if I want confidence intervals for two fixed factors and their interaction? When I specified the interaction term I get multiple rows for each level-combination between the fixed factors, but I don't want that. I want just the C.I for each fixed factor and the interaction. Do you know how to do this? I checked `help` for the package but I can't get what I want. If I use the code proposed by Ben Bolker, I get what I want, but I wanted to check if with the package I could get the same. Thanks!


Google Apps Script - percentage formatting and arrays

Question: I am perplexed by the following.
I have data on a google spreadsheet that I am pulling into an array.  I am doing some modifications on the data and then putting it back into the spreadsheet.  My numbers are formatted like this on the spreadsheet: 00.00%  When they come into the array they are formatted like this 0.0, and when I put them back on the spreadsheet into 00.00% format, they are being divided by 100.  So what started out as 20.00% becomes 0.20% when I put the data back.
So, I thought I'd multiply all the numerical values by 100 before I put them back on the sheet, which seems like it should be an unnecessary step.
My question is whether I could be doing something differently with how I'm handing the data in the array, or is multiplying every value by 100 my only option here?
Answer: This is a bug that has been known for a long time:

Issue 472: setValue(s) fails for percent formatted cells.

Visit and star it, maybe it will get more attention.
If you're reading and writing values from percent-formatted cells, you must recalculate the percentage values.
This function uses the format values for a range to apply the *= 100 operation on any cell that's a percentage:
/**
 * Adjusts the values for elements in values array if the
 * corresponding format element is a percentage.
 * Value array is changed in place, as well as returned.
 */
function percentAdjust(values,formats) {
  for (var row = 0; row < values.length; row++) {
    for (var col = 0; col < values[0].length; col++) {
      if (formats[row][col].indexOf('%') !== -1) {
        // Adjust any percent formatted values
        values[row][col] *= 100;
      }
    }
  }
  return( values );
};

function test () {
  var sheet = SpreadsheetApp.getActiveSheet();
  var rows = sheet.getDataRange();
  var values = rows.getValues();
  var formats = rows.getNumberFormats();

  rows.setValues(percentAdjust(values,formats));
}

Comment: thanks - starred it.  I was just testing if the column was a number before I multiplied by 100 but I like your method of checking if the format is a percentage instead.
Answer: Or for values is below 200%, check if value is below 2 and if so convert it to percentage...
var inputValue = row[0];
if (inputValue < 2) {
    inputValue = (inputValue*100 + "%")
}


Trouble with googlevis using Knitr HTML in RStudio 0.98.94

Question: When using RStudio 0.97, I used to be able to easily knit googleVis plots into html output.  However, now using RStudio 0.98.94, it causes an error even for the following Rmd:
---
title: "knitr googleVis"
output: html_document
---

```{r, results='asis'}
library('googleVis')
tbl <- gvisTable(data.frame(letters = letters[1:5], number = seq(5)))
print(tbl, 'chart')
```

The error message is:

pandoc.exe: Failed to retrieve https://www.google.com/jsapi?callback=displayChartTableID253831656700
InternalIOException getAddrInfo: does not exist (error 11001)
Error: pandoc document conversion failed with error 61
In addition: Warning message:
In if (grepl(" ", path, fixed = TRUE)) path <- utils::shortPathName(path) :
    the condition has length > 1 and only the first element will be used
Execution halted

The following is my sessionInfo():

sessionInfo()
  R version 3.0.2 (2013-09-25)
  Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
  [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    > LC_MONETARY=English_United States.1252
  [4] LC_NUMERIC=C                           LC_TIME=English_United States.1252
attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base
other attached packages:
  [1] googleVis_0.5.4
loaded via a namespace (and not attached):
  [1] digest_0.6.4     htmltools_0.2.4  RJSONIO_1.0-3    rmarkdown_0.2.49 tools_3.0.2      > yaml_2.1.13

Does anyone have any ideas on fixing this?  Thanks a lot!
Answer: Knitr does not render googleVis or devtools::install_github('mages/googleVis') is work for me.


How to add cash to a city government

Question: I am playing Capitalism Lab with the City Economic Simulation DLC. Is there a way for players or companies to transfer cash to a city government to help it balance its budget? I may want to donate money to a city government to help it fund more civic buildings and sports facilities, or to help it avoid bankruptcy.
If a donation is not possible, is there a cheat to increase the cash of a city government? The ^&*(, Altc cheat for adding $10 million to a company's cash balance has no effect on a city's cash balance, even when a member of my political party is the mayor of that city.
Answer: I have found two ways:

Buy land. The proceeds from land purchases goes to the city government. However, when the player sells the land, it is sold back to the city government, which will reduce the city government's cash.

If the city government owns media firms, then advertise through those media firms to increase the city government's revenues. For example, one could set up this useless retail store whose real purpose is to transfer cash to the government via the government's television station:

How to add cash to a city government


How do I get `gasLimit` in web3?

Question: I am running in a private ethereum network which I init with a genesis.json file that contains

"gasLimit": "31415926"

Now I am wondering how I can read that via web3, any suggestions? (I want to make sure the limit is set correctly).
Answer: Asking for the last block mined, it will return the gasLimit of the block
https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethgetblock
var block = web3.eth.getBlock("latest");
console.log("gasLimit: " + block.gasLimit);

Note for web3 v1.x: getBlock is an async function and you have to use await to get the expected result
var block = await web3.eth.getBlock("latest");
console.log("gasLimit: " + block.gasLimit);

Comment: The gas limit I am getting from this is absurdly high (For an individual transaction), but this is the gas limit for the whole block though, correct? If so, then to estimate the gas I should use on an individual transaction, do I just divide by the number of transactions in said block? Or is it safe to just always use the gasLimit minimum of 21000?
Comment: This is giving me 'undefined', maybe there is an upgrade?
Comment: @rsc05 You need to wait the function returns: await block.gasLimit
Answer: Here is the exact answer:
var block = await web3js.eth.getBlock("latest");
var gasLimit = block.gasLimit/block.transactions.length;

Comment: For python code, it should be ```gas_limit = int(latest_block.gasLimit / (1 if len(latest_block.transactions) == 0 else len(latest_block.transactions)))```
Comment: The block gasLimit total is always about 30000000, but the number of transactions is variable in each block. Sometimes 1, sometimes 6..... the gasLimit is so different in each case if I take your division by the trx length
Comment: This is giving me 'undefined', maybe there is an upgrade?

How do I get `gasLimit` in web3?


Accessibility slider with no min/max values

Question: What would be the best instructions for a slider that has no min/max value. For example, you are either all the way to the left or right of a question asked. You could also be in the middle, or anywhere within the slider. So the positioning of the thumb could be anywhere within the slider. Think decimal places. What is the best way to make this accessible and what output should the screen reader users get?
Comment: Hi, could you explain the use case of your slider? Is it a true "infinite negative to infinite positive values are accepted", or is it more like no values are displayed to provide a more abstract feeling? Thanks.
Comment: Like @Izquierdo said, can you provide some context? You mention there is a question, which sounds as if the slider is something like a semantic differential or a Likert scale. If any of these is true, the question is very different to what it reads now. Otherwise, I think JazZRo's answer is the right one
Answer: Is there really no min/max value, or is it that you don't want to distract users with numbers? The slider is very likely not infinite, so you probably want to use percentages as input for users who don't want or can't use the slider. You will need an extra number field that allows 0 to 100. It is preferably visible for everyone because not only screen reader users will benefit. (See also this excellent answer.) It can however be visually hidden and only accessible for screen readers (as described here).