Skip to content

Instantly share code, notes, and snippets.

View lambda-fairy's full-sized avatar
💜
Hello!

Chris Wong lambda-fairy

💜
Hello!
View GitHub Profile
@lambda-fairy
lambda-fairy / Soctopus.hs
Created May 22, 2012 01:17
Soctopus Prediction
-- | <http://ncss.edu.au/challenge/ncss_challenge_2012.pdf>
class Semigroup a where
(<>) :: a -> a -> a
data Result = Team String | Draw Int
resultLength :: Result -> Int
resultLength (Team name) = length name
resultLength (Draw lgth) = lgth
@lambda-fairy
lambda-fairy / Fold.hs
Created May 27, 2012 07:44
Data.List.Fold - fold lists in constant space
-- | Lock-step folding.
--
-- This module presents an elegant way of executing multiple left folds
-- on one list using constant memory. For example, the mean can be
-- expressed as:
--
-- @
-- average = foldLeft $ (/) <$> sumF <*> lengthF
-- @
@lambda-fairy
lambda-fairy / SaveRestore.hs
Created June 6, 2012 00:28
Set options temporarily - useful with Network.HTTP.Conduit.Browser
import qualified Control.Exception.Lifted as Lifted
import Control.Monad.Trans.Control
-- | Set an option, run an action, then restore the option to its
-- previous value.
--
-- @saveRestore get set value action@ is roughly equivalent to:
--
-- > do orig <- get
-- > set value
@lambda-fairy
lambda-fairy / kol.js
Created June 26, 2012 06:44
KoL auto-adventure script
javascript:
var frm = window.frames[2];
function next(f) {
setTimeout(f, 100);
}
function doClick(elem) {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
elem.dispatchEvent(evt);
}
@lambda-fairy
lambda-fairy / Birthday.hs
Created July 22, 2012 04:57
Birthday paradox calculator
-- | Birthday paradox calculator
import Control.Monad
import Data.Ratio
import System.Environment
import Text.Printf
birthday :: Fractional a => Integer -> Integer -> a
birthday days n = realToFrac $ 1 - inverse
where
@lambda-fairy
lambda-fairy / gist:3445830
Last active October 9, 2015 05:27
Aqua programming language

TODO

  • Exceptions
  • Delimited continuations, because continuations are cool.
  • Macros (maybe)
  • Attribute lookup – lenses?
  • Keyword parameters
    • [GHC implicit parameters][] are interesting
@lambda-fairy
lambda-fairy / technic.py
Created August 28, 2012 08:17
Epic Technic downloader thingy
#!/usr/bin/env python
from argparse import ArgumentParser
from collections import namedtuple
import os
import requests
import yaml
TECHNIC_URL = 'https://github.com/TechnicPack/Technic/raw/master'
@lambda-fairy
lambda-fairy / Temperatures.hs
Created September 3, 2012 04:53
Solution for Lab 6 Exercise 2
-- | Solution for Lab 6 Exercise 2
module Temperatures where
import Control.Applicative
import Control.Arrow
import Data.Char
import Text.Printf
type Row = [Double]
@lambda-fairy
lambda-fairy / parallel2.lua
Created September 15, 2012 08:38
parallel2 - a better parallel module
--[[
parallel2 - a better parallel module
====================================
@author Lambda Fairy (https://github.com/lfairy)
**parallel2** is a complete rewrite of the ComputerCraft parallel API.
It gives you many features over the original, including:
@lambda-fairy
lambda-fairy / treasureChestgui.py
Created October 2, 2012 00:07
Treasure Chest GUI
#!/usr/bin/env python
"""
----------------
Treasure Chest
----------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |