Skip to main content

Schneierfacts fortune cookies

A (long) while ago I stumbled upon the incredible Schneierfacts and thought "I must have these snippets of wisdom as a fortune(6) file!" Here's how I did that:

  mkdir schneierfacts && cd schneierfacts
  f=1
  while [ $f -lt 1610 ]; do 
      echo "fact: $f"
      wget -q http://geekz.co.uk/schneierfacts/fact/"$f"
      sleep 1
      f=$((f+1))
  done


  grep 'p class="fact"' * | \
          sed 's/.*fact\">//;s///;s/\&quot\;/\"/g' | \
          sort -u > ../schneierfacts.txt
  sed G ../schneierfacts.txt | sed 's/^$/%/' > ../schneierfacts

  strfile -r ../schneierfacts
  "../schneierfacts.dat" created
  There were 1600 strings
  Longest string: 24713 bytes
  Shortest string:  142 bytes
With that in place, we can install our new fortune file:
  sudo mkdir -p /usr/local/share/games/fortunes
  sudo cp ../schneierfacts{,.dat} /usr/local/share/games/fortunes/

  $ fortune schneierfacts
  When Bruce Schneier does modulo arithmetic, there are no remainders. Ever.
Note: There are currently over 1600 facts, be kind when downloading the facts! (i.e. use sleep(1) after every wget(1) call.)