Skip to content

Instantly share code, notes, and snippets.

View kig's full-sized avatar

Ilmari Heikkinen kig

View GitHub Profile
@kig
kig / gist:11252
Created September 17, 2008 16:08
post-commit:
#!/usr/bin/ruby
lastlog = `git log -1`
raise "Error in git log -1" if $?.exitstatus != 0
if lastlog.include?("fix") and not lastlog.include?("closebug")
`echo bug >> bug`
raise "Error in echo" if $?.exitstatus != 0
`git add bug`
@kig
kig / gist:12139
Created September 22, 2008 20:14
let id_map y = List.map (fun x -> x) y
*** Linearized code
camlTest__id_map_58:
y/29[%rbx] := R/0[%rax]
A/30[%rax] := "camlTest__2"
tailcall "camlList__map_90" R/0[%rax] R/1[%rbx]
@kig
kig / gist:13759
Created September 30, 2008 06:37
.equ EXIT, 1
.equ READ, 3
.equ OPEN, 5
.equ BRK, 45
.equ BUF_SZ, 4096
.section .data
filename:
.ascii "my_file\0"
(*
let s = Stream.of_string "foo\nbar\nbaz" in
let lines = Stream.refoldl (fun s c -> if c = '\n' then Done s else Acc (s ^. c)) s in
Stream.iter print_string lines;
print_newline ();;
foobarbaz
*)
type 'a accum = Acc of 'a | Done of 'a
@kig
kig / gist:23808
Created November 11, 2008 11:45
google_raw, a small google commandline tool
#!/usr/bin/ruby
=begin
$ google_raw -n1 euribor
Euribor Homepage
http://www.euribor.org/
Euribor (Euro Interbank Offered Rate) is the rate at which euro interban
k term deposits within the euro zone are offered by one prime bank to ano
ther prime ...Historical DataAbout EuriborAbout EoniaPress ReleasesWhat's
newFAQsPanel BanksTechnical FeaturesMore results from euribor.org??
@kig
kig / gist:28999
Created November 25, 2008 18:00
Gtk2Hs Cairo + Pango Hello World
-- Reqs: apt-get install libghc6-time-dev libghc6-cairo-dev libghc6-gtk-dev
-- Compile by doing
-- ghc --make hello.hs -o hello
import Graphics.UI.Gtk hiding (fill)
import Graphics.Rendering.Cairo
import Data.Time.Clock.POSIX
import Time
frac = snd . properFraction
import System.Directory
import System.FilePath
import System.Posix.Files
import System.Posix.Types
import System.Posix.User
import Data.List (partition)
data DirInfo = DirInfo {
@kig
kig / gist:32942
Created December 6, 2008 19:40
hex.hs
import Graphics.UI.Gtk hiding (fill)
import Graphics.Rendering.Cairo
import Data.Time.Clock.POSIX
import Time
frac = snd . properFraction
modf a b = frac (a / b) * b
normalizeAngle a | a < 0 = 2*pi + (a `modf` (2*pi))
@kig
kig / gist:33599
Created December 8, 2008 20:23
distorted_hex.hs
import Graphics.UI.Gtk hiding (fill)
import Graphics.Rendering.Cairo
import Data.Time.Clock.POSIX
import Time
frac = snd . properFraction
modf a b = frac (a / b) * b
normalizeAngle a | a < 0 = 2*pi + (a `modf` (2*pi))
@kig
kig / gist:34439
Created December 10, 2008 18:59
cairo drawing lib bits with combinators
-- cairo drawing lib bits with combinators
moveToP = uncurry moveTo
lineToP = uncurry lineTo
curveToP ((x1,y1),(x2,y2),(x3,y3)) = curveTo x1 y1 x2 y2 x3 y3
doWith g f x = do { f x; g }
withDo f g x = do { f; g x }
listDo _ _ [] = return ()