How can we reconcile Devarim 24:16 with BaMidbar 16:27?

Question: It is written at BaMidbar 16:27 וַיֵּעָלוּ, מֵעַל מִשְׁכַּן-קֹרַח דָּתָן וַאֲבִירָם--מִסָּבִיב; וְדָתָן וַאֲבִירָם יָצְאוּ נִצָּבִים, פֶּתַח אָהֳלֵיהֶם, וּנְשֵׁיהֶם וּבְנֵיהֶם, וְטַפָּם (here it appears the טַפָּם died also because of the sins of their fathers); how can we reconcile this with Devarim 24:16 לֹא-יוּמְתוּ אָבוֹת עַל-בָּנִים, וּבָנִים לֹא-יוּמְתוּ עַל-אָבוֹת:  אִישׁ בְּחֶטְאוֹ, יוּמָתו?
Comment: Usually טף refers to young children (under bar/bas mitzvah), who can indeed be punished for their parents' sins.
Comment: @DonielF how does one reconcile your answer with Devarim 24:16 לֹא-יוּמְתוּ אָבוֹת עַל-בָּנִים, וּבָנִים לֹא-יוּמְתוּ עַל-אָבוֹת: אִישׁ בְּחֶטְאוֹ, יוּמָתו ?
Comment: Only talking about adult children. See Sanhedrin 27b. As the Gemara there explains, the only clause regarding punishment is איש בחטאו יומתו - the rest deals with testimony. איש is universally used to the exclusion of children (see ex. Kiddushin 42b).
Comment: @DonielF So, adult children can not die for the sins of their fathers, but an infant טף (or if you wish, a young child) can die for the sins of its father?
Comment: That's how I understand the sugya, though I don't actually have a source for that assertion off the top of my head.
Answer: The Midrash Tanhuma (ed. Buber: Parashat Korah 6) notes that this was abnormal as normally children are not punished:

אמר ר' ברכיה כמה קשה המחלוקת שב"ד של מעלה אינן קונסין אלא מבן עשרים שנה, וב"ד של מטה מבן שלש עשרה שנה, ומחלוקתו של קרח תינוקות בני יומן נשרפו, ונבלעו בשאול תחתית, דכתיב ונשיהם ובניהם וטפם

Rabbenu Bahaya asks this as a question (Parashat Korah 16:29): what did the children do?  He answers that it can only be understood kabbalistcally.
Rambam writes in Hilkhot Teshuva (6:1), however, that Deuteronomy (24:16) only means that adults (איש) are punished on their own merits, but a child may be punished for his parents' sins:

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

Rambam's position is supported by the Sifrei Zuta to Ruth (ed Buber; 1:5) which states that until a boy is 13 he is punished for his fathers' sins; after that he becomes included in Deut. (24:16) and is only punished for his own sins:

אמר ר' חייא בר אבא עד שלש עשרה שנה הבן לוקה בעון האב, מכאן ואילך איש בחטאו ימות

Alternatively, R. Yissakhar Teichtal suggests in Mishneh Sakhir (Parashat Korah s.v. V'datan Vaaviram) that in reality these children were old enough to have been involved in the dispute themselves. Thus, they were punished for their own sin; not that of their parents:

ועיי"ש פרש"י בשם המדרש. ולי נראה עפ"י פשוט עפ"י המעשה דגם הנשים בכלל המחלוקת וגם הבנים והטף, וק"ל
Answer: The fact that the children of Dasan and Aviram stayed with their father was enough to include them in the sin. The children of Korach did teshuvah and moved away from their father so they were saved. In fact Hashem replies to the entreaties of Moshe.
Korach 16:24

"Speak to the congregation saying, 'Withdraw from the dwelling of
  Korah, Dathan and Abiram.'"

This leads to:
Korach 16:27

So they withdrew from around the dwelling of Korah, Dathan, and
  Abiram, and Dathan and Abiram went out standing upright at the
  entrance of their tents together with their wives, their children, and
  their infants.

This implies that the children of Korach did withdraw from around their fathers tent and did teshuvah.
Note that the infants are in the position of being killed by their parents like someone refusing to leave a burning building or evacuate during a flood. and not allowing the children to be saved. The adult children of Dasan and Aviram could have left with the infants.
As Rashi says on that pasuk.

their wives, their children, and their infants: Come and see the severity of dispute. The earthly courts do not punish until [an
  accused] has two [pubic] hairs, and the heavenly court does not punish
  until one reaches the age of twenty, but here even nursing babes were
  punished. - [Midrash Tanchuma Korach 3]

The implication is that even those who could not of their own free will leave, were caught up in the punishment, even though they had not done anything themselves.
Answer: From Rabbi Shmuel Goldin,
*A few thought on what is a very difficult subject
Of course, our first reference would be to the rabbinic teaching that פקד עון אבות refers to situation where the children continue the sin of their fathers.
The question that raises, however, is that they are being punished for their own sins-not their "fathers' sin"-In that case, what's the chiddush?
Perhaps it's the Torah's way of warning parents that the behavior they model will be perpetuated and "perfected" for good or for bad by their progeny-in a sense their children will be affected by the parents sins
Another area to consider, is when our tradition cites historical sins, such as חטא חמרגלים as the source of pain for generations. Once again, we might argue that the pain will be perpetuated as long as we fall prey to the same failings.
Finally, while we do not believe in intergenerational guilt, we do accept the clear existence of intergenerational effect for good or bad- I am not guilty of Adam and Chava's sin, as Christianity would suggest-but I continue to affected by it-we do not exist in Gan Eden, after all-we are still affected by their failings. So too, all decisions we make in our lives will potentially affect generations to come*
Answer: Simplest answer -- Devarim is prohibiting us from carrying out such a punishment (as was common in cases of treason, as the son would likely take up the challenge to the throne); Hashem can operate with different calculus.


Software for writing a book similar to Resnick-Halliday

Question: Which is the best software to write a book which is similar to Fundamentals of Physics by Resnick and Halliday?
I want to self-publish a book (on physics) on Createspace but have no idea regarding the software would be best suitable for the job.
Comment: FYI, look at Amazon's Kindle Direct Publishing rather than CreateSpace as they are planning on merging the two in the near future and it will all become just KDP. I don't know what, if any, formatting differences there are. I just had an email from my publisher about this.
Answer: LaTeX tends to be an industry standard for "mathy/sciency" open works, but you'd have to program some pretty sophisticated layout schemes to get to anything that looks like a high-school math book. LaTeX is a platform, not a software solution. You learn a language and write files using that language and then the platform has the ability to render it in several different ways.
Caution: If you've never done any programming, learning LaTeX to the point of proficiency is about as difficult as taking a year's worth of classes.
Comment: There are some wysiwyg editors for latex, and geogebra has pretty good export (for graphs and sketches). This might cut down on the time required to get started.
Answer: You could use typical desktop publishing tools like Adobe InDesign or Quark; you could use XML publishing tools such as MadCap Flare, or Paligo, or DITA... all of these will suffice - it's a question of your preferred workflow, budget and available learning time to master the workflow enough to get the quality of results you need.
Heck with time and patience enough, Apple's Pages or Microsoft's Word or Publisher could handle this task, albeit true that I'd not envy either you or your eventual printers if you choose the Microsoft route.
LaTeX is primarily a science-writing focussed open-source typesetting tool, and is often included as a plug-in to other tools to ease complex equation layout on specific spreads - though I myself don't personally know anyone who has used LaTeX to set up and produce an entire large document like a textbook, it clearly can be done that way - though given all the references in the documentation to LaTeX not being a layout environment and to letting authors remain authors and leaving the document layout to document designers, one suspects there may be a lack of tools to get top-shelf layout results.
I am (amongst other things) a document designer as well as tech writer - were it me, I'd either use InDesign or Flare - though if Affinity finally completes the development of their new Publisher application (Affinity Photo and Designer are directly out-competing Adobe Photoshop and Illustrator) I'd probably seriously consider that too.
From a quick look at the Createspace pages, they're expecting either print-ready PDFs or Word files... so quite possibly the best answer is to not overthink this: use whatever tool you are already familair with for producing typical .doc files, whether that's Open Office or Pages or Word or Libreoffice or  Google Docs.
Comment: Up voted, because solid professional experience, and more complete than my own answer. But, there are books written in latex, not unsurprisingly the ones I'm aware of are largely computer science oriented.
Answer: Oh, you definitely have to use LaTeX, but there's more than one way to skin that cat.
I recommend a program called LyX. It uses LaTeX under the hood, but it saves you much of the harder coding, and lets you see roughly what the document would look like before you export it to an appropriate format. Its document class choices make it incredibly versatile; I've used It to write books, papers, scripts, you name it.


How to switch base layer programmatically in MapBox/Leaflet

Question: I have multiple base layers, and need to switch them programmatically, dependent on various actions and states in my application. Can't find how, for the life of me.
Answer: This tutorial serves as a good example:
1) As shown in the example, set up your base layers with a variable name that can be accessed in the function where you want to switch them programmatically.
var grayscale = L.tileLayer(mapboxUrl, {id: 'MapID', attribution: mapboxAttribution}),
    streets   = L.tileLayer(mapboxUrl, {id: 'MapID', attribution: mapboxAttribution});

2) Then add and remove the layers you want to add or remove. The following swaps the grayscale layer for the streets layer. This assumes that both grayscale and streets are available within the scope of the function where you are doing the switching.
map.removeLayer(grayscale);
map.addLayer(streets);

3) If you are using the layers control L.control.layers shown in the example, then the control keeps track of what is on the map, and changes the checkboxes accordingly.
Comment: WHere is `mapboxUrl` & `mapboxAttribution` ?
Comment: @MohammadDayyan you need to refer to the tutorial that's linked above
Answer: From https://stackoverflow.com/a/33762133/4355695

Normally by simply adding a layer to the map (e.g.
  myTileLayer.addTo(map)), if that layer is part of the base layers or
  overlays of the Layers Control, the latter will automatically update
  its status (if you added a base layer, the radio buttons will be
  selected accordingly; for an overlay, the corresponding checkbox will
  be ticked).

I tried and it worked: I don't need to bother with removing the current baselayer (or with figuring out which one's active for that matter). Just myTileLayer.addTo(map) does the job : If it is already part of my baselayers, then the map "switches" to it. It automatically removes the current layer and changes to myTileLayer.


What does the "|" operator do?

Question: I don't get this operator. What does it do?
Here is an example of where I find it:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

Answer: That's bitwise OR.  It's useful in this case for composing bitmasks.  Those flags are defines for a number which has one bit set, and when you OR them together, you end up with a number with both bits set.
example:
I don't know what the exact value of those flags is, but let's imagine they are:
#define GL_COLOR_BUFFER_BIT  0x01
#define GL_DEPTH_BUFFER_BIT  0x08

If you write those out in binary, you get:
GL_COLOR_BUFFER_BIT = 00000001
GL_DEPTH_BUFFER_BIT = 00001000

And if you bitwise OR those together, you set the bit in the output to 1 if that bit is set in either GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT, so:
GL_COLOR_BUFFER_BIT = 00000001
GL_DEPTH_BUFFER_BIT = 00001000
                    = 00001001

So you end up with the number 0x09.
The function you're calling will examine the number you passed in, and based on which bits are set, it knows what flags you're passing in.
Comment: Can you explain in a little more detail on exactly what you mean?
Answer: It is a bitwise or operator. Bitwise or works in a way shown below:
Lets assume you have 2 bytes a,b.
a = 0 0 1 1 0 1 0 1

b = 1 0 1 1 0 0 0 0

Bitwise operators work on a bit level. What happens is it takes each bit in turn and performs an or operation on it. If at least one (or both) bits are 1s the the corresponding bit in the result byte will also be a one. If they are both 0 then result bit will also be 0.
So a bitwise or on a and b will do this:
a = 0 0 1 1 0 1 0 1

b = 1 0 1 1 0 0 0 0

c = 1 0 1 1 0 1 0 1

First bit 0 and 1. There is a 1 so bit in c will be a 1.
Second bit 0 and 0 so next result bit will be a 0.
Third bit both 1s. At least one 1 is present so next bit in c will be a 1... and so on.
Hope it clears it up for you.
PS. I used dummy bits here and by no means they correspond to the actual values used by GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT.
Mostly bitwise operators are used to enforce a mask on a value or combine two values together.
| will combine the two together
& will enforce a mask
Lets assume you are given a value and you want to make it look like this (we will use & to enforce that mask).
0 0 0 1 1 1 1 0

0s will correspond to places where there should be no value and 1s correspond to the bits which you are interested in and want to extact.
   a = 1 0 1 0 0 1 1 0
mask = 0 0 0 1 1 1 1 0

Now all bits in a which are above 0s will be dropped and result will have 0s in these bits because for and & you need both bits to be 1s to result in a bit 1.
Where you have 1s in the mask, thats where the potential 1s in result will occur. So using & on each bit you end up with this value.
result = 0 0 0 0 0 1 1 0

If you look closer the 4 bits in result which are in same position as 1s in mask are simply moved from a. So what it really did was removed the bits in a where mask had a 0 and kept the ones with 1s.
Answer: It depends a bit on the language you are using, but in many this is the bitwise or. This is often used to pass several flags that are encoded as a bit into a function. For instance if you have two flags
const char FLAG_1 = 0x01;
const char FLAG_2 = 0x02;

then FLAG_1 | FLAG_2 is 0x03. For bitwise disjoint bits this is equivalent to addition, which is can be confusing at first. In the call the bits are or'd
func( FLAG_1 | FLAG_2) // set both FLAG_1 and FLAG_2

The function func can then test the bits individually using the bitwise and:
void func( char flags ) {
     if( flag & FLAG_1 ) { // test for FLAG_1
     }
     if( flag & FLAG_1 ) { // test for FLAG_2
     }
}

What does the "|" operator do?


Bitcoin sent to invalid address

Question: In this transaction, some bitcoins are sent to bc1qp6k6tux6g3gr3sxw94g9tx4l0cjtu2pt65r6xp which appears to not be a valid bitcoin address. What is bc1qp6k6tux6g3gr3sxw94g9tx4l0cjtu2pt65r6xp  ?
Answer: That address is a bech32 encoded address, which is a new style of address used on the Bitcoin network, that starts with bc1....
It seems that the Blockchain.info explorer has simply not been updated to properly interpret and present this newer address type. The addresses you listed are perfectly valid.
Comment: They updated to decode them at least.

Bitcoin sent to invalid address


Cosine Similarity measure applied on images

Question: I am trying to work on a project which requires me to find the similarity between two images. Can anyone help me with the matlab code for applying cosine similarity on images or any other useful information on the same. Thank You!
Answer: Have a look at the MPEG-7 Visual descriptors if you are interested in doing image similarity Visual descriptors . I have had good results from combinations of the EHD (Edge histogram descriptor) and CSD (colour structure descriptor) and there are Matlab implementations on the web (though they are easy enough to implement your self from the original publications)
Some example source: Content Based Image Retrieval in Matlab


Fractions with radicals in the denominator

Question: I'm working my way through the videos on the Khan Academy, and have a hit a road block. I can't understand why the following is true:
$$\frac{6}{\quad\frac{6\sqrt{85}}{85}\quad} = \sqrt{85}$$
Comment: I'm not even sure how to read this fraction. If you know some $\LaTeX$ please use this to enhance the equation; otherwise please at least use parenthesis to make the readability well-defined.
Comment: At the moment what you've written is $6/(6\sqrt{85}/85) = 6\cdot 85/(6\sqrt{85}) = 85/\sqrt{85} = \sqrt{85}$, which is clearly not equal to 6. Can you copy down the fraction exactly?
Comment: As it's currently written: $\dfrac{6}{6 \sqrt {85}} = \sqrt {85}$ is not true. But I am struggling to come up with what was really meant.
Answer: With respect to handling square roots in the denominator:
Say, for example, you have $\displaystyle \frac {a}{\sqrt{b}}$.
If you want a "square-root free" denominator, remember that you can multiply any fraction by the number $1$ (or its equivalent) without changing its value.  In this case, we want to multiply the given fraction by $\displaystyle \frac{\sqrt{b}}{\sqrt{b}} = 1$. Can you see why we would want to choose this particular representation of 1?
Now, $$\frac{\sqrt{b}}{\sqrt{b}}\cdot \frac {a}{\sqrt{b}} = \frac{a\cdot \sqrt{b}}{(\sqrt{b})^2} = \frac{a\cdot \sqrt{b}}{b}$$
And if the greatest common divisor of a and b > 1, then we can reduce $\displaystyle \frac ab$ by dividing each of $a$ and $b$ by their greatest common divisor (i.e., reducing the fraction $\displaystyle \frac ab$.
Now, we take a look at a slightly more complicated situation, as in your problem, where the denominator is itself a fraction given by $\displaystyle \frac{6}{\frac{6\sqrt{85}}{85}}$
We can first multiply numerator and denominator by 85, then proceed as we did in the case above: $$\frac{6}{\frac{6\sqrt{85}}{85}}\cdot \frac{85}{85} = \frac{6\cdot 85}{6\cdot\sqrt{85}} = \frac {85}{\sqrt{85}} = \frac {85}{\sqrt{85}}\cdot \frac{\sqrt{85}}{\sqrt{85}} = \frac{85\cdot \sqrt{85}}{85} = \sqrt{85} $$
More simply, once we have reduced the expression to $\displaystyle \frac{85}{\sqrt{85}}$, we notice that $85 = (\sqrt{85})^2$, and so, this, together with the fact that we can then cancel a common factor of both the numerator and the denominator, we have:
$$\frac{85}{\sqrt{85}} = \frac{(\sqrt{85})^2}{\sqrt{85}} = \sqrt{85}$$
Note: When you have enough experience simplifying fractions and fractions with fractions with roots, etc., many of the steps which I've displayed explicitly above will be "second nature" for you, and you'll be able to manipulate such expressions with far less in the way of computations than I've shown above.
Answer: No one seems to have posted the really simple way to do this yet:
$$
\frac{85}{\sqrt{85}} = \frac{\sqrt{85}\sqrt{85}}{\sqrt{85}}
$$
and then cancel the common factor.
Comment: No one? You're blind-sighted, my friend: $$\frac{85}{\sqrt{85}} = \frac{(\sqrt{85})^2}{\sqrt{85}} = \sqrt{85}$$
Answer: Are you sure you entered that right? It looks like you have $$(6) \over ({6 \sqrt{85}\over 85})$$ which would be equal to $$\sqrt{85}.$$
Note: this answer was written before the original question was edited. The original question was asking why (6)/(6√85/85) was equal to 6.
Comment: Yeh, sorry thats correct. I am not 'why' though.
Comment: Ohh. I think  I understand now.I was getting confused with how to handle sqrt in the denominator


Chat widget in customer portal

Question: I want to show chat widget in customer portal. I have enabled it and it is working fine with salesforce user but not in customer portal. Any idea if that is possible as of now?
Answer: As of now, this functionality is not available for Portal users but there are some restricted options to interact with the customers. One of them is Chatter Answers which helps the internal team to interact with the customers and vice versa. Salesforce.com is also coming up with a new feature, that is, salesforce.com communities which is added in the Summer'13 release.
Comment: Chat currently isn't supported in communities either.

Chat widget in customer portal


Can the Greek Gods Be "Killed"?

Question: If Zeus and his siblings were able to hold Chronos down and chop him into pieces, effectively "killing" him, could there be a way for the gods or goddesses to die as well?
Or in other words, can the gods be destroyed so that they are reduced to a state of formlessness from which they are unable to return?
And since the Titans were actually stronger than the gods, would it take as much power/people to kill them, or would it be easier for them to be killed?
In similarity to the version of the story of Chronos in which he is imprisoned, could any of the gods or goddesses be captured and/or imprisoned? What would be able to hold them? And again, would it be easier to capture the gods than it was to do the same thing to Chronos or the Titans?
Comment: Cronus is neither actually nor "effectively" dead. The bit about Kronos getting chopped into pieces or some such appears to be a modern invention (of Rick Riordan?). A number of different accounts of his fate have been given in Greek sources, but the closest to that that I can find would be a castration. In most accounts he is imprisoned, and in some he later escapes or is freed and becomes a King. He is decidedly *not* killed.
Comment: PS Welcome to Stack Mythology!  (It's actually useful to get some disambiguation on the "Ouranous chopped into pieces" we've been hearing a fair bit about lately.  I do want to point out that this version, regardless of origin, is quite similar to the dismemberment of [Ymir](https://en.wikipedia.org/wiki/Ymir), so even if it derives from Riordan or some other modern source, the idea in relation to a primal deity is quite ancient--[Osiris](https://en.wikipedia.org/wiki/Osiris) is also famously dismembered.
Comment: I believe that the Killing Greek Gods theme comes mainly from the popular game God of War, which I haven't played, a guy named Kratos (Who I believe was an actual Greek mythological character, related to Styx), kills Ares or Athena or Zeus or some such. This is the most popular source for Greek mythological knowledge, bar Riordan, and this might influence people into thinking that they can be killed.
Answer: Offhand, I can't think of any examples of Greek gods dying.

Casting down into Tartarus seems to be the favored Ancient Greek methods for taking the old powers "off the game board".
The turning to stone of Atlas is an alternate method, although he "lives on" as a mountain range that still bears his name.  (This is similar to the memoriams of various tragic figures in Greek mythology who are transformed into constellations.)
Dionysus/Zagreus was dismembered and returned to life, so even sparagmos is not lethal for such creatures.  [See also this answer for a little more detail.]
The binding of Prometheus is another example of constraining a rival power without killing that power, possibly because that power represents an eternal idea or ideas.  (Plato would likely provide insight into this concept, which features in Ancient Greek mythology and philosophy, and provides an intersection for the two fields.)

Where we do tend see fatal consequences for supernatural creatures in Greek Mythology is the vanquishing monsters to tame the landscape so that civilization may blossom.  Heracles is particularly famous for this, killing creatures such as the Hydra in his labors, and taking part in the Gigantomachy in which many earth born giants were slain.

Sorry for the brevity of this answer.  When I get some more time, I'll try to come back and add more detail and links.  In the meantime, you might want to read a little Ovid--his Metamorphosis is a very comprehensive catalog of of the myths by perhaps the most influential of all the ancient mythographers (not least per his tremendous influence on Shakespeare) and you will immediately note an emphasis on transformation as opposed to death.
Answer: Yes, they can die. Only example for this is Pan:

Then the voice said aloud to him, When you are arrived at Palodes, take care to make it known that the great God Pan is dead.

Plutarch. Plutarch's Morals. Translated from the Greek by several hands. Corrected and revised by. William W. Goodwin, PH. D. Boston. Little, Brown, and Company. Cambridge. Press Of John Wilson and son. 1874.
As for how he died... no idea.

Related question: How rare is a dead god?
Comment: Here is a quote from book 5.418 of The Iliad, which seems to indicate that a god can die:

"Ares might have wasted away there on the spot
if the monster's stepmother, beautiful Eriboea
had not sent for Hermes, and out of the cauldron
Hermes stole him away---the War-god breathing his last,
all but broken down by the ruthless iron chains."
Comment: Let's find out how Pan died: https://mythology.stackexchange.com/q/2978/3230
Comment: Given that this text was written during the Christian era, it is safe to say that it is non-canon and highly metaphorical. There is no instance of a god dying in actual Greek mythology.
Comment: @Digio My understanding is that the Moralia were published sometime around 100 AD, hardly the Christian era?
Comment: @CharlieTizzardÓKevlahan Still, this is highly linked to the advent of Christianity, see also [the citations provided here](https://en.wikipedia.org/wiki/Pan_(god)#%22The_Great_God_Pan_is_dead%22). It cannot be viewed as a reference on Greek mythology.
Answer: The Greek Gods can't "Die", but they can be crippled forever, chopped into tiny pieces, or just fade.  For example, when Kronos sliced Ouranus (Uranus) to death, Ouranus was never able to have a physical form again.  In the 3rd Century BC, people referred to Apollo and Helios and Artemis and Selene as the same gods.  Then eventually people forgot about both Helios and Selene.  That would mean that Helios and Selene faded.
So, they can only be put in extreme agony or fade forever.
Source 1: https://en.wikipedia.org/wiki/Apollo
Comment: I notice you added a link for Wikipedia.  Good start but not sufficient for upvotes.  Please take the next step and run down the source of the Wikipedia reference, and post that source instead of the Wikipedia page.  (Ideally, the source should be academic, but Theoi is also considered reliable b/c it's easy to validate the accuracy of the material posted there.)  Once you have a root source, the answer will be up-votable.
Comment: Man, Some of you Stack Exchange users are SO Hardcore
Comment: @Xynozore haha--it's just that we're trying to improve the quality of this Stack by pushing for better citations.  I don't necessarily disagree with anything you're saying, just wanted to give you some perspective on why the answer has not been more well received.  (Full disclosure, I do on occasion post answers without heavy referencing, but if they get challenged or down-voted, I generally have to go back and amend.)  My advice here would be to cite the source material for "Ouranus was never able to have a physical form again." and you're good.  PS Welcome to Mythology!
Comment: Sorry, just joking!
Answer: Yes and no. Greek gods have been able to be chopped up and spread out, however, since they are immortal they are able to reform leaving them to be "alive". The "problem" is that it takes them a long time to reform leaving millennia, eons, etc. to ever be seen again until that amount of time. Sometimes beings are powerful enough to not have to reform, but the price is not having a physical body. Take a look at Kronos(Chronos or Chronus, idk) and Ouranos(Uranus). Kronos had cut up Ouranos and Ouranos no longer has a physical body.
Sometimes Greek gods fade, this means that people forgot about this one certain god and they cease to exist as no one offers them anything or gives prayers.
Answer: Yes, they can be killed, and also: yes, they can be captured and imprisoned, according to at least one ancient source (see next section).
Nothing in the original mythology states that the Titans are necessarily stronger than the gods. In fact, if anything, Hesiod's Theogony, for instance, repeatedly highlights the strength of the Olympians as an explanation of how they defeated their elder enemies to became the top dogs. Every situation bears different circumstances, which are what determine how easy or difficult it would be to capture or kill one of the gods. Not at all possess the same powers, resources or temperaments, so the results will vary on a case-by-case basis.
Ares' Greatest Misadventure
In Book 5 (Lines 381-391) of Homer's Iliad, the Oceanid Dione recounts the story to Aphrodite of how a pair of really young giant boys once wrapped the war-god Ares in chains and packed him into a metal jar, nearly killing him. (Further details on that in the second-last section below.) In this and every story in which a god is captured, his opponent is tremendously enormous, so I am assuming that the colossal size of the deity's captor is a major factor if not an outright requirement for the overpowering of the targeted divinity. Only two exceptions to this come to mind.
Hera's Tricky Golden Chair
In one of these exceptions, when Hephaistos [Hephaestus], the artisan of the gods, was young, he used a somewhat steampunk mechanical device—a golden chair with hidden fetters—to trap his mother Hera, who had thrown him away when he was a baby. Hera's other son Ares tried to release her from the trap but failed, whereupon none of the other gods could convince Hephaistos to extricate Hera from the device. Finally the wine-god Dionysos [Dionysus] tricked the artisan-god into getting drunk and brought him to Mt Olympos [Olympus] where Hera had been trapped, mother and son were conciliated to each other, and Hephaistos let Hera out of her inconvenient predicament.
Dionysos Goes on a Cruise
The other exception features Dionysos in his youth, wherein he is captured and bound in ropes by a band of Tyrrhenian pirates posing as operators of a passenger ship. Dionysos, however, is merely toying with these corsairs, whom he terrorises by transforming parts of their vessel into ivy and snakes before changing all these men into dolphins.
The Most Dead God Limited Edition
In Greek mythology there is only one instance of a full-fledged deity actually going through the full process of dying entirely as ordinary mortals do (although, in a way, he comes back to life again). This story, about Zagreus, however, is told by the Orphics, a mystical cult whose mythology was some distance left-field of the mainstream Olympian narratives and which borrows heavily from adapted Egyptian and Asian material. (More on Zagreus in the last section below.) Again there are two exceptions to this, which amount to not much at all after all.
The Tomb of Zeus
The first [exception] is a Cretan version of Zeus about whom it was said that he was actually a local prince who, like Adonis, had been gored to death by a wild boar. Several places on Crete Island displayed his tomb (one of which remains even down to the present day), but even in a time almost as far back as Homer and Hesiod, a famous poet and prophet named Epimenides, himself a Cretan, dismissed this story out of hand, decrying his fellow islanders as degenerate liars on account of this. A few centuries after Epimenides, Callimachus agreed with the Cretan prophet by quoting him on this point in his Hymn to Zeus. In between the times of these two, Pherecydes of Syros had expressed his belief that the Cretan Zeus tomb actually belonged instead to a giant who had been Zeus' school-teacher during the god's childhood on the island, and who thus was very closely associated with the Olympian king.
The So-Called Death of Pan
The second exception comes from an essay written by Plutarch c. 100AD, in which he narrates the tale of how an Egyptian sailor heard a voice announcing to him across the water that he should spread a rumour saying that "the great god Pan" had died. The deity in question never himself makes a cameo in the story, which to me is clearly a metaphor for the subject-matter of the essay, On the Obsolescence of Oracles. The news of Pan's death is an allegory of the decline of certain aspects of popular Ancient Greek religion in Plutarch's time.

Disambiguating and Dismembering Khronos and Kronos
There is a significant but often subtle and fairly confusing difference between the Titan Kronos (Κρόνος in Greek, which gets Anglicised to Cronos and Cronus), who became the father of Zeus; and the primordial mystical god Khronos (Χρόνος in Greek, which is Anglicised as Chronos or Chronus), the personification of time, who is essentially a part of the structure of the universe. In some Orphic cosmogonies Khronos is the father of Khaos [Chaos] and thus the ultimate origin of all things.
Even though Khronos, meaning "Time," from which we get English chronology, chronometer and chronicle, is a different word from Kronos, even in ancient times the two characters were confused and equated with each other. Plutarch mentions an allegorical interpretation that Kronos, who devours his own offspring, was a symbol of how the ravages of Time (Khronos) consumed posterity.
In the early 21st century AD, the most popular source for the idea that the Titan Kronos was chopped to pieces by his own children appears to be Rick Riordan's Percy Jackson and the Olympians series of books, movies and other related entertainment forms. Riordan does not seem to have invented this piece of neo-mythology, and from what I can tell it appears to have arisen from the conflation of the Titan with the Time-God.
In her 2012 poetry collection In the Fullness of Time, Anne Hughes' poem At the Sea's Edge says (p. 67):

Here is where death is—
  time dissolved into that eternity
  from which beauty is endlessly borne—
  agony of Chronos dismembered;
  joy of Aphrodite depth-born

There is a much older reference to the same mytheme, from 1862, in Volume 1 of the London Society Magazine. According to its article "On the Grotesque in Things Sorrowful" (p. 426),

Zeus... could only dismember his father Chronos or Time,

the author thus confirming that s\he thinks Zeus is the son of the primaeval time-deity.
Hughes, for her part, seems to be confusing the Titan (or perhaps the Time-God) with Kronos's father Ouranos [Uranus], the Sky. Kronos had dismembered Ouranos, not by chopping him to pieces, but by castration.
As early as the 19th century, therefore, the stories seem to have gotten heaped into a jumble in which Kronos and Khronos were totally merged, and the emasculation of Ouranos by Kronos somehow became the hatcheting of K(h)ronos by his child(ren) instead.
K(h)ronos Still in One Piece
There is, however, no ancient myth at all in which Kronos [the Titan father of Zeus] is chopped into pieces by anyone, whether by his own progeny or someone other. No such thing happens to the cosmic Time-God Khronos either, whether we equate him with the Titan or not. The worst thing that happened to Kronos the Titan is that he got imprisoned in Tartaros [Tartarus], the vast storm-pit at the lowest level of the Underworld.
But even while incarcerated therein he still received prayers and libations from his children on Mt Olympos, who, according to Iliad 14, were required to invoke his name and those of the other Titans in the Underworld in order to ratify their most sacred oaths. Some time after the Trojan War, Zeus released Kronos and the Titans from Tartaros and granted them amnesty.
Kronos, whose prison sentence had lasted thousands of years, was at this point still alive, well, and bodily intact. He ultimately, therefore, cannot be used as an example of a deity that died, except in the sense that he had inhabited the land of death for aeons, lying inert beneath the dwelling of the human dead who were housed in the layer of the netherworld which sat on top of Tartaros.
Mutilation
Ouranos, the character from whom originates the confused story about K(h)ronos being dismembered, himself did not die when his son Kronos chopped off a piece of him. It is he who was held down by his children and then dismembered. Of four of his sons, each one held down one of his four limbs, while a fifth son, Kronos, arose from the Earth beneath him in order to sever his reproductive organ from the rest of him.
Far from killing Ouranos, instead this action produced yet more life, for the blood which spilled from this violence impregnated the Earth, which from it gave birth to the Furies and the ash-tree nymphs, as well as, in some versions, the Giants. More famously yet, the severed genitalia, dumped by Kronos into the Sea, transformed there into the lascivious goddess Aphrodite.
Apart from the case of Zagreus, the loss of this one body-part is the most grievous injury sustained by any deity in Greek mythology. A very similar thing happens to Agdistis, a being born to Zeus and Gaia in Phrygia. Because Agdistis was born with both male and female organs, the gods feared the entity and cut off the male organ. Upon this emasculation, Agdistis was thenceforward the Phrygian goddess Kybele [Cybele].
An almond tree grew up out of Agdistis's discarded genitals. An almond from this tree then impregnated a local river-nymph, who gave birth to Attis, who, when he had grown up, was castrated and died. He was worshipped after his death and seems to have resurrected in his eunuch form. Attis evidently had been born and died a mortal man, only becoming a god after death, somewhat like Asklepios [Asclepius] and Herakles [Hercules].
The mutilation of Ouranos and Agdistis represents a reduction of their power rather than their destruction. Ouranos loses his rule over the universe and becomes a deactivated part of the cosmos like the more inanimate primordial deities such as Erebos [Erebus] and Tartaros. Meanwhile Agdistis now appears in a less threatening form to the other divinities.
Varied Forms of Injury and Incapacitation
There is otherwise no level of damage inflicted upon Greek deities which comes close to being as severe as any kind of amputation. For several thousands of years the crucified Titan Prometheus has his liver torn out but it grows back almost every day, and he seems to be bodily intact once this torture ends. In one battle against the super-strong mortal hero Herakles, Hades is wounded in the shoulder, Hera in her right breast, and Ares in the thigh. They are each badly hurt but after a visit to their doctor they are all good as new.
Typhon vs Zeus
Zeus has his head split open with an axe, a full-grown goddess bursts forth from his cloven skull, and he recovers just fine from that. Later in life Zeus undergoes an apparently more surgical procedure. As part of the Giants' attack on the Olympians, the cosmic-sized, many-armed, hundred-headed monster Typhon coiled around Zeus, presumably like a python with its prey, and cut the sinews out of Zeus's hands and feet. This apparently paralysed the king of the gods, whom Typhon then threw over his shoulders, carrying him across the Sea to his lair, a cave in Cilicia, Anatolia.
Here Typhon deposited Zeus, hiding the god's extraced sinews in a bear-skin which he placed under the guard of a female, part-dragon creature named Delphyne. Zeus's sons, the gods Hermes and Aigipan [Aegipan], managed to sneak past this sentinel and save their father by reconnecting him with his sinews. After this, a furious battle ensued between Zeus and Typhon which ended with the latter's demise or imprisonment.
At the onset of his attack Typhon had threatened to release the confined Titans from Tartaros, to distribute the goddesses—especially the virgins—as brides among the Titans, the Giants and himself, and to enslave the male deities. Because Heaven was too small to contain him, Typhon planned to tear it down and rebuild it, with himself as its overlord. Zeus, for his part specifically, was slated to became the western pillar of the Sky, replacing the Titan Atlas in this mode of imprisonment.
But once Typhon had Zeus in his mercy, for some reason never explained to us, he did not do anything to him worse than paralysing him. It seems that he could well have killed him, but perhaps Zeus was not so easily slain and Typhon just didn't now how to finish him off. Maybe he intended to first display him in a triumph after fulfilling his promise of unearthing the anciently defeated Titans.
Kidnapping the God of War
A somewhat comical scenario had transpired some time not too far removed from Typhon's attack. Poseidon, the King of the Sea, had consorted with his own granddaughter Iphimedeia, and she bore him a pair of gigantic twin sons named Otos [Otus] and Ephialtes. These kids, whose stepfather was named Aloeus, and after whom they were called the Aloadai [Aloads], grew by nine inches every month. By the time they were nine years old they were each nine cubits wide and nine fathoms tall. In more modern parlance, they were each 18 feet (roughly 6m) wide and 54 feet (approx. 16m) tall.
In circumstances regarding which we are not informed, the twins once kidnapped Ares, who thus went missing for thirteen months, during which no other deity, so it seems, knew where he was. Heriboia was the second wife of Aloeus, and she somehow found out that her husband's giant stepsons had Ares. She fed Hermes this bit of intelligence, and he came in stealth-mode to rescue Ares. The Aloadai had clapped Ares in "cruel bonds" and shoved him into a bronze urn, within which he almost died, perhaps mostly from muscular atrophy and starvation, before Hermes came and stole him out of there. Doing what these boys did to Ares must have required the imposition of a prodigiously incredible amount of brute strength.
I base this on the fact that in the same poem which gives us the twins' measurements we are told that Ares' body, when he fell down, covered seven plethra of land, which is something like 6.3 square kilometres (almost 4 square miles). This comes from Iliad 21.405-410, the measurements contained therein having been translated variously into English as "seven roods" (A.T. Murray, 1924), "seven acres" (R. Lattimore, 1951) and "over an acre" (A.S. Kline's PoetryInTranslation website), all of which are significantly smaller than 6km2 or 4 miles2 but the least of which is still hundreds of times bigger than the Aloadai are supposed to have been.
In comparison to Ares, they might as well have been a pair of ants! We could perhaps explain this away by assuming that Ares, like his cousins Otos and Ephialtes, continued to gradually expand over the years so that he would have been significantly smaller back when they had nabbed him some generations earlier. Or that he only grew so extensively large on battlefields during wartime, such as in Iliad 21, which takes place in the thick of combat during the Trojan War.
The God Whom the Titans Assassinated
One of the most bizarre stories in Greek myth takes place after Zeus rapes his own daughter Kore, who, renamed Persephone, becomes the queen of the Underworld by marrying Zeus' brother, her own uncle Hades. Before she gets married, she gives birth to Zeus's son Zagreus, a beautiful, and sort of monstrous, horned god. In her jealousy over the affection lavished upon this stepson of hers, Hera organises for a bunch of Titans to attack Zagreus, and they chop him to pieces using, as Nonnus calls it in his Dionysiaca, "an infernal knife". This weapon might be some sort of ceremonial instrument from the Underworld.
This and other features of the confrontation with the baby god surely must be connected with the Mystery rituals of the Orphics: features such as how the Titans are able to sneak up on Zagreus because they have painted their faces with chalk and beguiled him with a mirror; and also the way in which he wildly changes himself into various forms before finally being slaughtered while in the guise of a bull.
Being butchered into beef is the closest that a Greek god ever gets to being "reduced to a state of formlessness from which they are unable to return". The conception of such utter destruction does not seem to exist in the ancient myths. Every entity in the universe from the Sky down to the Earth and its mountains, islands, rivers, trees, animals and people, has an essence which continues to exist even after the body's disintegration. This essence is contained somewhere in the cosmos, e.g. most of the dead descend beneath the Earth's surface and are held in the house of Hades.
There are a few different accounts of what happens to the pieces of the slain Zagreus but the most central is his heart, which Zeus preserves. Centuries later, this organ, now powdered, he makes into a special drink for his lover Semele, who becomes the mother of Dionysos. Thus Zagreus becomes reincarnated as the raucous wine-god, a unique position in the mythology, as we have no other Greek deity who is a reincarnation.
Most of the remaining butchered Zagreus-beef supplies the Orphic myth about the creation of humankind. The same Titans who assassinated Zeus's son then devoured his flesh. In his rage over this,

Zeus used his lightning to reduce the murderers to ashes, from
  which, after being mixed with earth and water, humankind then arose...
  The Orphics used this version of the creation story to explain why
  human beings are stuck in a wheel of death and rebirth (virtually
  identical to the concept of saṃsāra in Hinduism and Buddhism) with
  the human soul (Dionysos Zagreus) and body (the Titans) as separate
  entities, the former trapped inside, or being devoured by, the latter.
  ~ From my Answer to another
  Question

Can the Greek Gods Be "Killed"?


Should I charge the client when I get stuck on stupid mistakes

Question: I work for a client for a few hours a week as a freelance web developer. I'm a mid level developer, but sometimes I make easy stupid mistakes, like spending around 35mins wondering why the addon I created is not working and start debugging to find out I didn't activate it in the first place.
should I charge on easy stupid mistakes like that?
Comment: Would I charge my clients for time I spent working for them due to my own lack of being thorough and my inattentiveness? No, I wouldn't.
Comment: @joeqwerty Most of freelancers advice to not charge per hour but for product and or service. At least in my experience it never works out with me.
Answer: I couldn't help but leave my own insights on this matter as two existing answers are all implying a client shouldn't be charged for his employee's mistakes.
If this question is about the right of getting paid when delays have been made due to a freelancer's inexperience, low-level skills, or working practices - as opposed to his/her hidden features like characteristics, inattentiveness, or negligence - the client still has to pay for it. Errors and mistakes happen everywhere, every time. There's nothing guilty about it.
The reason is clear: The client shouldn't have hired his employee in the first place if his/her skills didn't meet up his expectations. That's what employers do. Most importantly, he should be responsible for his choice of choosing whom he is working with, and what his employee's mindset looks like.
Refusing to pay for the mistakes can only happen when the client thinks he has hired a working robot, not a human. Otherwise, any hours spent on the work that is (even slightly, let alone directly) related to the client's project are subject to the regular payment, even when you are working on an hourly basis.
If it was like 5 or 8 hours, you might want to discuss, but heck, it's like 35 minutes, not even one hour. Nobody would claim confidently that he/she always makes every 35 minutes in his workplace super-productive, would you?
As long as you have materials that support your claim you didn't idly spend time for those 35 mins, you have full rights to get paid.
Comment: You got a point but the very topic we are currently involved in is about the basic work ethics - which shouldn't be differentiated by contract types.
Comment: *Employees* are quite different than *freelancers*.
Comment: I agree with the sentiment of this post (although maybe not the middle paragraph about employees). I'll add that the alternative is to charge a fixed price for the work - which in most cases the freelancer will have calculated the *real* time to do something, not the most optimum time a super-human could do it. As such, fixed price charging includes some "faffing about" time, so why can't charge-by-the-hour? That said, if I've wasted time on something stupid, I'll reduce the quoted hours on the task, because that seems the right thing to do.
Answer: Delays which are due to your business/working practices are typically not the clients responsibility.
Let's look at the situation with a similar scenario.....
You're working along on a client's project and mistakenly close a file without saving it. Silly error, but I'm sure it's happened to most. This error means you have to redo what you just did for the past hour. That's an additional hour of your time.
If something, in the middle of a client's project, incurs time not directly related to the completion of the project, then it should not be invoiced. If I made some silly oversight which adds significant time to working hours in order to correct, I wouldn't feel right invoicing the client for time spent correcting my oversight. I'd not invoice for time spent on my error.
Comment: And that's the nature of our work, much of our time is spent on patching stuff together and debugging issues, it's not always coding
Comment: I guess that's your call then as to what's inexperience and learning and what's simply an error. I don't think anyone else can answer that for you.
Comment: Okay but here's the thing, the client knows that I've never work on the platform he provided before, and sometimes my mistakes are lack of experience with the platform's logic, not coding itself.
Comment: Inexperience is often built in to the rate, so if a client is getting "cheap" resource, then they can expect a bit less productivity than a more experienced, higher rate freelancer. As I said elsewhere, the alternative is a fixed price contract, where the freelancer will have set the price based on the *real* time to do the task, not the time someone better than them might be able to do it. Thus, fixed price contracts have some "fluff" built in, why can't hourly charges too? That said, I would reduce the hours worked if I'd wasted a lot of time on something I should have known.
Answer: We would not charge our client on stupid mistakes. We commonly subtract the estimated time from the final hours if hourly pay was required for their project. Of course, any developer will probably spend time figuring out things and testing things trying to get it to work properly. In this case we might take a few minutes off that make sense. It's all about reason.
If you were hiring someone to do something, and you found out they charged you $100 extra because they did not do what they should've known to do (press the apply button before running the new code) how would you feel? Would you happily pay them or feel this would have been all avoided if they simply pressed the apply button instead of trying to edit, and reedit the code for 30 minutes to an hour over the course of the project?.
Answer: Up to a point the issues that surround freelance (contractor)work are part of the work effort, especially with software that is new or is an  unknown quantity. The contractor is not an employee and should not expect the same leeway or treatment. The point becomes shorter when the software is a known quantity or the issue is a personal mistake such as forgetting to hit a button at the appropriate time. The bottom line is that a contractor needs to be more disciplined and self-disciplined than an employee.


I s there a way I can show node teasers but don't allow access to full content?

Question: I need anonymous users to to be able to se the node teaser but don't allow access to the full content is there a way to do this?
Answer: To prevent users from access the node you can disable the "View published Content" permission but that will disable it for all node types. If you like to disable it just for one node type you can checkout the content_access module.
You can use a view of content to display the teasers.
In the format section use the format "Unformatted list" and choose your content display Teaser.
If you use a page for the view, you should also check the page access in the page settings section of the view.
I'm not sure if you need the following (It depends on how you prevent the node access):
In the advanced section under query settings you can disable sql-rewriting. This allows you to disable the node_access check. But take attention to this:
"Disabling SQL rewriting will omit all query tags, i. e. disable node access checks as well as override hook_query_alter() implementations in other modules."
Comment: Thank you for your help but this is what I'm trying to do I'm using" Display Suite" for the "search" the search options only gives me 7 options for display none of them is a  "view" display that is why I'm trying to make the teaser display for users that are not log in, on other sections of my page I try the option you gave me and it works but unfortunately I can not find a way to add this to the search page.
Comment: I'm using  Node Option Premium module but is not working for me I install it I check the box to premium content but my teaser doesn't show to anonymous users is there something else I need to mark that I haven't mark to make it work?

I'm using the Access Control module as well


FreeBSD and pf - packet filtering based on OpenVPN usernames

Question: I have an OpenVPN server which authenticates the users using an Active Directory server. I need to limit the bandwidth of each user based on their usernames, and I also want to be able to do some basic packet filtering on OpenVPN users. Users are assigned random IP addresses and I prefer to not change that. How can I do that?
Answer: Don't use Pf for that.
ipfw2 would be simpler because with its dummynet-subsystem you can enforce equal bandwidth sharing policy for all of IPs in a given IP-network. Check out ipfw2 pipes and queues.


Examples of SQL Injections through addslashes()?

Question: In PHP, I know that mysql_real_escape is much safer than using addslashes.
However, I could not find an example of a situation where addslashes would let an SQL Injection happen.
Can anyone give some examples?
Answer: Well, here's the article you want.
Basically, the way the attack works is by getting addslashes() to put a backslash in the middle of a multibyte character such that the backslash loses its meaning by being part of a valid multibyte sequence.
The general caveat from the article:

This type of attack is possible with any character encoding where
  there is a valid multi-byte character that ends in 0x5c, because
  addslashes() can be tricked into creating a valid multi-byte character
  instead of escaping the single quote that follows. UTF-8 does not fit
  this description.
Comment: How about magic quotes? I have seen site who just puts $POST['password'] into the SQL query, and it does not fail for them. Can you explain why does it work?
Comment: Magic quotes are a whole 'nother topic; see http://stackoverflow.com/questions/220437/magic-quotes-in-php.  Presumably the example you give 'works' because magic quotes are on.  Among the many reasons not to use magic quotes is that magic quotes uses the same logic as addslashes(), so has the same vulnerability described here.
Answer: As an addition for the readers of the answers here: This MySQL bug has already been fixed:)
Also, it is always good practice to use prepared statements. It is the most exploit-free way you can fire queries (and, in several use cases the most performant). And it would have saved you from this flaw.
Comment: Can you mention your source on this bug fix? Thanks!
Answer: Chris Shiflett clearly explains with the bellow example, That will of-course work if you try it when using GBK encoding in your database. Even I tried it, this proves, there are chances for sql injection, even though they are very less, but someone with good knowledge and capability can easily inject. Here is an Example...
<?php

       $mysql = array();
       $db = mysqli_init();
       $db->real_connect('localhost', 'myuser', 'mypass', 'mydb');

       /* SQL Injection Example */

       $_POST['username'] = chr(0xbf) . chr(0x27) . ' OR username = username /*';
       $_POST['password'] = 'guess';

       $mysql['username'] = addslashes($_POST['username']);
       $mysql['password'] = addslashes($_POST['password']);

       $sql = "SELECT * FROM   users
               WHERE username = '{$mysql['username']}'
               AND password = '{$mysql['password']}'";

       $result = $db->query($sql);

       if ($result->num_rows) {
              /* Success */
       } else {
              /* Failure */
       }

?>

Although the use of addslashes() or magic_quotes_gpc would normally be considered as somewhat secure, the use of GBK would render them near useless. The following PHP cURL script would be able to make use of the injection, I hope this will help you a bit more to understand:
<?php

       $url     = "http://www.victimsite.com/login.php";
       $ref     = "http://www.victimsite.com/index.php";
       $session = "PHPSESSID=abcdef01234567890abcdef01";

       $ch      = curl_init();

       curl_setopt( $ch, CURLOPT_URL,            $url     );
       curl_setopt( $ch, CURLOPT_REFERER,        $ref     );
       curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE     );
       curl_setopt( $ch, CURLOPT_COOKIE,         $session );
       curl_setopt( $ch, CURLOPT_POST,           TRUE     );
       curl_setopt( $ch, CURLOPT_POSTFIELDS,     "username=" . chr(0xbf) . chr(0x27) .
                                                 "OR 1=1/*&submit=1" );

       $data = curl_exec( $ch );

       print( $data );
       curl_close( $ch );
 ?>

Answer: mysql_real_escape_string() versus Prepared Statements clearly explains mysql_real_escape_string() isn't 100% secure.
using mysql_set_charset('GBK') to replace mysql_query("SET CHARACTER SET 'GBK'"), the mysql_real_escape_string() can be 100% secure.


Charting your Course

Question: Below is a puzzle I made for a university puzzle hunt.  The answer is one word.
Comment: Also, I'd appreciate any criticism you happen to have!
Comment: My only slight criticism (though I have no idea how you'd fix this) is that some of these flags are hard to match. However the country names are obviously important and need to be found so don't know how you'd get round that without giving away the name. Great puzzle though!
Comment: I'll respectfully disagree -- if you're allowed to use Google, matching flags to countries is actually quite easy using image search.
Comment: One thing I now noticed: if my answer is correct, try not to mention the answer in your introduction, it can be seen as a bit disappointing when the answer is found.
Comment: There's some stray dots above and mainly below the first line of text (remnants of some earlier text, perhaps?) that ideally wouldn't be there. Puzzling folk tend to look for oddnesses, and putting in extra oddnesses  which are meaningless is distracting. :)
Answer: Identifying the countries:

Costa Rica -> Bahrain -> Russia -> Malta -> Nicaragua
Canada -> Bosnia -> Laos -> Seychelles -> Canada
Armenia -> Colombia -> Australia -> Malta -> Central African Republic
Latvia -> Norway -> Liberia
Singapore -> Costa Rica -> Turks and Caicos -> Singapore

From the starting text,

 "Australia is gold, Korea is noble" clues us that we want the ISO alpha-2 codes for the countries -- so Australia would be Au, which is gold, and Korea would be Kr, which is krypton.

Finally,

 Draw each path on the periodic table (the mid point of the W is off because it should be in the Ru for Russia -- can't find my original image to edit it now):

 These form letters, giving us the final answer of WORLD.
Comment: Yep!  I think the middle point of the W is off, but the answer is right.  Thanks - I actually hadn't noticed that I'd included the answer in the introduction
Answer: Partial: (I have to go now, here is as far as I got, but someone else can continue...)

The first two letters of each country

represents an chemical compound or element (e.g. AUstralia - Au = gold)

The countries are

COsta Rica -> POland -> RUssia -> MAlta -> NIcaragua
CAnada -> BOsnia -> ? -> SEychelles -> CAnada
? -> (C?)Olumbia -> Australia -> MAlta -> Central African Republic
LAtvia -> NOrway -> ...
...

So the elements/compounds are

Cobalt -> Polonium -> Ruthenium -> Masurium -> Nickel
Calcium -> Boron -> ? -> Selenium -> Calcium
? -> Cobalt/Carbon -> Gold -> Masurium -> ?
Lanthanum -> Nobelium -> ...
...

The next step is to

Map this on the periodic table but I don't have time so I shall allow some other puzzler to finish this off...

Charting your Course


Properties of $\zeta(s)\zeta(2s)\zeta(3s)...$

Question: Let's consider the Dirichlet series $f(s)=\sum_{n=1}^\infty a_n n^{-s}$, where $a_n$ is the number of non-isomorphic abelian groups of order $n$. Now $a_n$ is weakly multiplicative and $a_{p^k}=P(k)=$ partition number of $k$, so we get $f(s)=\prod_{p} \sum_{k=0}^\infty P(k) p^{-ks}=\prod_{p} \prod_{k=1}^\infty \frac{1}{1-p^{-ks}}$ because of the generating function of the partition number. So we get $f(s)=\prod_{k=1}^\infty \zeta(k s)$ (where everything converges absolutely).
So my question is: what is known about this function? Is there a functional equation or an analytic continuation?
Thank you very much.
Comment: It has a meromorphic continuation with simple poles at $1/k$ and a [natural boundary](https://mathoverflow.net/questions/275706/does-this-product-have-analytic-continuation/275723#275723) on $\Re(s) = 0$ (non-trivial zeros $\rho$ of $\zeta(s)$ are copied at $\rho/k$) .
Answer: As usual when counting objects, it is preferable to assign a weight proportional to the inverse of their automorphism group. While the function
$\zeta(s)\zeta(2s)...$ does count the number of non-isomorphism abelian groups
of order $n$, if you now count them with the factor $1/|Aut(G)|$ the function
becomes $\zeta_\infty(s)=\zeta(s+1)\zeta(s+2)\zeta(s+3)...$ which is MUCH more interesting. What follows is directly taken from the basic paper I wrote with
H.W. Lenstra on heuristics for class groups (Springer L.N. 1068), in the
special case of abelian groups (one can do the same for finitely generated modules over Dedekind domains). Set
$$W(s)=(\Gamma(s/2)^{-1}\Gamma_2(s))^{1/2}\pi^{s^2/4}2^{(s-1)(s-2)/4}\zeta_\infty(s)$$
where $\Gamma_2$ is Barnes's double gamma function, and
$$\Lambda(s)=W(s)W(-s)\sin^2(\pi s)/(\pi^2C^2)$$
where $C$ is an easily given normalizing constant.
Then $\Lambda(s)$ extends to an entire function of order $2$ (like the
Selberg zeta function, but with quite different properties), which is of
course even, and its functional equation simply says that it is periodic
of period $1$ (morally speaking, it is a gamma factor times
$\prod_{n\in\Bbb Z}\zeta(s+n)$), this being equivalent to the functional
equation of the zeta function itself.
What's fun about this function is that if you graph it on the real line
(try it!) you get the constant $1$ (or some other constant if you don't
know the value of $C$), which is impossible.
In fact, its graph is close to less than $2.10^{-38}$ from the constant $1$,
as an easy exercise (or a look at the paper) shows.
Just my 2 cents because it's fun.
Comment: Also $\prod_{n=0}^{N-1} \zeta(s+n)$ has its own functional equation. It is the zeta function of the projective variety $ \mathbb{P}^N$ and it should be the Mellin transform of an automorphic Eisenstein series.


Best apples for apple pie

Question: I am making an apple pie for the first time this Thanksgiving.  I was wondering what the best apple was for apple pie.  There are so many to choose from.
Comment: If you happen to have some Red-seeded Citron watermelons hanging around, and the determination to cut them up and seed them, they're really excellent in mock apple desserts (with citric acid, brown sugar, nutmeg, and cinnamon): the flesh—not the rinds. Great firm texture. Nice apple-like flavor (not without the mock apple ingredients). Very easy melons to grow. The fruits can keep for over a year (so, they'll be around for the holidays).
Answer: Some of this is a matter of opinion, as you must decide what type of apple pie you like.  Do you want one with discernable applie slices, or one where the filling becomes somewhat like apple sauce?
Kenji Alt of Serious Eats has done an in depth review of 10 commonly available apples (at least in the US), and his conclusion is:

[...] the best ones in the running are the Golden Delicious and the
  Braeburn. They're the ones I use for all of my baking purposes.

Still, I suggest reading his review, and drawing your own conclusion.
He also shares that the level of acidity an apple has correlates with how long it takes to brown when cut and exposed to air--the slower the browning, the more acid.   Those apples with the most acid tend to produce the firmest cooked product, as the acid helps keep the pectin from breaking down.
Comment: Interesting - having a McIntosh tree means most of my pies use those, and I don't think I've ever tried Golden Delicious (when I have to buy apples, it's usually Braeburns or Jonathans). I think any non-mealy apple would be fine.
Answer: Granny Smith is the standard go-to. I think the best pies use a combination of apples. Alton Brown likes a combination of Granny Smith, Honeycrisp, Braeburn and Golden Delicious.
I love Granny Smith and Honeycrisp for out-of-hand eating, so I often have those on hand when I get a hankering for baking. A combination of those two apples do make for a great pie.
Answer: Having found this question on the Stack Overflow blog - I feel compelled to add a UK perspective.
Looking at Kenji Alt's list of apples, I find there are only probably three on there I've ever seen in the UK.
Here they are in what I would consider worst to best order...

Golden Delicious - there was a massive influx of these cardboard/floury-flavoured apples in the 80s & 90s, now thankfully diminished. They don't taste of much raw, so cooked they're just going to be filler. They also turn to mush when cooked.

Gala - a modern twist on an old English favourite. Great to eat raw, but they don't cook well. Too sweet & perhaps a little 'cidery' for pie. They remind me of Cox's orange pippin, but are apparently not closely related.

Granny Smith - just enough punch to cook with, tart raw, but floury when cooked.

But there's one very serious candidate missing from that list & from all other answers here.

Bramley [or to give it its full title Bramley's Seedling - this is the British cooking apple. Almost too tart & crisp to eat raw [though it has its adherents] & also comes in sizes big enough to make a pie from a single apple, this is absolutely the staple of the British apple pie.

Even Wikipedia calls it "the most important cooking apple in England and Wales"
Maybe US apple pie is aiming for a different flavour or texture profile than the UK - I've never had apple pie in the US - but if you can get hold of these [they are apparently available, if in limited supply, on the North American continent] then be sure to give them a try.
Answer: The secret is 3 different types of apples.  Keeps every bite different & your taste buds will thank you.

Best apples for apple pie


Tried to install 18.04LTS and failed. Now can't get to BIOS/UEFI. Screen blank

Question: I bought a new  Win10 laptop (UEFI, Teclast F7). So of course I had to try and install (dual boot) 18.04 LTS right away. I setup a USB flashdrive and went to BIOS, disabled SecureBoot then boot from USB.
I chose Install Ubuntu from the menu and the installation process started as usual. Unfortunately the Ubuntu installation failed in the middle with error (forgot exactly) but it continued to GUI live session. I then run the Install Ubuntu from the LIve session, but I cancelled it when asked about setting password for the UEFI.
So I restarted the laptop again thinking about going to BIOS again because I remembered I need to turn off FastBooting also (which I didn't do the first time). But this time, I could't get to BIOS, pressing ESC key didn't work (Teclast logo also didn't come up) and it booted directly to Windows 10. I tried the Recovery menu from Windows and chose UEFI Firmware to fix and enter the BIOS several times, but I couldn't enter the BIOS, it just kept going straight to Windows.  The Teclast Logo also didn't show up as usual when booting.
Pressing different keys other than ESC also didn't work. Trying the Recovery menu several times also didn't work. But still, Windows was working fine. That is until Win10 updated itself. After it finished updating I shutdown (Shutdown and Update) the machine and went to sleep.
In the morning I tried again. But this time, the display remains blank. So all I got after pressing the power button is the LED lights up, numlock LED also lights up then off after a while. Windows seems to be booting because pressing some keys produces that familiar ding sounds. But the display is blank.
So now I'm stuck, I can not get to BIOS to boot from USB or reinstall Windows/Ubuntu, and can't do anything in Windows because the screen is blank.  So here's what I think. During the windows update, something went wrong with the display or display driver causing it to blank. And failed ubuntu installation somehow messed up the BIOS/UEFI preventing me to enter BIOS.
Sorry for the long post, but Can anyone help? How should I go about troubleshooting this mess?
TL;DR:
Failed installing Ubuntu. Can't go to BIOS. Can't do anything in Windows (screen blank/display driver problem??). I want to reinstall Win/Ubuntu but how?
Thanks in advance,
Regards,
T.Kart
Comment: Can you bring up your BIOS menu during POST (Power On Self Test)?
Comment: That's just it. I can't enter BIOS anymore. Even Teclast BIOS logo didn't show up. Pressing ESC key (or any other keys I tried: DEL, F1-F12) doesn't do anything.
Answer: Windows 10 enters into recovery mode after a few failed boot attempts. Just turn your pc on and off a few times, that is before it has time to boot completely.
Comment: Thanks, but no luck yet. Screen still blank. Tried more than 20 times. I'll keep trying.
Answer: Finally got it to work by opening the back cover and disconnecting the battery.


Photoshop - Texture like tiny 3D bumps

Question: I don't even know how to describe what I'm looking for, that's why I'm showing you an image:

So how could I imitate this texture on Photoshop? I don't know how to search for it online. Anyone can help me please?
Answer: You could zoom in, and crop one small square of the pattern, then do Edit > Define Pattern
An example, zoomed into the pixel level, then cropped

Then use it by filling an area with the pattern you have defined
For example

Add a levels adjustment layer and a mask to create shading, then a warp transform to make it curve
Comment: That was exactly what I was looking for! Thank you very very much!
Comment: @FayeD. You're welcome.
Answer: This problem is already solved several days ago and the questioner got exactly what he asked.But the problem itself maybe earns more.
The tiny bumps obviously are like 3D half-spheres made by letting a multi-tip tool press and stretch a sheet of thin metal foil. The outset side of the foil is painted to nearly black.
As already shown, a 2D texture image of it can be made by using the pattern stamp tool. But for higher resolution one must make the pattern from scratch:

The pattern is a 20 x 20 pixels image which is filled at first with dark grey. A circular selection is made and the selection is filled with radial gradient from white to black. The idea of the gradient is the same as what's used in numerous cases where a shaded sphere was drawn.
It looks pretty good when a 1200 x 1200 pixels area is filled:

This can be warped to look curved and it can get also some (masked) light and shadow to make the lighting to be in accordance with the warping:

This is a not so perfectly succeeded attempt to make it look cylindrical with some perspective and a tilted watching direction. The curves layer with layer mask mercifully hide the badly warped edge areas and leave only the low distortion middle area well visible.
Photoshop's warping isn't good for this much distortion. The result would be much better if the curvature was only few degrees. 180 degrees is not manageable, but the shading partially hides the poor result in this case.
Illustrator's 3D effect or a real 3D program makes it much more easily. Even wrapping it around the neck of a bottle is done in a minute (assuming the bottle is already there):

This result reveals the other weakness of the bump texture image: It's flat. Good light shows that there's no bumps at all, its like printed. The shadings of the individual bumps are the same, no matter what's the direction of the light. At the edges the bumps should cover partially each other and their tops should be seen sideways. It can look right the first 2 seconds, but it stays flat after one has got the idea it's flat.
To get something more plausible the texture should be real 3D. Here's a curved piece of real 3D texture for a comparison:

The bumps even cast shadows on other bumps. Making this is not possible in Photoshop CC. Those who have old CS6 can get quite close, but it's easy only in a real 3D program.

Photoshop - Texture like tiny 3D bumps


Problem with modifying dice in another players turn

Question: I have the following problem: I want to create a multiplayer game where each player has a turn where he has to roll a lot of dice again and again. But the other players are capable of modifying each single dice with a special action. But since this is a rare action because each player has a limited amount of modifications, I do not want to implement a simple dialog where you have to approve each roll. This would make the game rather sluggish. Any suggestions for the best way to implement a UI which allows to modify every single dice, but makes the game as fast as possible?
Answer: You could make dice animations last longer on the main player screen than on the opponent screen. This way the opponent would have a very short time period to click or hit a button in order to modify the result. If all the rolls are longer on the main player screen and shorter on the opponent screen, then the main player should not be able to know if the final result has been modified or not. (Of course this require an UI that enable very fast modification)
You could also choose to give more time to the opponent to decide himself, but this is at the price of somehow informing the main player of the modification. It could be done using some kind of time traveling animations. Let's take an example: suppose the main player is rolling its fifth dice hand. In the meantime the opponent who is reviewing the third one decide to modify it. Then the main player temporary loose the control and an animation show the dice rolls in reverse animation until the third roll, then a modification occurs and finally the fourth and fifth rolls are re-played. At that point the player can continue to roll the others dices but he knows about the modifications.
Finally another way to proceed would be by modifying the results afterward. First the main player rolls all the dices and in a second time the opponent can decide to take part of the turn and modify the results or to let the game continue. Of course, this is a quite visible method too.
There is probably plenty of others approaches, but those are the main ideas that come to my mind now.
Comment: Well, I will definitely try out the one with the animations :)
Comment: This is not the easiest choice to implement, but this is the most oppressing for the opponent, and thus the most fun choice I guess ;) So good luck with that.
Comment: Well, the more I think about this solution, the more I like it. Keeps players watching all the time, since I will leave only 1500ms for this action...
Answer: Take a look at how Magic: Duels of the Planeswalkers does things.
Each player has turns made up of multiple phases.  Each action needs confirmation.  The system lets a player decide if he wants to act in any particular phase with a super easy in-game panel showing the phases and which ones the game will stop for.  There is a timer to ensure nobody takes forever.
You can also allow more than one modification to be applied at a time.  When a player rolls, give the other player time to select any dice he wants to modify and what mods to apply.  A simple drop-down or radial menu over each die might work.


Why does GPE convert to kinetic energy?

Question: What is it about GPE that makes it transfer to kinetic energy, why does it do this? What is GPE?
Comment: Two masses attract each other, leading to an acceleration which increases their velocity…
Comment: By "GPE" do you mean the Gross–Pitaevskii equation? :P  https://en.wikipedia.org/wiki/Gross%E2%80%93Pitaevskii_equation
Comment: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Comment: @Quillo No: gravitational potential energy.
Answer: Gravitational Potential Energy (GPE) is the amount of energy an object could have if it were to fall from that height. Thus - provided the gravitational acceleration is constant - gravitational potential energy only depends on mass and how far from the ground ($h=0$) the object is suspended, given by $U=mgh$. It is transfered to kinetic energy when droped from height h. This kinetic energy can be calculated from the equation $KE=\frac{1}{2}mv^2$. If you want to calculate the kinetic energy in terms of the gravitational force $mg$, you'll have to apply the Work-Energy Theorem, which states that the net work equals the change in kinetic energy; however, because the kinetic energy is initially $0$, it would just be the final kinetic energy, just before the object reaches $h=0$. The work is done by multiplying the force ($mg$) by the height, $h$. Hope this helps.
Answer: As I understand it(your question), we can use conservation of mechanical energy to answer your question.
Consider a ball (of mass $m$)falling from a height $h$. After some time before the collision, the ball must be at height $h_{2}$ which is obviously less than the original height. It is clear from the above observation that:
$$
mgh > mgh_{2}
$$
This means that the GPE has decreased. To balance the decrement in GPE, Kinetic energy increases so that overall mechanical energy remains conserved. Since mass cannot change, velocity increases to increase the kinetic energy.
At the bottom most point(on the ground), GPE is $0$ which means all Potential energy had been converted to kinetic energy of the mass. This is why velocity is maximum till the time the object reaches the ground.

Why does GPE convert to kinetic energy?


How to remove scratches on varnished wooden door?

Question: Is there any easy way to make scratches disappear from wooden, varnished doors? Doesn't have to be perfect, I just need to make them hard to spot for someone who doesn't know they're there.
Answer: There are several finish repair products on the market.  You can get most of them from the usual getting spots.
I've had very positive results with "restor a finish", they sell it in multiple colors so you just need to find the one that most closely matches the wood you are working with.   There are also "fill sticks" that are probably better suited to deeper scratches.  Also "Feed-N-Wax" will make a lot of scratches less visible.
Comment: @drake035 note that while one purchase of these repair products may be expensive up front, it's likely to last you the rest of your life, so the per-use cost is pretty low.
Comment: Thanks, gosh these products are expensive. Have you ever come across any cheaper solution that works? Some people said there were impressed by... walnuts (rubbing a peeled walknut against the scratch)
Comment: @drake035: yeah the walnut trick works, the restor a finish is also a varnish though so it will reseal the wood where the scratch is where a walnut wouldn't


Reseting Vista Admin Password from Installation DIsk

Question: I am trying to reset the admin account password that I forgot for an old Vista machine.  Because I don't have a password reset disk, I have resorted to attempting to run net user from the command line of the recovery environment on the vista install disk.  However, net user sees only the users (guest, administrator) from the live environment and refuses to recognize the users on my Vista install.  I am wondering if/how I can switch it so it sees the users on my local install?
Answer: I assume that you mean a Vista-created password reset disk. You don't really need that. You can go get the Ultimate Boot CD, and run the "Offline NT Password & Registry Editor" tool.
This will let you reset the password

http://www.ultimatebootcd.com/


Cannot access a disposed object

Question: i am facing a huge problem with the "Cannot access a disposed object. Object name: 'TreeView'." error.
On a windows forms of mine i use a custom windows explorer object.
And here come the code parts...
On the selected node event, i load the images found within the selected directory to the FlowLayoutPanel.
 Private Sub ExpTree1_ExpTreeNodeSelected(ByVal SelPath As String, ByVal Item As ExplorerControls.CShItem) Handles ExpTree1.ExpTreeNodeSelected
      'Loop until all images are loaded.
       LoadImagesToFlowPreviewPanel()
 End Sub

On the button close event
 Private Sub WizardControl1_CancelClick(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WizardControl1.CancelClick
        Me.Close()
 End Sub

On the Form Closing event
 Private Sub Wizard_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
                Select Case XtraMessageBox.Show("Exit the application?", Me.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                Case Windows.Forms.DialogResult.No
                    e.Cancel = True
                End Select
        End If
 End Sub

While debugging i noticed that when i confirm closing the application, the code within the LoadImagesToFlowPreviewPanel sub continues to execute. The error is raised when all the images are loaded to the FlowLayoutPanel control.
And here comes the stack trace...
   at System.Windows.Forms.Control.CreateHandle()
   at System.Windows.Forms.TreeView.CreateHandle()
   at System.Windows.Forms.Control.get_Handle()
   at System.Windows.Forms.TreeView.TvnSelected(NMTREEVIEW* nmtv)
   at System.Windows.Forms.TreeView.WmNotify(Message& m)
   at System.Windows.Forms.TreeView.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
   at System.Windows.Forms.Control.WmNotify(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Application.ParkingWindow.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
   at System.Windows.Forms.TreeView.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.TreeView.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   at CannonUpdater.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 82
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

UPDATE: IF all the images are loaded to the FlowLayoutPanel and the confirmation of the application close comes next, i get no error.
Comment: What's happening the `LoadImagesToFlowPreviewPanel()` method? Unless you're running that on a separate thread, you shouldn't be able to close the form unless that method is finished running. What does your "Loop until all images are loaded." comment mean? I don't see a loop...
Answer: Basically this happens when you perform an operation on a object that is still alive that you have disposed. So either like this:
A a = new A();
a.Dispose();
//operations performed on a will fail now

Or like this
using( A a = new A()){
  ...
}
//operations performed on a will fail now

Remember that a using block will also dispose your object just like manually calling Dispose.
Answer: You should post the relevant parts of your LoadImagesToFlowPreviewPanel method.
This is speculation without seeing the code, but one explanation could be:

LoadImagesToFlowPreviewPanel is calling Application.DoEvents in a loop
The Form is closed and the TreeView disposed during one of the calls to Application.DoEvents
But the loop continues to execute and accesses the disposed TreeView.

If it was this, the solution would be either a redesign to avoid calling Application.DoEvents, or at least checking if the Form is closed / TreeView is disposed after every call to Application.DoEvents.
UPDATE in response to comment:

Wow! Actually the LoadImages is calling the Application.DoEvents within a loop

If you use Application.DoEvents you expose yourself to reentrancy problems in your code - you need to be very careful and make sure you understand all the consequences when you use it.  The issue you described is not the only problem you're likely to face.  I would only use it in very specific cases where I can guarantee not to have reentrancy problems (e.g. while a modal progress dialog is displayed).  And many people will call DoEvents "evil" and have nothing to do with it at all.
Comment: I disagree that `DoEvents` is "evil", but it *is* a serious code smell. It can lead to difficult to diagnose bugs (like this one), and it indicates a poor understanding of the Windows event-driven model. The only people who should use it are those with a thorough understanding and appreciation for what it is doing, which are often the same people who find a better way of making their code work. That begin said, your answer is correct; I'm not sure why I'm the only one who's upvoted it so far and why it hasn't been accepted. Your psychic debugger is calibrated much better than mine.
Comment: Wow! Actually the LoadImages is calling the `Application.DoEvents` within a loop
Comment: @Cody - I completely agree with you.  As for upvotes, my experience is that answers to common general questions attract them more than specific ones like this.  But I have more points than I can ever spend so I'm not concerned :)
Answer: What's going on here is you start a thread that manipulates a TreeView object and then before the thread is done, TreeView is disposed.
To fix that, check if the TreeView is available to manipulate or is not disposed using TreeView's IsDisposed property in your thread.

Cannot access a disposed object


is there any way to make a loop animation in blender?

Question: a short loop animation in blender 2.81 ? How to make a short animation looping, so it plays and replays the animation itself.
Answer: Step 1. Make the animation
Step 2. At the end frame, duplicate the first keyframe of your animation and move it there.
Step 3. Done!
Comment: If want to loop on frame 1 to n,  copy frame 1 keyframes to frame n+1.  If then you only want action to have frames 1 to n, then insert keyframes at frame n and remove those at n+1.


Teasers/summaries don't show when body begins with picture

Question: I have a blog content type which uses a WYSIWYG editor and allows media to be inserted.  Usually things work out fine, and the blog page shows a list of nice trimmed teasers and/or summaries.  But when the blog post begins with a picture, the teasers and/or summaries don't show up on the blog page.  Instead, there is just a --- where the text would normally be.
I tried deleting the  tags around the image, but it didn't help.
Any advice? (We have to continue using the WYSIWYG editor/media insert, so that part can't change, unfortunately.)
Answer: Try this How to Add a WYSIWYG Editor to a "Text with Summary" Field if it works for you.


Icons in Finder, Safari, Mail, and Dock are not visible

Question: I booted my MacBook Pro a few days ago and some of the icons on my dock were not visible. I noticed that there were icons missing in Safari, Finder and Mail. I attach a screen-shot to make my issue more clear.
Answer: Try Safe Booting once. It causes all caches(including icon caches) to be rebuilt.
Steps for Safe Boot here

Choose Apple menu > Shut Down.
After your Mac shuts down, wait 10 seconds, then press the power button.
Immediately after you hear the startup tone, hold down the Shift key.
You should press the Shift key as soon as possible after you hear the startup tone, but not before.
Release the Shift key when you see the gray Apple logo and progress indicator.
To leave safe mode, restart your Mac again, but don't hold down any keys during startup.
Comment: Hello, i followed your advice but i still cannot see the icons. I downloaded a program that was meant to delete caches from my mac but that didn't fix my issue either.


Marginal distribution of the difference of two elements of a Dirichlet distributed vector

Question: Let $(X_1, X_2, \ldots X_n) \sim \text{Dirichlet}(\alpha_1, \alpha_2, \ldots \alpha_n)$, what is the marginal distribution of $X_i - X_j$?
Comment: You can collapse the distribution to $n = 3$, for what good that does, by combining all the elements of the vector other than $i,j$ into one.
Comment: It has a piecewise formula in terms of multidimensional hypergeometric functions.  It looks messy, especially for $n\gt 2$.
Answer: Analysis
The thread at Construction of Dirichlet distribution with Gamma distribution shows that the Dirichlet distribution with parameters $(\alpha_1, \alpha_2, \ldots, \alpha_{n+1})$ arises as the distribution of the ratios
$$X_i=\frac{Y_i}{Y_1+Y_2+\cdots + Y_{n+1}},$$
$i=1, 2, \ldots, n$ where the $Y_j$ are independently distributed with Gamma$(\alpha_j)$ distributions.  This permits two simplifications, because (a) we may choose the order of the $\alpha_i,$ reducing the question to the difference $X_2 - X_1$ and (b) since the sum $Y_3 + \cdots +Y_{n+1}$ has a Gamma$(\alpha_3+\cdots+\alpha_{n+1})$ distribution, we only have to consider the case $n=2.$
Solution
As usual for computing marginal distributions, change the variables in the Dirichlet distribution from $(X_1,X_2)$ to $(X,X+Y)$ where $Y$ represents the difference $X_2-X_1.$  This transformation has unit Jacobian, so the integrand remains otherwise unchanged.  The (unnormalized) integrand is proportional to
$$X^{\alpha_1-1}  (X + Y)^{\alpha_2-1}  (1 - X - (X+Y))^{\alpha_3-1}$$
and we have to integrate out $X$ to find the marginal distribution of $Y$.
Since none of the three terms can be negative, the integral breaks into two parts: one from $x=0$ to $x=(1-y)/2$ when $y \ge 0$ and the other from $x=-y$ to $x=(1-y)/2$ when $y \lt 0.$  These are well-known integrals--Mathematica or Maple or even tables of integrals should provide answers for you.  The results are
$$f_Y(y) = \frac{\Gamma (\alpha_1+\alpha_2+\alpha_3)2^{-\alpha_1}  }{\Gamma (\alpha_2)} y^{\alpha_2-1} (1-y)^{\alpha_1+\alpha_3-1} \,
   _2\tilde{F}_1\left(\alpha_1,1-\alpha_2;\alpha_1+\alpha_3;\frac{y-1}{2 y}\right)$$
for $0 \le y \lt 1$ and
$$ \eqalign{f_Y(y) &=
\csc \left(\pi  \left(\alpha _1+\alpha _2\right)\right) (1-y)^{\alpha _3-2} \\ &\left(\frac{(y-1) \sin \left(\pi  \alpha
   _1\right) \Gamma \left(\alpha\right) (-y)^{\alpha _1+\alpha _2}
}{y \Gamma \left(\alpha _3\right)} \,_2\tilde{F}_1\left(\alpha
   _1,1-\alpha _3;\alpha _1+\alpha _2;\frac{2 y}{y-1}\right)\\
-\frac{\pi  2^{-\alpha_1-\alpha_2+1} \left(\alpha-1\right) (1-y)^{\alpha_1+\alpha_2}}{\Gamma
   \left(\alpha _1\right) \Gamma \left(\alpha _2\right)}
\,_2\tilde{F}_1\left(1-\alpha _2,2-\alpha;-\alpha _1-\alpha _2+2;\frac{2 y}{y-1}\right)\right)
}
$$
for $-1 \lt y \lt 0,$ where $\alpha=\alpha_1+\alpha_2+\alpha_3$ and $\, _2\tilde{F}_1$ is the regularized Hypergeometric function.
For integral values of $\alpha_1+\alpha_2$ and negative values of $y$ you also have to take a limit (because the cosecant blows up).  For small integral values of the parameters the function is algebraic (because the Hypergeometric functions that are involved reduce to polynomials).  You can compute these by elementary means if you wish.
Verification
Here are histograms of independent simulations of $X_2-X_1$ using 50,000 iterations each for three combinations of $(\alpha_1,\alpha_2, \alpha_3+\cdots+\alpha_{n+1}).$ On each is superimposed the graph of $f_Y.$  All show close agreement.
Comment: Wow thank you for the detailed reply almost 2 years later! I ended up just sampling from the posterior in my application which was sufficient. The solution is pretty messy but it's cool to know it exists.