Slide Show Demo

A wiki page — and a slide show too?

Just export this page as S5 (in the sidebar). Or click here to view it as a slide show now.

Second slide: look at some (poignant) ruby

 require 'wordlist'

# Get evil idea and swap in code words
print "Enter your new idea: "
idea = gets
code_words.each do |real, code|
idea.gsub!( real, code )
end

# Save the jibberish to a new file
print "File encoded. Please enter a name for this idea: "
idea_name = gets.strip
File::open( "idea-" + idea_name + ".txt", "w" ) do |f|
f << idea
end

Third slide: or learn you some Haskell

import System.IO
main = do
handle <- openFile "girlfriend.txt" ReadMode
contents <- hGetContents handle
putStr contents
hClose handle

Running it, we get the expected result:

$ runhaskell girlfriend.hs  
Hey! Hey! You! You!
I don't like your girlfriend!
No way! No way!
I think you need a new one!

Fourth Slide … for Great Good

ghci> inits "w00t"  
["","w","w0","w00","w00t"]
ghci> tails "w00t"
["w00t","00t","0t","t",""]
ghci> let w = "w00t" in zip (inits w) (tails w)
[("","w00t"),("w","00t"),("w0","0t"),("w00","t"),("w00t","")]

Let’s use a fold to implement searching a list for a sublist.

search :: (Eq a) => [a] -> [a] -> Bool  
search needle haystack =
let nlen = length needle
in foldl (\acc x -> if take nlen x == needle
then True
else acc) False (tails haystack)

Fifth Slide: some math?

With some math: s=ateπ. (Doesn’t work yet in the slide show — need to add a link to jsMath!)

And a list:

  • one
  • two