11.09.05
Flipping a coin
Here’s my new favorite way for flipping a coin: In a command line, type:
echo "`date "+%S"`%2" | bc
and press enter, or even better, from a file in TextMate, type this in a line and press Control-R.
What’ s your favorite way?
Later
Sameer said,
November 9, 2005 at 10:56 pm
This is not very random. You might as well look at your watch and type in 1 or 0.
This is much much better.
http://www.random.org/cgi-bin/randnum?num=1&min=0&max=1&col=1
Haris said,
November 10, 2005 at 2:35 pm
Yeah, but it requires an internet connection.
We actually use the other method to create a script that would load a different TextMate theme each time it is ran.
Why isn’t there a shell command to generate a random number?
Allan Odgaard said,
November 11, 2005 at 9:11 am
From shell there’s /dev/random, but it’s verbose to pick the first byte from that stream (and work with it).
So how about: ruby -e ‘puts rand.round’
Rand gives a number between 0 and 1, so rounding it should be the coin flip.
Haris said,
November 11, 2005 at 5:11 pm
I like the ruby method, it almost forces me to learn more ruby.
Indeed the /dev/random approach is a bit too verbose:
as you mentioned in the mailing list.
But it’s good to know it’s there.