February 2023

S M T W T F S
   1234
567891011
12131415161718
19202122232425
262728    

Style Credit

Expand Cut Tags

No cut tags
Tuesday, October 2nd, 2007 01:47 pm
Can't decide where to eat? (and you're in the USA, I presume)? Grab the Wheel of Lunch and give it a spin!

I will not publicly admit that I have a shellscript to do the same thing. If I did have such a script, its database would be populated only with restaurants I happened to like, all near my current place of work, and I would be about half way through implementing "attributes" such as "quick" or "inexpensive" -- but only if I had such a script. Of course I don't. Only a computer geek type of person would have such a thing.
Tuesday, October 2nd, 2007 11:01 pm (UTC)
It's too bad that you don't have such a script.

It's really too bad that that script isn't someplace that people could get a copy.
Tuesday, October 2nd, 2007 11:22 pm (UTC)
Yeah, it sure is. It's a darn shame the script doesn't look anything like this. (Check out the /bin/date args available on your OS.)


#!/bin/csh -f

######################################
# Enumerate the potential food choices
######################################

echo "Amarin Thai on Castro" >> /tmp/cj.food.txt
echo "Amici's Pizza on Castro" >> /tmp/cj.food.txt
echo "Armadillo Willy's" >> /tmp/cj.food.txt


##########################################
# Pick a random number, spit out that line
##########################################

# Replace "%s" with %N" on RHEL3 machines.
# %s is seconds since the epoch; %N is nanoseconds and makes a better
# randomizer. (However, it seems always to report an even microsecond.)

# setenv OSVER `head -1 /etc/redhat-release | cut -d ' ' -f 5`
# echo $OSVER

# if ($OSVER == "WS") then
setenv RANDOM_NUM `/bin/date +%N`
setenv RANDOM_NUM `expr $RANDOM_NUM / 1000`
# else setenv RANDOM_NUM `/bin/date +%s`
# endif
# echo $RANDOM_NUM

setenv NUM_LINES `cat /tmp/cj.food.txt | wc -l`
setenv PICK_LINE `expr $RANDOM_NUM % $NUM_LINES`
setenv PICK_LINE `expr $PICK_LINE + 1`
# echo $PICK_LINE

head -n $PICK_LINE /tmp/cj.food.txt | tail -n 1


rm /tmp/cj.food.txt

Wednesday, October 3rd, 2007 11:37 pm (UTC)
now you're just trying to get us hot :)
Thursday, October 4th, 2007 12:06 am (UTC)
I admit it would work on me too -- mainly because there are comments in it. Anyone who writes comments gets a thumbs up from me. Years of being a contractor will do that to a person. :-)
Thursday, October 4th, 2007 12:11 am (UTC)
*makes a mental note to write more comments* :)
Thursday, October 4th, 2007 12:22 am (UTC)
Now THAT'S geek flirting! ;-) ;-)
Thursday, October 4th, 2007 12:24 am (UTC)
ideally, geek flirting would have used /* rather than * :)
Thursday, October 4th, 2007 12:54 am (UTC)
or # or // or even ;

:-)
Thursday, October 4th, 2007 12:59 am (UTC)
# no comment :)