MacBook Pro has kernel panic same time every time

Question: I purchased a second hand MacBook Pro 2015 and installed High Sierra on it and upgraded the SSD. Every day between 5-6pm it has a kernel panic and restarts. Any idea what might be behind this? I can't identify an activity trigger and its been happening daily for about 6 months.
Comment: Have you done an SMC, NVRAM/PRAM reset? Does it happen in safe-mode? Does it happen when you login to a different account? You could set up a rule to shut down automatically by night and boot back up in the morning - not a fix but could help for now. Also without any logs its basically impossible to tell what the problem may be
Comment: We need to look at the panic logs to start diagnosing this. Please use www.PasteBin.com to upload a few panic logs from `/Library/Logs/DiagnosticReports` (they will have the file extension `.panic`) and add the links to your question.
Comment: Thanks. Here is today's panic log: https://pastebin.com/vd9Q8TaD
Answer: This panic signature reminds me of a panic I saw a while back that was caused by Norton AntiVirus, which you have installed. In fact, here is someone on the Norton forum seeing the same thing. It's possible that you have a daily scan in the 5-6pm timeframe which hits this bug.

If you're not already running the latest version of Norton AntiVirus, update to the latest.
If you are on the latest version and this panic continues to happen, uninstall Norton AntiVirus. Specifically, this means making sure that its four kernel extensions are uninstalled. You can verify via kextstat | grep com.symantec.
If the panic continues after uninstalling Norton, uninstall your other KEXTs (Black Magic, Soundflower, SoundGrabber).
If panics continue, we can start to debug them by adding symbolication to your panic output: Disable SIP, run sudo nvram boot-args="kextsyms=1", reboot, and collect & upload a new panic report.
Comment: @Rusty It should be right underneath the vote up/down arrows at the top left of my answer
Comment: Thanks for that. The first thing I looked at after viewing the logs was to ensure the antivirus was not scheduling scans at that time. Its Symantec Enpoint Protection but I'm unsure that product is still available. I'll turn it off today and monitor. At least this gives me something to keep an eye on. Those KEXTs could probably go as well.
Comment: @Rusty How is this going?
Comment: I got a bit sidetracked by a large project - I checked for system cron jobs and scheduled Norton scans around the reboot time, but none. I uninstalled Norton and for the last few days no reboots. Fingers crossed Norton was the issue.
Comment: @Rusty is this still an issue? If this answer resolved it, can you please mark it as accepted? Thanks!
Comment: Removing Norton fixed and resolved the issue
Comment: I can't see a checkmark or any other option to resolve the post
Comment: There was a tick at the first answer so I checked that. Thanks


Numerical approximation of an integral

Question: I read a problem to determine the integral $\int_1^{100}x^xdx$ with error at most 5% from the book "Which way did the bicycle go". I was a bit disappointed to read the solution which used computer or calculator. I was wondering whether there is a solution to the problem which does not use computers or calculators. In particular, is there way to prove that the solution given in the book has a mistake because it claims that
$$\frac{99^{99}-1}{1+\ln 99}+\frac{100^{100}-99^{99}}{1+\ln 100}\leq \int_1^{100}x^xdx$$
gives a bound $1.78408\cdot 10^{199}\leq \int_1^{100}x^xdx$ but I think the LHS should be $1.78407\cdot 10^{199}\leq \int_1^{100}x^xdx$? I checked this by Sage and Wolfram Alpha but I was unable to do it by pen and paper.
Comment: My integration routine gives $1.78464\times 10^{199}$ for the right hand side.
Answer: Because your integrand grows so fast the whole integral is dominates for $x\approx 100$. We can write $x^x = \exp[ x \ln(x)]$ and then expanding $x \ln(x) = 100 \ln(100) + [1+ \ln(100)] (x- 100) + \cdots$ around $x = 100$ (note that it is important to expand inside the exponent). The integral can therefore be estimated as
$$\int_1^{100} dx \, x^x \approx 100^{100} \int_{-\infty}^{100} dx\, e^{[1+ \ln(100)] (x- 100) }
= \frac{100^{100}}{1 + \ln (100)}.$$ Numerics shows that this result is off by $3\times 10^{-4}$.
Answer: $x^x$ grows really fast.  Notice
$$n^n>\frac{1}{n}\sum_{i=1}^{n-1} i^i.$$
In short $100^{100}$ is a lot bigger then $99^{99}$, so $$\frac{99^{99}-1}{1+\ln99}+\frac{100^{100}-99^{99}}{1+ln100}\sim \frac{100^{100}}{1+\ln100}=10^{99}\frac{10}{1+\ln100}$$
By calculator $$\frac{10}{1+\ln100}=1.78407,$$ (notice the same as above) but we can get bascially that by hand.  First show $4<\ln100<5$.  Then $$1.6=\frac{10}{6}\leq  \frac{10}{1+\ln100}\leq \frac{10}{5}=2.$$
But lets do better.  Use the fact that $$\sum_{i=1}^n\frac{1}{i}=\ln n +\gamma +E$$ where $|E|\leq \frac{1}{2n}$, and $n\geq 4$.
Then $$\ln(100)=1+\frac{1}{2}+\frac{1}{3}+\cdots +\frac{1}{100}-0.577+E$$ and diligently adding this together (under 5 minutes) gives $\ln(100)\sim 4.6$.  From here we get the coefficient $\frac{25}{14}$ with an error bounded by $\frac{2}{100}$ or 2%.  (We gained error because I cut off 4.61 to 4.6)
Comment: $100^{100}$ is just over 270 (or just under $100e$) times $99^{99}$.   Does that count as "a lot" here?
Comment: @Henry: absolutely. The "exact" value of the LHS is $1.784078998771057... 10^{199}$.
Comment: @Henry:  I said what I meant by a lot.  The sum only depends on the last piece to get an error under $\frac{1}{n}$.  In other words, only the last interval in the integral matters when we want an error of 5%.  So we can get rid of 99% of the length of the interval of integration and have an error of less than 1%.  That is a lot in my mind.

Numerical approximation of an integral


How to predict the duration of burst given several series

Question: I've got sets of time series data collected from Weibo. It contains the number of posts under certain topics over a year. It can be found that from time to time there're bursts of discussion on certain topic. What's interesting is some burst die down quickly while others sustain on the agenda for quite a long time and die down gradually. How to predict and model the decays given a time series data. Also, I've got data of some exogenous data including time series data of links, pictures, and retweeting and original data in the community. Can I predict the duration of decay from these variables?
Answer: I guess, a nice place to start is seminal work of John Kleinberg:  https://www.cs.cornell.edu/home/kleinber/bhs.pdf
Yes, this paper is outdated, but anyway it's still very influential and simple. Also, digging articles, citing this paper, could be very helpful. By the way, these guys solve very similar task ( and they even use Weibo logs as well!): http://www.csce.uark.edu/~xintaowu/publ/pakdd15.pdf
Comment: Thanks a lot for your sharing. I've gone through these two pieces and like the first one very much. However, it aims at a different problem as what I'm expecting. I might not make that point clearly in my questions. I'm actually working on time series data with fixed time gap for each action. Therefore the variable that consists the key part of the model is invariant in my case. The second piece seems relevant to mine. It mentioned the Cantelli's inequality that serves as burst detection theorem.


Is it feasible to calculate an HMAC-SHA512/256 MAC from an environment that only supports HMAC-SHA512?

Question: I need to verify a MAC for something signed with HMAC-SHA512/256, however, the language I'm using (Salesforce's Apex language) doesn't have support for that algorithm. It does have HMAC-SHA512 and HMAC-SHA256 though – is there a way to transform one into the other, or somehow emulate the truncated version via other arithmetic/string operations?
Comment: Hash functions are the building blocks for HMAC functions.  See RFC2104 for more information.  https://en.wikipedia.org/wiki/HMAC is also informative.  You may be able to build your own HMAC-SHA512 or HMAC-SHA256 functions in Salesforce scripting using SHA512 or SHA256 respectively, using the algorithms referenced above.
Comment: Sorry, I wasn't clear there - it does have HMAC-SHA512 and HMAC-SHA256, but not HMAC-SHA512/256.
Comment: Thanks for clarifying and editing your question accordingly.  Does Salesforce scripting have the  SHA-512/256 hash function?  If so, you might be able to use this to build a HMAC-SHA-512/256 HMAC function.  If not, it's going to be a challenge to implement SHA-512/256.  SHA-512/256 is more than just sha512 truncated to 256 bits - it uses a different method to generate the initialization values, among other things.
Comment: No, SF doesn't have it as a hash function either. This is mostly what I feared...
Answer: There is no way to transform either SHA-512 or SHA-256 into SHA-512/256.  SHA-512/256 is based off SHA-512, but uses a different initial value and is truncated.  In order to successfully use SHA-512 to create a SHA-512/256, you'd have to be able to invert the hash function, change the IV, and then recompute the new hash value.  Unfortunately for you, cryptographic hash functions are designed to be computationally infeasible to invert.
SHA-256 shares a similar structure with the other SHA-2 functions you've mentioned, but it works on 32-bit values instead of 64-bit values and has a few other parameter changes, so it's also not possible as an option.  The fact that HMAC is involved definitely doesn't make anything easier here, either.
In your particular case, you may wish to write some sort of plugin for your Salesforce environment that calls out to a suitable crypto library which can provide the functionality you want.  Recent versions of OpenSSL and Nettle both support SHA-512/256 and HMAC.
Comment: Thanks for summarizing what I suspected! At the signing end HMAC-SHA512/256 was chosen because it's faster than HMAC-SHA256 and smaller than HMAC-SHA512. It also has very wide language support, and is even the default MAC in the well-respected libsodium. Unfortunately Salesforce Apex doesn't support it, so I'm stuck.
Answer: I'm not familiar with Salesfoce, but I heard that it has a PHP SDK.
PHP 7.1 does support SHA-512/256, and it can be used in hash_hmac and related functions.
Side notes:
SHA512/256 is a strange choice for instantiating HMAC - while SHA512/256 is secure against length-extension attack, HMAC is secure against it as well; even when performance advantage on 64-bit platforms considered, SHA256 has better interoperability. So maybe the source that produces HMAC-SHA512/256 can be changed.
The Apex API Doc strangely states that

Invalid algorithm algoName. Must be AES128, AES192, AES256, AES384, or AES512.

There is no such thing as AES384 or AES512, and it brings the validity of its claims to question.
Next, the API generateDigest supports SHA3-384, but not SHA-384, so I'd suspect that the listing of algorithm may be incomplete. You may bet on the chance of it happen to provide SHA-512/256.
Comment: No, Salesforce is not written in PHP, and the language that it supports is not PHP but their own language called  "Apex", and [it does not support the HMAC-SHA512/256 algorithm](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_restful_crypto.htm).
Comment: @Synchro Sorry about the factual error. But it does seem have a PHP SDK. Not sure if this is a viable solution.
Comment: Their SDK is for talking to the Salesforce API from the outside. This case is about their Apex language that runs on the *inside* of their environment. It might be feasible to "shell out" to some external service that can calculate a MAC (Apex supports arbitrary HTTP requests), but that would add an awful lot of overhead for something so small!


Typography problem for textloss due to perforator – highlight text

Question: I'm not sure whether help can be found here, but maybe anyone has an idea? I edit letters with XeTeX and many originals of the letters have holes punched with a perforator. It is usually easy to reconstruct the right reading but I need a simple and inoffensive way to mark the text. I can't do grey letters, because I use that for uncertain readings. I don't want to do brackets as that would be too visi[b]le. I can't do underline as I already have that in the text. I thought of making a grey line like a strikethrough only behind not in front of the letters. To achieve that I played around with a framebox with little extension but that seems to be in front of the letters as well.
Does something come to mind?
Comment: Have a look at Stylistic Set 7 on p. 17 of  `…/texlive/2016/texmf-dist/doc/fonts/junicode/Junicode.pdf`.  Your text has been (accidentally) "deleted" by the perforator, so perhaps a convention for deleted text is not inappropriate.
Comment: @Thérèse Great idea! But two problems arise: 1) What if underline and dots underneath come together? (One could say that dots overrule the underlining.) 2) The real problem to me seems that the holes usually delete one or two characters, too short, to make the dots visible I'd say on the first guess. But I'll try it right away.
Comment: @Thérèse I have a font given to me by the publisher. Dotting with uline isn't working because for an "I" there is just a simple dot underneath, not even placed properly. I found several fragments of code hinting at a proper solution with tikz but my first attempts were not successful as there is a small space added before and after the dotted character when using this code: \newcommand{\udensdot}[1]{%
    \tikz[baseline=(todotted.base)]{
        \node[inner sep=1pt,outer sep=0pt] (todotted) {#1};
        \draw[densely dotted] (todotted.south west)--(todotted.south east);
    }%
}%
Comment: I have little experience with `tikz`.  A gray, dotted underline would be nice, but I'm not sure how to get it.  Have you seen https://tex.stackexchange.com/q/244732?  I suggest gray so that it's clear that these are obscured characters, not velarized letters.
Comment: I do feel overwhelmed by the TikZ-manual. But i will dig into it. To get the dots gray should be achievable, it seems.
Answer: I decided to go with a gray underlining. The tikz-solution works because it is possible to combine a bolder gray line with a thin black underline, so I actually can combine both. Another advantage is, that the tikz-underlining allows line break within strike out and underlining. I basically could use the code posted by Peter Grill here:
Mixing underline and strike-out
The only disadvantage is that tikz needs several runs.


What spells can not be found as loot in Skyrim?

Question: Yes, I'm aware that spell books are rare loot and if you want them all, it is more useful to buy them. But I don't want to - it is a roleplaying thing. I'm not a mage anyway and don't have the maciga for most of the spells, I want them all because I'm a hopeless idealist. And I don't mind that it will take time, Skyrim is still one of my favorite games and exploring and clearing new dungeons is what's fun, so having the possibilyty of finding a new spell adds to that.
Therefore I do not want to buy even one spell that can be obtained otherwise. Which are the spells that never drop, even inside Black Books, and can only be obtained by buying them?
Answer: According to the uesp wiki (http://www.uesp.net/wiki/Skyrim:Spells),

Nearly all spell tomes can also be found randomly as loot. The only spell tomes that can not be found randomly are quest-specific spell tomes (those that can not be purchased), tomes added by Dawnguard or Dragonborn, and master-level tomes. The appearance of random tomes is dependent upon your character's overall level (but is not related to your skill in the magic school, unlike tome purchases)
Comment: So does that mean that in Dragonborn dungeons, spell books added by Dragonborn do not drop? Also, (though my level is way high, over 70) I have have one master level spell drop inside a Black Book - I have the Flame Thrall spell, and my destruction is only 80, and was below that when I got it.
Comment: That is interesting, especially about the master level spell. Looks like the wiki is off on this one.
Comment: Actually going through the list, the wiki does mention this further down (Flame Thrall: "Found in Apocrypha - The Sallow Regent"), but this seems to be the only exception to the rule


connect to ssh server thru 80 via HTTP proxy?

Question: Please help:
I want to connect to my ssh server at home
However, I'm behind a corporate (CORP) firewall,
which blocks almost all ports (443, 22, 23 etc).
But it seems that 80 is not blocked,
coz I am able to surf the web after I login
(i.e. IE sets to CORP's proxy server, and
start IE -> displayed CORP intranet portal -> type in google.com ->
dialog pops up for userid + pwd ->
login successful, and surf without restrictions)
My ssh server listens at 443.
My question is:

Is there a way to connect from
  a computer behind the CORP firewall
  to the ssh server
  thru the 80 port, with the ssh server
  still listening on port 443?

Changing the ssh server to listen to port 80
is not an option, coz
my home ISP blocks 80.
Can I use a public proxy which listens at 80?
After some research on google
I found that there is something called
"connect to SSH thru an HTTP proxy"
using the Cockscrew software.
Is it useful?
Or is there some other way to solve the problem?
Comment: Talk to your system administrator. We're not here to help you circumvent restrictions imposed on end users.
Comment: @pehrs: why do we care?
Comment: Generally it's a bad idea to bypass firewalls at work. It tends to be ground for termination of your employment if somebody finds out.
Answer: PuTTY supports tunneling SSH through an HTTP proxy.  See this guide
Comment: +1 PuTTY is simple and works well with http-proxies.
Answer: Yes, corkscrew is useful.  See this tutorial.
Answer: You are unlikely to find any publicly accessible solution, though you could setup one for yourself fairly easily if you don't mind paying a few $ per month. Get the cheapest VPS you can find (this is the cheapest offer in the first page of WHT's VPS advertising area, you may find cheaper if you search deeper and are willing to pay quarterly or annually), make sure no web servers are installed, installed rinetd, and have it it listed on port 80 forwarding connections to your home server's SSH port. This requires no new software at either the client or server end but does require a new external machine with a little cost.
Your corporate firewall may do more than just block ports though - if they are using packet inspection it may block your SSH attempts as it could identify the connections as not HTTP.
Depending on what you wish to do with your SSH connection you could install something like this script on your web server. Obviously this would not allow port forwarding and such, but it would be fine for many uses. The traffic traversing your corporate firewall will be plain HTTP(S) connections so should pass even if packet inspection or other protocol limitation techniques are used, though if you use HTTP rather than HTTPS your then your traffic is not protected by encryption so your corporate overlords will be able to record the SSH sessions if they wish to do so. Also, make sure you are aware of relevant security matters configure any such script correctly - you don't want to open a route for anyone to get into your server unauthenticated...
Before considering any of the above give careful consideration to the fact that, as other have pointed out, circumventing security measures is likely to be a serious enough matter for your employer that your job is at risk if your actions are noticed.
Comment: you meant "to your home server's port 22", i guess
Comment: @hop: ah, yess. will correct.
Answer: You could set up a SOCKS proxy running on your server. That tunnels any kind of TCP connection over HTTP. Your corp firewall might be looking for that kind of thing, though.
@hop I don't think you understand. You set up a proxy on the OUTSIDE of the corp network, and connect to it through the firewall on port 80 or 443. That proxy is outside the corp network, so connections that travel through that proxy are not firewalled.
Comment: that socks proxy would be on the wrong side of the corporate firewall
Answer: There is another option that I've had some success with. It is possible to tunnel SSH over DNS. See http://www.dnstunnel.de/ for how. Once you have that running you can use your SSH server as a socks proxy and then tunnel everything else through that.
As stated above by others while it may appear that 443 and 80 are not interfered with you really can't be entirely certain thats the case.
and as always, be careful not to annoy your sysadmin :)


Microsoft All in One Media Keyboard Scrolling

Question: So, just finished building an HTPC for the living room and have only one small issue. The keyboard listed above works perfectly, except the two finger scroll on the track pad. Even the media keys elicit a response, which I didn't expect. Running most current version of Ubuntu, windows website shows absolutely zero support/drivers for Linux. Manual says to download the Microsoft software to customize media keys, but seems to indicate the two finger scrolling gesture should work native with the keyboard. Ubuntu settings do not detect a track pad under mouse and keyboard, only settings shown are pointer speed and double click speed. I would really like to stop using a dedicated wireless mouse on my leg, so any and all advice is appreciated. (Even if it is to buy a different, compatible keyboard)
Thanks so much!
Answer: I am using ubuntu 17.10 and the two finger scroll worked for me straight out of the box.
I've had this keyboard a mere minutes, but I am very happy with it. I don't think the backlit keys justified the extra money being sought and while the logitech k400 does have pg dn, pg up, home and ins keys, the larger track pad and spill resistance of the Microsoft product persuaded me me to purchase it instead.
As a linux novice I rely on reading forums for help, so I tbought I would reciprocate accordingly with where I could about what is a good product to purchase with a linux system.


Are Yongnuo flashes interchangeable between dslr's or are they brand specific?

Question: I see the Yongnuo triggers are brand specific. For example YN-622c (for Canon) and the YN-622n (for Nikon)
I was looking at the YN-565 and YN-568 but did not want to make a wrong purchase and buy a Canon one as I have a Nikon.
Answer: If they're TTL-capable flashes, they're brand specific. And they only come in Canon and Nikon flavors.  The manual-only models are not brand-specific and will work on any ISO-compatible hotshoe.
It's not a 100% reliable guide (e.g., the YN-500EX is an exception), but generally any model that ends in a 0 is manual-only and brand-agnostic; any model that doesn't end in 0 is probably TTL capable and may be Canon-only, or come in both Canon and Nikon flavors.
If both Canon and Nikon versions of a TTL Yongnuo model exist, (e.g., YN-568EX, YN-565EX), the Canon version will have silver lettering on it; the Nikon version will have gold lettering.
There are a lot of weird listings on Amazon/eBay for Yongnuo flashes that are the Canon version that also say they're TTL-compatible with Nikon cameras. My personal take is that these are listings by people who simply move lots of units of lots of cheap Chinese goods, and they don't actually know anything about flashes. And in a weird way, the iTTL-compatibility claim is true, because Yongnuo's "EX"-designated flashes can be used as CLS slaves in the Nikon optical wireless triggering system as well as Canon's wireless eTTL, but they won't work as an iTTL flash on a camera or TTL radio trigger hotshoe unless they have the Nikon pin placement on the foot.
Check the pins on the feet
The pins will always tell you what kind of flash you're dealing with. If there's a single pin to communicate the sync signal in the center of the foot, it's a manual-only flash and brand-agnostic.  The TTL-capable, brand-specific models will have pins on the foot that match the hotshoe contact placement for the specific brand:

So, for example, as a Nikon shooter, you want a YN-568 with a foot that looks like this:

On the YN-622 triggers, you'll note that the same applies to the pins on the feet of those triggers, as well as the passthrough shoes up top.
With Yongnuo's manual triggers (RF-60x triggers), however, this only holds on the feet (they use a TTL signal for wake-up, but only for wake-up); the passthrough shoe on top has a modified contact placement that covers the wake-up signal in both patterns. This is why they don't do full TTL passthrough, but the YN-622s do.
Answer: I'm using  2 Yongnuos YN560 IV with all their settings on my Fuji xt 2 both as TTL and with Fuji flash as trigger.
Before used them with Nikon.  Seems to me they aren't brand specific.  Isn't the big pin on hot shoe all that matters? Might be wrong but I'm having fun with them flashing away through selected channels and chosen power output
These are FANTASTIC ... the ridiculous money I wasted on branded stupid fragile speed lites...
Comment: The YN-560IV is a manual-only flash; it can't do TTL. That's why it works with all the different brands.


How can we conduct experiments to verify formulas without special equipment? How was it done in the past?

Question: If we wanted to verify experimentally/empirically as laymen without special instruments a formula such as $s=16t^2$ which is used to approximate the distance s, in feet, that an object falls freely from the rest in t seconds by using a stone for instance, how exactly would we do it?
I image that someone would need to write down the distance s the stone traveled at various times t, tabulate the results and try to derive the formula.
But what is not clear to me is how the actual experiment is done. I.e. how would one proceed to "mark" where the stone is on its falling path at various times without having special equipment? E.g. how would they do it 400 years ago?
Comment: Tall tower with windows at multiple heights, some reasonably accurate time piece, and walking up/down a lot of stairs...
Comment: @Jim You make models based on the experiments and observations you can perform. You verify them with more experiments. Eventually, you get data that suggests you need a better model. So, start with the Galilean gravity we're talking about here. Newton finds that a different model fits orbits (while preserving the Galilean model as a limiting case). Later, Einstein took another step, with a completely different model that nevertheless matched Newton and Galileo within their restricted domains. The method is as reliable as the data it's based on.
Comment: @JonCuster: When doing such a test with e.g a tower of 10 story's high, how can we be sure that the values we observed will be valid if the tower went on higher? Isn't this just inductive reasoning hence not reliable?
Answer: This was done initially by "diluting" the force of gravity by rolling objects down a ramp, tilted at a shallow angle to the horizontal. Trigonometry yields the resulting (reduced) force accelerating the object. The dilution was chosen to accommodate the clocks available at the time and the experiment conducted for a range of ramp lengths.
Comment: How were they confident that the calculations based on trigonometry gave the almost the same result as free fall?
Comment: @ jim, arithmetic did the trick.
Comment: @Jim Galileo did experiments using ramps & water-clocks. He also used singing to do timing in some of his experiments. See https://galileoandeinstein.phys.virginia.edu/lectures/gal_accn96.htm His reasoning was sound, but he would certainly agree that empirical testing of physical hypotheses is vital. And of course, Galileo's work predates Newton's experiments and development of mechanics and calculus.
Answer: Let several persons climb a tower to different heights
proportional to the squares of integer numbers, $h_n=h_1 n^2$
(for example $1$ m, $4$ m, $9$ m, $16$ m, $25$ m, $36$ m, ...).
Then let all of them drop a stone at exactly the same moment in time.
According to the law $h=\frac{1}{2}gt^2$
the falling times will be
$$t_n=\sqrt{\frac{2h_n}{g}}=\sqrt{\frac{2n^2h_1}{g}}=n\sqrt{\frac{2h_1}{g}}$$
That means the stones are expected to hit in equal time steps of $\sqrt{\frac{2h_1}{g}}$.
So listen to the stones hitting the ground
and check if you really hear the expected beat with equidistant time steps.
Humans are very good at detecting small deviations from this regular beat.
Comment: How does the height being proportional to the square root of integer numbers help? Wouldn't this idea work if heights were 1m, 2m, 3m etc?
Comment: Also extrapolating that the measurements for those meters are valid for higher levels isn't it inductive reasoning and hence it does not really prove the outcome?
Comment: @Jim Sorry, I meant to say proportional to squares, not square roots.
I have corrected this and added some explanation.
Comment: 1) Why did you define it as $h_n=h_1 n^2$ and not just $h_n= n^2$?
Comment: 2) How did $h=\frac{1}{2}gt^2$ appear? The formula I was asking is different. I suppose you give an experimental approach for another example? But in this case it seems that those who perform the experiment are already aware of the formula right? But what if they weren't aware and were trying to derive it?
Comment: 3) "That means the stones are expected to hit in equal time steps of $\sqrt{\frac{2h_1}{g}}$." I don't really understand this statement fully. I think it means that from one sound to the next the time interval is $\sqrt{\frac{2h_1}{g}}$?
Comment: @Jim Galileo was from a generation before Descartes, so his understanding of geometry was Euclidean rather than analytic. He observed the parabolic trajectory of bodies in free fall, and interpreted it as a consequence of uniform horizontal motion together with accelerated vertical motion. Now, of course, we understand that there's a formula for a parabola, but I don't know that Galileo ever used it.
Comment: @Jim 1) Because $h_n$ is a length (with measurement unit: feet or meter)
 and $n^2$ is dimension-less (without a unit)
Comment: @Jim 2) Your formula $s=16t^2$ and my $h=\frac{1}{2}gt^2$ are essentially  the same because gravity of the earth is $g=32\text{ feet/sec}^2$.  In physics people often guess a law, and then perform experiments to verify or falsify the guessed law.
Comment: @Jim 3) Yes, that is what I mean.


Symlink directory into an existing directory (merging files)

Question: I have a ghc directory containing ghci.conf:
$ tree ghc
ghc
└── ghci.conf

0 directories, 1 file

And I want to create symbolic link at $HOME/.ghc, but the latter directory contains other files and directories.
When doing:
$ ln -s -f ghc ~/.ghc

I get a symbolic link to my ghc under $HOME/.ghc, which is not what I intended:
$ ls -l ~/.ghc
total 16
lrwxr-xr-x  1 jviotti  staff    41 Nov 30 20:40 ghc -> /Users/jviotti/dotfiles/link/ghc
-rw-r--r--  1 jviotti  staff  1883 Nov 30 20:34 ghci_history
drwxr-xr-x  3 jviotti  staff   102 Jul  9 13:35 x86_64-darwin-7.6.3
drwxr-xr-x  3 jviotti  staff   102 Nov 11 13:51 x86_64-darwin-7.8.3

A quick solution do accomplish this would be to iterate trough the contents of ghc and execute ln -s on each file, however I was wondering if there is an easier way to instruct ls to merge the files automatically of trying to create a symbolic link to a directory from an existing directory.
Does such option exist?
Answer: Forgive me if a misunderstand the question, but is 'rsync' an option to get the directories in sync and THEN recreating the symlink you want?


Replacing double light switch 4 black and one red

Question: I hear a popping from one of my old double switches. I opened it up to understand the wiring before replacing. I have 4 blacks and 1 red. I have attached pictures. One of the switches controls a light that is controlled by a different switch as well. That switch has a dimmer. The other switch is the only control for another light. How do I go about replacing this? Also, why do I have no ground included?
Comment: Hello, and welcome to Home Improvement. Big, big props: you did NOT pull everything apart and then come to us when it didn't work, as 90+% of our new visitors do. Makes things much easier for us.
Comment: The red, and one of the blacks, goes into the same cable.  Which black? Can you mark it and the red with yellow tape?
Comment: It looks like the black, directly under the red, is in the same sheath. IE, the top left black cable.
Comment: __Also, why do I have no ground included?__  Not all (older?) switches have ground connections.
Answer: It looks like you have something like this.

The top switch is the three way and controls the light along with the other dimmer switch. The bottom one is is a single pole that controls a light by itself. You're going to want to buy a switch just like this and wire back the same. As long as you make sure the wires go back in the same positions, you'll be fine.
As someone mentioned, putting some tape around the wires as they are pulled off might help to identify them later. You can get different colors of electrical tape at a hardware store. Also important is to make sure the power is turned off to that switch before working on it to avoid being shocked.
When in doubt, call a professional.
Comment: That's the solution. Thank you. I missed this switch the first time I walked through the store.


Why did the women need to prepare spices when Nicodemus and Joseph had already wrapped a 100 pounds of spices into the linen they wrapped Jesus in?

Question: The Gospels state that the women who accompanied Jesus to Jerusalem from Galilee saw Joseph and Nicodemus (Luke 23:50-56 and John 19:38-42) not only entomb the body of Jesus but saw them wrap Jesus in linen with 100 pounds of spices (John 19:35), Why then, did they need to prepare spices the same evening of the entombment and then to buy spices after the Sabbath was past (Saturday night)? The women also saw them roll the stone to the door of the tomb (Mark 15:46-47; Matthew 27:60). If the women saw the tomb was shut (see also Mark 16:3) and the stone was great (Mark 16:4), why didn't they bring someone with them that had enough strength to roll the great stone away from the door? Instead, they went alone without any guarantee someone would be there. So in reality I have two questions. Can someone help?
Comment: Yet again, I suggest it is a good idea before raising a 'contradiction' question, to search the site as all these so-called (and well known) 'contradictions' have been previously researched (both on the internet generally and on this site particularly).
Comment: While the wording of the question is very different, answering is basically the same.
Comment: Hi Saber Truth, it looks like this question will be closed due to the similarity to another one. I would like to see people have at least 10 hours to justify how their question is different from an apparently similar one. I don't know how practical that is, though.
Comment: @Martin My answer to this question and the answers to the duplicate are near the same.
Comment: @PerryWebb Yes, I suppose the downside of leaving question open for editing is that they attract answers which moderators frown upon. Maybe there is a way around that by putting a notice on the question.
Answer:
Either the women didn't know.  Joseph of Arimathea and Nicodemus were secret disciples.  However, then we need to explain how the women knew where the tomb was.

After these things Joseph of Arimathea, who was a disciple of Jesus, but secretly for fear of the Jews, asked Pilate that he might take away the body of Jesus, and Pilate gave him permission. So he came and took away his body. 39 Nicodemus also, who earlier had come to Jesus by night, came bringing a mixture of myrrh and aloes, about seventy-five pounds in weight. 40 So they took the body of Jesus and bound it in linen cloths with the spices, as is the burial custom of the Jews. 41 Now in the place where he was crucified there was a garden, and in the garden a new tomb in which no one had yet been laid. 42 So because of the Jewish day of Preparation, since the tomb was close at hand, they laid Jesus there.
(John 19:38–42, ESV)

Most likely they had gathered the spices before for Jesus' burial as a tribute and wanted to put them on Jesus in addition to what was  already done.

50 Now there was a man named Joseph, from the Jewish town of Arimathea. He was a member of the council, a good and righteous man, 51 who had not consented to their decision and action; and he was looking for the kingdom of God. 52 This man went to Pilate and asked for the body of Jesus. 53 Then he took it down and wrapped it in a linen shroud and laid him in a tomb cut in stone, where no one had ever yet been laid. 54 It was the day of Preparation, and the Sabbath was beginning. 55 The women who had come with him from Galilee followed and saw the tomb and how his body was laid. 56 Then they returned and prepared spices and ointments.
On the Sabbath they rested according to the commandment.
(Luke 23:50–56, ESV)

Joseph of Arimathea was rich.  He had the tomb and spices already available, probably for a relative or himself.

57 When it was evening, there came a rich man from Arimathea, named Joseph, who also was a disciple of Jesus. 58 He went to Pilate and asked for the body of Jesus. Then Pilate ordered it to be given to him. 59 And Joseph took the body and wrapped it in a clean linen shroud 60 and laid it in his own new tomb, which he had cut in the rock. And he rolled a great stone to the entrance of the tomb and went away. 61 Mary Magdalene and the other Mary were there, sitting opposite the tomb.
(Matt. 27:57–61, ESV)

The women gathering their spices weren't ready and had to wait until after the Sabbath.

23:54–56. Because bodies decomposed rapidly, mourners were allowed to anoint, wash and wrap the body in its shrouds even on the sabbath. More elaborate arrangements that these loyal women disciples wish to bestow on Jesus, however, might wait until the sabbath (sundown Friday evening to sundown Saturday evening) has passed.
--
Keener, C. S. (1993). The IVP Bible background commentary: New Testament (Lk 23:54–56). Downers Grove, IL: InterVarsity Press.


Compute the image of the house under the transformation ABC.

Question: http://puu.sh/54hzk.png is the question at hand.
Can someone explain this to me? Is this just knowledge of the matrix transformations such as reflections and shears? What order are the transformations done in?
Answer: It depends on what you mean by order. In general, matrices are not commutative, so when you are transforming some vector by $ABC$, then $ABC\vec{v} \neq ACB \vec{v}$ and so on. You should apply this transformation strictly as $ABC\vec{v}$. However, matrices are associative, so once you have the matrix multiplication set up, you can multiply adjacent matrices in pairs. For example, $ABC = (AB)C = A(BC)$.
The matrices do not correspond to the image -- they transform any vector in $\mathbb{R}^2$ into another vector. You can represent the points on the house by vectors, thus allowing you to "apply ABC to the house". For example, I might choose the point on the top right corner of the house, which is the vector
$$\left(
\begin{array}{c}
 1 \\
 1.5 \\
\end{array}
\right)$$
To find where that point of the house ends up after applying the transformation, I would multiply:
$$\left(
\begin{array}{c}
 x \\
 y \\
\end{array}
\right) = ABC\left(
\begin{array}{c}
 1 \\
 1.5 \\
\end{array}
\right)$$
Answer: Here's a hint/rough sketch of how to apply $C$ that should give you an idea about what to do to complete the problem. My suggestion would be to not multiply the matrices together. Try to describe in words what each matrix does to a vector $v$ in the plane. Each of these matrices does a very specific and easy to describe thing to vectors in the plane. For example, for any real numbers $x$ and $y$
$$
\begin{pmatrix}1 & 1\\ 0 & 1\end{pmatrix}\begin{pmatrix}x\\ y\end{pmatrix}
 = \begin{pmatrix}x+y \\ y\end{pmatrix}.
$$
So if we think of the vector $(x,y)^T$ as the point $(x,y)$ in the $xy$-plane in the usual manner, then you can visualize $C$ as taking the point $(x,y)$ and moving it horizontally (i.e., in the $x$ direction) by $y$ units. (Note: Here the notation $(x,y)^T$ denotes the transpose of $(x,y)$ for convenience, i.e., $(x,y)^T = \begin{pmatrix}x\\y\end{pmatrix}$.)
Now think about what this does to the points on the house from your picture. If you can't imagine what this looks like yet, that's OK. It will help to plot the points $C(x,y)^T$ in a plane where, say, you first only look at points $(x,y)$ that are the corners of the polygons in your figure (the corners of the house and door, the vertices of the triangle forming the roof, etc.). You can then get what the image of the house should look like by "connecting the dots". Note from what we saw above, the larger the $y$-value of the point $(x,y)$ the farther to the right its image $C(x,y)^T$ will be shifted. So you should expect the image of the house under $C$ to look similar to your current house but leaning to the right.
Once you have that settled, move on to the next matrix $B$ and consider what it does to the house. Again, my suggestion would be to first look at what $B$ does to an arbitrary vector $v = (x,y)^T$ and then apply this information to the problem.
You can do all of this for the matrix $ABC$ after multiplying the three matrices together, too, but it's harder to visualize how $ABC$ transforms vectors than it is to visualize how $A$, $B$, and $C$ do so separately.

Edit: Forgot to respond to your second question (about the order in which you multiply the matrices together). Matrix multiplication is associative but not commutative. In other words, for any $n \times n$ matrices $X$, $Y$, and $Z$
$$
X(YZ) = (XY)Z\qquad\qquad\text{(Associativity)},
$$
and so you can compute $XYZ$ by first computing $XY$ and then right multiplying by $Z$ or by first computing $YZ$ and then left multiplying by $X$.
However, matrix multiplication not being commutative means that sometimes
$$
XY \neq YX.
$$
So you couldn't, for example, compute $ABC$ by computing $AC$ and then right multiplying by $B$, since it's not necessarily true that $ACB = ABC$.


Properties of light and refractive index of materials

Question: Why does the refractive index of a material dependent on the wavelenght of light incident on it.
Comment: Because the electrons/phonons/polaritons/plasmons/etc. in the material all have different dispersion relationships based on solid state physics, so the material overall will react differently to different wavelengths.
Comment: @JonCuster isn't it rather the coupling of the light field and density of states of these parcticles/quasi-particles rather than their dispersion relation which is making the difference?
Comment: JonCuster pretty well explained the reason, but it is too few to an answer. But it is not his fault, simply the question is too simple. If you want to know some deeper reason, or its mechanism, then ask for that, by extending your question. Do it fast, until it will be closed.
Comment: @user_na - well, the dispersion relationships for each mode come directly in to the overlap integral, so I'm not sure I see how there is a real distinction to be made. If a dispersion relationship were different, you would get different coupling.
Answer: The refractive index is defined by the ratio
$$n=\frac{v}{c},$$
between the speed of the light in the medium and the speed of the light in the vacuum. From the wave equation we read the velocity $v$ in terms of the permittivity and permeability of the medium,
$$v=\frac{1}{\sqrt{\epsilon\mu}},$$
and, in particular, for the vacuum we have
$$c=\frac{1}{\sqrt{\epsilon_0\mu_0}}.$$
From the three equations above and the definition of relative permittivity and relative permeability we can write the refraction index as
$$n=\sqrt{\epsilon_r \mu_r}.$$
For simplicity, let us consider non magnetic materials (non metals would be enough), so that
$$n=\sqrt{\epsilon_r}.$$
This relative permittivity depends on the frequency of the incident wave (or rather its wavelength), so $n=n(\omega)$ (or $n=n(\lambda)$).
To get an intuition on this frequency dependency we have to recall that from a microscopic point of view, the electronic permittivity actually measures how well an electronic cloud can be polarized by an electromagnetic field. The greater the distortion, the greater the dipole moment, the atomic polarizability, and the permittivity. The botton line is that we can understand how the refraction index depend on frequency if we understand how the electronic polarization depends on frequency.
A simple model to explain that consists on considering the centre of mass of the electronic cloud a driven oscillator. The equation of motion is
$$\frac{d^2x}{dt^2}+\gamma\frac{dx}{dt}+\omega_0^2x=qE,$$
where $qE$, the electric force, is the driven term. The constant $\omega_0$ is the cloud's natural frequency of oscillation and gamma is same damping. The amplitude of oscillation (for the steady solution) is frequency dependent, it follows curves like those in the figure

where the different curves are associated to different damping. As we can see, light with different wavelengths (different frequencies) put the electronic cloud to oscillate with different amplitudes leading to different refractive index. Of course this is a crude model, but it can predict refraction index that agrees with the experimental result up to the fourth decimal place.
Comment: But none of this looks like the answer to my question.My question is towards the behaviour of light of different wavelegth in the same medium.The refractive index increases on decreasing the wavelenth of the incident light. What causes this to happen and why not light's velocity decrease by the same amount when incidented in the same medium.And this property is so vivid that it causes dispersion and so what makes all of this stuff , this light's behaviour to change on the change in its wavelength.
Comment: @akashagarwal But that is exactly what I answered. Just replace frequency by inverse of wavelength in my answer. Different wavelengths of light interacting with the same atom put the electronic cloud to oscillate with different amplitudes.


What is the function of the capacitor \$C_\infty\$ in connecting the DC supply of a common-emitter amplifier to ground?

Question: this circuit using voltage divider but I don't know why there is \$C_\infty\$ connecting to ground and DC voltage supply. Also, normally, many CE models I have seen don't have \$R_L\$ included to serve as load. Can the variation of \$R_L\$'s value changes the gain?
Comment: Which node are you calling ground?  I'm confused by the schematic too.  It looks like it's been partially rearranged to suit AC analysis, where all DC voltages are AC grounds.
Answer: Your schematic is a weird way of showing the first step of an AC analysis. The original DC version should like this:

simulate this circuit – Schematic created using CircuitLab
For AC analysis, you're supposed to deactivate any DC sources. Voltage sources become short circuits, and current sources become open circuits. Your schematic shows this with an infinite capacitance shorting out U0. Everything connected to U0 was moved to the bottom of the schematic, probably because they will later be shown connecting directly to ground.
C1 and C2 are DC-blocking capacitors, and CE is an emitter bypass capacitor. These will be large enough to act as short circuits at the VG frequency. Thus, the final AC version will look something like this:

simulate this circuit
The transistor will be replaced with a small-signal model like the hybrid-pi model or the T model:

simulate this circuit
The value of RL definitely affects the gain! The output of your amplifier can be simplified to look like a voltage source in series with a resistance. (Just like VG and RG!) The output resistance and RL form a voltage divider, which affects the total gain. Likewise, the input resistance and RG form another voltage divider. In a common emitter amplifier, the input resistance comes from R1, R2, and the transistor base. The output resistance comes from RC and the transistor collector.
Comment: Hi, the \$C_\infty\$ is connect from DC source directly to the ground. As I know there'll be no current run through it so what's the point of having it. Can you explain to me how difference the circuit will behave with and without it? Additionally, why AC analysis of amplifier is important?
Comment: I don't think they meant to have a physical capacitor there. It just shows what happens to the DC voltage source at AC. AC analysis gives you the gain, input impedance, and output impedance of the amplifier, which are the most important things. DC analysis just gives you the bias point.
Answer: The capacitor across Uo the supply voltage that's labled C infinity is just a power supply bypass cap .It should have a low impedence at the  lowest frequency of interest.Large values are common here.The output impedence of your amplifier is close to Rc so loading it will affect the output volts unless Rl is very high compared to Rc.


Is sea water more conductive than pure water because "electrical current is transported by the ions in solution"?

Question: Apparently, electrical charge is transported by the ions dissolved in water, is this true?
Answer: Yep. Pure water is an extremely bad conductor of electricity, it has very few ions. Water with an electrolyte (like NaCl) is a much better conductor of electricity; as the ions can migrate. Migration of ions is just like migration of electrons. If you place an imaginary surface inside the cell, there will be net negative charge crossing over to the positive terminal and vice versa. This is just like a current. Since there is net current inside, its conducting.
The equivalent conductance (a loco* chemistry concept) of a solution is simply the sum of the conductances of its constituent parts (Kohlrausch law). Here, $\Lambda$ denotes equivalent conductance of a portion of the solution, and $\lambda$ is the same for ions. Just a notation.
For pure water,
$$\Lambda_{H_2O}=\lambda_{H^+}+\lambda_{OH^-}$$
Now, since the concentrations of $H^+$/$OH^-$ are small ($10^{-7} M$ at STP), the $\lambda$s and thus $\Lambda_{H_2O}$ are pretty tiny.
For water with salt in it, we get
$$\Lambda_{soln}=\Lambda_{H_2O}+\Lambda_{NaCl}=\lambda_{H^+}+\lambda_{OH^-}+\lambda_{Na^+}+\lambda_{Cl^-}$$
Since $NaCl$ nearly dissociates completely, we get large $\lambda$s, and thus $\Lambda_{soln}$, which can be related to conductivity (in the aforementioned loco way).
So, pure/distilled water is an extremely bad conductor, while impure water with ions in it is a good conductor
 * Loco because they assume a 1 m cell throughout, and don't keep the necessary $\text{m}^{-1}$ or whatever in their units. Due to this fixing of parameters, yes, we get that $\text{Area of plates}=\text{volume}$, which lets us relate it to concentration; but this gives us predictions for a specific case; when length of the cell is 1 m only. For some reasons these predictions are blindly applied to the general case. The whole thing gets confusing if you try to visualise it.
Comment: @AJP yes. This takes time (forever) though, since there is a solid-ion equilibrium for the impurities, when the ions start disappearing ions are created from the solid. But it will try to maintain the equilibrium so the number of new ions will be much smaller. This process will go on, effectively to infinity since the equilibrium laws won't let the amount of solid or ions disappear completely. Practically, there will be some point when these numbers become too small, but again, practically this is very far off.
Comment: Excellent, thank you.  So it's not the electrons moving through the water but the ions moving to counter balance the charge of the electrodes (+ve ions going to an electrode with electrons and anions going to the electrode lacking electrons).  So under AC this can occur forever, but under DC, at some point presumably, the current will eventually stop flowing once all the available ions have moved to either electrode.  Is that correct?  (and thanks for the foot note!... awesome :-) )
Comment: Hey @Manishearth do you have any thoughts on "... presumably, the current will eventually stop flowing once all the available ions have moved to either electrode. Is that correct?".  Thanks.


Optical Tunneling

Question: Is there light tunneling taking place in optically transparent mediums like glass? wherein light travels a larger path in these mediums without interacting with atoms and without any change in velocity, frequency, wavelength or momentum? but just getting affected by the field of atom and following the least resistant path through the medium?
Comment: related question http://physics.stackexchange.com/questions/30325/why-isnt-light-scattered-through-transparency/30330#30330
Answer: There is no analog of tunneling in transmission through a transparent medium, that's the light analog of the particle phenomenon of entering a region of potential energy.
The direct analog of light tunneling is transmission through a narrow gap between two materials, where you would have total internal reflection on one side of the gap if the other material wasn't there. This was understood in Maxwell theory without quantum mechanics in the 19th century. Even though you have total internal reflection, there is still an evanescent wave outside which allows the light to continue if a new medium which does not require total internal reflection at this angle is just brought within a few wavelengths of the total-internal-reflection point. The photon is going across a region which is forbidden in the geometric optics (classical) limit.
Answer: I'm not sure what you mean by light tunneling through an optically transparent medium without interacting. When light propagates through a medium, it does interact with the medium. You can think of a transparent medium to be composed of a lot of tiny dipoles which are driven to oscillate due to the electric field of the light. This sets up a net polarization in the medium which then affects the electric field, changing the velocity of propagation through the medium (or the refractive index).
Light does tunnel through barriers. Imagine a prism such that light enters it and then gets internally reflected through one of the surfaces. Bring another prism, with one of its surface parallel to the internally reflected surface, close to the original prism, such that there is a very thin air-gap between the two surfaces. If the air gap were zero, then its as if there was no interface, and you would observe no internal reflection. If however, the air gap was non-zero but really small (on the order of the wavelength of the light), then some of the evanescent wave would get into the second prism and start propagating in it.
Comment: If you want to think of light propagation in a medium in terms of photon scattering, then you cannot consider just a single atom. Indeed, if a single photon scatters off an atom, then there are infinite possibilities for the scattering. However, a medium has essentially an infinite number of such scatterers and you have to add up the probability amplitudes of all these scattering events. Doing so you find that most of the scattering is in the forward direction. Also, the Kramers-Kronig relations imply that if a medium "bends" light, it has to absorb some if it as well.
Comment: If light is interacting with atoms of the medium, for example if we consider only single atom and photon, then there are infinite possibilities in which light may be emitted in other direction (scattering) but light travels in a particular direction, pointed by the momentum, if momentum has to be conserved, so as to keep the initial direction, then it can only be bent by the field of atom and not absorbed and remitted, thus photon travelling a longer distance in a denser medium as proved by QED. Similar like electrons through a conductor and superconductor

Optical Tunneling


changing TEMPORARY TABLE default collation

Question: when I use CREATE TEMPORARY TABLE to create a temporary table, the collation of this table is utf8_unicode_ci by default. why by default it is utf8_unicode_ci? How can I change the default?
Comment: Try `show variables like "%character%" ;`  `show variables like "%collation%";` and pay particular attention to the collation_database
Answer: The CREATE TABLE syntax allows for specifying the character set and collation
The MySQL Documentation for CREATE TABLE shows this syntax:

CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
    (create_definition,...)
    [table_options]
    [partition_options]

table_options:
    table_option [[,] table_option] ...

table_option:
    ENGINE [=] engine_name
  | AUTO_INCREMENT [=] value
  | AVG_ROW_LENGTH [=] value
  | [DEFAULT] CHARACTER SET [=] charset_name <<------ (YOU NEED THIS OPTION)
  | CHECKSUM [=] {0 | 1}
  | [DEFAULT] COLLATE [=] collation_name <<------ (YOU NEED THIS OPTION)
  | COMMENT [=] 'string'
  | CONNECTION [=] 'connect_string'
  | DATA DIRECTORY [=] 'absolute path to directory'
  | DELAY_KEY_WRITE [=] {0 | 1}
  | INDEX DIRECTORY [=] 'absolute path to directory'
  | INSERT_METHOD [=] { NO | FIRST | LAST }
  | KEY_BLOCK_SIZE [=] value
  | MAX_ROWS [=] value
  | MIN_ROWS [=] value
  | PACK_KEYS [=] {0 | 1 | DEFAULT}
  | PASSWORD [=] 'string'
  | ROW_FORMAT [=] {DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT}
  | STATS_AUTO_RECALC [=] {DEFAULT|0|1}
  | STATS_PERSISTENT [=] {DEFAULT|0|1}
  | TABLESPACE tablespace_name [STORAGE {DISK|MEMORY|DEFAULT}]
  | UNION [=] (tbl_name[,tbl_name]...)

Therefore, your syntax should be something like this:
CREATE TEMPORARY TABLE tblname
(
) ENGINE=MyISAM CHARACTER SET '...' COLLATE '...';

Give it a Try !!!
If you want to manipulate the default options for collation, you have the following:

collation_connection
collation_database
collation_server

These variables can be changed at the Global or Session Level.
If you want to set the collation permamnently, you could put it in /etc/my.cnf
[mysqld]
collation_connection = 'collation_connection'

and restart mysql
If you only want this for an individual BB Connection, you would run this in the session
SET collation_connection = 'collation_connection ';

See my recent post Why are there different levels of MySQL collation/charsets? to see installed character sets and collations.
Comment: How can I change the default collation at the server/DB level?
Comment: Updated my answer ...
Answer: normally the temp table takes the default from server/database level. if you want to change it, then change at the sever/DB level and this will impact all your other objects as well.
if you want it only once for your current temp table, then declare it strongly at your temp table creation process.
Comment: How can I change at the server/DB level? by which query or config?


Extract energy from magnets

Question: Is it possible to "extract" energy from a magnet, making it lose its magnetism? Or, to put in another way, is magnetism a form of energy? (I am not talking about potential energy in a magnetic field).  Since matter is equivalent to energy, is  the property of magnetism equivalent as well?
Answer: Perhaps, the following paper is relevant -
"Extracting Energy from an External Magnetic Field"
http://arxiv.org/abs/1208.1702
I have only quickly perused it, but it appears to provide a way to extract energy from a uniform, uni-directional magnetic field by surrounding it with a rotating cylindrical magnetic insulator.
Possibly, this approach could extract energy from a portion of a magnet's field which is small enough to be approximately uniform.
Comment: How is that different from an electric generator, if movement is involved?
Answer: Magnetism (as we know it in magnets) is nothing more than the alignment of a great number of atoms in similar directions so they end up producing a noticeable magnetic field. In a way you're taking advantage of the inherent kinetic energy associated with electrons orbiting a nucleus. The question would then be could we take advantage of that energy - which we really can't without disrupting the atom itself. The energy we get from atoms (fusion/fission) is from the bonds in the nucleus. The orbital speed of the electrons are defined by their orbital (energy level), and to modify it disrupts the atom's makeup.
Comment: Heating a magnetized bar demagnetizes it, it shows it is in a lower energy state than the ambient temperature . It can only gain energy and be destroyed not give energy.
Comment: @annav It could still be in a metastable state, with heating required to take it over the barrier, but generally it will depend on the specifics of the thermodynamics.
Answer: Under normal circumstances you cant extract the energy from a permanent magnet, but it is there and under special conditions you can extract that energy to do usable work. However any scenario where you extract energy from a magnet the result would be a magnet that is weaker or completely demagnetized afterwards.
Consider a hypothetical thought experiment to prove this out.. Suppose we have some magnet where its curie point, the temperature at which it will loose its magnetism, is only infinitesimally higher than the surrounding room temperature. the magnet is sitting on the floor and you tie a weight to it. An iron plate is some distance above it.
In this scenario the magnet will be pulled upward towards the plate and lift the weight upward. Then when the magnet strikes the metal plate the kinetic energy would raise the temperature of the magnet ever so slightly pushing it past its curie point, demagnetizing it and causing the weight to then drop to the floor again. The magnet will now be completely demagnetized and the energy which was stored in its magnetic field was the energy that moved the weight in the first place.
Keep in mind this is similar to just lifting the weight the same distance yourself and then dropping it. Even though gravity is what makes the weight fall it is the initial energy you put in with your arm lifting the weight that is doing the work, not gravity. In the case of the magnet that energy comes from the magnetic field and not from your arm.
Also note that if the magnet never demagnetized and the weight was only moved upward and never fell again no actual work was done because you'd have to put energy into the system to get the magnet away from the metal. Without the magnet demagnetizing it would be no different than spring where the spring itself isnt really what is doing the work as you have to put energy into it.
Comment: Do you know approximately how much energy is released when the magnet is demagnetized? Is there any way to find out what the energy difference is between a non-magnetized magnetic material and the same magnetic material but magnetized, at the same temperature? In other words, how much energy it in theory would be possible to extract from a magnet?
Comment: Will a permanent magnet really have the same Curie point when close to another magnetic substance? The interaction energy between the magnet and the other object will be negative, and demagnetizing the magnet would effectively make that interaction energy zero. In other words, at least the absolute value of that interaction energy would be needed to demagnetize the magnet in this situation. Where do you get that energy from?
Comment: @HelloGoodbye You dont need to add energy to demagnetize a magnet, only to magnetize it. The analogy would be a bowling ball on the top of a cliff. You have to put energy in to get it there, a lot of energy. But if you want to throw it off the cliff you do not need to put that energy in again just to make it fall. You need to add just a tiny bit of energy to push it off the cliff. In this case you only need to add a little energy (heat) to get it demagnetized at which point the energy of the magnet will be released and it will become demagnetized. The energy put in will eventually be heat.
Comment: @HelloGoodbye We might get in trouble for doing this in comments, may want to open a question or move to chat. But for a quick answer see this quora discussion that asks your exact question: https://www.quora.com/How-much-energy-is-stored-in-a-magnet-How-efficient-is-it-as-a-battery-What-is-the-quickest-way-to-turn-all-its-magnetism-into-electricity
Answer: You cannot extract energy from magnets. You can just disrupt the orientation of the molecules(dipoles) in the magnet(by heating or so..). The answer to the question is same as the answer to the question, "Can you remove charge of an electron??" or "Can i extract energy from the charge of an electron?". Its impossible. You can just disrupt the molecules or decompose the electron(to quarks).
Comment: Electrons are [elementary particles](https://en.wikipedia.org/wiki/Elementary_particle) and cannot be decomposed into quarks (which are another kind of elementary particles).

Extract energy from magnets


What is the command for opening a PDF file?

Question: I saw many answer related this question in "Stack Overflow" and "Ask Ubuntu". I also tried with this solution. I tried gnome-open and evince commands. This command works when the filename has one word. But my filename is "Java The Complete Reference Ninth Edition.pdf". Is there any solution to open this file using command in Terminal. I am using Ubuntu 14.04 LTS.
Comment: OpenSaysMe, I could not resist....
Answer: Spaces in file names need to be escaped with a \, for example with a document called "Document Name.pdf" you need to type "evince 'Document\ Name.pdf'. Autocompletion in your shell should do this for you if you type for example "evince Doc" and press tab.
Answer: There are two ways to quickly open a pdf file from the terminal in Ubuntu without typing the pdf file's full name.

You can use gnome-open or evince followed by a space character and then drag the pdf file's icon into the terminal to automatically input its full name.
cd to the directory containing the pdf file and then you can use gnome-open or evince followed by a space character and type the first few letters of the pdf file's name followed by the Tab key to automatically complete the full name of the pdf file in the terminal. All of the space characters in the pdf file's name will be automatically replaced by a \ character, used to escape the next character in the string from not having a special meaning in the Bash shell, followed by a space character.
Answer: You can also do it with the filename between '"' characters, for example:
evince "Java The Complete Reference Ninth Edition.pdf"


Model retraining

Question: I trained my model with RandomForestRegressor(), but now my training data is updated continuously. So I have to train my model with all the train data set i.e past and new data, or can I directly train my model only with new data? But if I train model only with new data, will it keep the pattern in existing data or not?
Comment: Tree-based models are not trained in an Incremental way.
Comment: That has already been explained in the answer (not all algos accept that approach by default)
Answer: For sure you have to make sure your final model has seen all the history training dataset some time .
The only chance you have is to retrain your model (and not all the training algorithms accept it) in the fashion of incremental learning, where an already trained model is updated by being exposed to the new incoming data (used in online learning for instance), but it does not mean to completely retrain your model only on new data. In case you need it, have a look at it: https://scikit-learn.org/0.15/modules/scaling_strategies.html#incremental-learning  where decision trees are not actually included for incremental learning
In your case, I recommend you (in case you can deal with performance cost) to retrain with all your available dataset.

Model retraining


Difference between 不了 and 不到

Question: This question focuses on the differences between 了and 到.

What's the difference between verb + 不了 and verb + 不到?
Do the differences also apply to Cantonese?

Examples:

收不到 vs 收不了
幫不到 vs 幫不了
來不到 vs 來不了
Comment: ["不了""不起""不到"的区别](http://www.cim.chinesecio.com/hbcms/f/article/info?id=7ff26b3ac39b4832819d7c47c78cd12f) This could help answer your question.
Answer: The differences are contextual. I do agree it is very subtle.
到 is used when the verb, (action), produces a response from a purely physical perspective. Whereas, 了 is from a non-physical moral, legal, ethical standpoint.
So, in 收不到 vs 收不了, the former connotes the physical impossibility of receiving whatever is sent, perhaps it was physically destroyed in an air accident; hence 不到, (physically not arrive) The latter connotes the non-physical inability or refusal to accept for some moral, legal, ethical reason; perhaps it was seen as a corrupt bribe, hence 不了, (can't)
Here is an example to illustrate the point further:-
(a) 起不了 vs (b) 了不起
The former is physically impossible to rise up.
The latter means something amazing or superlative.

Difference between 不了 and 不到


What is causing my web app to stall on some Android devices? How do I detect?

Question: I am building a cross-platform mobile app in HTML, CSS & Javascript and publishing it to Android and iOS using PhoneGap as a wrapper.
I have published in the Android Market, and am finding out through customer reviews that the app stalls early during the user setup phase, with some users/devices. I do not have any kind of error handling and reporting set up in the app, and the Android Market's crash report is still giving me 0 crashes after hundreds of downloads and half a dozen disappointed reviews.
I haven't thought about error reporting while building the app. Now that it exists, is there a simple way to implement it? I'm currently trying to intercept the window.onError event, but is that the right approach?
I've read about Acra http://code.google.com/p/acra/ but this seems to be Java error reporting. If Javascript fails on a missing function or non-existing object, will Acra report the details of that?
EDIT:
Since my app has internet access anyway, I implemented a listener for the javascript 'onerror' event, which provides a description of the error.
This listener uses Cordova/PhoneGap to detect if there is a connection: if there is, it sends the error description to the server along with the device. If there isn't, it attaches an event listener to Cordova/PhoneGap's 'online' event to send the error when the device goes online.
It's not running perfectly yet (which is why I'm not adding this as an official answer)
Answer: No, and believe me, it's a bad thing for a huge amount of us!


Where is the /boot partition?

Question: I'm trying to boot my pi running NOOBS, and my monitor's not displaying any input. After checking other similar problems, I was advised to place the lines hdmi_config=1 and hdmi_safe=1 in the config.txt file under the boot partition. Where is this file located? I'm looking for them on my PC, but I can't seem to locate the file or the partition.
Answer: NOOBS has 3 partitions.  One is FAT, another FAT32 (which has the images) and an EXT4. The First is mounted as /boot when the OS is running. This is where you should find your files.
Comment: How do I access these to add code for when the pi boots?
Comment: Any computer Windows/Mac/Linux can see the FAT partitions. You use your normal File Manager and Editor.

Where is the /boot partition?


Item properties pane serialization or deserialization using the JSON JavaScriptSerializer issue SPO

Question: We have done SP2013 to the Online migration for a large custom document library having around 600k items. We are getting the error like "Properties can not be displayed having error: Error during serialization or deserialization using the JSON javaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property". As per my understanding, It is dependent on the number of columns/content types that the DocumentSet has. The properties pane tries to serialize this in a JSON in order to render the results and it is unable to do it. any help or any lead to resolving it much appreciated.
Answer: Whether you have many lookup columns show in this list which exceed the recommended value?
If true,please refer to Brian Meeuwenberg's reply in this post, the suggested fix from Microsoft is to reduce the number of lookup columns.


How to convert array of png image data into video file

Question: I am getting frames from canvas through canvas.getDataURL().
However, now I have an array of png images, but I want a video file.
How do I do this?
var canvas = document.getElementById("mycanvaselementforvideocapturing");
var pngimages = [];
...
setInterval(function(){pngimages.push(canvas.toDataURL())}, 1000);

Answer: For a full browser support way, you'll have to send your image batch to the server then use some server-side program to do the encoding.
FFmpeg might be able to do it.
But in newest browsers the canvas.captureStream method, has been implemented.
It will convert your canvas drawings to a webm video stream, recordable with a MediaRecorder.
All of this is still not stabilized though, and will only be available in latest version of browsers, probably with some flags set in user's preferences (e.g chrome needs the "Experimental Web Platforms" one).

var cStream,
  recorder,
  chunks = [];

rec.onclick = function() {
  this.textContent = 'stop recording';
  // set the framerate to 30FPS
  var cStream = canvas.captureStream(30);
  // create a recorder fed with our canvas' stream
  recorder = new MediaRecorder(cStream);
  // start it
  recorder.start();
  // save the chunks
  recorder.ondataavailable = saveChunks;

  recorder.onstop = exportStream;
  // change our button's function
  this.onclick = stopRecording;
};

function saveChunks(e) {

  chunks.push(e.data);

}

function stopRecording() {

  recorder.stop();

}

function exportStream(e) {
  // combine all our chunks in one blob
  var blob = new Blob(chunks)
    // do something with this blob
  var vidURL = URL.createObjectURL(blob);
  var vid = document.createElement('video');
  vid.controls = true;
  vid.src = vidURL;
  vid.onended = function() {
    URL.revokeObjectURL(vidURL);
  }
  document.body.insertBefore(vid, canvas);
}

// make something move on the canvas
var x = 0;
var ctx = canvas.getContext('2d');

var anim = function() {
  x = (x + 2) % (canvas.width + 100);
  // there is no transparency in webm,
  // so we need to set a background otherwise every transparent pixel will become opaque black
  ctx.fillStyle = 'ivory';
  ctx.fillRect(0, 0, canvas.width, canvas.height);
  ctx.fillStyle = 'black';
  ctx.fillRect(x - 50, 20, 50, 50)
  requestAnimationFrame(anim);
};
anim();
<canvas id="canvas" width="500" height="200"></canvas>
<button id="rec">record</button>

And since you asked for a way to add audio to this video, note that you can use cStream.addTrack(anAudioStream.getAudioTracks()[0]); before calling new MediaRecorder(cStream), but this will currently only work in chrome, FF seems to have a bug in MediaRecorder which makes it record only the stream with the tracks it was defined to... A workaround for FF is to call new MediaStream([videoTrack, audioTrack]);
[big thanks to @jib for letting me know how to actually use it...]
Edit: video.onend --> video.onended
Comment: @Kaiido I've updated the [MDN article](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder_API/Using_the_MediaRecorder_API). Thanks for pointing out it was outdated! Yes please file a bug.
Comment: @Kaiido Your workaround is unnecessary. Instead of checking state in `ondataavailable`, use `recorder.onstop` instead, and it'll [work the same in both browsers](https://jsfiddle.net/tmwLxjLy/) regardless of the number of chunks.
Comment: Thanks. I must test it on firefox (as chrome is not supporting it).
What does the 30 mean in `canvas.captureStream`? Is that the framerate.
Comment: Yes it is, just like the comment says ;-)
Comment: Oh, oops! Missed that. Thanks a million.
Comment: Just wondering.. Does this support audio, if audio is playing on the webpage.
Comment: @DavidCallanan, I'm sorry, actually chrome does support recording the canvas stream too. It's just both browsers implementations are so different I though it didn't, and I might got fooled by MDN's article about it... Anyway, added a way for saving both canvas, and a small note about recording audio, which won't be possible currently for your use case...
Comment: To get chunks in Firefox, call [`recorder.requestData()`](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/requestData) to trigger `ondataavailable`.
Comment: @jib, actually, reading your link, I'm not sure it would help a lot, since my horrible workaround to handle both implementations doesn't really needs the chunks, it's just that chrome does fire the ondataavailable automatically after some short time, with the chunks in it. So `requestData` would allow to produce the same behavior only by calling it manually in a timed loop right? But then, won't l get incorrect data for chrome? I hope all this will finally stabilize...
Comment: Also, this is a [w3c spec](https://w3c.github.io/mediacapture-record/MediaRecorder.html#dom-mediarecorder-requestdata), not whatwg.
Comment: @jib ah that makes sense ;-) will update accordingly. The MDN article I point to in my answer is really misleading then. Also, do you know for the FF bug I mention about stream.addTrack and MediaRecorder taking only the initial tracks? Or should I open a bug report?
Comment: @Kaiido Yes, please [file a bug](https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&component=Audio%2FVideo%3A%20Recording). Did you try `new MediaStream([canvasTrack, audioTrack])`?
Comment: @jib "TypeError: Argument 1 is not valid for any of the 2-argument overloads of MediaRecorder.". Tried with both streams and with both tracks in an array, in a Blob containing both tracks/streams. Anyway, that would still be a bug that it doesn't record the manually assigned tracks.
Comment: @jib, not sure it needs an SO question either, since the only response I would get would be "file a bug" and that it's now done : https://bugzilla.mozilla.org/show_bug.cgi?id=1296531
ps: OP asked for audio in comments, and anyway, chrome doesn't work either.
Answer: The MediaRecorder + canvas.captureStream approach in Kaiido's answer is definitely the way to go at the moment - unfortunately as of writing it's only supported in Chrome and Firefox.
Another approach that will work when browsers adopt webp encoding support (only Chrome has it, currently) is this:
let frames = []; // <-- frames must be *webp* dataURLs
let webmEncoder = new Whammy.Video(fps);
frames.forEach(f => webmEncoder.add(f));
let blob = await new Promise(resolve => webmEncoder.compile(false, resolve));
let videoBlobUrl = URL.createObjectURL(blob);

It uses the whammy library to join a bunch of webp images into a webm video. In browsers that support webp encoding you can write canvas.toDataURL("image/webp") to get a webp dataURL from a canvas. This is the relevant bug report for Firefox webp support.
One cross-browser approach as of writing seems to be to use libwebp.js to convert the png dataURLs output by canvas.toDataURL() into webp images, and then feeding those into the whammy encoder to get your final webm video. Unfortunately the png-->webp encoding process is very slow (several minutes for a few seconds of video on my laptop).
Edit: I've discovered that with the MediaRecorder/captureStream approach, you can end up with low-quality output videos compared to the whammy approach. So unless there's some way to control the quality of the captured stream, the whammy approach seems like the best approach, with the other two as fall-backs. See this question for more details. Use this snippet to detect whether a browser supports webp encoding (and thus supports the whammy approach):
let webPEncodingIsSupported = document.createElement('canvas').toDataURL('image/webp').startsWith('data:image/webp');


Analysing crash dump in windbg

Question: I am using a third party closed source API which throws an exception stating that "all named pipes are busy".
I would like to debug this further (rather than just stepping through) so I can actually learn what is happening under the covers.
I have taken a dump of this process using WinDbg. What commands should I now use to analyse this dump?
Thanks
Comment: Is it managed or native? Can you throw some more details?
Answer: You could start doing as follows to get an overview of the exception:
<code>!analyze -v
</code>
Now you could load the exception context record:
<code>.ecxr
</code>
And now... just take a look at the stack, registers, threads,...
<code>kb     ;will show you the stack trace of the crash.
dv     ;local variables
</code>
Depending on the clues you get, you should follow a different direction. If you want a quick reference to WinDbg I'd recommend you this link.
I hope you find some of this commands and info useful.
Answer: In postmortem debugging with Windbg, it can be useful to run some general diagnostic commands before deciding where to dig deeper.  These should be your first steps:
<code>.logopen <filename>    (See also .logappend)
.lastevent             See why the process halted and on what thread
u                      List disassembly near $eip on offending thread
~                      Status of all threads
Kb                     List callstack, including parameters
.logclose
</code>
These commands typically give you an overview of what happened so you can  dig further.  In the case of dealing with libraries where you don't have source, sending the resulting log file to the vendor along with the build # of the binary library should be sufficient for them to trace it to a known issue if there is one.
Answer: This generally happens when a client calls CreateFile for an existing pipe and all the existing pipe instances are busy. At this point CreateFile returns an error and the error code is ERROR_PIPE_BUSY. The right thing at this point is to call WaitNamedPipe with a timeout value to wait for a pipe instance to become available.
The problem generally happens when more than one client tries to connect to the named pipe at the same time.
Answer: This is an excellent resource for using WinDbg to analyze crashes that may be of some use: https://www.networkworld.com/article/953697/how-to-solve-windows-10-crashes-in-less-than-a-minute.html
The article is for Windows 10, but it contains links to similar information for earlier versions of Windows.
Comment: The link is broken.
Comment: @UserControl: thanks for pointing that out. I've updated the answer.
Comment: link broken again
Answer: I assume that the 3rd party dll is native (Otherwise, just use Reflector)
Before using WinDbg to analyze the dump, try using Process-Monitor (SysInternals, freeware) to monitor your process's activity. if it fails because of a file system related issue, you can see exactly what caused the problem and what exactly it tried to do before failing.
If Process-Monitor wasn't enough than you can try and debug your process. but in order to see some meaningful information about the 3rd party dll you'll need it's pdb's.
After setting the correct debug symbols, you can view the call stack by using the k command or one of it's variations (again, I assume you're talking about native code). if your process is indeed crashing because of this dll than examine the parameters that you pass to it's function to ensure that the problem is not on your side. I guess that further down the call stack, you reach some Win32 API - examine the parameters that the dll's function is passing, trying to see if something "smells". If you have the dll's private symbol you can examine it's function's local variables as well (dv) which can give you some more information.
I hope I gave you a good starting point.

Analysing crash dump in windbg


language change my laptop windows 8

Question: I have an HP laptop computer running Windows 8. It was purchased in the NORWAY and is in NORWEGIAN. I need to  use English  and have the entire system language be English. Can I change this myself or do I need to purchase Windows 8 in English and install that on the laptop?
Comment: You don't need to purchase an english version. You can change it using language settings
http://my.safaribooksonline.com/book/-/9780735670952/4dot-customizing-windows-8/id679819
Comment: @Khaleel you should post this as answer.
Comment: @Khaleel I encourage you to type in your comment as *asnwer*, you'll just get the right answer.
Answer: No need to purchase any new version.
Just go to the language settings in control panel, there you will find an option to download language packs. Download English language pack, It is free and should take only a few minutes.
Now set out as your default language.
Answer: You can always change the language display settings,for the whole interface and also change the keyboard layout settings (maybe this last might be a lil complicated but it can be fully solved too).
So, for changing display language, you must download some language packs, avaliable for a plenty ammount of languages.These you can get them from here:
Microsoft Windows site for language packs downloading.
And instructions are avaliable here:
Windows 8 language customization.
In resumed words, all you have to do is:

Going  to the first web site,
find and download the US English language pack,
then go to Control Panel, Clock, Language and Region settings,
go exactly for Language settings
and in Add Language option, load the previously downloaded language
pack.

I think you can even download the pack at the moment once you get to step 5.

language change my laptop windows 8


Has the rate of time passage been measured?

Question: We know certain astronomical events in our neighborhood occur within a specific time interval,for example a solar flare, a nova, etc. Does the time interval of these 'standard metronomes' change if they are further away (millions of light years?)
Comment: An important fact about things million of years away is that they are moving relative to us, so experience relativeistic time dilation.  There is a standard clock to use, the rate of decay of nickle56 as this causes the brightness of supernovae to change at a regular rate.  As far as I recall, the predictions of relativity are supported by these observations, that is, there is time dilation for objects moving at high velocity, but not for merely being in a different place, I'll try to find where I read this.
Answer: Yes, there are two good examples that I know of that have been used to show that a natural phenomenon appears to show time dilation that is consistent with the redshift that they are observed at.

Type Ia supernovae have decay light curve widths that are reasonably standardised (there is some dispersion). However, when the widths of distant supernova light curves are observed, they appear to be dilated by a factor $(1+z)$, where $z$ is the redshift (e.g., Blondin et al. 2008).

Another piece of evidence comes from Gamma Ray bursts under the assumption that they should have (statistically) a similar mean duration at any point in the universe. Zhang et al. (2013) find that the duration of "long" GRBs at known redshifts (and measured in the same rest-frame energy) varies as $(1+z)^{0.94±0.26}$, consistent with cosmological time dilation. See also Littlejohns & Butler 2014.
Comment: Thank you for your reply. So my naive interpretation of these data is that the rate of time passage is due only to relativistic time dilation (due to motion) and there is no other phenomenon. For example, if the duration of long GRBs was different than the time dilation predicted by their redshift, then we would have to say that time passage was intrinsically different at some time in the past. Because time passage is therefore constant across the age of the universe, we can then state the corollary, the speed of light is constant across all space AND time.
Comment: @aquagremlin if the amount of time dilation was a factor of 1 (i.e. independent of redshift), then it would be evidence for the so-called "tired light" explanation of the redshift. It isn't. Interpretation for dilation of $(1+z)^\alpha$ where $\alpha \neq 1$ could be that the nature of these events has changed over cosmic time. The speed of light is defined to be constant, it is meaningless to discuss a change in the speed of light; only dimesnsionless constants can show evidence for variation.


Display ValueMember when selection is changed

Question: I have searched all day for what I would think would be a simple concept, but that is what I get for thinking.
I have a DataGridView control with a ComboBox column that uses a DataTable as its DataSource as follows:
    With CType(dgvICS213.Columns(GridCol("CostBasis").Name), DataGridViewComboBoxColumn)
        .DataSource = Common.ExecuteQuery("SELECT ID, CostBasis FROM ICS213CostBasis", CommandType.Text)
        .DisplayMember = "CostBasis"
        .ValueMember = "ID"
    End With

The database table stores the value (ID) from the combo box.
I use the DefaultValuesNeeded event to set new values to the DisplayMember (CostBasis) value:
Dim dgv As DataGridView = sender
CType(e.Row.Cells(GridCol("CostBasis").Index), DataGridViewComboBoxCell).Value = CType(dgv.Columns(GridCol("CostBasis").Index), DataGridViewComboBoxColumn).Items(0).Item(1)

I also use the DisplayMember value to fill existing rows from a database query (handling the DataError event)
So far, so good but when I select a an entry from the combox, the ValueMember is displayed in the combo instead of the DisplayMember. Can someone explain where I am going wrong.
Comment: this shouldn't be relevant but why do you have two different gv names here : `dgvICS213` and `dgv`
Comment: It is the same grid - I amended the post.
Answer: I faced the same problem and solved it by changing the field in the database from byte to int16.


How to prove that $ f(x) = \sum_{k=1}^\infty \frac{\sin((k + 1)!\;x )}{k!}$ is nowhere differentiable

Question: This function is continuous, it follows by M-Weierstrass Test. But proving non-differentiability, I think it's too hard. Does someone know how can I prove this? Or at least have a paper with the proof?
The function is
$$
f(x) = \sum_{k=1}^\infty \frac{\sin((k + 1)!\;x )}{k!}$$
Thanks!
Comment: See also [this question](http://math.stackexchange.com/questions/67120/) -- not an exact duplicate but with much the same properties.
Comment: I wonder if it can be proven using induction and the fundamental theorem of calculus.
Answer: (Edited: handwaving replaced by rigor)
For conciseness, define the helper functions $\gamma_k(x)=\sin((k+1)!x)$. Then $f(x)=\sum_k \frac{\gamma_k(x)}{k!}$.
Fix an arbitrary $x\in\mathbb R$. We will construct a sequence $(x_n)_n$ such that
$$\lim_{n\to\infty} x_n = x \quad\land\quad \lim_{n\to\infty} \left|\frac{f(x_n)-f(x)}{x_n-x}\right| = \infty$$
Such a sequence will directly imply that $f$ is not differentiable at $x$.
Let $x'_n$ be the largest number less than $x$ such that $|\gamma_n(x'_n)-\gamma_n(x)|=1$. Let $x''_n$ be the smallest number larger than $x$ such that $\gamma_n(x''_n)=\gamma_n(x'_n)$. One of these, to be determined later, will become our $x_n$.
No matter which of these two choices of $x_n$ we have $|x_n-x|<\frac{2\pi}{(n+1)!}$ so $\lim x_n=x$.
To estimate the difference quotient, write
$$f(x) = \underbrace{\sum_{k=1}^{n-1}\frac{\gamma_k(x)}{k!}}_{p(x)}+
\underbrace{\frac{\gamma_n(x)}{n!}}_{q(x)}+
\underbrace{\sum_{k=n+1}^{\infty} \frac{\gamma_k(x)}{k!}}_{r(x)}$$
and so,
$$\underbrace{f(x_n)-f(x)}_{\Delta f} = \underbrace{p(x_n)-p(x)}_{\Delta p} +
\underbrace{q(x_n)-q(x)}_{\Delta q} +
\underbrace{r(x_n)-r(x)}_{\Delta r}$$
Of these, by construction of $x_n$ we have $|\Delta q| = \frac{1}{n!}$.
Also, $r(x)$ is globally bounded by the remainder term in the series $\sum 1/n! = e$, which by Taylor's theorem is at most $\frac{e}{(n+1)!}$. So $|\Delta r| \le \frac{2e}{(n+1)!}$.
$\Delta p$ is not dealt with as easily. In some cases it may be numerically larger than $\Delta q$, ruining a simple triange-equality based estimate. But it can be tamed by a case analysis:

If $p$ is strictly monotonic on $[x'_n, x''_n]$, then $p(x'_n)-p(x)$ and $p(x''_n)-p(x)$ will have opposite signs. Since $q(x'_n)=q(x''_n)$, we can choose $x_n$ such that $\Delta p$ and $\Delta q$ has the same sign. Therefore $|\Delta p+\Delta q|\ge|\Delta q|=\frac{1}{n!}$.
Otherwise, $p$ has an extremum between $x'_n$ and $x''_n$; select $x_n$ such that the extremum is between $x$ and $x_n$. Because $p$ is a finite sum of $C^\infty$ functions, we can bound its second derivative separately for each of its terms:
$$\forall t: |p''(t)| \le \sum_{k=1}^{n-1}\left|\frac{\gamma''_k(t)}{k!}\right| \le
\sum_{k=1}^{n-1}\frac{(k+1)!^2}{k!} \le
\sum_{k=1}^{n-1} (k+1)!(k+1) \le 2n!n $$
Therefore the maximal variation of $p$ in an interval of length $\le\frac{2\pi}{(n+1)!}$ that contains a stationary point must be $\left(\frac{2\pi}{(n+1)!}\right)^2 2n!n = \frac{8\pi^2n}{(n+1)^2}\frac{1}{n!}$. The $\frac{8\pi^2n}{(n+1)^2}$ factor is less than $1/2$ for $n>16\pi^2$, so for large enough $n$ we have $|\Delta p+\Delta q|\ge \frac{1}{2n!}$.

Thus, for large $n$ we always have
$$|\Delta f| \ge \frac{1}{2n!} - \frac{2e}{(n+1)!} = \frac{1}{n!}\left(\frac{1}{2}-\frac{2e}{n+1}\right)$$
and therefore
$$\left|\frac{f(x_n)-f(x)}{x_n-x}\right| \ge \frac{(n+1)!}{2\pi}|\Delta f| \ge \frac{n+1}{2\pi}\left(\frac{1}{2}-\frac{2e}{n+1}\right) = \frac{n+1}{4\pi}-\frac{e}{\pi} \to \infty$$
as promised.
Comment: this site should have a +10 arrow :) Nice argument! Thanks for sharing this.
Comment: @Henning Makholm Sorry for my stupid question Henning, but I only see that $
\Delta p
$ it´s bigger than $
\frac{1}
{{n!}}\left( {1 - \frac{{n^2 }}
{{n + 1}} - \frac{{2e}}
{{n + 1}}} \right)
$
 but the factor $
\left( {1 - \frac{{n^2 }}
{{n + 1}} - \frac{{2e}}
{{n + 1}}} \right)
$
 it´s negative. The other step that i don´t understand it´s why also it´s bigger than $$
\frac{1}
{{n!}}\left( {1 - \frac{{2e}}
{{n + 1}}} \right)
$$
since $$
\left( {1 - \frac{{2e}}
{{n + 1}}} \right) > \left( {1 - \frac{{2e}}
{{n + 1}} - \frac{{n^2 }}
{{n + 1}}} \right)
$$
Comment: @Susuk, that's what the handwaving at the end was for. I will edit the proof to make it more explicit how this part works.
Comment: @Susuk, now de-handwaved. That was harder than I had expected ...
Comment: @HenningMakholm  Nice answer! Thanks!


Twisted Deferred.addCallBack() vs. yield and @inlineDeferred

Question: Is there any reason to use one over the other?
Do they have the same performance?
Answer: I tend to use inlineCallbacks for multistep initialization (such as auth) to some service where each subsequent step depends on a result from the previous step, for example. Other than these situations, I tend to find that inlineCallbacks could lead to lazy programming that could slow down your app.
Here's an example:
@defer.inlineCallbacks
def some_func():
    res1 = yield call1()
    res2 = yield call2()
    ... do something with res1 and res2 ...

If call1 and call2 are completely independent calls that you want to parallelize, this function will end up serializing those calls. To convert this to a parallelizing call you should:
@defer.inlineCallbacks
def some_func_better():
    d1 = call1()
    d2 = call2()
    res1 = yield d1
    res2 = yield d2

This way you get call1 and call2 running simultaneously, but you wait on the results as they come in. So, while it's possible to get the same benefits out of stock deferreds, it seems inlineCallbacks just make it too easy to implement the former solution.
Also, keep in mind that you still have to wrap try...except blocks around all your yield calls, as they're the only way to trap errbacks within your code (unless a calling function of an inlineCallbacks function handles the errback at that level).
So, I find it's not really a question of performance per se, but rather good habits that would make me recommend against inlineCallbacks in general - they're still great for quick code snippets, multi-stage initialization routines, or tests for example.
Comment: Surprisingly `inlineCallbacks` don't support `cancel()`. I once had to rewrite several ready-to-read functions to messy constructs of nested callbacks since I needed the ability to `cancel()` the process.
Answer: The differences should really be subtle. If this code really does run that often that it matters, perhaps you should look into your application design. Otherwise, take the variant which is more easy to read, you will have to make heads and tails out of it a couple of months or years down the road.
EDIT: If you really want to know, here is how you find out (it could, after all, be implementation specific to your python version): run both version in a tight loop and measure the time. Increase loop count until the time difference between the versions is far greater than the time variance of the same version across multiple runs. Repeat after changing python version, OS etc.
Comment: Also, it's more useful to do that test on your own application code, because it depends how you use these.
Answer: use defer.inlineCallbacks can make your codes easiler to read..
and it somehow like corountine style: you neither block the call nor use chain of callbacks to build the whole logic. It is intuitive.


Simulate pressure brush with mouse in Illustrator

Question: I want to get a brush working like in Adobe Illustrator Draw where the ends are thinner than the main body. I cannot figure out how to apply a fake pressure like this without having a drawing pad/tablet, but I know this exists. I'm using the latest Illustrator CC. Thanks!
Comment: Hello and welcome, have you heard of width profiles?
Answer: There is the width tool (SHIFT + W), you should be able to achieve your desired effect with it.
First you draw a line with the pen tool, then use the width tool to change the width along the line.
Comment: Please explain better what you mean ...
Answer: Okay so first I have to tell you that there is no way you can simulate pressure with a mouse. It just cannot work since you will need to provide a value of pressure before you draw the line and then provide another value of pressure for the end of your line.
As you can see it would be very difficult but don't worry there is hope. You can make an outline of what ever artwork you wish to make with your mouse using the brush tool. Then you can edit the brush strokes with the direct selection tool and add depth and variation in the brush strokes by altering the position of the anchor points. I know it sound like a lot of work but adding a little depth and make basic artwork look impressive.
I hope my answer helps.