Skip to content

Instantly share code, notes, and snippets.

@sphynx
sphynx / gist:817407
Created February 8, 2011 22:26
Task 3
module Main where
d = [3, 4, 9, 14, 15, 19, 28, 37, 47, 50, 54, 56, 59, 61, 70, 73, 78, 81, 92, 95, 97, 99]
superset [] = [[]]
superset (x:xs) = ss ++ map (x:) ss
where ss = superset xs
check [] = False
check xs = m == sum xs - m where m = maximum xs
@sphynx
sphynx / gist:813324
Created February 6, 2011 12:01
SSH agent setup in .bashrc
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initializing new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
}
@sphynx
sphynx / gist:807908
Created February 2, 2011 16:04
Tweaking Raphael easing function ">"
// send first ball from (0, 0) to (200, 0)
animate(firstBall, 0, 200)();
// send second ball from (0, 0) to (100, 0) but with the tempo like it was sent to (200, 0)
animateWithTweak(secondBall, 0, 100, 200)();
function animate(ball, start, intended) {
return function () {
ball.animate({cx: intended}, 2000, ">");
}
@sphynx
sphynx / gist:807906
Created February 2, 2011 16:02
Easing function with tweak
// send first ball from (0, 0) to (200, 0)
animate(firstBall, 0, 200)();
// send second ball from (0, 0) to (100, 0) but with the tempo like it was sent to (200, 0)
animateWithTweak(secondBall, 0, 100, 200)();
function animate(ball, start, intended) {
return function () {
ball.animate({cx: intended}, 2000, ">");
}
@sphynx
sphynx / pairings.hs
Created November 27, 2010 20:41
Pairings average difference calculation
module Main where
import Data.List
monkeys = [{-2416, -} 2117, 2085, 2018, 2013, 2010, 2006, 1929, 1749, 1746, 1678, 1622, 1622, 1586, 1543, 1497, 1487, 1445]
bishops = [2064, 2052, 2031, 1965, 1935, 1930, 1904, 1808, 1772, 1760, 1732, 1730, 1715, 1676, 1656, 1599, 1550, 1523, 1410]
diff :: Num a => [a] -> [a] -> [a]
diff = zipWith (-)