Skip to content

Instantly share code, notes, and snippets.

Suppose that:
f(n)*f(n-2) - f(n-1)^2 = (-1)^(n-1) (1)
This is the same as the assumption, but for n-1. The inductive step requires us to show that it is true for n:
f(n+1)*f(n-1) - f(n)^2 = (-1)^n (2)
We notice that:
(-1)^n = -1*(-1)^(n-1) (3)
{-|
The Grid module creates a grid datatype that represents the pixmap that we will output to. It is a glorified matrix. This code really sucks.
-}
module Grid (Grid
,createGrid
) where
import Data.Complex
-- |As was already stated, glorified matrix.
#!/usr/bin/ruby
############################################################
# Simple wallpaper-rotation script. You can run it in cron.#
############################################################
#
# Defaulting parameters which can be specified at the CLI
#
command = ARGV[0]
command ||= "/usr/bin/feh --bg-scale"
dir = ARGV[1]
module ROT13 ( rot13 ) where
import Data.Char
import Data.List
rot13 :: String -> String
rot13 = map (rotate 13)
rotate :: Int -> Char -> Char
rotate n c
#!/usr/bin/env ruby
#######################################################
# Call qemu without having to remember stupid options.#
#######################################################
require 'yaml'
$qemu = "qemu-system-i386"
config = File.open("/home/michael/.qemu.yaml") {|yf| YAML::load(yf) }
def parse_machine(config,machine)
x = config["machines"][machine].each_pair.map.reduce "" do |acc,key|
case key[0]
@tensorpudding
tensorpudding / say
Created April 8, 2011 20:13
say command, using festival and sh, that i came up with in five minutes
#!/bin/sh
# A very simplified version of OSX's say, using festival
# Usage: say [words]
usage="Usage: `basename $0` [-n | -f FILE | [WORDS]]"
if [ $# = 0 ]
then
echo $usage
@tensorpudding
tensorpudding / backend.clj
Created November 6, 2011 04:08
compojure, ring, enlive blog webapp
(ns blog.backend)
(def posts (atom {:1 {:title "Hello" :body "World"} }))
(defn get-post-title "Get title of post of given id"
[id] (((deref posts) (keyword id)) :title))
(defn get-post-body "Get body of post of given id"
[id] (((deref posts) (keyword id)) :body))
@tensorpudding
tensorpudding / posts.clj
Created November 8, 2011 01:17
more clojure webapp goodness
(ns blog.models.posts
(:require blog.db [clj-time.core :as ctime] [clj-time.format :as format]
[clj-time.coerce :as coerce])
(:use korma.core))
(defentity posts
(pk :pid)
(database blog.db/db))
(defn sql-current-time "Current timestamp in SQL Timestamp format"