The best way to manage database changes

Question: What is the best way to manage database changes? I need to have a solutions regardless the database client's language. Also I'd like to be able to use specific database features in those changes such as stored procedures, triggers and so on.
Answer: First of all, make sure you have your entire Database Build scripted so you can rebuild the database if needed.
Each change should then be written as an Update script. That way you can run each change individually against the your databases.
Once the change has been commited to the codebase, merge the change script with the build process so it happens automatically...and then archive the change script in case any questions arise.
Answer: First and foremost, put all database changes in scripts and put them into the source control system.
Next remove any permissions to production that developers have. Exactly two people should have rights on production in a small to medium shop, the designated dba and his or her designated alternate. Once devs can't make changes to prod, you will find it easier to get them to actually write and use scripts.
Never run a script on prod that wasn't first loaded to QA or staging. If there are issues with the script, it should be found at this point.
Answer: Use idempotent change scripts (and maybe have a look at LiquiBase or dbdeploy).
Answer: Not sure what you are asking here, but if it's a good way to manage schema changes, and keeping them in synch between versions and deployments, it's hard to go wrong with Visual Studio Database Edition. It's sole purpose in life is to manage database schema changes, validate the schema, build and generate deployment scripts. If you have Visual Studio Developer Edition or Visual Studio Team Suite, you can get it for free.
Answer: Well, we are currently using Redgate's toolbelt which contains a Database Compare, Data Compare, etc.
You can also use any source control to track changes to your database objects.
Comment: If you're using Red Gate tools, you will be able to use SQL Source Control to connect your existing source control system to SQL Server via SSMS.
Answer: In my case, I build a SH script for this work:
https://github.com/reduardo7/db-version-updater
And a MySQL script:
https://github.com/reduardo7/db-version-updater-mysql

The best way to manage database changes


Dispelling contingent magic

Question: If someone casts a Contingency spell triggered by Dispel Magic, will the contingent spell still trigger if an attempt is made to Dispel Magic on the Contingency-caster, or will the Dispel Magic wipe away both the Contingency and the contingent spell before the Contingency spell can trigger?
Comment: [Related](http://rpg.stackexchange.com/q/27901/8610), I guess.
Answer: Contingency can almost-certainly interrupt dispel magic. The description of the casting includes words like "immediately" and "'cast' instantaneously" – and while 3.5's rules are notoriously vague on the subject of timing, many so-called Immediate Actions must interrupt things in order to be meaningful. Attacks of opportunity also explicitly occur prior to the provoking action, and also use the term "immediately."
Thus, contingency most likely occurs prior to the triggering action. Even if it doesn't, you could simply make the trigger be "someone is casting dispel magic" since that is a separate event from dispel magic actually affecting anything, and can be seen and understood (e.g. with Spellcraft, though contingency doesn't need it).
Either way, if contingency triggers and resolves prior to the effect of dispel magic, it will be discharged and therefore end – and thus will not still exist for dispel magic to dispel.
If someone has a contingency that is not triggered when they are affected by dispel magic, it can be dispelled as normal for a 6th-level spell with its caster level.

It is worth noting, however, that contingency is almost-certainly the most powerful spell in the game, due in no small part to its incredible ability to happen right when it is necessary if you word the condition correctly. That this furthermore comes at no cost to you and requires no action on your part is just massive icing on the cake. Thus, it would be safe to houserule some limitations into contingency to limit its potency.
Answer: Contingency cannot disrupt a dispel magic spell.  Contingency occurs after the condition is met - "In all cases, the contingency immediately brings into effect the companion spell, the latter being "cast" instantaneously when the prescribed circumstances occur.  The benefit of the contingency spell is that as soon as the condition is met the contingency is triggered - no casting time needed.  Since the duration of dispel magic is instantaneous, it can't be interrupted by an action that occurs after - furthermore (and specific to Dispel Magic) "The effect of a spell with an instantaneous duration can't be dispelled, because the magical effect is already over before the dispel magic can take effect". So your contingency instantaneous spell can't break my instantaneous spell for 2 reasons- 1 yours had to have occurred after mine - because yours was waiting on my spell, and because mine was instantaneous-and thus can't be interrupted.  In order for contingency to stop the spell you'd have to change it to "prognosticated contingency"
Even if a successful dispel magic was cast on the focus item itself then I would rule that the contingency does not fire immediately - but later in the 1d4 rounds that the suppression lasts (since the condition was met the contingency fired but since the focus was suppressed it couldn't pull the trigger- so to speak)
Casting Dispel Magic on the user has no effect on contingency since the magic items aren't affected
The language of contingency is specific and clear "In all cases, the contingency immediately brings into effect the companion spell, the latter being "cast" instantaneously when the prescribed circumstances occur....The companion spell occurs based solely on the stated conditions, regardless of whether you want it to".  There is no concept of contingency occurring prior to the conditions

Dispelling contingent magic


Bathroom Sink Odor

Question: I have recently replaced my bathroom vanity with a new vanity top and built in sink. When I turn on the water, especially the cold, there is a smell like rotten eggs that is coming from the vent in the sink. How can I get rid of this problem. This only occurs in this sink.
Comment: "Vent" in the sink?  Drain?  Overflow drain?  Faucet?
Answer: Use Clorox on the sink drain as follows:
Run some hot water from the faucet. Pour 1/2 cup of concentrated Chlorox down the drain. Rinse the concentrated chlorox out of the cup with 2 or 3 small potions of hot or warm water, putting each in turn into the drain. Let sit for 1 h or more. Report results to us.

Bathroom Sink Odor


If an astronaut had stationed in International Space Station for the duration of mission, 17 years, would he be older?

Question: Today the NASA International Space Station started the 100000 orbit after 17 years in the space.
I just wonder if there were a team of astronauts which were in the Lab for all the duration of last 17 years, how much older they would be due to the combination of Einstein's especial theory of relativity and general theory of relativity?
  Here is the link to NASA's youtube video. http://youtu.be/g5chOA-WEuw
Answer: This is anwered in Gravity on the International Space Station - General Relativity perspective, where we learn that time dilation in the ISS with respect to Earth equator is 1.00000000028655.
So after 17 years for us, the astronauts would come back younger by about 0.15 seconds than if they have stayed on the ground.
Note that a full GR treatment is required. Now it looks like NASA people (well, at least one of them) break the calculation into a SR part concerned with velocity and a GR part accounting for the difference in gravity. This approximation gives a result of about 0.16 seconds after 17 years, close but different.
Comment: Thank you very much. My only question is in a case like this if the astronauts use the Greenwich meridian as a marker for orbital coordinate angle when they just cross it for hundred k times, are they going to be 0.17 seconds too early?
Comment: Since they are in an accelerating frame relatively to us, what they see as simultaneous spacelike separated events is not what we see as such, so I am not too sure about the proper way to formulate that question, and even less about how to answer it. General relativity is tricky.
Answer: The first answer has all the results, but I will try to show some calculations, cause I have been writing them since there was no answer.
It is known from General Theory of Relativity (GTR) that the closer you are to a massive object - the slower the time goes. On the other hand Special Theory of Relativity (STR) gives us the next statement: the faster you move - the slower the time goes.
I can give here only a half of an answer due to my low knowledge of GTR.
Let's compare relative speeds of the ISS and a person on the surface of the Earth (on the equator):
We know that the orbit of ISS is approximatele 400 km. Knowing this we can calculate its speed: $$\frac{mV_1^2}{r+400000}=G\frac{mM}{(r+400000)^2}$$
where $r$ is a radius of the Earth, $M$-its Mass, $m$-mass of the ISS, $G$-Gravitational constant. From this we get $V_1=\sqrt{\frac{GM}{r+400000}}$
Also we can approximate the speed of a person on the surface of the Earth:$$V_2=r\frac{2\pi}{T}$$
So from theese two equations we can calculate the time dilation per second relatively to the center of the Earth for each case: $$\tau_1=\frac{1}{\sqrt{1-\frac{V_1^2}{c^2}}}, \tau_2=\frac{1}{\sqrt{1-\frac{V_2^2}{c^2}}}$$
Then we can calculate the difference and multuply it on 17 years:$$|\Delta \tau|*17*365*24*60*60=0.174634$$
For better understanding we can look at the problem from different angle i.e. Lorentz contraction (effect of STR) or contraction of the distances in the direction of speed:
Let the orbit length be $l=2 \pi (r+400000)$ With every turn the ISS will cover the distance equal to $l_1=l \sqrt{1-\frac{V_1^2}{c^2}}$. Then we just calculate the differenc between 2 times $$T_1=\frac{100000l}{V_1}, T_2=\frac{100000l_1}{V_1}$$ We get that $\Delta T \approx 0.17$
Note:we have only paid respect to time dilation due to STR. The GTR requires more complex calculations but it will shift our answer a bit to the direction of zero, because it will slow the time more for those who are closer to the center of the Earth.
Comment: As @stephane said we have to take the effect of acceleration due to both gravity and orbital circulation! my guess is the time space  of astronauts has 2 curves, possibly working at opposing directions.  in an  exaggerated way one can imagine when you floor the pedal in a car you are buying time! and if you go around circles  you lose time?
Comment: @kamran I understood what you are talking about. As I can suppose that it is not true, cause time dialation depends only on the speed: a clocks with a high speed have slower timeflow than the clocks in the rest. And it doesnt depend on the moving in circles or in a straight line. You wanted to say not orbital circulation but orbital speed.
Comment: There is centripetal acceleration: A=r. omega^2. it has to be accounted for.  According to GR space-time is shaped and modified by mass, momentum, acceleration, pressure...
Comment: @kamran ok. I am telling that I am not so deep in GTR. But I can say that the effect of it according to known figures and calculations I made is just approximately 0.02 sec in 17 years, whereas STR gives 0.15 sec.
Answer: our aging is directly proportional to metabolism of body and division,growth and death of cells of body and if gravity has some effect on the rate of above aspects astronauts will be definitely younger


Why are my potato leaf edges white?

Question: They sprouted out of the ground this way, but I've noticed more white in the past few days. They were planted around 2 weeks ago.
Answer: This is probably an attack by the potato flea beetle. Deficiency or simple necrosis (leaf tissue death by mechanical means) would be more yellow, brown or black; the white is distinctive. The beetles chew out the green layer inside the leaf and do so in a spotty fashion leaving circular patches, so the leaf surfaces remain but the green is gone, leaving a white appearance.
More detail on potato flea beetle in this University of Maryland Extension IPM paper.

Why are my potato leaf edges white?


How to ensure my dependencies use Safe Rust?

Question: Is there a way to declare in the Cargo.toml that my project depend only on 3rd-party crates that guaranteed to be using Safe Rust transitively?
I am new to Rust and Rust is new to me. I haven't had a chance to try anything out yet.
Answer: Analyzing Dependencies
First, check the crates.io documentation whenever the author(s) mention the usage of unsafe code. You can double-check it by searching for the unsafe keyword in the source code.
However, inspecting the crate's and its dependencies' source code is a tedious job. The tool called cargo-geiger provide statistics about unsafe usage in the crate and all its dependencies. After installing it, navigate to your Cargo.toml file and analyze it:
cargo geiger

It will download and scans all dependencies, then assigns one of the three symbols to a crate:
Symbols:
      = No `unsafe` usage found, declares #![forbid(unsafe_code)]
    ❓  = No `unsafe` usage found, missing #![forbid(unsafe_code)]
    ☢   = `unsafe` usage found

Note that it provides only the usage of unsafe keyword. But for more thorough analysis, review the code with cargo-crev to verify the trustworthiness and the security vulnerabilities of package dependencies. Additionally, if you found an unsafe code, you can report to the safety-dance repository.
Analyzing Project
Once you checked your dependencies, it is time to assess your project as well. For start, catch common mistakes using the clippy linter tool:
cargo clippy

Moreover, add the #![forbid(unsafe_code)] attribute to your files to communicate that unsafe code blocks are forbidden. I don't know if you can declare that your package (is guaranteed) to use safe Rust. But you can show a badge in the README.md file after eliminating all unsafe code:
[![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance/)

It will help others to discover that your crate is safe.
Note that there is no 100% memory safety in Rust because the standard libraries use (with great caution) unsafe blocks. Sometimes it is unavoidable. In any case, you should always try to implement safe code, even if you lose a little performance gain.
Less bug, less maintenance pain, more tRust.
Further readings:

https://github.com/rust-lang/unsafe-code-guidelines
https://rust-lang.github.io/unsafe-code-guidelines/
https://doc.rust-lang.org/nightly/nomicon/
Comment: `#![forbid(unsafe_code)]` isn't a macro, it's just a built-in attribute. But the rest of this post is very thorough!
Comment: Thank you for the review, the comment was incorporated.


Old Maid Card Game Probability Question

Question: I am not a math person but was shocked by something that happened when I played Old Maid for the first time ever with with my two young sons tonight. We were playing with a deck that had 37 cards in total, which means 18 pairs plus the Old Maid. When I dealt the cards into three groups (12+12+13), not one of us had a single pair in our hands. What is the statistical likelihood that this could happen? Can anyone figure out the math for me? I doubt this will ever happen again in our lifetimes, but maybe I'm wrong..
Comment: @JoséCarlosSantos Really? This is actually a good question because there's a real-life experience behind it (not a homework problem).
Comment: Seems that the odds are about $1:800$ according to my simulation with PARI/GP
Comment: Maybe , there is a direct way to solve this, but my approach would be to make a simulation.
Comment: This time I agree that it is an interesting question and should not be closed , let alone deleted , despite of the policy contents.
Answer: Let players $A,B,C$ have $13,12,12$ cards in their initial hand. Considering hand order to be important and labelling the Old Maid as $0$ and the pairs from $1$ to $18$, but not distinguishing the cards of each pair, the number of initial deals is $T=\frac{37!}{2^{18}}$.
There are two possibilities for a pair-free initial deal. The first is when the Old Maid is held by one of the $12$-handers, say $B$. The numbers of pairs shared between the three players are forced: denote by $N_{PQ}$ the number of pairs shared between $P$ and $Q$, then we have
$$N_{AB}+N_{AC}=13$$
$$N_{AB}+N_{BC}=11$$
$$N_{AC}+N_{BC}=12$$
Solving this gives $N_{AB}=6,N_{AC}=7,N_{BC}=5$. The exact number of pair-free deals with $B$ holding the Old Maid can now be computed as a product of several factors:

Where is the Old Maid in $B$'s hand (remember that we assume ordered hands)? $12$
Which $6$ ($5$/$7$) positions in $A$'s ($B$'s/$C$'s) hand hold cards whose matches are held by $B$ ($C$/$A$)? $\binom{13}6$, $\binom{11}5$, $\binom{12}7$
How many ways can the pairs be drawn betwen the ordered hands? $5!6!7!$
How many ways can the drawn pairs be numbered $1$ to $18$? $18!$

Thus the number of pair-free deals when $B$ has the Old Maid is
$$S_1=12\binom{13}6\binom{11}5\binom{12}75!6!7!18!$$
The other possibility is $A$ having the Old Maid, in which case $N_{AB}=N_{AC}=N_{BC}=6$ and the number of pair-free deals is by a similar computation
$$S_2=13\binom{12}6^36!^318!$$
The final probability, where $S_1$ must be doubled to account for the symmetric case where $C$ has the Old Maid, is
$$\frac{2S_1+S_2}T=\frac{2883584}{2276020775}=0.12669\dots\%=\frac1{789.302747899\dots}$$
Far from being impossibly remote, in $800$ properly randomised deals you should expect your situation to come up at least once.
Comment: Incredible. Thanks so much for solving this. I am in awe.
Answer: Alternative approach:
I will express the probability as
$$\frac{N}{D} ~: ~D = \binom{37}{13} \times \binom{24}{12} \times \binom{12}{12}. \tag1 $$
That is, in (1) above, the denominator reflects the total number of (equally likely) ways that the $37$ cards can be distributed to the three people.
I will compute $N = [N_1 + (2\times N_2)]$, where $N_1$ represents the number of satisfying distributions where the $(13)$ card hand gets the old Maid, and $N_2$ represents the number of satisfying distributions where one of the $(12)$ card hands gets the old maid.  The factor of $(2)$ represents that two of the three people will have $(12)$ card hands.
Without loss of generality, I will assume that the $(36)$ paired cards are $(18)$ cards numbered from $(1)$ through $(18)$ inclusive, that are Black, and (similarly) $(18)$ such cards that are Red.

To compute $N_1$, first, the $(13)$ card hand must have $(12)$ singletons.  This partial enumeration is
$$\binom{18}{12} \times 2^{(12)}.$$
Here, you can assume, without loss of generality, that the 13 card hand is specifically the old Maid, plus the cards numbered $(1)$ through $(12)$, all Black.
Then, the 2nd player must specifically get exactly one of the cards from each of the ranks numbered $(13)$ through $(18)$.  This can be done in $2^6$ ways.
Further, the 2nd player must then get $6$ more cards, from the remaining Red cards, numbered $(1)$ through $(12)$.  This can be done in $~\displaystyle \binom{12}{6}~$ ways.
So, the overall enumeration of $N_1$ is
$$N_1 = \binom{18}{12} \times 2^{(12)} \times 2^{(6)} \times \binom{12}{6} $$
$$= \binom{18}{12} \times \binom{12}{6} \times 2^{(18)}.  \tag2 $$

To compute $N_2$ first focus on the $(12)$ card hand that does not have the Old Maid.  Then, focus on the $(13)$ card hand, which is assumed to also not have the old Maid.
As in the previous section, the first partial enumeration is
$$\binom{18}{12} \times 2^{(12)},$$
followed (again) by the assumption, without loss of generality, that the pertinent $(12)$ card hand is the $(12)$ Black cards, numbered $(1)$ through $(12)$.
Now, the $(13)$ card hand must (again) specifically get exactly one of the cards from each of the ranks numbered $(13)$ through $(18)$.  Again, this can be done in $2^6$ ways.
Further, there is now the slight modification from the previous section.  The $(13)$ card hand must then get $7$ more cards, from the remaining Red cards, numbered $(1)$ through $(12)$.  This can be done in $~\displaystyle \binom{12}{7}~$ ways.
So, the overall enumeration of $N_2$ is
$$N_2 = \binom{18}{12} \times 2^{(12)} \times 2^{(6)} \times \binom{12}{7} $$
$$= \binom{18}{12} \times \binom{12}{7} \times 2^{(18)}.  \tag3 $$

Putting it all together,
$$N = N_1 + (2N_2) = \binom{18}{12} \times 2^{(18)} \times \left[ ~\binom{12}{6} + \left\langle 2 \times \binom{12}{7}\right\rangle ~\right]$$
and
$$D = \binom{37}{13} \times \binom{24}{12} \times \binom{12}{12}.$$
This yields
$$\frac{N}{D} \approx 1.267 \times 10^{(-3)} \approx \frac{1}{789.302}$$
which agrees with Parcly Taxel's computations.
Answer: A simple approximation is $2(\frac{2}{3})^{18}\approx0.001353\approx \frac{1}{739}$.
Ignore the presence of the Old Maid (which is reasonable since the number of cards is rather large), and call the number of pairs $3n$.
The probability that no player gets a pair is $P(n)=\dfrac{\binom{3n}{2n}\binom{2n}{n}2^{3n}}{\binom{6n}{2n}\binom{4n}{2n}}$.
Explanation:

The denominator is the total number of ways to divide the $6n$ cards
among the three players. First, among the $6n$ cards, we choose $2n$ cards
to go to the first player, so $\binom{6n}{2n}$. Then among the
remaining $4n$ cards we choose $2n$ cards to go to the second player, so
$\binom{4n}{2n}$. Then the remaining $2n$ cards go to the third
player.
The numerator is the total number of ways in which each pair is
separated. First, among the $3n$ pairs, we choose $2n$ pairs to
each be represented in the hand of the first player (one card from each pair),
so $\binom{3n}{2n}$. Then we allocate the $n$ remaining pairs to
the second and third players (each player getting one member of each of
these pairs), so then the second player must now get an additional $n$
cards, and these are chosen among the $2n$ cards whose "partner" went
to the first player, so $\binom{2n}{n}$. Then the remaining $n$ cards
go to the third player. Then each pair has two ways of being separated among two players, so $2^{3n}$.

Now it can be shown, either algebraically or by Wolfram, that
$$\lim\limits_{n\to\infty}\frac{P(n)}{2(\frac{2}{3})^{3n}}=1$$
So, for large $n$, $P(n)\approx 2(\frac{2}{3})^{3n}$.
As for an intuitive explanation of why this approximation works, see here.

Old Maid Card Game Probability Question


A word for someone who shows great interest/love for something that they know very little about

Question: I'm searching for such a word so I can use it for myself. I'm still young and I sadly have numerous passions for many things but sometimes find myself at a loss, for I know very little in the subject, and I can't find the time to learn all about my interests. Please help me find the word to describe this.
Comment: You may, for example be an *avid* golfer, even if you can hardly hit the ball, since "avid" simply means having great enthusiasm for the sport.
Comment: You might need more than one word to convey the idea accurately. You are a passionate novice, an enthusiastic abecedarian, an unschooled aficionado, an eager newbie, a fan on the sidelines. If you learn a little of each of your passions, but never gain full expertise, you're a jack of all trades, master of none.
Comment: I would use an "enthusiast."
Comment: Like, getting married ?
Answer: amateurish
dilettante
upstart
self-deprecating
Comment: Ooh -- ooh -- dabbler!
Comment: Dilettante is created specifically for this situation. A person who knows a little bit about a topic that they find delight in.
Comment: How does 'upstart' qualify to be here?
Comment: Maybe it's a stretch -- but here's a definition that gives a bit of the feel I was thinking of: "characteristic of someone who has risen economically or socially but lacks the social skills appropriate for this new position" (see http://upstart.askdefinebeta.com/).  The lack of skills part is what I was thinking about, I suppose.
Answer: You are aspiring.

aspiring |əˈspī(ə)riNG|
adjective [ attrib. ] –
directing one's hopes or ambitions toward becoming a specified type of person: an aspiring artist.

It is uncommon, however, to be "aspiring" full-stop.  If you are aspiring in many areas, you could use aspirant.

aspirant |ˈaspərəntəˈspīrənt|
adjective [ attrib. ] –
(of a person) having ambitions to achieve something, typically to follow a particular career: an aspirant politician.

Both of these terms imply that you will one day be skilled, but you're just not there yet.
If you're talking about a hobby or activity for which you expect or intend little improvement, I would use "enthusiastic".  When I tell people, "I'm very passionate about basketball, but very terrible at it," they often respond with, "So, you're enthusiastic."
Of course, it only works in some contexts.  Alone, "enthusiastic" does not imply adeptness or its lacking.

enthusiastic noun – having or showing intense and eager enjoyment, interest, or approval

But in a case where skill is being questioned, then it's a great way to imply an absence of ability. For example, it would work if "enthusiastic" is used to substitute "talented" or "good".

A: "Is George a talented dancer?"
B: "Well, George is an enthusiastic dancer."

This is a kind way of saying "no".  The two qualities aren't mutually exclusive, but B answered a yes-or-no question by correcting "talented" to "enthusiastic".  A should understand now that George may never be a good dancer, but he likes dancing.  "Eager," "passionate," and "keen" also work here.
Answer: Neophyte
From the ODO:

A person who is new to a subject or activity: four-day cooking classes are offered to neophytes and experts


How do I get started using OpenSeadragon?

Question: I was wondering how to get started with OpenSeadragon. I have it installed through node.js according to the repository readme on github. Then I was looking at the API and it looks like you have to use the OpenSeadragon.Viewer function. But that is as far as I got. I just want to create a simple page with one deep-zooming image using OpenSeadragon.
Answer: You only need node.js if you're going to be modifying the OpenSeadragon source. If you just want to use OpenSeadragon, grab a built version from http://openseadragon.github.io/#download. Then, assuming your project directory looks like so:
project/
  dzi/
    foo.dzi
    foo_files/
      ...
  index.html
  openseadragon/
    images/
      ...
    openseadragon.js
    openseadragon.min.js

Your index.html could look like so:

I guess I should add something like this as a "getting started" on the web site!
Answer: So, to answer my question,
The dzc_output.xml file is in fact the DZI file. Microsoft sets the filetype to xml as browsers have difficulty with dzi according to information buried on their website.
Answer: The OpenSeaDragon website has an example page for Deep Zoom Composer created images.
The example, XMLHTTPRequest for DZI XML or JSON, shows how to use DZI, but not XML.
I would like some guidance on this.
The export of Seadragon AJAX from Deep Zoom Composer is a collection of folders, xml files and images,

GeneratedImages (folder)

dzc_output_files (folder)
0 (folder)
... (intervening folders)
15 (folder)
dzc_output.xml (xml file)
scene.xml (xml file)
SparseImageScenedGraph.xml (xml file)

There is no DZI file anywhere in this collection. The text further states, "
OpenSeadragon sniffs for whether the DZI is formatted as XML or JSON", and I don't know what this means.
Should it be possible to use the Deep Zoom Composer generated folder structure and files with the xml file data with OpenSeadragon?
Answer: iangilman's answer is still relevant and useful today. One thing I would add... if you are using Microsoft's Deep Zoom Composer to create your DZI, check the XML file. If it contains DisplayRects, delete them. OpenSeaDragon does not handle them correctly (see https://github.com/openseadragon/openseadragon/issues/1081) and will not display the image at all. Delete the entire section from the XML and everything works fine. There is some conversation about a potential performance impact, but I have not seen that issue myself.
Also, it looks like the height and width are critical - I removed them at one point and the entire image disappeared (0 height and 0 width I presume).


Show that p ∧ q → r and p ∨ q → r are not logically equivalent.

Question: I tried to use truth tables but couldn't get it, I used logical equivalences and got it, can someone show me how to do it with a truth table?
Comment: How did you use equivalences and 'got it' when they are *not* equivalent?
Answer: $p=1,q=0,r=0, p\wedge q = 0, p\vee q=1, p\wedge q\rightarrow r = 1, p\vee q\rightarrow r = 0$
Edit: To figure out counterexamples such as this it is often instructive to rewrite the implication in terms of disjunction or conjuction, and negation:
$$a\to b \equiv \lnot a \lor b$$
Then:
$$(p\lor q\to r)\land(p\land q\to r) \equiv \left(\lnot(p\lor q)\lor r\right)\land(\lnot(p\land q)\lor r)$$
From here you figure out that if $r=1$ then the above is always true, so you choose $r=0$ and try to find $p,q$ for which $\lnot(p\lor q)\ne \lnot(p\land q)$, which is the same as: $p\lor q\ne p\land q$. The latter occurs when $p\ne q$, then you pick $p=0, q=1$ or $p=1, q=0$.
Answer: You probably just miscalculated the truth table.
Here is the complete truth table for the two statements:
$$\begin{array}{ccc|c|c}
p & q & r & p\wedge q \to r & p\vee q\to r \\ \hline
T & T & T & T & T \\
T & T & F & F & F \\
T & F & T & T & T \\
T & F & F & T & F \\
F & T & T & T & T \\
F & T & F & T & F \\
F & F & T & T & T \\
F & F & F & T & T
\end{array} $$
It is easy to see that the two statements are not equivalent.
An easy way to work out the truth table for a statement of the form $A\to B$ is to note that this will only be false when $A$ is true but $B$ is false, and is true everywhere else. This fact is what I used to calculate the tables above.
Answer: \begin{array}{ccc|ccc|ccc}
p&q&r&(p \land q)& \rightarrow &r&(p\lor q)& \rightarrow &r\\
\hline
T&T&T&T&T&T&T&T&T\\
T&T&F&T&F&F&T&F&F\\
T&F&T&F&T&T&T&T&T\\
T&F&F&F&\color{red}T&F&T&\color{red}F&F\\
F&T&T&F&T&T&T&T&T\\
F&T&F&F&\color{red}T&F&T&\color{red}F&F\\
F&F&T&F&T&T&F&T&T\\
F&F&F&F&T&F&F&T&F\\
\end{array}
Answer:
can someone show me how to do it with a truth table?

If and only if they were logically equivalent, then you could construct a table such that $p\land q\to r$ and $p\lor q\to r$ are given identical truth values by each assignment of $p,q,$ and $r$.
So you would have to construct a table for the eight assignments of the literals and verify that that happens.
However, that can be a lot of effort.   We only need one counterexample to show that they are not equivalent.   That is, one assignment of $p,q,r$ which gives differing values for the conditionals.
So if we could see a way for this to happen, then it would save all that  work.   Now how might that happen?
Why now, a conditional is only falsified when the antecedent is true while the consequent is false.   So let us assign $r$ to be false and think about which evaluations of $p,q$ are needed to make one of $p\land q$ or $p\lor q$ false while the other is true (falsifying one conditional but not the other).


How do you delete multiple rows in excel

Question: How do you delete multiple rows in excel, if I mark everything and try to delete it just deletes a single row.
Answer: Content-wise: Mark the rows you'd like to delete and hit Del.
If you want to delete the rows, i.e. you want to reduce the number of rows:

hold Ctrl, hit - (minus sign), then let go of Ctrl
hit r (for selecting r ows, you'll observe you can use c for c olumns)
hit ENTER
Answer: You're using backspace instead of the 'Delete' key. Use the 'Delete' key for that.
Answer: I'm personally a fan of right-click (or control click on an Apple) and select delete from the pop-out menu.  That will also delete the rows, not just clear out the data.
Comment: "That will also delete the rows, not just clear out the data." -> This is especially important since Excel seems to mark cleared cells as if they are still in use. If you then use that Excel file as a data destination (for example, outputting data from Integration Services into the Excel file), you might find that your data begins to appear right below the last cleared row instead of at the beginning of the cleared cells. Thanks for bringing it up.
Comment: +1 - Selecting rows then hitting  or  is deleting the contents of the last highlighted cell of the selection.
Answer: Ctrl+Shift+Down will select all the rows down the current selection till a row which has text.
Click on the Row Header to highlight the entire row and press Ctrl+Shift+Down
Answer: Click + Shift or Shift + Click on the Row Header (the number cell at the far left) to select multiple rows and either "delete" or right click to the context menu and delete.
Cheers,
CEC
Answer: If you want to delete row contents, then select multiple rows from Row Headers (Left most of your screen normally) and press Delete key. However, if you want to delete rows entirely, then select multiple rows and then right click->Delete will do the trick.
Answer: For anyone else also googling this solution:
Remember to remove any filters before attempting to delete multiple rows, otherwise it will only let you delete a single row even when selecting more than one.
Comment: This is more commentary then an actual answer to the author's question.  Please do not submit commentary as an answer in the future.


Changing the checkmark

Question: I checkmarked the wrong answer here.  Is there any way I can change it?
Comment: Some kind soul unchecked it for me.  Thanx, whoever you are!
Answer: If you put the green checkmark on an answer by mistake, you can always change it:

either by re-clicking the checkmark on that answer, which unaccepts it,
or by clicking the checkmark on another answer, which accepts that one and unaccepts the first one.

Nobody else can affect the checkmarks on answers to your question. Acceptance is the prerogative of the question asker only. So judging from your comment, you must have unaccepted the wrong answer without realising it, perhaps by accepting another answer instead.
Comment: Thanx so much for your help, Rand!

Changing the checkmark


Rough opening..overthinking?

Question: In the middle of framing my basement, I realized I made a rough opening for a bathroom door approximately 4" too big. I glued m & screwed in another 2x4 to each jack stud to get the opening where it needs to be. I have PT wall plates for all walls but I got to thinking, do these new 2x4s need to be PT due to their ends in contact with the concrete? It's an interior wall. I really hope not... thoughts??
Comment: Part time wall plates? Physical therapy wall plates?
Answer: No need for the jack studs to be PT, In a basement that has no water or moisture issues, using PT material for plates is just a precaution, not a necessity, IMHO. This has been my experience in demoing older work while remodeling. BUT for what its worth,  hold the jack studs up off the floor a little, say 1/8" just for the heck of it. If I think about it, I set a little construction adhesive where the end of the jack stud goes and set the end in the glue to bond it to the floor and seal the end. If you have the studs set, do not sweat it.
Comment: He didn't indicate if he has any moisture issues so if he does then trimming 1/8" from the bottom as you suggest should be done.
Comment: Thank you! Alleviated some anxiety this morning. It was a newly constructed home two years ago. I live in MN. I have to test the sump pump just to make sure it works. Also, worked a lot in the basement this winter and spring and never saw any moisture/condensation anywhere for what it's worth.
Answer: You need to isolation non pressure treated wood from contact with concrete. This is code and you want to do this to prevent future issue with decay.
Because of your very solid attachment of the spacer stud to the trimmer stud, you do not need to support the bottom of the spacer stud by attaching it to the floor. Also, it is not necessary to fully extend the spacer stud down to the floor for attachment of the door, dry wall or door trim, just to near the floor.
In your case, isolating the wood from the concrete is very simple to do, just cut in a gap between the end of the spacer stud and the floor. Noting the lack of a need to extend the spacer stud down close to the concrete allows for options to cut it. I would personally just run a skill saw over the face of it with the guard on the concrete and the blade set to the 1-1/2" depth of the 2x4. Don't hit a screw of course.
Comment: Ack, you rule! Thank you! This forum has been a tremendous help and a life saver for some of these questions. I'd rather ask a silly question aas opposed to just doing crappy work. I do have another framing/fire blocking question but it may be lengthy.
Comment: You're very welcome! I very much like your thinking about the value of asking a question related to doing quality work. The way I look at it, questions are only questions and knowledge is the answers, while judgement of the value of a question is a different topic. We all had to learn everything we know and we all don't know everything. Maybe break up your other question into separate parts? I think there could be a benefit from having a guide on posting complected questions, if we don't already have one, I'm pretty new here myself

Rough opening..overthinking?


Hyperlink to open latest item in a folder (SharePoint 2010)

Question: I'm trying to insert a link on the home page. The link will be to a folder in a document library on a different page (but within the same site) and will open up the latest file added to that folder.
Answer: On the document library create a view sorted descending on the column which you want to use in your definition of latest item (Id, Modified, Created, ...) with a limit of 1 item and just showing the column "Title (linked to item)"
Insert a List View Web Part using that view on the page.
Comment: Thanks for your answer Per but what I'm trying to achieve is to create a link on the home page that opens up the most recent document added in a folder in document library.
Comment: And what I describe will do that. If it doesn't fit your requirements then you should add those requirements to your question as well as more information about which toolset you're allowed to use.
Comment: Hi Per, I have edited my original question. Please see if you can help me with this.


Do not translate the admin area / How can I set the language of the admin area to English?

Question: I am building a multilingual site with 3 languages. Lets say English, Italian and German. English is the default language. Is it possible to leave the admin area untranslatable, even I am currently seeing the actual site in different language other than the default one, just for the administrator of the site, using a module or custom code?
Answer: You could try the Administration Language module. There's only a dev version for the Drupal 7.x branch out currently, but it seems to work well enough (used it in a project myself).
Comment: The only thing bothering me is that it doesn't work for the tabs on the front (edit/translate/delete), you happen to know a solution?
Comment: To dianikol: Glad I could help. @Jurgen All I could come up with is manually overriding the tab titles in the code (in template files, before rendering). The t() function allows you to get them in your preferred language.


How large could a blue whale get in a zero-gravity environment?

Question: Let's say that I had some sort of habitat in a space station or similar structure, which had everything a blue whale would need to survive, but did not have any gravity. How large could a blue whale reach in a zero gravity environment? If allowed to breed and evolve, would they become larger? (The project I am working on isn't actually with blue whales, but I felt like would be a good example of the general concept I'm thinking of, which I could use to make my question more specific)
Edit: This question is ONLY using blue whales as an example of "really large animal that could function in an environment with no ground to walk on", and I am only asking about how large they could get without the restriction of gravity, not whether or not they could survive. I do not agree with the sentiment that the ocean is "already pretty much zero gravity", as there is very clearly gravity in the ocean, and even just a little bit of gravity would still have at least some sort of effect on how large an organism could grow. Even if the increase is only a tiny fraction of a percent, I still want to know that.
Comment: They already live in what is effectively a near zero-g environment.  And in zero-g, how would they know how to go "up" to the surface in order to breathe?  Indeed, would there even be a surface where they could count on there being air instead of water?  You might try whale sharks instead: https://en.wikipedia.org/wiki/Whale_shark
Comment: Probably thermal dissipation is ultimate limiter. Processing of food generates heat. An ever large body will require increasingly large amounts of food. However square-cube law says that there will be less surface area to dissipate that heat. They rely on water for cooling, In zero G that might not be as readily available.
Comment: A whale's biggest challenge isn't beating gravity, is beating its own body (heat dissipation and nutrient circulation to the cells at the end of the capillaries)
Comment: (1) Aquatic animals do live in an effectively zero g environment. (2) A closed habitat is in many ways similar to an island; an insular environment can produce both an increase in size and a decrease in size. See [insular gigantism](https://en.wikipedia.org/wiki/Island_gigantism) and [insular dwarfism](https://en.wikipedia.org/wiki/Insular_dwarfism).
Comment: 1) This question is not about if they could survive in a zero-g environment, it's about how big they could get.
2) I don't think that the ocean is close to zero-g, as there are up and down axis, and creatures are still affected by gravity, just not as much as on land. The idea that "the ocean is already close to zero gravity" just doesn't make much sense to me. Yes, it is affected much less severely than terrestrial environments, but it still *has* gravity. Even if it's only a few feet of a change in the maximum possible size of an animal, that would still be nice to know.
Comment: @LandPlacoderm I agree with you on the 0 gravity vs water part. One has no force, so water is spilled everywhere evenly, while the other has the concept of increased pressure as you go deeper, something organisms do adapt against them. I doubt you would be able to dive 100m in water as you would in space without some time adapting to this. This can change a little bit the perspective on the size matter, too :).
Comment: @Land Placoderm: If they can't survive in the environment, they aren't going to get any bigger than they were when you transported them to it. DUH!
Answer: Absurdly large.
The main limitation on size is gonna be blood flow, and if you don't need to do much energetic stuff, it's not gonna be that hard to evolve some arteries to contract to push blood around.
The main limitation on whale size is food, and if you give them more food if they're larger you could push them to be even more massive.
You'd need to push them.
Blue whales are huge because competition is intense. They use lunge feeding, where they lunge after krill or similar prey to get huge amounts of food. This means they need huge amounts of energy for quick bursts and to have a larger mouth to catch more krill.
There are many more maneuverable or agile predators, but none with as much endurance and size of mouth as blue whales.
If they don't need to be larger to be fed, why would they evolve to be larger?
Comment: Nope, just accepted it. Thanks for reminding me to do so.
Comment: Thank you for an actually helpful answer. That first section of your answer was exactly what I was looking for.
Comment: Glad to help. Do you need anything else to accept my answer?
Answer: You are going to have very strange evolutionary forces if a single species and all it's ancestors never have to lift a fin for food or breeding. Perhaps it just evolves to be as cute as it can so the handlers will give them more food or attention. Sure it could get huge, but I don't think it would be a option all roads must lead to.


Space Complexity Reduction for Dynamic Time Warping

Question: I'm currently trying to use dynamic time warping to group a large number of time-series I have. Unfortunately, each series has around 400000 entries, and Python can't handle creating a 400000 x 400000 matrix. Is there a another way to use DTW that doesn't use as much space?
Answer: If you just need the distance (not the warping path) then DTW is just O(n) not O(n^2). Does that solve your problem?
Useful tutorial https://www.cs.unm.edu/~mueen/DTW.pdf


parse: query a project to see if a table name exists

Question: I am a relative newbie to parse (and IOS) so I hope that this question is legitimate. I am using parse tables as events with entries into the table being all who have joined the event. I want to be able to query my project to see if an event (table name) exists.  Is there a way to query the entire project to see if a PF object exists based on the table name? Thanks in advance for any help provided.
Comment: Extremely inefficient and horrible data base design. Make one table. Name it Events. In that table, make these columns. eventID (Unique, primary key),   attendingMembers (array of pointers to Users who are attending). Read about designing databases and different types in Parse .
Comment: Later you can simply query by eventID, if you get a result, the event exists. If you get 0 objects in return, it means no such event exists.
Answer: If I understand well, you are creating a table by event, you will end up having as many tables as events, which is not what you want. In my opinion, you should be creating a table with all events, then another table with all the persons joining the events. On this second table, you will use a Pointer to the first table. This way, you can query all events in the first table and see if a particular event exists.


Translating 16-bit digital counts on a CD to voltage on the output RCA connector

Question: CDs use 16-bit signed integers to represent each sample.  So each sample is an integer between -2^15 and 2^15-1.  A typical consumer CD player has two RCA outputs coming out the back of it, one for the right channel, one for the left, and no volume control.  If the right channel on a CD track is simply a (discretized) 1 kHz sine wave with an amplitude of 2^14 "counts", what will be the amplitude (in volts) of the signal on the RCA output?  (Just to be clear, when I say "amplitude", I mean one half the peak-to-peak amplitude.  So the maximum of my digital sine wave is 2^14 counts, and the minimum is -2^14 counts.)
Comment: So, to clarify... You're asking for the peak output voltage of the audio signal on the RCA line-output from your home stereo CD player?
Comment: Yes, basically.  If you told me the peak _possible_ output voltage on the RCA line out, that would tell the answer to my question.  I.e. if the peak possible output voltage was (2^15-1)/2^15*Vscale, the answer to my question would be Vscale/2.
Answer: There isn't a strict standard, but "nominal" line level for consumer-grade gear is typically -10 dBu, which is the voltage that would dissipate 0.1 mW in a 600 Ω load. This works out to about 0.245 Vrms, or 0.346 Vpeak.
Now, the level you are asking about is relative to the full-scale range of the DAC. The key question is: What is the relationship between dBFS and dBu? This depends on how much "headroom" the designer of the CD player decided to build into the DAC. A typical relationship is that full-scale is 10 dB above the nominal level, which means that the clipping level of the DAC (full scale) is 1.095 Vpeak (0.775 Vrms, or 0 dBu).
Therefore, a -6 dBFS signal (half the voltage) would be 0.549 Vpeak, or 0.388 Vrms. YMMV
Comment: OK, thanks.  And not to quibble, but I really want to be 100% clear on this: that Wikipedia article also says that the line level for consumer devices is -10 dBV (rather than -10 dBu).  Which is correct?
Comment: The difference is only 2.2 dB, which is hardly worth worrying about. I deal mostly with professional gear, and work mainly with dBu. But it's a tiny adjustment of the input pad either way, and falls within the scope of [YMMV](https://en.wiktionary.org/wiki/YMMV).
Answer: I made a .wav file with a full-range 1 kHz sine wave on it, burned it to an audio CD, and played it out a Yamaha CDC-565 CD player, and measured the amplitude of the resulting signal on the RCA output (this CD player has no volume control).  The amplitude was 3 V, almost exactly (i.e. 6 V peak-to-peak):

I took the same sound file and played it on my Sonos system, and recorded the analog output from a Sonos bridge (that's a box for hooking your Sonos system up to a traditional component stereo system).  Sonos lets you set the Bridge output to be "Fixed" or "Variable".  The "fixed" setting is designed to be line level, with the intent that you control the volume on your receiver (or preamp).  The "variable" setting allows you to control the volume via the Sonos software, by modulating the amplitude of the signal on the RCAs coming out the back of the Sonos.  With the Bridge output set to fixed, the amplitude of my test file on the RCA was again 3 V:

With the Bridge output set to variable, and the volume on the Sonos software set to the maximum, the amplitude on the RCA was again 3 V.  In this case, by turning the volume down in the Sonos software, I could reduce the amplitude on the RCA.
So two different devices for converting digitally-stored audio to a line-level analog signal, of very different vintages, both produce a 3 V sine wave when the 16-bit digital signal is of amplitude 2^15 counts.  This leads me to wonder if this isn't a common practice.
The question asks for the peak amplitude of a signal half this large, which would be 1.5 V.
Several online sources (see below) indicate that a typical consumer CD player, when playing a full-range sine wave, produces an analog output with RMS amplitude equal to approximately 2 V.  This implies a peak amplitude of sqrt(2)*2 V ~= 2.828 V.  The RMS amplitude of the 3 V sine waves produced by the equipment I tested would be 3/sqrt(2) V ~= 2.121 V, which could be construed as "approximately" 2 V, I suppose.
So it seems like the final answer to the question is that the peak voltage of a half-full-range digital signal will likely vary across makes and models, but will probably be around 1.5 V.
Sources:
http://www.stereophile.com/content/quality-lies-details
"The processor under test is driven by the digital code representing a full-scale or 0dBFS 1kHz sinewave. [...]  The standard CD-player output voltage is 2V RMS, with units varying between 1.74V on the low side (the Audio Research DAC1) and a whopping 7.2V on the high side (the Theta DS Pro Basic). Most CD players and processors put out between 2.2V and 3.5V."
https://hydrogenaud.io/index.php?PHPSESSID=62rkq3fprkobabohufnbg21ov3&topic=109784.msg904084#msg904084
"Yes. Digital full scale = 2Vrms. An unwritten standard."
http://www.msbtech.com/support/clipping.php
"Before digital sources, nominal audio levels were specified and the quality of the product determined just how high a signal could be accommodated before clipping would occur. With the advent of the CD player, suddenly a source was available that had a maximum output level that could not be exceeded. That level was specified to be 2 Vrms."
Answer: According to the Wikipedia Article:
Line outputs usually present a source impedance of from 100 to 600 ohms. The voltage can reach 2 volts peak-to-peak with levels referenced to −10 dBV (300 mV) at 10 kΩ. The frequency response of most modern equipment is advertised as at least 20 Hz to 20 kHz, which corresponds to the range of human hearing. Line outputs are intended to drive a load impedance of 10,000 ohms; with only a few volts, this requires only minimal current.
So, if you're wanting rectified voltage/Vpk, that should be <=1V.


Black body radiation emits white

Question: A black body hypothetically absorbs all wavelengths of light and simultaneously emits all of them at the same time. Since the visible spectrum combines into white light, is true to say that emitted radiations must also appear white?
Comment: No black bodies do not *simultaneously* emit all wavelengths absorbed. That describes a perfect reflector, not a perfect absorber.
Comment: In this kind of question we always forget to account for eyes response. Besides this general comment, the black body is not a flat line and its appearance depends on T as you know. Sun is technically a good approximation of a black body and classifies as yellow star. Tough is still a decent source of white light for our eyes. Warmer stars are more bluish etc. A black body can (mostly) emits out of our visible range,
Answer: This is not true.
While an ideal absorber (aka a black body) is also an ideal emitter, this does not mean it emits light at all frequencies equally ("white noise"). The spectrum of the electromagnetic radiation from a black body instead follows Planck's Law. This is anything but white noise. The intensity peaks at a wavelength that is inversely proportional to the object's temperature.
A black body at room temperature emits light primarily in the thermal infrared with almost no emissions in the visible range while a black body at 11000 kelvins (e.g., Rigel) emits light primarily in the visible and near ultraviolet, peaking in blue.

Black body radiation emits white


If $E_{k_1}(p_1) = c_1$, what is the probability that there exists key $k_2$ such that $E_{k_2}(p_1) = c_1$?

Question: Let $k_1$ be a 56 bit DES key that performs $E_{k_1}(p_1) = c_1$. What is the probability that there exists another key $k_2$ such that $E_{k_2}(p_1) = c_1$?
Comment: The same advice still stands in that case, too. Instead of just copy-pasting the exercise here from the book, you should tell us *why* you find it unclear or difficult to solve.
Comment: Is this an assignment for some course? If so, you should describe your attempts at solving it so far, and specify which part you're stuck with.
Comment: No it an exercise question in Bernard Menezes book
Answer: DES is a block cipher with $b=64$-bit block width, and $w=56$-bit key width (ignoring key parity bits). An ideal model of a block cipher is that each key defines an independent, random-like permutation of the blocks. Under that model, if $E_{k_1}(p_1)=c_1$, then

For each key $k\ne k_1$ there is independent probability $u_1=2^{-b}=2^{-64}$ that $E_k(p_1)=c_1$
Hence for each key $k\ne k_1$ there is independent probability $v_1=1-u_1=1-2^{-b}=1-2^{-64}$ that $E_k(p_1)\ne c_1$
There are $n=2^b-1=2^{56}-1$ keys $k\ne k_1$, hence the probability $v$ that for each of these keys $E_k(p_1)\ne c_1$ is: $v={v_1}^n={(1-u_1)}^n=(1-2^{-64})^{(2^{56}-1)}$
Hence the desired probability $u$ that there exist any key $k\ne k_1$ such that $E_k(p_1)=c_1$ is: $u=1-v=1-{(1-u_1)}^n=1-(1-2^{-b})^{(2^w-1)}=1-(1-2^{-64})^{(2^{56}-1)}$
For integer $n>0$ and real $\epsilon$, it holds that $(1-\epsilon)^n=1-n\,\epsilon+O((n\,\epsilon)^2)$
Therefore, for $m\gg1$ and $m\,|\epsilon|\ll1$, it holds that $1-(1-\epsilon)^{(m-1)}\approx m\,\epsilon$
Applying the approximation in (6) to the expression in (4), with $\epsilon=u_1=2^{-b}=2^{-64}$ and $m=2^w=2^{56}$, it comes
$$u\approx2^{w-b}=2^{-8}\approx0.39\%$$

Note per Ilmari Karonen's comment: the approximations made after step (4) fail when the key width $w$ approaches or exceeds the block size $b$, as would be the case for 3DES ($b=64$ and $w\in\{112,168\}$) or AES ($b=128$ and $w\in\{128,192,256\}$). We then want a better approximation. We can use ${v_1}^n=\exp(n\log(v_1))$ and $\log(1-\epsilon)=-\epsilon+O(\epsilon^2)$, giving at step (7) $u\approx1-\exp(-2^{w-b})$, valid for $b\ge20$ and $w\ge20$. That's mathematically more accurate, but numerical accuracy requires extended precision when $b-w$ is positive and sizable, which is dangerously close to hold for $b-w=8$ in the question.
Note: Our model of DES is imperfect, in particular when we consider many plaintexts $p$ : DES has additional properties that our model misses. In particular the complementation property $E_\overline k(\overline p)=\overline{E_k(p)}$; that the permutation of blocks for any particular key is even; existence of weak keys. More generally, DES is a particular block cipher (a Feistel cipher within a few cryptographically neutral bit permutations). But given that in the context there is as single plaintext $p_1$ considered, and that DES is a fair cipher (except for its last-century key and block size), it is reasonable to believe that our model is good enough for an excellent approximation of $u$ for random choice of $k_1$ and $c_1$.
Note: with DES a fixed cipher, we can no longer talk of the desired probability $u$ when the whole of both $k_1$ and $c_1$ is fixed. I conjecture that the approximation still holds when $c_1$ and all but say 16 bits of $k_1$ is fixed, but wonder what happens when $k_1$ is fixed to some particular values (like all-zero, which is a weak key).
Comment: As a tiny nitpick, your linear approximation for $(1+\epsilon)^n$ is only good when $|n\epsilon| \ll 1$ (or, equivalently, $|\epsilon| \ll |1/n|$). This become relevant when considering ciphers like AES, where the key size is equal or greater to the block size. A more useful approximation in such cases would be $(1+\epsilon)^n = \exp(n \log(1+\epsilon)) \approx \exp(n\epsilon)$.
Comment: @Ilmari Karonen: Thanks for pointing my mistake, fixed now.
Answer: I approached this problem like this:
Let the number of bits in ciphertext be $n$.
So the total number of possible ciphertexts is $2^n$   --------[1]
Probability of getting a particular ciphertext = $1/(2^n)$ (we used any key)
Let the number of tries taken to get the same cipher text be $t$ (Including first encryption).
From [1]: P(not getting the particular ciphertext) = $1-1/2^n$
P(getting the same cipher text from $t$ number of Encryption) =$(1/2^n) \cdot(1-1/2^n)^{(t-2)} \cdot 1/2^n$.
Here the first term $1/2^n$ is the first encryption (try) [@ $t=1$]
Here the first term $(1-(1/(2^n))^{(t-2)}$: $t-2$ failed attempts to get the same ciphertext.
Here the last term $(1/(2^n)$: final try where we got the same cipher text [@ $t$]
Therefore,
P(getting the same cipher text from $t$ number of Encryption)  = $(1/(2^{2n})) ( (2^n)-1)/(2^n) ) ^ {(t-2)} $.


removing tree roots without stump grinder

Question: I am installing a sprinkler system in my backyard but a thick tree root is crossing a pipe path. This tree was actually removed last year (cut & stump grinding) and the tree roots are the remaining ones. One easy way is of course to rent a stump grinder but don't want to spend money only for this job. I am wondering if there is any other alternative way. I was thinking of using router bits to cut off the top portion of the roots up to, say 10" so that the pipe can pass. But, I am wondering if there is any other better method.
Comment: Please don't use a router in the dirt - utterly the wrong tool. It's actually pretty abusive for a chainsaw, too, though some people will do that (probably with a saw they have borrowed, rather than their own.) @gbronner has the right idea - this is an ideal job for an axe (one large tooth, easily resharpened after use on dirty wood) or a saw you don't love much (even if you have saw-sharpening skills, this would be a job for a saw you save for the ugly jobs, such as a pruning saw.) If you want a power tool, get a sawzall (you can rent, or for this you could get a harbor freight version.)
Comment: Do you have a chainsaw or tree trimming saw?
Comment: About how thick is the root?
Answer: Use a pickaxe to dig a hole around the tree root, and use an axe or a saw to cut the root. Repeat as necessary.
This works reasonably well for one tree, not so well for a forest.
Comment: Technically, the perfect tool would be a cutter mattock. I've always found them to be a bit unwieldy, so I prefer to use a cheap axe along with the occasional yard sale saw.
Comment: I could see where this method might take some time for a forest.
Comment: Depending on the "other" end of your pickaxe, you might be able to chop through the root with that. I've used an adze type of head to get rid of roots before. Roots are often quite soft compared to wood, so you don't need a super-sharp axe.
Answer: When I have been in a similar situation (dead roots), this has worked for me:

Dig around the root with a shovel to remove the bulk of the dirt in the way.
Use a trowel, your hands, something smaller to remove the rest of the dirt near the root.
Use a reciprocating saw (aka Sawzall) to cut through the root. This may take some time depending on how green the roots are, but those saws will eventually cut through it. Homeowners are more likely to own a reciprocating saw than a stump grinder, as well. If not, a decent one can be had for under $100 and is useful for a lot of demolition tasks.

You said the tree was removed "last year" so the roots are probably fairly dry by now, so a saw should cut through it easier than if it was just removed.
Comment: Buy blades in multi-packs, because dirt quickly dulls the mild steel. Also, reciprocating saws draw lots of current; either buy the biggest battery pack available or buy corded.
Comment: There are blades made specifically for cutting trees. They have low TPI and deep gullets - they look like sections out of an old-school bow saw. _Very_ effective on limbs and roots.
Answer: There are several stump removal products; commonly, potassium nitrate (salt peter) works best, but sodium pyrosulfite also works. Drill 5 or 6 holes in the stump and pour in about 1 lb of salt peter (if it's larger maybe you need more). Pour in water, or let it rain in for about a month. This allows the salt peter to be completely absorbed by the stump and roots... it needs to work all the way though the wood.
Then cover it in kerosene and charcoal briquettes. Light it up and it will burn out completely. When done properly it will burn out the roots and all. takes about 3 to 4 days to finish burning larger stumps.
Edit- Stump grinding usually only removes the surface of the stump. Most of it will probably still be there under the ground. But regardless, you can also drill into the offending root, which from what you describe, sounds like is over 10 inches thick. This will save you quite a bit of digging. It may take a little longer, but a lot less labor. I suppose the decision boils down to urgency. Can it wait a few weeks, or do the sprinklers need to be installed ASAP?
Comment: Did you even read the question? - there is no stump, and it's a bit absurd to wait a month and then light a fire that may be legally questionable when the requirement is to cut one root...
Comment: I'm with @Ecnerwal on this one in relation to the question.  However, I'm very happy to have read it and REALLY want to try it but even though I've got 2 stumps in my yard currently, I can't possibly believe either the city or my neighbors would approve.  I wonder of any of my more rural friends have any stumps to remove...
Comment: @Ecnerwal check the edit to my post
Comment: @kinar I made some edits to my post. It's not a giant fire, it a slow burn that is not obnoxious (like a slow roasting camp fire). When it's all done, there's little evidence that it was ever there... don't forget the s'mores.
Answer: Not at all sure what's left to grab on to, but I've used a machine (made by a friend of mine) that is 4 legs with a platform on top. The legs straddle what's left of the tree stump and supports a hydraulic bottle jack. The top of this jack has provision for a hefty chain to slide over it, which has both ends under to attach to whatever it can that's left of the tree. In your case, maybe just the offending root.
The jack is then pumped up, bringing the stump and roots up, opposite from the way they grew. About 10" lift, then re-position so the chain's tight again, and/or adjust the 4 legs. At some point after several goes, it all rises out of the ground, job done.
It's a heavy piece of machinery, and cumbersome to erect/use, but sure did the job well. Worked for me on tree stumps around 12" diameter easily, so could work on tree roots as well.
Otherwise, a similar idea - a sturdy engine hoist, if there's room to get it over the root, and that's maybe more available for hire for a day. This was in UK, so maybe it wasn't available anywhere else.


add_theme_support( $feature='menus' )

Question: I want to ask why after I deleted the add_theme_support($feature='menus') in my functions.php there is still menus in my theme activated. why it is still there even if I did not write the add_theme_support for menu. Can anyone explain it? thanks and best regards
Answer: From the documentation for add_theme_support():

The following parameters are read only, and should only be used in the context of current_theme_supports():
...

menus: Use register_nav_menu() or register_nav_menus() instead.

...

So your theme shouldn't be using add_theme_support($feature='menus') to begin with. Support is automatically added by register_nav_menu(). If you don't want menu options for your theme, make sure you're not using register_nav_menu() anywhere.
Comment: Thanks. I accidentally fix the problem and that was I not activating my custom theme that is why the code does not effect. Thank you for answering my question.

add_theme_support( $feature='menus' )


How to automatically generate a random url for a views rss feed?

Question: I have an administrative RSS feed generated by views in a feature that needs to generate a random/unique URL so that non-admins can't easily stumble upon it. I know that after installing the feature, the user can easily manually create the URL, but this will override the feature and put it in the DB, making updates troublesome. Thoughts?
Comment: What you're asking for only provides security through obscurity. Ask yourself: if someone does find these pages, then what? And what are the repercussions of someone finding the RSS feed itself? Instead of worrying about how easy the links are to find, what I would do is make sure that the links you are providing are only accessible to users with the appropriate permissions. With a bit more information, I would be happy to clarify my answer.
Comment: It is not the end of the world if somebody stumbles upon them. I just want to take the extra step to obscure them. I cannot add any permissions to the feed itself as it needs to be able to be read anonymously by a rss reader. I don't think I too crazy to look at something like this, since Drupal core already does this by generating a unique URL to run cron from outside the site.
Answer: Just configure the menu path for the page/feed display of your view to include a "random" token. You can set them to be whatever you want.
Users will require the token to trigger the menu item and therefore view. You can rotate the token by simply updating the view (though it's a manual process).
If you need to automate rotating the token, you could build a module that hook_menu_alter's  access callbacks (yourmodule_access) onto the desired paths that checks the token (variable_get) that a hook_cron periodically updates (variable_set) and mails out to appropriate admins (users with some role). This has added benefit that it's not limited to use with Views. Though that's a bit complex for providing obscurity.
Also, many RSS readers support HTTP basic auth (via adding username:password@hostname to the feed URL), so you could install a contrib module that adds support for logging in via HTTP Basic.
Comment: And http://drupal.org/project/tokenauth supports the rest, and has an alphanumeric token. But it is not intended to be used in the creation of obscure URLs, just minimally authenticated ones.


Update existing records with before trigger

Question: I need to update the fields of a few records (around 20) that were existing before I made a trigger. I know that before triggers cannot update existing records (or can they ?) but I think that using batch apex for such a small number of records may not be the best solution. Is there a different way to update these records or do I still need to use a batch ?
Comment: I would simply use Workbench to export the data in the form of CSV, then update the data manually(considering your number of records is pretty less) on the spreadsheet and perform a update from the Workbench again.
As @sfdcfox mentioned, you could also do a simple anonymous script.
Answer: 1) Yes, You can update the existing records on same object trigger. You need to make sure the trigger do not convert on recursive mode.
2) Batch calss is npt a good solution to do DML for small number of records but you can use asynch call to do the process.
Answer: It depends on if it is before insert or before update. If it is only before insert, you will need to manually update the records. If it is before update, you can usually just run an execute anonymous script:
<code>update [select id from objecttype where somefield = null];
</code>
Comment: this worked perfectly for the issue I got ! thanks again !


Diagram notation for events

Question: I have a part of my program which can be called by various events. Each event however does something different before making use of this part. How can I represent these using a diagram? I was thinking of a flowchart but as far as I know a flow chart can have one start terminal, right?
Thanks a lot for the help,
Regards,
Krt_Malta
Answer: UML Activity Diagram.
http://www.ibm.com/developerworks/rational/library/2802.html
You have a "wait for event" node that has multiple incoming events.  Each event has a different state transition.

Diagram notation for events


z-index issue in IE7

Question: We have a z-index problem with a div that's supposed to be over a particular div. The div named (house-over-banner) is absolute, whilst the one below it is relative.
In Firefox, IE6, 8 - it shows all good!
Just in IE7, it doesn't!
The link is http://www.showhome3d.com.au. - it's the house over the banner on the right hand side of the page.
Comment: It looks fine to me in IEs 6 , 7, and 8 in IETester?
Answer: A dirty css trick is to make parent div relative while the child div absolute. This way child div won't escape out of the parent div but you have not done something like that, you might do it that way to see if this works for you. Also z-index only works with elements which are set to absolute positioning.
Answer: I couldnt work out how to reply to Calebs Post so ill just post here,
im one of the team working with caleb on this (we are all combining forces to slay this beast of an issue :P ) but what appears to be happening now is that sometimes it will work in IE 7 and then other times it wont..its just chance when the page loads as to if it will be on top of below.
We applied a jquery z-index fix (http://www.vancelucas.com/blog/fixing-ie7-z-index-issues-with-jquery/comment-page-1/) which has seemed to cause this behaviour but its weird that it is not consistent
Answer: positioned elements in IE 6 and 7 form their own z-index stacking context, which is unescapable.

z-index issue in IE7


Is it necessary in any circumstance to modify Wordpress other than writing plugins and themes?

Question: I recently had to work on a project where the previous developer modified the wp-admin directory. It seems like a bad idea to me, since Wordpress is constantly updated. Am I just not at that level of expertise with modifying Wordpress?
Answer: Being open source, I think it's a common thing for software like WordPress to be modified and extended at any point.
To modify or not to modify is a choice between trade-offs. New features can be encapsulated as modules, which may, perhaps, cause their functionality to be less integrated than desired. However, fully integrating changes may hinder easily updating the software as new versions are released.
It does require that someone be very familiar with the software to modify the software directly, but this isn't necessarily a bad idea.
On a side note, I think modifying WordPress is almost a necessity, especially if you want it to have a decent architecture or to actually be secure (ok, that was a jab, sue me).
Answer: Well, it is a bad idea only in that it means you are now responsible for maintaining an internal defacto fork ... every time WordPress releases an update, you have to do a three-way diff to merge your changes into the new "real" WordPress. (Three-way diff means you do a diff between your fork of the old version and the standard old version to build a patch set, then apply that patch set to the new version.) You should also be using a VCS yourself to keep yourself sane.
If you aren't up to this then you aren't up to it, there's nothing wrong with following the KISS principle and not mucking up the application code.
If you can write a plugin that does the same thing and does it just as efficiently, then you should do that so you don't have to maintain your own fork.
However, there are a lot of things WordPress is terrible at (efficiency, security) that you can ameliorate (sometimes without much work, just by disabling code you don't need) only by hacking the application code. WordPress is dirty legacy spaghetti code originally written by people with virtually zero knowledge of software or database design, and it does a lot of tremendously stupid things like querying the database on every request to see what it's own siteurl is, when this never changes -- there's nothing wrong with taking 5 minutes to change 2 lines of code so it doesn't do this any more.
I worked as tech lead on a then-top-20 Technorati-ranked blog and did a lot of work to scale WordPress on a single server and then onto a cluster (with separate servers for admin vs. public access). We had upstream reverse proxies (i.e. Varnish or Squid) acting as HTTP accelerators and an internal object/page fragment cache system that plugged into memcached with failover to filesystem caching using PEAR::Cache_Lite. We had to modify WordPress to do things like send sane, cache-friendly HTTP headers, to disable a lot of unnecessary SQL and processing.
I modified WP to run using MySQL's memory-only NDB cluster storage engine, which meant specifying indexes in a lot of queries (in the end we opted for a replicated cluster instead, however). In modifying it to run with separate servers for admin vs. public access, we locked down the public-side version so it ran with much reduced MySQL privileges allowing only reads (a third MySQL user got commenting privileges).
If you have a serious comment spam problem (i.e. 10K/hour), then you have to do something beyond plugins. Spam will DOS you because WordPress just initializing its core is something like half a second on a standalone P4 with no concurrency, and since WP is a code hairball there's no way to do anything without initializing the core first.
"WP-Cron" is braindead and should be disabled if you have access to an actual crontab to perform these functions. Not hard to do.
In short, I could go on forever listing reasons why you might want to make modifications.
Throughout this it was of course a goal for maintainability reasons to keep these modifications to a minimum and document them as clearly as possible, and we implemented many as plugins when it made sense.
Answer: On one blog/forum combination, we hacked together the signup procedure so that people filled in one form to sign up to both WordPress and phpBB at the same time. I'm sure there's a better way to do that with plugins, but it did have one unexpected benefit - it really confuses the spambots. Despite having several of them register each day, we've had about two spam posts in the life of the forum.
Not something I'd recommend, of course - it stops us from upgrading either software.
Answer: I tend to strongly advocate against modifying core code if at all possible, especially in a project that updates like WordPress does.  If WordPress can't be made to do what you need it to with plugins and the like, you're probably better off with a more extensible/generic system like Drupal. Hacking a blogging-oriented CMS into something else might not be worth it.
Answer: In the older versions of WordPress (1.0 and even the early 2.0s), I wouldn't bat an eye to modifying WordPress itself.
However, WordPress' architecture has matured.  Sidebars no longer need to be manually coded.  Instead, you can port your theme to use widgets and just create widgets (what a godsend!).  Don't like how something is displayed - just modify the theme!  Don't like how WordPress handles something?  Create a plug-in.  I'm hard pressed to think of a reason to modify the WordPress code itself that cannot be handled via WordPress' contemporary modular components (widgets, plug-ins, themes) instead.
I'm the type of person to always get "under the hood" in open source apps like WordPress.  However, nowadays, there's really no good reason to modify the core WordPress code.


What does it mean to sample from an RBM?

Question: In restricted Boltzmann machines we ofter say that given $v$ we sample $h$, and also that given $h$ we sample $v$.
Can someone explain the physical meaning of this, considering a MNIST image as example?
Answer: RBMs are energy-based models. Quoting from LuCun et al. notes (pdf):

Energy-Based Models (EBMs) capture dependencies by associating a
  scalar energy (a measure of compatibility) to each configuration of
  the variables. Inference, i.e., making a prediction or decision,
  consists in setting the value of observed variables and finding values
  of the remaining variables that minimize the energy. Learning consists
  in finding an energy function that associates low energies to correct
  values of the remaining variables, and higher energies to incorrect
  values.

In practice, for an RBM, this means that the state of the network, completely characterised by the weights and biases, defines an energy function of the form
$$E(\boldsymbol v, \boldsymbol h) = -\boldsymbol a^T\boldsymbol v - \boldsymbol b^T\boldsymbol h - \boldsymbol v^T  W\,\boldsymbol h.$$
This energy function then defines a probability distribution over hidden and visible neurons of the network as
$$ P(\boldsymbol v, \boldsymbol h) = \frac{\exp(-E(\boldsymbol v, \boldsymbol h))}{Z},
\quad Z \equiv \sum_{\boldsymbol v, \boldsymbol h} \exp(-E(\boldsymbol v, \boldsymbol h)).
$$
Notice that the above actually defines a probabily distribution, as $\sum_{\boldsymbol v, \boldsymbol h} P(\boldsymbol v, \boldsymbol h) = 1$.
To sample from the network (without fixing a state for hidden or visible neurons) means to sample from the above probability distribution, that is, to draw states of the network's neurons according to $P(\boldsymbol v, \boldsymbol h)$.
To sample $\boldsymbol h$ given $\boldsymbol v$ means to sample from the conditional probability distribution $P(\boldsymbol h|\boldsymbol v)$. "Physically" this means that you are asking what are the probabilities of getting a specific set of values for the hidden neurons, having fixed the values $\boldsymbol v$ for the visible neurons, and sampling from this probability distribution.
This conditional probability distribution is computed as
$$ P(\boldsymbol h|\boldsymbol v) = \frac{\exp(-E(\boldsymbol v, \boldsymbol h))}{\sum_{\boldsymbol{\tilde h}}\exp(-E(\boldsymbol v, \boldsymbol{\tilde h}))}.$$
Sampling $\boldsymbol v$ given $\boldsymbol h$ has similar meaning.
As also explained in this related answer, this conditional sampling can be used to obtain the way an input is represented by the network. For example, after having trained the RBM, feeding a MNIST image in the visible layer, and sampling from the hidden layer conditionally to this input, gives the internal representation that the network has built of the image, which can then later be used for classification or whatever other purpose.
Answer: Sampling simply means to draw a sample from a probability distribution. For example, you can draw a sample from a Gaussian distribution. When you draw one sample, it tells you nothing about the distribution. But after you draw lots of samples, their values should follow the distribution.
RBM is a stochastic neural network, meaning that the values of every neuron follow certain probability distributions. When you have the p(v, h), theoretically you can draw samples of pair value (v, h) from the distribution. But it does not make much sense to do that, because that is almost useless.
On the other hand, it is useful to know the distribution of p(h|v) and p(v|h), because then you can sample h given v. It means, when you have an observed value v, you can compute the probability distribution of the hidden value h, i.e., p(h|v). Once you have the distribution, you can sample the value of h, and vice verse.
This is important, because then you can use value h to represent v (together with the weights and biases). That means, you can reconstruct v from h, and you can use h for any learning or computations in place of v. It also means you can pretrain a layer of network with RBM unsupervisedly, while still extracting the useful features.


Is deleteLater() necessary in PyQt/PySide?

Question: Since there is already a Garbage Collector in Python, is deleteLater() necessary in PyQt/PySide?
Answer: It depends what you mean by "necessary".
An application could potentially consume a lot of memory if (for example) care is not taken when closing widgets. The QObject-based classes are designed to be (optionally) linked together in a hierarchy. When a top-level object is deleted, Qt will automatically delete all its child objects as well. However, when closing widgets (which are sub-classes of QObject), automatic deletion will only happen if the Qt.WA_DeleteOnClose attribute is set (which, by default, it usually isn't).
To illustrate, try repeatedly opening and closing the dialog in this demo script, and watch how the global list of objects grows:
import sys
from PyQt5 import QtCore, QtWidgets

class Window(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()
        self.checkbox = QtWidgets.QCheckBox('Delete')
        self.button = QtWidgets.QPushButton('Open', self)
        self.button.clicked.connect(self.openDialog)
        layout = QtWidgets.QHBoxLayout(self)
        layout.addWidget(self.checkbox)
        layout.addWidget(self.button)

    def openDialog(self):
        widget = QtWidgets.QDialog(self)
        if (self.checkbox.isChecked() and
            not widget.testAttribute(QtCore.Qt.WA_DeleteOnClose)):
            widget.setAttribute(QtCore.Qt.WA_DeleteOnClose)
            for child in self.findChildren(QtWidgets.QDialog):
                if child is not widget:
                    child.deleteLater()
        label = QtWidgets.QLabel(widget)
        button = QtWidgets.QPushButton('Close', widget)
        button.clicked.connect(widget.close)
        layout = QtWidgets.QVBoxLayout(widget)
        layout.addWidget(label)
        layout.addWidget(button)
        objects = self.findChildren(QtCore.QObject)
        label.setText('Objects = %d' % len(objects))
        print(objects)
        widget.show()

if __name__ == '__main__':

    app = QtWidgets.QApplication(sys.argv)
    window = Window()
    window.setGeometry(500, 300, 100, 50)
    window.show()
    sys.exit(app.exec_())

With PyQt/PySide, there are two aspects to object ownership: the Python part, and the Qt part. Often, removing the last Python reference to an object won't be enough to fully clean up, because there could still be a reference held on the Qt side.
In general, Qt tends not to implicity delete objects. So if your application creates and removes lots of QObjects (or opens and closes lots of QWidgets), you may need to take steps to delete them explicitly if memory usage is a concern.
UPDATE:
Just to add to the points above on object ownership. Sometimes, it is possible to hold a Python reference to an object, whilst the Qt part gets deleted. When this happens, you will see an error like this:

RuntimeError: underlying C/C++ object has been deleted

Usually, the Qt documentation will give some hints about when this might happen. For instance, QAbstractItemView.setModel gives this warning:

The view does not take ownership of the model unless it is the model's parent object...

This is telling you that you must either keep a Python reference to the object, or pass a suitable parent object to the object's constructor, because Qt will not always automatically reparent it.
Comment: 1)I think there is no difference in PyQt/PySide or Python part ,
as long as the object is referenced, it will not be cleaned up .Don't you think so ?

2)Besides, WA_DeleteOnClose is suitable for widget that we can close it ,but
for QOBject like QNetworkReply and QDialog here closed but isn't be deleted ,deleteLater() is appropriate ,right ?
Comment: deleteLater() will cause the event loop to delete the object after all pending events have been delivered to it, so it is often safer to use deleteLater() rather than deleting a QObject subclass directly.I found   deleteLater() is still useful in PyQt/PySide.
Comment: @user1485853. (1) Yes, but see the update to my answer for an important exception. (2) Yes, `WA_DeleteOnClose` is just _one_ common example of when things _might_ not get cleaned up properly. For QOjects, if they have no parent, and no python reference, they will be automatically garbage-collected (eventually) - so no need for deleteLater(). In general, don't worry too much about explicitly deleting objects: beware of "premature optimimization"! Only worry about these issues when you have _real_ evidence that they are causing a problem.
Answer: One application of deleteLater can be cleaning up of yourself, i.e. scheduling a delete of an QObject (for example in threading) to free resources from within the object itself.
Here for example someone is using it in connection with the signal thread.finished. It might be restricted to cases with heavy signalling though.
Comment: I updated the link pasting the one from web archive.
Comment: Sadly, the example link is now dead. (*Of course. Of course it is.*)
Comment: The link is about C++. This question is about Python and ARC.


How cross validation works for regression?

Question: For regression type problem we know the result is a continuous value, so how is it be cross validated?
In classification type problem we know the class label so easy to compare, but how is it compare in regression type problem?
Answer: The idea behind cross validation is to understand the performance of some measure of your model's performance on unseen data. This can be applied to loads of different statistics, not just ones relevant to classification like accuracy. Common measures for holdout performance of regression models include MSE and MAPE, either (or both) of which can be cross-validated over.
Answer: In both scenarios, we pick one or more performance measures and validate the model based on them. In classification, one may choose to use accuracy, precision, recall, or F-score. In regression, other metrics such as Root Mean Squared Error (RMSE), Mean Absolute Error (MAE), and R Squared Score (R^2) might be useful.
In regression/classification problems that the order of data points matters (eg time series), we cannot use conventional cross-validation. Instead, some special variations of cross-validation procedure must be used to make sure we do not train our model on the current samples and validate on past instances.

p.s. In regression problems, the labels do not need to be "continuous" (as we define in the continuity of a function in calculus). They can be discrete but real-valued.


Why is there water dripping through my soffits?

Question: This picture was taken directly below the roof in the 1st picture. You can see it is soaking wet. I do have a skylight on that roof but that has been replaced and sealed repeatedly. I always blamed the skylight but now I am wondering about the drip edge.
Comment: One tight shot of a piece of flashing doesn't provide much info re a roof leak. Is the soffit leak directly below this flashing? Pls provide some overall pictures of the roof and soffits indicating where the leak is occurring. Water leaking from a soffit could have traveled a long way down a rafter before surfacing. Provide some detail.
Comment: Also, you should [take our tour](https://diy.stackexchange.com/tour) so you know how this site works.
Comment: If the leak is in only one spot removing one of the soffit panels may give you a good idea of the source of the leak.
Comment: That flashing looks totally wrong to me higher than the roofing, a gap it looks like someone designed it to leak.
Answer: I'm sorry for your frustrations but what a sh!t job by this roofer. What even are those flaps hanging in the gutter; drip edge backup plan?
I'd like to see more angles of your roof line but I think this picture will illustrate how water is flowing on your roof.

If you're comfortable with ladders then grab a hose and pour water on your roof while you record the flow. You should quickly see whether things are working properly.
If my illustration is accurate then expect your fascia to rot in the next few years.
For the record, water dripping from your soffits is not normal. Keep investigating until you find the source and do everything in your power to make the roofer properly fix it. Presumably you paid at least $10,000 for this new roof so if they suggest patch-work such as silicone or some mastic then be aware that they are trying to avoid doing it right.
Comment: Over $25,000 this cost me. There is snow on the roof at the moment and the hose will not be on for many months. I understand what you are saying in the picture. I am looking forward to being able to look at it a bit better when we get better weather. Thanks so much for the advice.


Is the partition function of non-conformal theories on a torus modular invariant?

Question: Usually we say that the partition function of CFTs on a torus is modular invariant, because we define theory on a torus. If I have a non-conformal field the theory on a torus, is its partition function still modular invariant?
Answer: No, a generic theory on a torus is not modular invariant.
A conformal field theory cannot depend on the metric of the space it is defined on but only on its conformal equivalence class. It is a fact that the space of such classes for the torus is given by a complex parameter $\tau$, the (conformal) modulus, defining the lattice we quotient out of $\mathbb{R}^2$ to get the 2-torus: The basic lattice vectors are $(1,0)$ and the vector in the plane corresponding to the complex number $\tau$, i.e. $\tau$ is the "ratio" between the two fundamental circles on the torus. If we did not have conformal invariance of the theory we would not be allowed to identify the lattice given by $(1,0)$ and $\tau$ with the lattice given by $(2,0)$ and $2\tau$ because while related by a rescaling the area of these parallelograms and hence the resulting torus is different, so we would not have only this one parameter $\tau$ describing the relevant torus structure.
The modular group $\mathrm{PSL}(2,\mathbb{Z})$ sends $\tau$ to values that are equivalent in the sense that they define the same lattice after rescaling one of the basis vectors to $(1,0)$ as allowed by conformal invariance, and so the partition functions, as a function of $\tau$, must be modular invariant since $\tau$ related by modular transformation define tori with the same conformal equivalence class.
Comment: What about theories with a conformal/Weyl anomaly? In that case the partition function should depend not only on the conformal class of the metric. Of course in string theory the total conformal anomaly is required to vanish, and one requires modular invariance of the partition function. But in a generic CFT, with nonvanishing central charge, it seems to me that one should not require modular invariance.
Answer: Let $T = \mathbb{C}/\left( {\mathbb{Z} \oplus \tau \mathbb{Z}} \right)$. This torus is conformally equivalent to any torus $T' = \mathbb{C}/\left( {\mathbb{Z} \oplus \tau '\mathbb{Z}} \right)$ with $\tau ' = \frac{{a\tau  + b}}{{c\tau  + \operatorname{d} }}$ such that a,b,c,d integral and $\left| {\begin{array}{*{20}{c}}
  a&b \\
  c&\operatorname{d}
\end{array}} \right| = 1$.
This is a modular transformation.
We you take a partition function in a 2D CFT like you would see in String Theory, you are integrating over the moduli space of conformally inequivalent Riemann surfaces. So it is important that your Partition function has modular invariance so it does not distinguish between tori which are conformally equivalent.
If you are working with a QFT which is not conformal, then this argument is not really relevant.


Raman activity in sulfur

Question: I was wondering why sulfur is Raman active but other elements (e.g. carbon) are not.
Comment: Raman activity is a property of compounds, not elements.
Comment: Be aware that C is a very bad counterexample. For single atom there cannot be vibrational spectroscopy. But in principle a  pure element that exists in a specific bound forn can have Raman active modes of vibration. C is famous for its allotrooes, diamond graphite fullerenes-nanotubes....
Answer: In a review (PDF, CalTech) of the properties of elemental sulfur, the author notes that the most stable form of sulfur at STP is in fact cycloocta-sulfur, $\ce{S8}$, with other polyatomic species also found. Elemental sulfur is commonly formed as a molecular solid, with arrangements of $\ce{S_n}$ rings or chains, and the S-S bonds can be Raman active.
The paper offers depictions of some of those structures, and also tabulates the principal Raman bands for selected allotropes of elemental sulfur.

Raman activity in sulfur


Parse/Edit Apache conf files with Ruby?

Question: I need to write some scripts to make changes to Apache conf files, namely to add/update VirtualHosts. I plan on doing this in Ruby. before I write my own, are there any scripts/rubygems which allow Ruby to parse/modify Apache conf files, specifically <VirtualHost> directives?
Comment: Not sure if StackOverflow would be a better place. Let's try ServerFault first and see what happens :-)
Answer: I ended up just writing my own ruby script... Not very well done, but in case anyone needs it, here's the guts of it. It is looking for the contents of the <VirtualHost></VirtualHost> tag so that it can create a second <VirtualHost> with a ServerName which is a subdomain of our wildcard SSL cert...
begin
  logMsg "Updating apache config file for user #{user} (#{domain_httpd_conf})"

  domain_httpd_conf_io = File.open(domain_httpd_conf,File::RDONLY)

  ip_addr = ''
  main_vhost_config = []
  ssl_vhost_config = ["  ServerName #{auto_ssl_domain}",'  Include "conf/wildcard-ssl.conf"']

  indent = 1

  while line = domain_httpd_conf_io.gets

    line_indented = '  '*indent+line.strip

    if line =~ /^[[:space:]]*<VirtualHost ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)(:[0-9]+)[^>]*>/
      ip = $1
    elsif line =~ /^[[:space:]]*<\/VirtualHost>/
      break 2
    elsif line =~ /^[[:space:]]*(ServerAlias|ServerName).*/
      main_vhost_config.push line_indented
    else

      if line =~ /^[[:space:]]*<[^\/]/
        indent += 1
      elsif line =~ /^[[:space:]]*<[\/]/
        indent = [1, indent-1].max
        line_indented = '  '*indent + line.strip
      end

      main_vhost_config.push line_indented
      ssl_vhost_config.push line_indented
    end
  end

  main_vhost_config.push "  Include #{extraconf_dir}/*.conf"

  domain_httpd_conf_io.close
  domain_httpd_conf_io = File.open(domain_httpd_conf,File::WRONLY||File::TRUNC)

  domain_httpd_conf_io.puts "<VirtualHost #{ip}:80 #{ip}:8080>"
  domain_httpd_conf_io.puts main_vhost_config
  domain_httpd_conf_io.puts "</VirtualHost>"

  domain_httpd_conf_io.puts

  domain_httpd_conf_io.puts "<VirtualHost #{ip}:443 #{ip}:8888>"
  domain_httpd_conf_io.puts ssl_vhost_config
  domain_httpd_conf_io.puts "</VirtualHost>"

rescue SystemCallError => err
  logErr "ERROR: Unexpected error: "+err

  domain_httpd_conf_io.close
end

Still has some bugs to work out but it mostly does what I want.
Answer: No clue, but one thing that may help you is apache's support for mass virtual hosting:
http://httpd.apache.org/docs/2.2/vhosts/mass.html
If you can enforce consistency across your vhosts then maybe you don't need ruby to create/manage/edit them.  Convention over configuration is the rails way right?
Comment: I would love to. Sadly what I'm trying to do is fix an issue with Virtualmin, which generates VirtualHosts which are lacking: http://serverfault.com/questions/121313/virtualmin-automatically-create-ssl-based-website-with-a-shared-ssl-wildcard-cer

Parse/Edit Apache conf files with Ruby?