Skip to content

Instantly share code, notes, and snippets.

View sordina's full-sized avatar

Lyndon Maydwell sordina

View GitHub Profile
@sordina
sordina / Hilbert.hs
Created August 10, 2011 17:15
Hilbert Curve with Graphics.AST
import Diagrams.AST
main = outputImage "hilbert.png" w w (hilbert i) where (i,w) = (8,1200)
hilbert i = Modifier (LineWidth 0.1) $ Shape $ Path Open $ Offsets (iterate build base !! i)
base = [(0,1),(1,0),(0,-1)]
build x = l $ n x ++ o ++ r (r (l (x ++ o ++ x) ++ o ++ n x))
@sordina
sordina / gravity.hs
Created August 16, 2011 13:13
Gravity Simulation
import Data.Monoid
import Data.List
import Graphics.Gloss hiding (Vector, scale)
-- Rendering
main = animateInWindow "Gravity" (1000,700) (0,0) black (Pictures . map picture . (progression !!) . round . (*40))
@sordina
sordina / Life.hs
Created December 9, 2011 01:40 — forked from anonymous/Life.hs
Small game of life implementation
import Data.List
import Control.Arrow
import System.Random
-- Core Life Engine
life = f 3 >>> map (map (q 3 >>> uncurry s))
s n 1 | n < 3 = 0 -- There is no 'off-by-one' error here
@sordina
sordina / lookup.hs
Created February 9, 2012 11:57
Key-Val Lookup Server
{-# Language OverloadedStrings #-}
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as B
import qualified Data.Conduit.Binary as CB
import qualified Data.Conduit.List as CL
import qualified Data.Map as M
import qualified Data.IORef as R
import Data.Conduit.Network
import Data.Conduit
@sordina
sordina / WindowSort.hs
Created March 16, 2012 15:21
Sort Data Within the Bounds of a Window (Online)
import Data.List
import Data.Ord
class (Ord t, Num t) => Windowed a t | a -> t where
windowTag :: a -> t
dataTag :: a -> t
type SB a = (a -> a -> Ordering) -> [a] -> [a]
insertionSortBy cmp = foldr (insertBy cmp) []
@sordina
sordina / fetch.hs
Created April 11, 2012 15:55
HXT + Conduit based scraper for members-list of Agile-Perth
{-# LANGUAGE NoMonomorphismRestriction #-}
import Network.HTTP.Conduit
import Text.XML.HXT.Core
import Data.ByteString.Lazy.Char8 (unpack)
import System.IO
main = prog 0 []
prog offset lastItems = do
@sordina
sordina / fetch2.hs
Created April 11, 2012 18:47
Fetch and Parse XML with Conduit
{-# LANGUAGE OverloadedStrings #-}
-- http://www.yesodweb.com/book/xml
import Text.XML
import Text.XML.Cursor
import Network.HTTP.Conduit
main = do
cursor <- fmap fromDocument prog
@sordina
sordina / HTML2XML.hs
Created April 12, 2012 08:01
Convert a HTML StringLike to an XML StringLike with TagSoup
module HTML2XML where
import Control.Monad
import Control.Monad.Identity
import Text.HTML.TagSoup
import Text.StringLike
import qualified Control.Monad.Trans.State.Lazy as State
data CloseState a = CloseState {incomming :: a, open :: a, result :: a}
@sordina
sordina / .zshrc
Created June 18, 2012 02:47
zsh config
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="sordina" # "sunaku" # "alanpeabody" "dpoggi" # random robbyrussell sunrise afowler dpoggi
# muse.zsh-theme
@sordina
sordina / .gitconfig
Created June 18, 2012 04:43
git config
[user]
name = <name>
email = <email
[color]
diff = always
[alias]
st = status
ci = commit