Skip to content

Instantly share code, notes, and snippets.

@threedaymonk
threedaymonk / references.md
Last active December 15, 2015 13:09
Links for the references in Tim Williams's talk on Recursion Schemes by Example http://www.timphilipwilliams.com/slides.html
@threedaymonk
threedaymonk / gccmock.rb
Last active December 14, 2015 06:29 — forked from tenderlove/gccmock.rb
# gccmock - generate exploding link stubs from linker error messages
#
# Usage: gcc [files] 2>&1 | ruby gccmock.rb > [filename].c
LINK_SYMBOL = /"_([_a-z0-9]*)",/
puts "#include <assert.h>"
puts "#define EXPLODE(name) void name() { assert(!\"unexpected call\"); }"
puts *ARGF.read.scan(LINK_SYMBOL).map { |a| "EXPLODE(#{a[0]})" }.sort.uniq
@threedaymonk
threedaymonk / mandel.clj
Created September 11, 2012 20:32
UTF-8 Mandelbrot in Clojure
(def screen-width 100)
(def screen-height 30)
(defn scaled-x [x]
(- (* (/ x screen-width) 3.5) 2.5))
(defn scaled-y [y]
(- (* (/ y screen-height) 2) 1))
(defn mandel [x y iteration x0 y0 max-iteration]
@threedaymonk
threedaymonk / srutis.clj
Created August 16, 2012 00:00
Hacking Chris Ford's Overtone code to play Indian scales.
(ns noize.core
(:use [overtone.live :exclude [midi->hz sharp flat scale run pitch shift]]))
(definst harps# [freq 440]
(let [duration 1]
(*
(line:kr 1 1 duration FREE)
(pluck (* (white-noise) (env-gen (perc 0.001 5) :action FREE)) 1 1 (/ 1 freq) (* duration 2) 0.25))))
(def midi-0 8.1757989156)
@threedaymonk
threedaymonk / README.md
Created July 18, 2012 13:26
Basic <ruby> (furigana) support for Firefox
@threedaymonk
threedaymonk / decode.sh
Created July 16, 2012 18:43
Breaking the http://www.olympicgamesmonitoring.com/ CAPTCHA in one line of shell script
#!/bin/sh
convert -threshold 30% $1 pnm:- | gocr - | tr 'OI' '01' | tr 'A-Z' 'a-z'
@threedaymonk
threedaymonk / grid.js
Created July 5, 2012 16:11
View and test vertical rhythm
(function(){
var isGridActive = false;
var lineHeight = function(){
return parseInt(window.getComputedStyle(document.body).lineHeight, 10);
};
var gridDataURL = function(){
var size = lineHeight();
@threedaymonk
threedaymonk / gist:2888097
Created June 7, 2012 10:33
Disable access-time logging on Raspberry Pi Debian
~ > cat /etc/fstab
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 0
/dev/mmcblk0p2 / ext4 defaults,noatime,nodiratime 0 0
#/dev/mmcblk0p3 none swap sw 0 0
#!/bin/sh
# Expose ssh on port 2222; solr on 8983; HTTP on 8001.
qemu-system-i386 \
-m 1024 \
-hda my-disk.img \
-daemonize \
-nographic \
-net nic \
@threedaymonk
threedaymonk / gist:1679615
Created January 25, 2012 23:20
BigDecimal 1.9.2 vs 1.9.3
1.9.3
>> require "bigdecimal"
=> true
>> b = BigDecimal.new("1234")
=> #<BigDecimal:27c05e0,'0.1234E4',9(18)>
>> BigDecimal.new(b)
=> #<BigDecimal:27c0c70,'0.1234E4',9(18)>
1.9.2