Equivalent of varchar(max) in MySQL?

Question: What is the equivalent of varchar(max) in MySQL?
Answer: The max length of a varchar is subject to the max row size in MySQL, which is 64KB (not counting BLOBs):
VARCHAR(65535)

However, note that the limit is lower if you use a multi-byte character set:
VARCHAR(21844) CHARACTER SET utf8

Here are some examples:
The maximum row size is 65535, but a varchar also includes a byte or two to encode the length of a given string. So you actually can't declare a varchar of the maximum row size, even if it's the only column in the table.
mysql> CREATE TABLE foo ( v VARCHAR(65534) );
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs

But if we try decreasing lengths, we find the greatest length that works:
mysql> CREATE TABLE foo ( v VARCHAR(65532) );
Query OK, 0 rows affected (0.01 sec)

Now if we try to use a multibyte charset at the table level, we find that it counts each character as multiple bytes. UTF8 strings don't necessarily use multiple bytes per string, but MySQL can't assume you'll restrict all your future inserts to single-byte characters.
mysql> CREATE TABLE foo ( v VARCHAR(65532) ) CHARSET=utf8;
ERROR 1074 (42000): Column length too big for column 'v' (max = 21845); use BLOB or TEXT instead

In spite of what the last error told us, InnoDB still doesn't like a length of 21845.
mysql> CREATE TABLE foo ( v VARCHAR(21845) ) CHARSET=utf8;
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs

This makes perfect sense, if you calculate that 21845*3 = 65535, which wouldn't have worked anyway. Whereas 21844*3 = 65532, which does work.
mysql> CREATE TABLE foo ( v VARCHAR(21844) ) CHARSET=utf8;
Query OK, 0 rows affected (0.32 sec)

Comment: I'd also suggest using TEXT
Comment: @DanW, `TEXT` length limit is 64K.  `MEDIUMTEXT` length limit is 16M.  `LONGTEXT` length limit is 4G.
Comment: The biggest problem with this is that if you create a column of that size, you can only have that **one** column in your table. The *MAX* row size in MySql is 64k, so if you have a 64k column, that's all you get. This same constraint does not apply to Sql Server's `varchar(max)` column type.
Comment: @AdnanShammout: Sure, unless you want to declare a `DEFAULT` value for the column.  Can't do that with TEXT or BLOB types.
Comment: @joshperry, yes but TEXT/BLOB columns count only a small amount (9-12 bytes) toward that 64KB row size limit, so if you need a large VARCHAR as well as a number of other columns, it's better to use TEXT.
Comment: @2rs2ts, yes, if the default charset at the database or table level is utf8, then you get an error if you try to declare any varchar longer than 21844. I'll edit the answer above to show an example.
Comment: Will using Text give you more than 65535 length?
Comment: What if the table is already set to use utf8? Does that mean the max is `VARCHAR(21844)`?
Answer: TL;DR
MySQL does not have an equivalent concept of varchar(max), this is a MS SQL Server feature.

What is VARCHAR(max)?
varchar(max) is a feature of Microsoft SQL Server.
The amount of data that a column could store in Microsoft SQL server versions prior to version 2005 was limited to 8KB.  In order to store more than 8KB you would have to use TEXT, NTEXT, or BLOB columns types, these column types stored their data as a collection of 8K pages separate from the table data pages; they supported storing up to 2GB per row.
The big caveat to these column types was that they usually required special functions and statements to access and modify the data (e.g. READTEXT, WRITETEXT, and UPDATETEXT)
In SQL Server 2005, varchar(max) was introduced to unify the data and queries used to retrieve and modify data in large columns.  The data for varchar(max) columns is stored inline with the table data pages.
As the data in the MAX column fills an 8KB data page an overflow page is allocated and the previous page points to it forming a linked list. Unlike TEXT, NTEXT, and BLOB the varchar(max) column type supports all the same query semantics as other column types.
So varchar(MAX) really means varchar(AS_MUCH_AS_I_WANT_TO_STUFF_IN_HERE_JUST_KEEP_GROWING) and not varchar(MAX_SIZE_OF_A_COLUMN).
MySQL does not have an equivalent idiom.
In order to get the same amount of storage as a varchar(max) in MySQL you would still need to resort to a BLOB column type. This article discusses a very effective method of storing large amounts of data in MySQL efficiently.
Comment: @njk Yes, but in order to explain what the "equivalent" in MySql (or the lack of an equivalent in this case) necessitated describing exactly what `varchar(max)` **really** means.
Comment: This has more to do with SQL Server than MySQL.
Answer: The max length of a varchar is
65535
divided by the max byte length of a character in the character set the column is set to (e.g. utf8=3 bytes, ucs2=2, latin1=1).
minus 2 bytes to store the length
minus the length of all the other columns
minus 1 byte for every 8 columns that are nullable. If your column is null/not null this gets stored as one bit in a byte/bytes called the null mask, 1 bit per column that is nullable.
Comment: I like the format of your answer but it seems to be missing some useful information that the top answer provides regarding charsets and stuff
Answer: For MS SQL Server:
ALTER TABLE prg_ar_report_colors
ADD Text_Color_Code VARCHAR(max);

For MySQL:
ALTER TABLE prg_ar_report_colors
ADD Text_Color_Code LONGTEXT;

For Oracle Database:
ALTER TABLE prg_ar_report_colors
ADD Text_Color_Code CLOB;

Comment: note that longtext, text and blob are stored differently than varchar. varchar is stored with the other fields, while text is stored on a separate file in the server. it has pros and cons so careful which one to choose
Answer: Mysql Converting column  from VARCHAR to TEXT when under limit size!!!
mysql> CREATE TABLE varchars1(ch3 varchar(6),ch1 varchar(3),ch varchar(4000000))
;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> SHOW WARNINGS;
+-------+------+---------------------------------------------+
| Level | Code | Message                                     |
+-------+------+---------------------------------------------+
| Note  | 1246 | Converting column 'ch' from VARCHAR to TEXT |
+-------+------+---------------------------------------------+
1 row in set (0.00 sec)

mysql>

Equivalent of varchar(max) in MySQL?


CS Lewis said time would probably continue in Heaven...But how?

Question: (See 'Letters To Malcolm') CS lewis said, because mankind is by definition finite, that we shall always be in a situation of successive time, with the present becoming past. In 'The Problem Of Pain' he says that time in Heaven may not be so much like a linear line but have thickness like a plain as well.
I'm a bit confused by that analogy as that still inplies length...does he mean we will just experience 'a lot of things' within time or, erm, well, help!
Great guy CS Lewis but  am a little confused on 'how' he thought time would behave in Heaven.
Comment: Related: http://christianity.stackexchange.com/questions/16345/from-where-does-the-doctrine-that-there-is-no-time-in-heaven-originate
Answer: As I understand it, he is saying that our future perception may be "expanded", while still being qualitatively the same - in particular, not approaching the very different perception of time that God has. (We experience time as a succession of cause and effect; we can remember the past but can only conjecture about the future. On the other hand, God sees all times at once.)
In the letter, he talks about the thicker line as a suggestion that we could experience a "wider" present than we currently do, by being able to see and understand more  things at once. However, we are still on the line, and so we have the same inability to see the future as we do now. This matches the standard account of angelic knowledge: angels' intellect is like our own, but better, so that they can make more accurate deductions about the future, but still have to deduce rather than perceiving it directly. In the same way, angels are better than us at noticing things and in the general acuity of their senses, but they still fall short of God's ability to see things as they truly are, as opposed to their being mediated by the senses.
Part of Lewis's thought in the letter is that the future "resurrection of the body" implies that we will have bodies (and senses, and minds) that are still basically the same as now. They are perfected, but are still not divine. Scholastic philosophers argued that our perception of time in heaven might be different for several reasons -

We couldn't measure the progression of time from our physiological processes (getting hungry or tired).
With no celestial bodies to look at, we can't use them to measure hours, days, seasons, or years.
The same goes for measuring time by the decay of objects (eg, watching an apple go rotten). That doesn't happen any more.
The "speed of thought" may be different, and in any case is incommensurable with what's going on in the minds of others. You can spend an amount of time thinking about something, but did it "really" take ten minutes or ten years?

This seems to match the Lewis conception of the thicker line. There is still a succession of moments, but we may perceive things differently during those moments.
Comment: Aha. Sounds very frustrating if I might say so. A bit too 'endless' whereas I think I'd prefer a finale. Ah well, God's the boss, he knows what he's doing better than I do...
Comment: there is a section on the future in the Screwtape Letters, where the future is described as being the thing least like eternity. Surely then Lewis didn't see us looking forward whilst in Heaven? For the most "temporal" part of time to continue? But then, can it end- if the present is still so and the past also...
Comment: @ThomasJennings I think his concern in Screwtape is people worrying too much about the uncertain and dangerous future, which wouldn't be a problem in Heaven. It's also possible that his ideas developed between Screwtape and Malcolm.
Comment: Ah, yes, I suppose. I suppose I'm not being very achedemic here...I'm desperatly chasing down lewis material that might suggest the future will end because, frankly, I'd hate if we were literally stuck in an 'endless time' if time remains the same as now. How frustrating- even if you were in a place of utter bliss, you'd never reach a completetion, the road would go on forever and you'd be part of a never ending story. Sends shivers up my spine- and, as it does, I assume that I've got it wrong. God surely overjoys you- doesn't horrify you! Best day ever + unending =
Comment: @ThomasJennings Do remember that just because Lewis might think something, doesn't mean it's true.
Answer: There are at least two solid Biblical scriptures which prove that time continues in heaven.  First in Revelation 19 Jesus returns in the second coming riding a white horse, we know that at that time the saved are taken to heaven for it is written

"For the Lord Himself will descend from heaven with a shout, with the
  voice of an archangel, and with the trumpet of God. And the dead in
  Christ will rise first. Then we who are alive and remain shall be
  caught up together with them in the clouds to meet the Lord in the
  air. And thus we shall always be with the Lord. " (1 Thessalonians
  4:16-17)

The very next verse after Jesus return in Revelation 19, Revelation 20:1-2 says

Then I saw an angel coming down from heaven, having the key to the
  bottomless pit and a great chain in his hand. He laid hold of the
  dragon, that serpent of old, who is the Devil and Satan, and bound him
  for a thousand years;

Here we see a time element, a thousand years.
Also there is another verse that tells us that the seven day week will continue even in heaven for it is written

For as the new heavens and the new earth Which I will make shall
  remain before Me," says the Lord, "So shall your descendants and your
  name remain. And it shall come to pass That from one New Moon to
  another, And from one Sabbath to another, All flesh shall come to
  worship before Me," says the Lord. (Isaiah 66:22-23)

Herein is evidence that the seventh-day Sabbath will still be kept even in heaven.  A comprehensive Christian site about this can be found here - http://www.sabbathtruth.com/
Hope that helps!
Comment: Thanks, it helps a lot. Though it 'seems' rather depressing to think of eternity as literally endless time. I can't imagine that not being frustrating or boring but then, I am only man...Perhaps I don't see it as it will really be?
Comment: Don't worry brother Thomas heaven will not be boring at all for it is written "Eye has not seen, nor ear heard,
Nor have entered into the heart of man
The things which God has prepared for those who love Him." (1 Corinthians 2:9) Imagine a world with no more pain, suffering, death or sin.  A world where you may see Jesus and the holy angels face to face.  A world that is filled with love, kindness, selflessness.  We may be able to explore the depths of creation and worlds that mankind has never seen.  With each new passing day our happiness will only increase, it will be worth it!
Comment: Revelation 10:6 is translated in different ways. Most say there will be no more delay. But the KJV says: "And sware by him that liveth for ever and ever, who created heaven, and the things that therein are, and the earth, and the things that therein are, and the sea, and the things which are therein, that there should be time no longer." This offers the possibility that in Heaven, time is no more.


Why is melting spontaneous when the liquid phase is less stable and should have more free energy than the solid phase?

Question: Imagine a 1kg block of ice that has completely melted at room temperature. If melting is a spontaneous reaction, then wouldn't that mean the products (1kg of water) would have less Gibbs free energy than the reactants (1kg of ice)? I am confused because water is more disordered than ice and less stable, so it should have more free energy than ice.
Comment: Note that the Gibbs energy change of phase transition is temperature dependent, being zero at the melting point.
Answer: The liquid phase does not have more free energy than the solid phase (when the liquid is stable).
True, the liquid has more total energy, or more accurately more enthalpy (which is essentially internal energy plus the work put into it from the outside pressure). But part of that energy is tied up in the greater disorder, or entropy, of the liquid versus the solid. When you add everything up according to the relation $G=H-TS$, the bigger enthalpy ($H$) of the liquid is outweighed by the bigger entropy ($S$) if the temperature ($T$) is high enough. Then the liquid has less of its energy as free energy.
Comment: If the temperature is high enough, as in greater than 0 degrees celsius? Also, this would mean that in a Gibbs free energy diagram, the curve at the liquid phase would be lower than the same curve during the solid phase?


Why would I need more than 1 public IP address for a single dedicated host?

Question: What is the point of having more than a single public IP address for a dedicated server with a single network interface?  I see a lot of dedicated server hosting offers that show something like "public IPs: 8".  What am I missing? Thanks!
Answer: One reason is to provision multiple SSL encrypted services on the same port. SSL starts before the application layer which leads to certificate errors when accessing the host on a hostname that doesn't match the CN value on the certificate.
Using HTTP virtual hosting as an example:
The SSL layer sits between the client and the webserver. Once the client has issued the GET request (and hence transmitted the hostname it was expecting) the server has already started SSL. At that point its too late  to specify a different certificate.
If you implement IP-based virtual hosting then each hostname can have it's own IP and subsequently its own certificate. Of course, wildcard certificates are another way around the problem, but they're often more expensive than just allocating another ip.
Comment: Almost all major web browsers already support TLS Server Name Indication extension, allowing the use of hostname-based virtual hosts with SSL.
Comment: True, although plenty of older browsers are still kicking about without support. Certain elements within the university I work for still develop for IE 6 exclusively so I end up having to support it more than I'd like to.
Answer: VM's? Multiple websites with their own certs? There are lots of things you could use 'em for.


Tire depth is 4, is it safe to drive?

Question: when took my car for oil change, mechanic said that the tire Threads are too thin to drive , less than 5. So it is not safe to drive. Till what depth we can drive the car safely. Tires also has some minor cracks.
Comment: 4 what? 4 millimeters? This should be covered by law. In my country the legal safety limit for winter tires is 3 mm, and for regular tires - 1.6 mm. So 4 mm is not unsafe, but you should start looking for tires.
Comment: If the road is perfectly dry, you would get the best grip with no tread at all - https://en.wikipedia.org/wiki/Racing_slick .  However most of us live in countries that have laws that dictate the minimum tread thickness, so you need to look into the law in your country/local area.
Comment: If it's 4/32" (3.17mm), you should consider getting new tires soon.
Answer: According to TireRack.com:

In most parts of the world, tires are considered to be legally worn out when they reach 2/32" (approximately 1.6mm) of remaining tread depth. U.S. law requires tires to have easy-to-see Tread Wear Indicator bars running from one side of their tread design to the other when the tire's tread has worn down to the minimum legal limit of 2/32 inch.

Tread wear indicator bars on a partially worn tire:

They also state:

... if snow-covered roads are a concern, it's time to replace your tires when they reach approximately 6/32" of remaining tread depth. For rain and wet roads, you should consider replacing your tires when they reach approximately 4/32" of remaining tread depth.

While you can possibly get away with running tread that thin, it really isn't advised to do so. The place where you got your oil changed at is right in suggesting you get new tires, but they are still legal. My suggestion is to invest in some new tires soon, especially with the winter months fast approaching.

Tire depth is 4, is it safe to drive?


Is it possible to get High Chaos in the last mission?

Question: If I go into the last mission with low chaos, is it possible to get the high chaos ending by killing a lot of guards? If not, how many missions back do I have to go to get a high chaos ending?
Answer: Yes, you can get high chaos within the level if you start with low chaos, but the ending will be corresponding to the chaos level you started the level with.
The last mission (The Light at the End) is shaped by your overall chaos in the game before you start this mission. If you have low chaos when you start this mission, you will get the low chaos ending no matter how many you kill. But you can still get the overall high chaos at the ending summary screen, but this has no practical effect in-game. The only thing that the overall chaos level on the ending screen counts for is the achievement for completing the game in high/low chaos.

If the low chaos version of the mission loads, the good ending will show, even if Corvo kills enough guards to achieve high chaos in the mission stats.

If you want the high chaos ending, you'll need to get high chaos before the last mission. That means you will need to get high chaos in the mission stats for The Loyalists (which is the previous mission).
EDIT
I tested, and if you play flawlessly (never detected and not killing anyone) until The Loyalists, you can't get high chaos by killing everyone in this level, including civilians. Which means you'll have to go back another level and raise chaos there too. But if you haven't played flawlessly, you should in most cases be able to get high chaos in The Loyalists level.
Comment: I just want the achievement for high chaos. It sounds like, if I get high chaos in the last mission, I still get that achievement? If so, that's fine with me. I've probably killed like 10 people throughout the game though so I don't know how difficult it would be, or how many people I would have to kill to get it.
Comment: I do not know how the chaos level is calculated, only what increases/decreases the chaos [Wiki about chaos here](http://dishonored.wikia.com/wiki/Chaos). But yeah, you should be able to get the achievement for high chaos from just getting high chaos in the ending stats. The achievement will pop at the end of the post game cinematics.
Comment: Thanks for the info, I think I'll just replay the latter half of the game and just kill everyone. I made an excessive amount of savefiles because I figured something like this would happen.
Answer: To get the chaos ending, you need to kill minimum 50% of the seen population in dunwall. Which means you minimum need to get back the half of the game.
But I'm not quite sure if it also depends on some key events too.
Read it here

It has been reported that, for High Chaos to be achieved, Corvo must
  kill 20% of the human population per mission. If his total kills
  exceed 50% of the population seen in Dishonored, Dunwall is
  irrevocably thrown into chaos, and the High Chaos ending is depicted.
Comment: Where are you pulling that 50% statistic from? It makes sense but I'd want some backing source on that.
Comment: I've getting this from [here][1] [1]: http://dishonored.wikia.com/wiki/Chaos
cite:
It has been reported that, for High Chaos to be achieved, Corvo must kill 20% of the human population per mission. If his total kills
exceed 50% of the population seen in Dishonored, Dunwall is
irrevocably thrown into chaos, and the High Chaos ending is depicted.
Comment: As a point, you'll need to go a -maximum- of back fifty percent, assuming you've killed even one person.
Comment: Well and it's not very clear if it's just 50%. The first missions have many civilians in the area. Later on many missions are a bit more alone (just a feeling). But the missions in the villa (including the city around) are good places to kill very many people without going to far behind I think.


Traveling with a cat by train

Question: My cat is kinda scary (she starts crying and shaking a bit) when it comes to even a simple trip to the vet. Soon I'm going to take her with me to another city, by train. Although the trip will take only three hours I'm afraid she'll be very frustrating (gonna start crying or trying to get out of her carrier). Are there any tips on how to make this trip less stressful for her? Maybe give her a little sedative or put a toy in the carrier?
Comment: Sedatives work but dosage is not something you can do on your own. You need to consult a vet.
Comment: did you mean that the cat is "scary" (scares other people) or "scared" (seems to be frightened herself)? Similarly, is she "frustrating" (causes frustration to the people around her) or "frustrated" (feeling frustration herself)?
Comment: Welcome to Pets! Please have a look at the [tour], it only takes a minute. In order to help you, we need to know more about how exactly your cat is "kinda scary" and "very frustrating". It would also help to know how long the trip will be. If she's not very stressed but only annoying other passengers, I wouldn't sedate her. If she is stressed, certain types of sedatives can make the experience even worse for her. Please [edit] your question to add more information.
Comment: Thanks for your suggestions! I'll edit the question
Comment: Just wanted to let you know that the trip went very well! She was so calm and even a bit curious
Comment: @hellofaride It is completely okay and wanted, if you write your own answer when you solved the problem :) So what did you prepare? How did you and the cat behave while the trip?
Answer: Caution: sedatives may cause breathing problems that require immediate medical treatment, which presumably won't be available on your train. Most carriers prohibit sedated animals (unless accompanied by a vet) for exactly that reason.
What you actually want is something for travel anxiety. The two most common medications I've seen are gabapentin and diphenhydramine (aka Benadryl). These are safe for travel/shipping since they aren't sedatives, though they may still cause drowsiness. Discuss with your vet to get the correct dosage for your pet, which varies by species and weight; this is a common enough thing they may even be able to do it over the phone.
My rescue cat was shipped to me by air cargo, and the sender's vet recommended diphenhydramine.  After two flights and eight hours, he arrived calmer than most humans would have.
I don't have personal experience with gabapentin, but I've seen anecdotes that it is similarly effective.

Traveling with a cat by train


What is this wooden puzzle called?

Question:

What is this wooden puzzle called, and how do I solve it?
Comment: There is a huge variety of these puzzles. Usually there is an unexpected way to *just* pass a loop of the string over, round, or through another part, perhaps more than once. Presumably the idea is to remove the metal ring, a seeming impossibility.
Comment: What about the pieces on the post? What interaction does the cord have with those?
Comment: It is a [Disentanglement puzzle](https://en.m.wikipedia.org/wiki/Disentanglement_puzzle)
Comment: @DanielMathias Yes, but what us the exact name and how do i solve it
Answer: I agree with Gareth McCaughan's comment that it is unclear that such rope-type of disentanglement puzzles actually have names, because they are simply too common and too varied. I finally found an isomorphic version with the product name "Family Games Flabber Floovers Brain Teaser Puzzle (Gripper)", but I do not believe that the puzzle's original name is "Gripper".
In any case, there is a generic solution to most such puzzles. You simply have to not move any of the parts except the rope, by thinking how you would detach the rope if the pole was not there.

You would easily take the red-circled part and push it through the indicated hole and get it to the green position where you want to make it cross both strands of the rope attached to the wooden pieces, as shown by the yellow arrows. This would be trivial if the pole was not there. Since the pole is there, you need to cross one strand at a time. I will show you for the strand connected to the left wooden piece, and you can do the same for the other strand. The idea is that you simply must cross the pole on both sides of the wooden piece. To cross on the left side, push it through the pieces' holes and across the pole end and back out through the same holes, as shown by the blue arrow. To cross on the right side, push it through the right piece's hole and across the pole end and back out through the same hole, as shown by the pink arrow.
Comment: It seems that bobble thinks it's clear that OP is only really interested in what the puzzle is called, while user 21820 thinks it's clear that OP is only really interested in how to solve it. I don't see any reason to believe either of those things. So to my mind, this answer is useful and answers something OP was asking (so it shouldn't be at -2 unless it's just _wrong_) but it also isn't a complete answer to OP's question.
Comment: I also remark that it's not clear that the "what's it called?" question actually _has_ an answer. Maybe whoever made the puzzle didn't give it a name. Maybe they did but it was something useless like "Wooden puzzle".
Comment: This answers how to solve it, but that's not what the question is asking. It's asking for what it's called.
Comment: I've cleaned up the comment thread under this answer, leaving a few comments that are still relevant. Please, keep it civil.
Comment: @GarethMcCaughan: See my edit.
Comment: Ooo, you found a name! Excellent.

What is this wooden puzzle called?


Adding -Ex to the name of a type in .Net

Question: I've noticed a pattern recently in our codebase at work, where most of our model class have a name such as User, and there is an inheriting type that has extra fields on it called UserEx.  I've also noticed this in the C# async CTP where they put the additional static methods for Task in a class called TaskEx (due to technical restrictions, since they couldn't alter the existing library).  Talking to someone at work, I learned that -Ex classes exist to optimize network transfers (you can pull only the bare minimum if you need).  My question, then, is what does -Ex stand for?  The only thing I can think of is possibly "Extra".
Comment: Could also be "extension" - and with a little searching on this forum: http://stackoverflow.com/questions/3963374/what-does-it-mean-when-ex-is-added-to-a-function-method-name (although this is for the Windows API, I assume people have been using the naming convention since)
Comment: I will go with Extended , Micorosoft com used this notation as well :)
Comment: It's probably part of their naming convention for example at work they want us to prefix any class that we write as clsSomeClasee.cs make sense
Comment: Thanks @C.Evenhuis, extension or extended makes a lot more sense than extra.
Answer: The other answers all got it correct: the Ex suffix stands for "extended". It's a way of introducing a new class or method without obsoleting or removing the old one, a common way of retaining backwards compatibility while introducing new features.
The Windows API does this all over the place, as explained here.
Hans hints at the problem with this approach in his explanation: it doesn't scale. What if you want to extend an "extended" function? Do you call it FunctionExEx? That looks stupid.
So stupid, in fact, that Microsoft's own coding guidelines for .NET (subjective though they are) specifically recommend against appending Ex to a type. Instead, if you must do this, you should use a number:
MyType
MyType2   // modified version
MyType3   // oh wait, we had to modify it again!

Blaming this on poor planning as dowhilefor tries to do is a bit premature. When writing real world applications and frameworks, you often need to ship. That means getting out a quick-and-dirty version of the function that works. Later, you decide this is a poor design and something needs to change. Rather than throwing up your hands and completely re-writing (producing giant delays and obsoleting all of the old code), you introduce a new type with a different name. Hindsight is always 20/20.
Comment: Great post. Btw, 20/20 is normal vision, hindsight probably gives you much more than normal vision - https://answers.yahoo.com/question/index?qid=20080215115045AATahKe
Answer: Ending a new class or method or type in Ex is a naming convention, and like any naming convention, it is subject to the whims of those implementing it.
There are no hard and fast rules, and it is no more or less correct than appending 2 to the end of the class (or Extra, or More, or DidntWantToMessWithThePublicApi).
As for why it is used, Microsoft has a long history of using it to provide a revision to an existing API without breaking older code. You can find examples of this in classes, in methods, and in structures. You can also find different examples, which instead use 2.
Comment: Note that the .NET team no longer does/recommends this, in part because of the problems experienced by the Win32 team. It simply doesn't scale in the event you want to "extend" something twice or three times.
Comment: Oh I agree, *"it is subject to the whims of those implementing it"*. I didn't intend on providing conformance advice.
Answer: It stands for "Extension" or "Extended", as far as I know. It's a common suffix to when you need to add functionnality to something that you can't change. A good example was the various -Ex functions in the Win32 APIs, which were added because C does not support function overloading.
Answer: This practice is NOT industry-standard.  I'll admit I do it myself, but it's mostly vestigial emulation of some of the old win32 kernel functions.  for example, they initially had a "beginthread" C function and later created another new-and-improved "begintreadEx".
I would suggest that you start using the [Deprecated] attribute to signal to other coders (or yourself) to stop using the old function in favor of the new one.  That has more intrinsic meaning.
Long story short -- you should name classes & functions based on what they are or do, and try to avoid pseudo-meaningful prefixes/suffixes that create confusion such as this.  That is the industry-standard approach.
Comment: What happens if the two functions *are* and *do* [basically] the same thing? Appending something to the end is a fairly self-documenting way of indicating that one is an extended or modified version of the first. The suffixes are not meaningless in context. What would you name `BeginThreadEx`?
Comment: Most of the time in C# you can keep the existing method name and just create a new overload (with different parameters).
Comment: i rather like BeginThreadEx since at least it was consistent w/ the other win32 kernel functions.  I meant what I said as a guideline, not a hard rule.  I don't think there's a recipe one can follow to always name functions well, there's no substitute for thinking particularly about your particular function -- and recognize that being consistent (even if not industry-standard) has a lot of value.
Comment: @AlanR - the -Ex classes, in our code base, do not deprecate the old ones.  Instead they provide extended functionality.  As I said in the original post, User is for sending bare minimum, whereas UserEx is for sending more information when needed.
Answer: I thought possibly:

external
extricated
simply 'ex' (as in 'out of' or 'beyond')
Comment: To complete your list: an alternative to obsolete - "I used to date `classNameEx`, now I'm with `className`" :P
Answer: Honestly, i think it means "We didn't plan this feature long enough, didn't thought about the changed requirements, and we have to deal with this now close to the deadline". Of course this is not always the case, but everytime i find a class with Ex i try to figure out why it was introduced and not properly added into the framework. For me its mostly like // HACK:
This only counts for our code, if it is in a framework i "hope" thats just naming convention.
What it could mean was already answered, my guess was always "Extended"


Are a bond's yield and interest rate the same thing?

Question: Are they the same thing?
Is yield the annualized return rate?
Why when yield rise, yearly return increases, but price falls?
Answer: Let's say you paid $10,000 for a ten-year bond with a coupon rate of 5%. That's a promise from the bond issuer that they'll pay you $500 per year for ten years, and at the end of those ten years they'll pay you back your $10,000. The $10,000 is the bond's face value; the 5% is its coupon rate.
Now suppose interest rates go up, so new bond issues are paying 10%. What can you sell your bond for? Clearly, nobody's going to pay you $10,000 for a $500 annual income when they can get $1000 annual income for the same $10,000. So the market value of your bond is less than the $10,000 that you paid for it. If it's a really long way from maturity (think, temporarily, of 100-year railroad bonds), it's worth $5,000, because that's what someone would pay for $500 per year now that interest rates are 10%.
On the other hand, if you've held your ten-year bond for nine years, it will mature in one year, and whoever you sell it to will get $10,000 when that happens. That means you can sell it for nearly $10,000, since that's what the issuer will pay to whoever holds the bond. So the closer the bond is to maturity, the closer its market value is to its face value.
If someone bought your $10,000 bond for $7,000 with, say, nine years to go to maturity, they'd expect to be paid $500 per year in interest. They'd also expect to get $10,000 in nine years, which is a $3,000 gain. Caution: what follows is a gross oversimplification, offered only to provide some intuition for how this stuff works. They'd get roughly $333 per year in appreciation, so the bond "pays" them $500 + $333, or $833, per year. Based on the $7,000 that they paid for it, that works out to about 12% each year. That 12% is the yield to maturity.
Answer: They are related but not completely the same. The yield of an instrument such as a bond is the ratio of its coupon (payment) to its Par value (price/face value). This is often expressed as an annual return per year, but not all APY/annual return rates are yields. The annual yield can also vary somewhat due to other factors, but let's ignore that for now.
The yield and the price of such an instrument are inversely related because the coupon payment is often fixed in the short term. So for example, when a commercial bond is issued, the issuer promises to pay $X per period. This doesn't change over the life of the bond. If the company chooses to restructure, they might offer a tender to pay off the bond early and issue a new bond on different terms, but the coupon is fixed for the life of the bond. In this case, the yield is essentially a function that depends on the price.
As a result, if the price of the bond changes over the duration of the bond, this affects the ratio of the price to the coupon. So for example, let's say ACME company sells a $100 bond that pays $3 per year with one payment per year. The yield is 3% per year. Now, let's assume that the market decides that ACME company is in big trouble and may have trouble paying its debt service. At this point, investors will demand a higher yield in order to be interested in buying the bond on the open market, in order to reflect the increased risk of default. However, since the coupon payment is fixed, this will be expressed in a decrease in the bid price investors are willing to offer for the bond. So instead of offering $100 for the bond, let's say they are now only willing to offer $75. In this case, the yield has now risen to 4% per year (the $3 fixed coupon divided by the new lower $75 price). The price will continue to fall until the yield rises high enough to satisfy buyers.
In order to really evaluate an investment like this, you need to consider the level of risk implied by the yield, or a risk-adjusted yield. This is where markets and rating agencies come in, such that bonds, for example, are separated into various grades of investment-quality and "junk" bonds. The movement of assets between these classes is what people are referring to when they say that investors are "chasing" yields or there has been a "flight to safety". On the whole, higher yields tend to carry greater underlying risks, and the market is compensating investors for taking on those additional risks through the higher yields.
Conversely, if conditions improved, or under the same conditions ACME company issued bonds with a higher coupon/rate of return, the market might well bid the price of the bond up from its PAR/issuing value, resulting in a lower yield. The yield on US government bonds is often considered an example of what the global bond market considers to be a "risk-less" rate of return.
Comment: If, as you claim, the _yield_ of a bond is the ratio of the coupon amount to the face value, what is the _interest rate_ and the _coupon rate?_
Comment: See Pete B.'s answer on the Coupon rate.
Comment: Oh, I know what coupon rate means. I am just very interested in **your** opening statement that the _yield_ of a bond is the **ratio of the coupon payment to the face value of the bond.** The _coupon_ rate is also the ratio of the coupon payment to the face value (as clearly and correctly stated in Pete B.'s answer), and so according to you, the coupon rate and the yield are the same?
Answer:
Are they the same thing?

Sometimes. When the bond is sold at par, then the 2 are the same thing. If a $1000 bond with a $50 coupon has its price drop to $500, then the yield becomes 10% since 50/500 is 1/10 or 10%. However, the interest rate isn't necessarily the same thing as some bonds may have higher yields do to the potential for defaults like junk bonds for example.

Is yield the annualized return rate?

No. The yield is the interest the bond gives in a year based on its value which may or may not be the entire story on the return. In the US, there are TIPS which can have principal adjustments that make the annualized return different and if one is looking at bond funds, there can be capital appreciation from the bonds that are also part of the return.

Why when yield rise, yearly return increases but price falls?

Because the 2 are linked. The bond above was originally sold for $1000 and paid $50. If the price drops down to $x then the new yield will be $50/x which is likely to be more than the 5% initially thought. Similarly, to bring up the yield, the price has to go down.


Custom skins in MineCraft

Question: Today I changed my skin five times and after that it wouldn't let me change my skin again! I want to pick a different skin because the skin I have currently doesn't look that good. Did I do something wrong or is it Minecraft?
Comment: Are you using the Pocket Edition or the PC version of Minecraft? Can you show us the error message it gives you?
Comment: I've changed my skin more than 5 times in a day. May just be the servers lagging, but it's hard to say without knowing what you're actually doing. You could try fully logging out and back in.
Answer: There are limits for contacting the Mojang servers for same thing over and over. This apply for basic getting of info about player (getting UUID, nick, etc) and also for skins, capes and other info.
Be aware that if you (or the server you play on) ask too often for your new skin, the next connections will be refused by Mojang servers for some time.
If you changed it more times in small time window, Mojang servers could consider you as attacker or spammer. Waiting some time should fix this problem, try it the next day(after 24 hours) and you should be good.
If there are more issues after that time, then you can always try to contact Mojang Support.
Answer: the problem is you have to head on over to the minecraft website and log in and then select change your skin than you have to download the skin you just made and drag it to the minecraft website, choose your settings, and you're done. of course there is a limit to how many times you can do this.
Comment: If you read the post they said they did already change their skin several times.  So the only thing you got right is your last sentence, which is the same as and already given answer therefore you've added nothing useful

Custom skins in MineCraft


Why is the velocity of a voltage wave in a pure copper wire so high?

Question: A pressure wave in air travels at the speed of sound. However a voltage wave in a copper conductor travels at a significant fraction of light speed. Why the difference of many orders of magnitude?
Comment: A light wave in air travels close to the speed of light. Why is it so much faster than the speed of sound in air? Well, light and sound waves are two very different things obeying different physics requirements.
Comment: What your question doesn't include is that EM waves travel outside of the wire aswell as inside, as demonstrated in the popular veritasium  video, if your question is "An isolated conductor is attached to the positive terminal of a battery. How is the battery voltage "communicated" to the entirety of the wire at light speed."  Then you aren't just looking at the speed of an EM wave in copper, you are modelling the EM.waves travelling across the air aswell https://youtu.be/oI_X2cMHNe0 and https://youtu.be/bHIhgxav9LY
Comment: Are you asking about an "isolated" conductor, or about signal propagation in a [transmission line](https://en.wikipedia.org/wiki/Transmission_line)?
Comment: An isolated conductor is attached to the positive terminal of a battery. How is the battery voltage "communicated" to the entirety of the wire at light speed.
Comment: Did high-school science not show you first that pressure waves travel at the speed of sound?

Don't you remember science lessons teaching that in perfect conductors, electricity travels at light speed?

Why are you trying to compare the speeds of light and sound?
Answer: This answer will probably seem lame to you -- for the real answer, take a course in electrodynamics.  In the one I took, in my third year in an electrical engineering program, this question was answered about three or four weeks into the course, at least in the context of a parallel-conductor transmission line.
The instructor wrote Maxwell's equations in the upper left corner of the board, and 50 minutes later we had an answer in the bottom left corner of the board.
The short and unsatisfying answer is that at those time scales a conductor does not so much conduct electrons as it guides the electromagnetic field, and that electromagnetic field naturally travels at the speed of light.
Comment: +1. Yet you may want to make it explicit that it is the speed of light *in the medium* or *at the interface (between wire and air / whatever)*
Comment: It's sixty years since I did my electrical engineering degree hence my cloudy brain! I would really appreciate a qualitative description on how a battery voltage travels along an isolated conductor connected to its positive terminal.
Comment: Note that the speed has little to do with the nature of the conductor: it's controlled by the stuff around the conductor. So, it doesn't matter that your conductor is copper.
Comment: You need to expand your question (and remember your EE classes, to the best of your ability).  A _truly_ isolated positive conductor presumes a truly isolated battery, and that's a near-useless case study (short answer: the system acts like a voltage source connected to an antenna with one short side and one long side, and voltage is undefined because the battery-wire system is isolated).
Comment: If I connect an AA battery to a 10m length of copper wire I would expect to be able to find the open circuit battery voltage at any point on the wire. What is a qualitative explanation of how the voltage is distributed. Using an analogy with a hydraulic pipe it is self evident how the hydraulic pressure is distributed, but this is electricity!
Comment: @TimWescott Re "voltage is undefined because the battery-wire system is isolated," presumably the wire will end up with a positive voltage relative to the negative terminal of the battery, right? (And if I'm not mistaken, if the whole system has no net charge, the wire will also end up with a positive voltage relative to space infinitely far away.)
Comment: Immediately the wire is connected to the battery it will indeed be charged - after all there is non-zero resistance and (vanishing small) capacitance between the wire and the battery negative terminal. The time constant will be vanishing small but non-zero. My interest is in gaining insight as to the mechanism used to "communicate" the battery voltage throughout the copper atoms. It is surely some form of EM wave caused by the perturbation when the wire-battery connection is made.
Answer: The speed of sound depends on the bulk properties of the medium that is carrying the sound.  Generally the speed is:
$$v=\sqrt{\frac{\text{elastic properties}}{\text{inertial properties}}}$$
For a solid, the "elastic property" is the Young's modulus for the substance, and the "inertial property" is its density.
But the transmission of an electric signal doesn't depend on the bulk properties of the conductor, since the signal is carried in the electromagnetic field. The conductor acts as a waveguide, steering the flow of energy carried in the electromagnetic field. The energy is in the em field that surrounds the conductor.  The speed of the waves depends only on the electromagnetic properties, but for good conductors separated by good insulators, the speed is always going to be close to the speed of light.
The speed of sound in a solid will be much slower, since it depends on the Young's modulus and density of the matter that make up the conductor. The speed of electricity doesn't.
So while the speed of sound will be on the order of several thousand km/h, the speed of electricity will be close to the speed of light, c.


GPS working and anonymity

Question:
Does gps make any log, which is store in there positioning system ?
Even if gps is off in our smart phone and we don't have any sim card in it and our internet is off too still is their any chance to get our location?
Answer: No, there isn't any log on the satellite - it's just broadcasting a time signal and an identifier. Anyone can pick it up - think of it as being like a radio broadcast.
Phone location, as in how police track a specific phone, doesn't work using GPS directly. A limited amount of location data can be obtained by looking at which cell tower the phone is connected to. The range that this provides varies in relation to the cell size - in dense areas, like cities, it gives a more precise location than in sparse coverage areas, like lightly populated rural regions. If the phone has an internet connection, you can also plot location with some accuracy from the WiFi access points which can be seen (especially in countries with regular Google maps updates). If the internet connection is off, that probably won't work, but it might be possible to identify locations which have been visited at a later point, when internet connectivity is restored. It would depend on the specific applications on the phone.
Comment: So it means internet connectivity is necessary, but still it has chance to locate in an open area if internet is off. And our gps is broadcasting signals to satellite? But what about navigation system? The navigation system work without any sim cards and internet connection.
Comment: No, the satellite broadcasts, and the phone receives. Navigation systems work in the same way as looking on a map - they don't require any outward signal from the phone.
Comment: Note that some GPS devices (passively) detect your location, then (actively) send that location to a remote server. This is commonly done by GPS applications on mobile devices.
Answer: For question 1, Matthew answer is perfect, with nothing to add.
For question 2, the answer is no, but only if the phone is in the airline more (not just SIM card is out). Please note that the phone can still connect to cell towers even without a SIM card, because the Emergency number could be dialed without a valid SIM card. Of course GPS and Wi-Fi should be off too.

GPS working and anonymity


How to add new component type in webform?

Question: I want to add a reset component type to a webform. Is there any contributed module available? if not suggest me how can I achieve this through code.
Answer: I got answer for my question from this link, Hope this will help somebody who have same requirement.
follw this link.
Answer: You can add below markup on the webform to create a reset form button:
Component type: Markup
Value:
<code><input type="reset" value="Reset" id="reset-button">
</code>
Comment: Thank you for your response..This one i know, but i need separate component type as "reset", So that my client can add easily wherever he want.


MVVM detailedpage navigation

Question: I am not entirely sure how to explain this, the best way I can is the DataBoundApp in the windows phone 8 templates, when the user navigates to the detailed page of a listbox item, I want the user to be able to navigate through all the items by swiping left or right. I am not entirely sure where to begin with this, or how to search for this online.
Answer: i dont Clearly understand your question but if you want that the user can scroll all the items by scrolling left or right then u have 2 option either use Panaroma View or the Pivot View they both will do the same with some changes in the transition .....
Answer: I got it, was searching for dynamically adding items to a panorama control, so the user can navigate through the list of items without him knowing how many their are, excellent tutorial:
http://www.felinesoft.com/blog/index.php/2010/12/dynamic-panorama-control-wp7-basics/

MVVM detailedpage navigation


CSRF Login: can Attacker Login using valid credentials?

Question: Consider the picture below (taken from page 21 here). Is this possible? If so, how can I prevent it?
Comment: This slide is from a lecture from a class at Stanford taught by Collin Jackson, and yes it's possible.  If you're familiar with the web security community, you may know that Collin Jackson is one of the pioneers.  Also, for what it's worth: those Stanford instructors aren't exactly dumb; if they're teaching their undergraduates this is possible, there's a decent chance they have a good reason for that.
Comment: If you ask "how to prevent it", do you mean how can the victim prevent this, or how can the target-system (google in this example) prevent this? If it is about the victim (supposing the traget doesn't prevent it or we do not know) the sollutions would be more difficult (I can only think of browsing more security aware, so not allowing automatic posts without intervention, maybe even blocking scripts), so I'd say the 'target-system' part might be more interesting?
Comment: It's a rather strange example but it *would* be feasible if Google didn't have CSRF protection.  @GBC has already mentioned more common ways of using CSRF such as the attacker causing an already logged-in admin to perform an action that's restricted to admins.
Comment: My concern is about user, how user can detect that an attacker used his (attacker's) credentials, also, how browser include the cookie for next requests, because the cookies are considered third party...
Comment: @Nanne: is there any tools or mechanism that user can implement it to be sure about each navigation in the Browser? the target system might change, however, users are still there for different systems...
Comment: I'd say you have to go full paranoid. Block all scripting for instance. No solution comes to mind without breaking almost everything. (Basically: see conclusion of that pdf)
Answer: Yes, it's possible.  Or rather, it would be possible, except that Google has deployed countermeasures to defend against precisely this attack.
This attack is known as "login CSRF".  It's similar to a standard CSRF attack, but a little different.  If you search on "login CSRF", you will find information on the attack.  It is a real threat against some web services.  For more details, see my answer to a related question, and the following research paper:

Robust Defenses for Cross-Site Request Forgery.  Adam Barth, Collin Jackson, and John C. Mitchell.  CCS 2008.

See especially Sections 1-3 of that research paper for more technical details.  The paper describes how to defend against the attack.
The short version of how to defend against the attack is that you include a secret CSRF token in all POST requests, including login attempts; and on the server side, you require that login attempts have the proper secret CSRF token included.  OWASP has more on how to deploy secret CSRF tokens.
Comment: dose browser distinguishes between third party cookie and normal cookie? because at this case, the cookie should be considered third part, and when user visits the site (here is google) dose browser include it as normal cookie? (this is just assumptions)
Answer: The goal of a CSRF attack isn't usually to steal credentials, or to log in though stolen details, but to get a valid account to perform an action chosen by the attacker. For example, if an administrator of a target site were victim of an CSRF attack, they may elevate a non-admin account to an admin account without realizing it.
This can either happen through an XSS flaw on the target site itself, or the administrator could be tricked into visiting a malicious website that executes a command against the target site (as shown in the image above). Or the administrator could have been tricked into visiting their own site directly, for example: http://somesite.com/edit_user.php?action=setClass&class=admin&userId=23443 (not sure if this counts as CSRF still, or if it's just social engineering).
To protect against this you can use CAPTCHAS on pages that perform important actions, or you can use secret hash codes to attempt to verify that a request is wanted.
There's a good description and suggestions for countermeasures here: https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)
Comment: This answer has a bunch of errors. You're talking about an ordinary CSRF, but this is a different kind of attack: it involves logging in the victim, using the attacker's account.  That doesn't allow elevating a non-admin account to an admin account.  This attack (login CSRF) has nothing to do with XSS.  Login CSRF can cause harm in certain special scenarios (maybe not the usual case, but it does apply to some web sites).  It is known as login CSRF, and it is different from standard CSRF (and different from XSS).  CAPTCHAs are neither necessary nor sufficient to defend against login CSRF.
Comment: Interesting. I'd never heard of it - my apologies!


Save Mac Terminal session to text file

Question: Is there a way of saving the terminal history of a script to file? I know I can do this by Shell > Export Text As... but is there a command (Bash) to do this?
Comment: What is the terminal history of a script? It's output? Would redirecting it to a file with `my_script > output.txt` be enough?
Comment: @patrix My script has a main menu. If the user enters some option, it produces an output. I would like to include an option in the main menu that saves whatever that is on screen to a text file, I meant. Hope that makes it clearer!
Comment: @patrix Basically, the current session.
Comment: "Session", "history" and "content of current screen" are three different things. If you want to have the same as the Export Text as function, it's definitively more than what's on screen :-)
Answer: This can be done with the standard unix command script(1) though requires running a subshell under the current shell. That is, start a terminal, and run script, issue whatever commands need to be logged, then exit from that shell:
$ script
Script started, output file is typescript
$ uptime
11:30  up 22 days, 16:15, 1 user, load averages: 1.43 1.37 1.38
$ exit

Script done, output file is typescript
$

Then in the output typescript file there should be a record of the shell session run under script(1).
But wait, there's more! With expect one can also save a session and possibly replay it. This requires installing expect from a ports system (Fink, Homebrew, or here MacPorts) which should install autoexpect:
$ port installed | grep expect
  expect @5.45.3_0 (active)
$ which autoexpect
/opt/local/bin/autoexpect
$ autoexpect $SHELL
autoexpect started, file is script.exp
$ uptime
 6:47  up 23 days, 11:32, 1 user, load averages: 1.37 1.39 1.33
$ exit
autoexpect done, file is script.exp
$

Doing something useful with script.exp in turn probably requires knowledge of expect and TCL, so this is a more advanced option. (expect in particular has a log_file option that can be toggled to save everything, but then you'd be writing everything in TCL and not bash...)
Otherwise the terminal itself must save the session; iTerm.app probably has more options for this (Session -> Log -> Start) than Terminal.app.

Save Mac Terminal session to text file


Solidity Vs Vyper

Question: What is the key differences between Solidity and Vyper?
In present and future which one can more acceptable for making smart contracts and why?
Answer: From a top-level, the biggest difference is the fact that Vyper is focused on security and doing its best to protect developers' code from being exploited. It has the advantage of having seen Solidity go through various stages of development and is being designed around Solidity's experiences. Vyper is built with security, language and compiler simplicity, and auditability in mind.
Additionally, Vyper's syntax is much easier to follow, as it is a Python-like syntax.

In present and future which one can more acceptable for making smart contracts and why ?

This is up to the developer. Functionally, they both do the same thing (interact with the EVM). If the contract is simple, I would say Vyper should be used, as there is less room for error. There are times, where Vyper may simply not work, such as if you need to write low-level assembly to manipulate the EVM.

From Vyper's Github page, a few of the items that Vyper has removed for simplicity:

Some examples of what Vyper does NOT have and why:
Modifiers - e.g. in Solidity you can do function foo() mod1 { ... }, where mod1 can be defined elsewhere in the code to include a check that is done before execution, a check that is done after execution, some state changes, or possibly other things. Vyper does not have this, because it makes it too easy to write misleading code. mod1 just looks too innocuous for something that could add arbitrary pre-conditions, post-conditions or state changes. Also, it encourages people to write code where the execution jumps around the file, harming auditability. The usual use case for a modifier is something that performs a single check before execution of a program; our recommendation is to simply inline these checks as asserts.
Class inheritance - requires people to jump between multiple files to understand what a program is doing, and requires people to understand the rules of precedence in case of conflicts (which class' function X is the one that's actually used?). Hence, it makes code too complicated to understand.
Inline assembly - adding inline assembly would make it no longer possible to Ctrl+F for a variable name to find all instances where that variable is read or modified.
Function overloading - This can cause lots of confusion on which function is called at any given time. Thus it's easier to write missleading code (foo("hello") logs "hello" but foo("hello", "world") steals your funds). Another problem with function overloading is that it makes the code much harder to search through as you have to keep track on which call refers to which function.
  Operator overloading - waaay too easy to write misleading code (what do you mean "+" means "send all my money to the developer"? I didn't catch the part of the code that says that!).
Recursive calling - cannot set an upper bound on gas limits, opening the door for gas limit attacks.
Infinite-length loops - cannot set an upper bound on gas limits, opening the door for gas limit attacks.
Binary fixed point - decimal fixed point is better, because any decimal fixed point value written as a literal in code has an exact representation, whereas with binary fixed point approximations are often required (e.g. 0.2 -> 0.001100110011..., which needs to be truncated), leading to unintuitive results, e.g. in python 0.3 + 0.3 + 0.3 + 0.1 != 1.

Solidity Vs Vyper


Can I use the same home folder on different Linux systems (multiboot)?

Question: When installing more than one Linux version on the same computer (for testing purposes e.g. Ubuntu 10.10 and 11.04), is it possible to have the same home folder (e.g. on a separate partition) on all Operating system versions?
Answer: Although it is possible to have the same partition as a home partition on both installations, I would not recommend this:
Apart from user files, the home folder includes also the settings for programs in hidden folders, and if the both operating system (OS) versions use the same programs in different versions, this can lead to conflicts.
Therefore it is better to only share only the user files. This can be done as follows:

On the first OS installation, just
use a normal separate home partition
On the second OS installation, don't use a separate home partition, but bind all folders inside the home folder you want to share on both operating systems via /etc/fstab:
first, be sure to mount your home partition from the other OS somewhere. E.g., when your home partition is a ext3 partition on /dev/sda5, this fstab line does this:
/dev/sda5  /mnt/sda5       ext3    defaults        0       2

now, bind all folders from that home partition to your own home folder on the second OS. This could also be done with a /etc/fstab line:
/mnt/sda5/username/Downloads    /home/username/Downloads      none  bind  0  0

does this for your Downloads folder. (adjust path to your own needs and repeat that with all other folders you want to.)
when you have finished /etc/fstab editing, remount all /etc/fstab entries by
sudo mount -a

Comment: tobi: your problem with Music-old was not caused by symlinks - you renamed the folder via Nautilus, which is smart enough to notice that you renamed a special folder and to update its settings (i.e. "the folder for music is now ~/Music-old"). Editing /etc/fstab allowed you to "fool" Nautilus and swap the folder without it noticing, that's all. You could achieve the same by creating a symlink in terminal :)
Comment: I answered this myself to share this solution I found to be very useful. Additional tips and opinions are welcome! :-)
Comment: +1, but why bind mounts and not symlinks?
Comment: @enzotib: I tried symlinks before, but that caused troubles: e.g., before creating a symlink, I renamed my Music folder to "Music-old" and then created a symlink from my other home partition's Music folder to ~/Music. But now, all programs looking for Music (e.g. Banshee) supposed them in "Music-old", not in "Music". (Same for Downloads and so on...) The System seems to have "remembered" the original folder although I renamed it. Using binds solved that problem for me.
Comment: @tobi where is the line `/mnt/sda5/username/Downloads    /home/username/Downloads      none  bind  0  0` done in the first or second OS
Answer: I am currently running Fedora 15 and Ubuntu 11.10 on the first 2 partitions, but they both share the third partition as a home partition.  It seemed the real conflict was trying to share the same directory, not the same partition.  If you want to point out why what I did was so terrible I would love to hear it, but I have had no issues so far.
Comment: So you're saying you have a real experience (not guesses) in sharing a home partition between Fedora and Ubuntu (i.e. they use the same home directory - is that right?) - and you experienced no problems?
Comment: @Sergey If I'm understanding correctly Odin is saying that he has separate directories but that they both live on the same partition.
Answer: I have 2 dual booting machines - both sharing the same /home which is an entire drive.
One is currently running Ubuntu 14.04 32-bit and Ubuntu 14.04 Studio 64-bit and this one I'm on now is running Ubuntu 14.04 32 bit and Pinguy 14.04 32 bit.
Although I use Ubuntu 32 bit most often on both systems, I haven't had any problems with this approach thus far. This is by no means a guarantee that you won't have trouble and I'll admit I was a bit concerned that I might have issues with having a 64 bit and a 32 bit share the same home.
Note: I haven't tried this with non-Debian based systems thus far. The nice thing about having a good backup/restore plan is that even  if you do something incredibly stupid, overcoming the problem is pretty straightforward.
Source: Experience


Secure MAC and secure encryption schemes combined to form insecure Authenticated Encryption?

Question: I'm reading up on Authenticated Encryption and can't really wrap my head around how a generally secure MAC and a generally secure encryption scheme can be combined into an insecure AE scheme, such as in MAC-and-Encrypt.
I'd be fine with just having links to sources so that I may read up more about it on my own.
Answer:
Consider MAC-and-encrypt with a cipher of AES-CTR using sequential nonces, and a MAC of HMAC-SHA256 on the plaintext of the message.
Obviously these are respectively a secure cipher and MAC, but send the same plaintext twice, and the adversary learns that it's the same plaintext.  (Authenticate the nonce too, and this particular problem goes away, though.)
For a 128-bit string $m$, define $E_{k_1}(m) = \operatorname{AES}_{k_1}(m)$, and $M_{k_2}(m) = \operatorname{AES}_{k_2}(m)$.
Obviously these are respectively a secure cipher and (as a PRP approximation to a PRF) a secure MAC, but if $k_1 = k_2$, rather than using independent keys for MAC and encrypt as you should (or keys apparently independent, derived from a master key by a PRF, e.g. HKDF), bad things will happen when you try to compose these.

The standard reference on the security of generic composition of ciphers and MACs is Bellare and Namprempre 2004.  There are various standard security notions for a putative authenticated cipher: indistinguishability (IND-) or nonmalleability (NM-), under chosen-plaintext attack (-CPA) or adaptive chosen-ciphertext attack (-CCA2); unforgeability of plaintexts (INT-PTXT) or of ciphertexts (INT-CTXT).
Bellare and Namprempre prove or provide counterexamples for all implications and nonimplications between these security properties.  They also prove or provide counterexamples for the security properties generically attained or not by MAC-then-encrypt (MtE), encrypt-and-MAC (E&M), and encrypt-then-MAC (EtM), composed out of a cipher indistinguishable under chosen-plaintext attack (IND-CPA) and a MAC unforgeable or strongly unforgeable under chosen-message attack (UF-CMA, SUF-CMA).*  The results hold for any deterministic or stochastic, stateless or stateful, cipher and MAC, as long as decryption and verification are deterministic and stateless.
If, like me, you find this menagerie of security notions dizzying, you may find it reassuring that they can be gathered into a single notion of authenticated encryption meaning IND-CCA2 and INT-CTXT (which collectively imply all the others, and are equivalent to another notion of IND-CCA3), which in turn can be extended to authenticated encryption with associated data.  But the Bellare and Namprempre paper is helpful for studying the relations between the notions, and counterexamples for generic compositions where intuition might lead us astray into a false sense of security not provided by the standard definitions.
Beware that the story may be a little more complex than simply choosing a 'mode of operation' for a block cipher and choosing a MAC, as everything is in the misbegotten nonsense paradigm that is choosing modes of operation for a block cipher, a confusing paradigm that should have been left in the dumpster of history out back.
Example.  If you pick CBC mode, then you need to decide what to do with messages that are not exactly multiples of 128 bits long.  You might choose AES-CBC-PKCS7.  But if you try to apply that in (say) MAC-then-encrypt, you effectively have MAC-then-format-then-encrypt, and the reverse procedure is decrypt-then-parse-then-verify.  A lot happens before the verify stage, so this exposes opportunities for padding oracle attacks, because the adversary may have more than just a decryption oracle as is posited in the adaptive chosen-ciphertext attack model.
Even if you had only a UF-CMA MAC and not an SUF-CMA MAC, you are better off remembering encrypt-then-MAC as your go-to composition than you are with MAC-then-encrypt.  Although perfectly safe use of EtM and MtE give the same security properites (IND-CPA and INT-PTXT), anything other than EtM exposes you to the cryptographic doom principle, because you are tempted to touch unauthenticated data, which is pure evil.

* Spoiler alert: Only EtM with IND-CPA cipher and SUF-CMA MAC generically provides all the security properties.  EtM and MtE with IND-CPA cipher and UF-CMA MAC generically provide IND-CPA and INT-PTXT.  With SUF-CMA instead of UF-CMA, MtE still doesn't provide IND-CCA2 or INT-CTXT because the cipher may be malleable.  E&M doesn't even generically provide IND-CPA.
Answer: Combining a deterministic MAC and an encryption scheme by concatenating the MAC and the result of the encryption (MAC-and-encrypt) is insecure: enciphering the same message twice is recognizable by the MACs being identical, against the encryption's goal of hiding all characteristics of messages (the cipher is no longer CPA-secure).
Combinations that can be secure are MAC-then-Encrypt (which is different because the MAC is enciphered along the plaintext), and Encrypt-then-MAC (where the result of encryption including Initialization Vector is the input of the MAC). Both are theoretically secure if independent keys are used for MAC and encryption, but Encrypt-then-MAC has the practical advantage that the decryption is only attempted on good ciphertext, which guards against implementation goofs where it is delectably acted on alleged plaintext that did not yet pass the MAC check, which opens to attack.
If keys used for MAC and encryption are not independent, security of MAC-then-Encrypt and Encrypt-then-MAC depends on specifics. When restricted to a single  key, we can use a secure Key Derivation Function to expand the key into two keys (one for the MAC, the other for the cipher), and can generally get away with using the same single key for very different cryptosystems (e.g. HMAC-SHA-256 for the MAC and AES-128-CTR for the cipher). Otherwise, using the same key for a MAC and a cipher can be insecure.

Here is an example of the later. Assume the AES-256 block cipher with encryption $E$ used per a single key

for a MAC restricted to authenticating two blocks $B_0$ and $B_1$ with the MAC $E(E(B_0)\oplus B_1)$, which in itself is secure;
and for CBC encryption with random IV, which in itself is secure.

With the two combined by encrypt-then-MAC, a 1-block message $M$ gives a 3-block cryptogram:

the random $\text{IV}=B_0$,
the CBC-encrypted block $E(\text{IV}\oplus M)=B_1$,
the MAC $E(E(B_0)\oplus B_1)=E(E(\text{IV})\oplus E(\text{IV}\oplus M))$.

It follows that the third block of cryptogram for the all-zero plaintext is a constant, while it typically changes according to IV for other plaintext. And that breaks confidentiality under CPA, by allowing to recognize the all-zero plaintext.
Answer: I assume "perfectly" means not really that (one time pad etc.), but good-enough algorithms for today, like AES.
Then, it's the same even for eg. AES alone, without MAC.
As you probably know, AES has a block size (16 byte), and pure raw AES itself works exactly on one block. Not 15 bytes, not 17, not 32, just always 16.
Given this, AES is assumed to be uncrackable in real world. (There were some weaknesses found, meaning it is not as secure as the inventors thought, but just decrypting something without key takes still way too much time etc. to be possible).
Now, if there is more (or less) data than 16 byte, there are block modes and padding schemes that give us a ways how to apply AES to any data size. Among them is ECB: If the data consists of multiple AES blocks, just use AES one each of them independtly, and nothing more.
ECB is also very discouraged because of its properties: Most notably, an attacker can see in the encrypted data which blocks of the plain text were equal (simply because the encrypted data there is equal too).
In many use cases for encryption, this is a big security problem. Despite AES being uncrackable, the attacker can gain some infos about the plaintext very easily. Just because of the way AES is used.
It's nothing different for auth. enc. schemes - the way encryption and MACs are combined may weaken the overall scheme.
On a different note, AES etc. are not pefect / good enough in all cases themselves. For example, AES losing much of it's strength if two data things are encrypted with two keys that are similar (in a specific way).
Comment: So ECB mode obviously doesn't provide indistinguishability and this gets inherited to A&E.
But this doesn't really answer my question, rather satisfies a niche pertaining to it.


Does an electrolytic capacitor have a minimum voltage?

Question: Do electrolytic capacitors have a minimum voltage below which they won't operate? I'm pretty sure they don't, but anything below 7V and 1A will not power the circuit below when the capacitor in added.
Answer: For most practical purposes electrolytic capacitors can be considered to NOT have a minimum voltage rating.
The "problem" in your circuit that causes it to not work at less than 7V is that you are using a 12V relay as seen here. This is designed to operate to specification at 12V applied to coil but will pull in at somewhat less than 12V. How much less depends on various factors including the rate of rise of the applied voltage. Without knowing what is "out there" on your +12VDC supply it's not possible to give a full picture (and even then one would need to look at relay specs) but as you reduce Vin the capacitor charges in a "more leisurely" manner and at 7V the relay may still operate without the capacitor, even while being well below specified voltage, but with the capacitor the slow rise time defeats it.
It's possible that adding a large capacitor from relay center terminal to ground MAY allow lower voltage operation by making a larger source of surge current available.

Here is the relay datasheet all the way from Ningbo (directly south of Shanghai across the very wide river delta).
Guaranteed pull in voltage is >= 9.6V so 7V is "rather low".
Dropout MAY be as low as 0.6V!
Comment: Thanks for the help! I just now remembered that the relay is  12v. So I would have to wait till the capacitor charges or would just not work at all because of the coils voltage operation?
Comment: @ChrisManning - With a 7-volt supply you need a relay which will operate at 7 volts. A 12-volt relay will not operate at 7 volts. If you use a 6-volt relay your circuit will work.
Comment: @WhatRoughBeast As per my answer and his wording it seems that even with the 12V relay it probably does work at 7V and maybe slightly below without C1 as the kick of voltage is enough to pull the relay in - just BUT adding C1 slugs the rise time.


Do we have any control over sharding in IPFS?

Question: Suppose I have a huge N-dimensional database and want to store it using IPFS, is there any way I can shard my dataset in such a way that I get N hashes each for single dimension using IPFS?
Answer: You can create your own sharding structure using the DAG API. You can learn about it through this examples https://github.com/ipfs/js-ipfs/tree/master/examples/traverse-ipld-graphs
Answer: Additionally see:

I think we want to use sparse merkle trees
   https://ethresear.ch/t/data-availability-proof-friendly-state-tree-transitions/1453/6
https://github.com/ethereum/research/blob/master/trie_research/bintrie2/new_bintrie.py

https://gitter.im/ethereum/sharding?at=5ad49182102fac7b7b19334c


Hide div 24hr cookie javascript?

Question: I would like a simple JavaScript code that will allow me to hide a certain div element when clicked for a predefined amount of time. To be a little more informative, I have a suggestions box that appears when the home page is loaded. What I would like is when the div close button is clicked it sets a cookie to keep the box div closed for 24 hours (1day). Simply said, when the div close button is pressed, the box div is hidden for 24 hours. Note: I have a javascript that allows the close button to close the box but it will load every refresh.

https://i.stack.imgur.com/du1pA.jpg
Comment: Welcome to Stack Overflow! SO is for asking *questions*, not asking people to write code for you. If you make an effort on the above and run into trouble, ask questions about that (showing your code), and people will be very happy to help.
Comment: Sounds more like a request, not a question per se.
Answer: Although T.J. Crowder is right in his comment that stackoverflow is not here for writing your code... I wrote some code for you. Here's a solution using jQuery. In it you'd use a
...
 for the message and a link in it with id "close" to close the div.
$(document).ready(function() {

  // If the 'hide cookie is not set we show the message
  if (!readCookie('hide')) {
    $('#popupDiv').show();
  }

  // Add the event that closes the popup and sets the cookie that tells us to
  // not show it again until one day has passed.
  $('#close').click(function() {
    $('#popupDiv').hide();
    createCookie('hide', true, 1)
    return false;
  });

});

// ---
// And some generic cookie logic
// ---
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function eraseCookie(name) {
  createCookie(name,"",-1);
}

Here's a js fiddle: http://jsfiddle.net/FcFW2/1/. Run once and then run again. The second time the popup does not show.
Comment: blah.js is the the file I save this data in?
Comment: I;m not sure what you mean? What data exactly. If you mean what to do with this code: create a .js file and include that in your page. Make sure that the id's of the popup and the close button match up.
Comment: that code doesnt appear to be working
Comment: Hmm, it works for me: http://jsfiddle.net/FcFW2/1/. Make sure to add a #popupDiv {  display: none; } so that the popup is initially always invisible.
Comment: it was that an the javascript link was not added, i did a view in incognito and think it works now, i am very much appreciative, www.computersolutions.spruz.com if you wish to see what i am about
Comment: for future viewers I was refering to ""
Answer: this should get you started: http://www.quirksmode.org/js/cookies.html
the following examples use the functions declared in the above link.
creating a cookie:
// when the div is clicked
createCookie('hideSuggestionBox', 'true', 1);

reading a cookie:
// when deciding whether to show or hide the div (probably on document ready)
if (readCookie('hideSuggestionBox') === 'true') {
    // do not show the box, the cookie is there
} else {
    // the cookie was not found or is expired, show the box
}

Hide div 24hr cookie javascript?


How to detect collisions of two canvas object Tkinter

Question: Hello I am developing easy space invaders clone game and i need to figure out a way how to detect collision of the bullet and the alien when i shoot. Any suggestions ? Thanks
Answer: Use Pygame in place of Tkinter (eventually in place of Canvas) - there are functions to check collisions.
To check collision you have to get position both elements and check distance between them:
a2 + b2 = c2
a = x1 - x2  , b = y1 - y2 , c = distance between objects A(x1,y1) and B(x2,y2)
If distance is smaller then some value then you have collision - distance doesn't have to be zero to have collision. This way you check collision in circle around object.
But you can check collision in square area around the object - it wil be easer for you to calculate it
Object A (x1,y1) has square area x1-10 ... x1+10, y1-10 ... y1+10. You have to check whether object B (x2,y2) is in that square.
Answer: You can use a coordinates check with tkinter's bbox this returns 4 tuples, x1, y1, x2, y2 , which are the top left and bottom right points of the object. with a little math, check they are not in their same space and prevent them from going in or whatever your desired effect is when they meet.
Things that might also help during your math are
tkinter's find_overlapping. which returns a tuple of the intruding your items space.
tkinter's find_enclosed. which returns a tuple of items completly enclosed.
tkinter's find_closest. which provides a cool barrier for your item.
and a lot more great words that will help you in the link posted in this post. Unfortunatly i am too low reputation to put more than one link...
checking print((canvas.bbox(item)) in python 3 helps if you want to check the tuples manually or print it in a label or such.


Pre-charge for 230 V household appliances

Question: Most common household appliances (TVs, LED drivers, etc.) have short inrush current (50-60 A). As I understand it is for charging input side capacitors. Can I use pre-charge system with resistor, to slowly charge the device? I need it because my AC supply cannot handle such peaks. Is 230 VAC pre-charge a common practice? I would just put ~10 Ω resistor for 100 ms and then enable main relay.
Comment: @Finbarr It's a common problem on inverter-based sources that have relatively little transient energy storage (car converters, solar, battery, UPS, inverter generators). It's becoming a problem for utilities too, as solar, battery, wind, and DC transmission becomes prevalent. There it's called grid inertia, referring to the energy stored in rotating generators.
Comment: Why do you say your AC supply can't handle short high peaks of current?
Comment: Can you section your appliances over several breakers and turn them on one by one?
Comment: I'm not sure how you figured an inrush current of 50 to 60 amp for a TV or LED driver. If you had a huge motor, you might see inrush in that order of magnitude, but for a TV, I highly doubt it!
Comment: @Julien My laptop's supply brick reliably sparks at the cord plug every time I plug it into mains. And it's not a little spark. You hear it very clearly - a "pop". It's drawing way more than 15A then. A cold 1.5kW space heater doesn't make such pops when plugged in.
Comment: Yes, it is for inverter source. If it was mains or generator, the short surge would be "eaten" by the source, but inverter just cannot do that.
Answer: Commonly devices handle the inrush limiting by themselves if they need to. Such resistor limiters are commonly seen on audio amplifiers that take a large current surge to charge the supply bulk capacitors on the secondary side.
And usually power supplies already have NTC or small resistance to limit the surge current.
If a device does not expect external resistive limiting, it might not work properly, because it may try to take the current it needs to start up and it may need the current within certain time to make the supply voltage rise quickly enough. One such example might be power supplies with power factor correction (PFC) on their input.
The 10 ohm resistor might be too high as well. Usually it is lower. The resistor would need to pass a lot of current and it would momentarily need to dissipate a lot of power.
If your supply can tolerate a single device being turned on one at a time, it might better to just build a time delay which energizes one device at a time.
Answer: The idea isn't bad.
At the most basic, a hand-controlled rheostat will do the job. Doesn't need to be rated for full device power since it will dissipate heat only for a couple of seconds. The most critical rating is the continuous current. A bypass switch for when the rheostat is turned down to zero takes care of that.
That "switch" could be an end-switch-activated DPST relay that holds closed until the power is turned off. Another such relay, at the high-ohms end of range, can turn on power to the rheostat. That way it'd be safe in case of power loss and absent-mindedness. To turn it on, the rheostat wiper needs to hit the high-end switch. As soon as you then turn it down to zero, it gets bypassed. Power loss will cause the relays to drop out and the contraption is off until manually handled to restart it.

Main problem with pre-charging is that the device doesn't "know" that it's pre-charging. As soon as the DC link capacitor has charged high enough, the power supply will start up and will draw a fairly high current since the DC-link voltage is at the low end.
But today most devices start up in some kind of a low-power mode, so that shouldn't be an issue most of the time.
You'll have to experiment. Instead of a fixed resistor you may also use a synthetic resistance that ramps down to zero instead of just switching to zero. The synthetic resistance works by using a low power variable reference resistor, and "duplicating" it in series with the load.
The variable reference resistor can be a variable gain op-amp, a photoresistor with variable light source, a digitally adjusted potentiometer, a motorized potentiometer, etc.


Why is the concept of the Null hypothesis associated with the student's t distribution?

Question: There are dozens of continuous probability distributions like Gaussian (normal), Variance-gamma, Holtsmark, etc. Yet, the concept of the Null hypothesis is basically associated with Student's t-distribution.
Any idea why.
Tanks
Comment: It isn't. Since hypothesis testing is taught immediately after the t-test in Stats 101, it is usually the first time the "null hypothesis" is *taught.* And for more than a few people it is also the last time they see it.
Comment: what do you mean by "basically associated?" Are you asking why the t distribution appears to be the most common null distribution in hypothesis testing? The answer might be opinion-based.
Comment: Yes, I am wondering why t-test is the most used to study the hypothesis test.
Answer:
There are a dozen of continues probability distributions

There are an infinite number of continuous probability distributions. The ones that have been discussed enough to be named and included in the space of a couple of pages are nevertheless sufficient to fill numerous books (and indeed they do - see, for example, the many books by Johnson, Kotz and other co-authors).

Yet, the concept of the Null hypothesis is basically associated with Student's t-distribution.

This is not the case. If you take a look at either the writing of Neyman and Pearson or that of Fisher on hypothesis testing (the two main approaches to hypothesis testing), the t-distribution is not a necessary nor in any way a major part of either.
Neither is it "the most used to study the hypothesis test" (if you're studying the theory of hypothesis testing you might well only look at it in passing - perhaps as part of one chapter, for example), but it is one of the first examples of hypothesis tests many students learn about.
There are hundreds of hypothesis tests that are used (at least; more probably well into the thousands) and new ones are easy enough to construct. Some situations you may have heard of include: testing independence in contingency tables, testing multinomial goodness of fit, testing equality of means in one way analysis of variance, testing equality of variance, rank based tests of location, or omnibus tests of distributional goodness of fit. None of these are likely to involve t-distributions (and there are many, many more that you probably haven't heard of).
I'd have said the chi-squared distribution and the normal distribution are much more fundamental to hypothesis testing (in particular, as approximations in large samples), but even there, hypothesis tests would still exist even if they didn't come into it at all.
If you look at the Neyman-Pearson lemma, at Fisher exact tests/permutation/randomization testing, and at bootstrap tests, you might instead wonder if the t-distribution would really come up all that much.
Now a substantial subset of tests that are done in applications do involve the t-distribution, but that's in no way an essential property of null hypotheses.
It occurs for a pretty simple reason - it comes up when dealing with inference (tests and intervals) about sample means of normally distributed population quantities (and some other circumstances) under the case where the population variance is unknown.
Consequently the t-distribution (through one-sample/paired t-tests, two sample t-tests, tests of single regression coefficients, and tests of 0 correlation) may be the bulk of your exposure to hypothesis tests but that's not an overwhelming fraction of hypothesis testing more generally.
Answer:
...the concept of the null hypothesis is basically associated with Student's t-distribution.

Not really.  The null hypothesis is associated with a corresponding null distribution, which varies depending on the model and test statistic.  In classical hypothesis tests for unknown linear coefficients or mean values, one generally uses a test statistic that is some kind of studentised mean estimator, and this leads to a null distribution which is the Student's T distribution.  In other tests, one obtains a different null distribution.  It seems that you are associating the two concepts more strongly than they are actually associated, and then wondering why this is.
Answer: When we want to test a hypothesis, we need a test statistic with a known probability distribution. This usually involves standardisation of the data. For example, if we collect a random sample $X_1, \dots, X_n$ with mean $\mu$ and variance $\sigma^2$, and the data is assumed to be normally distributed. Then we would standardise it as
$$Z_n = \frac{\bar{X}_n-\mu}{\sigma/\sqrt{n}}$$
$Z_n$ has a standard normal $N(0,1)$ distribution, and so it's values can be used to test whether our hypothesised mean $\mu$ is true.  Even if the data is not normal, the central limit theorem says that it will be asymptotically provided the variance exists (ie. $EX^2 < \infty$).
The problem is that while we are normally interested in the mean $\mu$, the variance $\sigma^2$ is also unknown. This is called a nuisance parameter. Thus we need to approximate $Z_n$ by substituting in an estimate for $\sigma^2$, which is the sample variance
$$s^2 = \frac{1}{n-1}\sum_{i=1}^n (X_i - \bar{X}_n)^2$$
But in doing so we have a new test statistic
$$T_n = \frac{\bar{X}_n-\mu_0}{s/\sqrt{n}}$$
This turns out to have $t$ distribution with $n-1$ degrees of freedom if the null hypothesis is true (ie. if the true mean is used). Thus, even though $\sigma^2$ is unknown, we have obtained a test statistic with a well known distribution for which to make inferences.
The reason it follows a $t$ distribution is that the above can be expressed as a normal random variable divided by the square root of an independent chisquared random variable, which gives a $t$ distribution.
Comment: Thanks for your answer. I am trying to digest the answer, Could you give me a quick example?
Answer: It isn't, but it would probably seem so to a non-statistician who is just learning it while trying to do some basic inference in the context of a science class or something like that.  Because the sorts of things in science experiments you want to do inference/hyp testing on have the characteristics of a t-test:  the variance is not known, the samples are small, and you are dealing with something that is continuous in nature. A stats student will almost certainly be introduced to a z-test first, through population proportion testing.
The trick is to realize that the transition from z to t test for population mean inference and hypothesis testing comes from the addition of another parameter that needs to be estimated -- the variance -- and in the vast majority of situations you'll encounter the population variance is not known.
I would guess most people who associate hypothesis testing with the T test do so because it's by far the most common one encountered in the sciences and humanities, at least at the lower levels.
Answer:
Yet, the concept of the Null hypothesis is basically associated with
  Student's t-distribution

No, actually it isn't. What gives you that impressions is null hypothesis and student's t-distribution being taught together because a simple 1 sample t test is simple and easy. But the truth is that there are many other sampling distribution besides t-distribution for a given set of assumptions.Whereas the null hypothesis is associated with a corresponding null distribution based on your assumptions and test statistic.
Comment: OK, but hard to see that this adds anything to other answers or is better explained,


Add fields to user roles

Question: I'm using Drupal 7 to create a project linking organizations to volunteers. My initial approach is to use profile module to create different profiles for each role (volunteer & organization). Is it possible to create new fields which would attach only to a selected role?
Answer: This is a great example use-case for the Profile 2 module.
As listed on the project page:

Profile2 allows for creating multiple profile types, which may be assigned to roles via permissions (e.g. a general profile + a customer profile)
Comment: From an OO perspective, I'm basically trying to extend the user entity, although coding entirely new entities to use as roles seems like a lot of work ;)
Comment: Unfortunately, this isn't quite the use case I'm after. I don't want to add additional profiles to users by role, I want to extend roles to have more fields. For instance: a profile type: Volunteer, and a profile type: Organization, each with their distinct fields. Profile2 seems to handle this rather awkwardly...
Comment: @starsinmypockets In Drupal 7, fields are added to nodes, comments, taxonomy terms, and users. There isn't a way to add a field to roles, which are not considered entities. The closer you can get is what reported by @tim.plunkett, which is to have a different profile type for each user having specific roles.
Answer: I guess you could also try to add all fields to the user directly and then use a custom hook_field_access() implementation to control when they are shown for edit/view.
Comment: This sounds promising!
Answer: I think you can use https://drupal.org/project/user_role_field
This module allows you to specify role specific fields. When creating a new field, you specify for what roles this field is enabled..
Answer: Sounds like a good idea to collect all fields in one entity. You could then have a enumerator-field, where you could choose entity-sub-type (organization or volunteer). That would be needed in case the author had authority to create both.
You can use User Role Field to hide the fields that the author is not allowed to see.
You can use Field Permissions to restrict access that the author and viewer is not allowed to access.
You can use also hide or show fields dependent on values of other fields with Conditional Fields. The dependee field would then be the enumerator-field.
You could probably use Computed Field to add extra logic dependent on sub-type.
I like to use taxonomy for enumerator, but it could be a text list instead.
You would probably also like to group the subtype specific fields together in a drupal.org/project/field_group
This pattern could just as well be applied on contenttypes. I think I will try it out.
In Microsoft Sharepoint, ContentTypes has had inheritance for years. I wonder if it will come in a future Drupal version.

Add fields to user roles