Posts

Showing posts from October, 2010

bash case statement fall through

bash case statement fall throughShort answer is that there isn't a fall through. Here is an example from http://en.wikipedia.org/wiki/Switch_statement.Most people just want a or functionality so here is how you achieve that.case$nin 0)echo'You typed 0.';;1|9)echo"$n is a perfect square.";;3|5|7)echo"$n is a prime number.";; 4)echo"$n is a perfect square. $n is an even number";;2|6|8)echo"$n is an even number.";;*)echo'Only single-digit numbers are allowed.';;esac

Ruby sleep in milliseconds

The short answer is sleep(0.0001) for a millisecond.

sleep(0.0001)
The details are that it's not that simple. Depending on your platform(OS) and details on thread sleeping, which I won't go into. When you get under a second and definitely under a tenth of a second accuracy really goes down the tubes. On some computers you won't see it work on less than a second. This is a complaint on some message boards. If you need much better accuracy look into realtime linux as your OS.

Bash move forward a word and backward a word using command line shortcut keys

Bash move forward or backward a word on the command line shortcut keys

Will move you forward one word on the command line
ESC f
Will move you backward one word on the command line
ESC b