"Monte Carlo" Perl
This is pretty cool - had not seen it before.
http://math.fullerton.edu/mathews/n2003/MonteCarloPiMod.html
http://en.wikipedia.org/wiki/Monte_Carlo_method
Those of you with cygwin or unix and perl:
#!/usr/bin/perl my $COUNT = 8; #Orders of magnitude my $HIT = 0; for(my $i = 1; $i < 10**$COUNT; ++$i){ $HIT++ if rand()**2 + rand()**2 <= 1; printf "PI ~ %1.8f after %0${COUNT}i points\n", 4*$HIT/$i, $i if ($i % 1_000) == 0; }
I got PI ~ 3.14155046 after 99999000 points and a second run with PI ~ 3.14160204 after 999990000 points
A Better "Bash Here"
There are a lot of ways to do a "bash window here" in WinXP, but this is my fav by far. It gives you the proper unix style mouse buttons since it is a terminal window not just cmd
. After installing it, right click on any directory:
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shell\0cmd-rxvt] @="Bash Window Here" [HKEY_CLASSES_ROOT\Directory\shell\0cmd-rxvt\command] @="C:\\cygwin\\bin\\rxvt.exe -bg black -fg white -sr -sl 1000 -fn \"Fixedsys\" -ls -e /usr/bin/bash --login -c \"cd \\\"`cygpath -u '%1'`\\\"; exec bash\""
You may need to change the beginning of the last line if you installed in a different path, e.g. e:\cygwin\
.
Updated March 2009
My buddy Bill told me there is now a Cygwin command xhere
and a setup command chere
that will do all the Registry insertions for you. So launch Cygwin in the default crappy shell (with admin privs) and you can type:
chere -i -af -t rxvt -o "-bg black -fg white -sr -sl 1000 -fn \"FixedSys\" -ls" -s bash -e "Bash prompt here"
You can change -af
to -cf
for current user only if you don't have admin on the machine.
Because he was kind enough to give it to me, I will give you his command which seriously hurts my eyes. I also prefer the default size and expand it if needed.
chere -i -af -t rxvt -o "-ls -sr -sl 1000 -bg grey70 -fg black -geometry 120x65+300+15 -fn 10x16 -title Bash" -s bash -e "Bash prompt here"