Skip to content

Instantly share code, notes, and snippets.

View matthewleon's full-sized avatar

Matthew Leon matthewleon

  • around the world
View GitHub Profile
@matthewleon
matthewleon / FizzBuzz.purs
Last active May 10, 2017 22:28
purescript fizzbuzz DSL
-- based on "FizzBuzz in Haskell by Embedding a Domain-Specific Language"
-- by Maciej Piróg
-- https://themonadreader.files.wordpress.com/2014/04/fizzbuzz.pdf
-- and "skiphaltprint" by Mathias Verraes
-- https://github.com/mathiasverraes/skiphaltprint
module Main where
import Prelude
import Control.Monad.Eff (Eff, forE)
import Control.Monad.Eff.Console (CONSOLE, log)
@matthewleon
matthewleon / test.js
Created May 30, 2015 15:21
mocha jsverify shrink failure
jsc = require('jsverify');
(function() {
arbitraryPositiveInteger = jsc.nat.smap(
function (n) {return n + 1;},
function (n) {return n - 1;}
);
describe('test with arbitrary array and two smapped arbitrary params',
function() {
@matthewleon
matthewleon / merge_generators.py
Created September 7, 2012 01:13
gevent merge generators
from gevent import monkey
monkey.patch_all()
from gevent import Greenlet
from gevent.queue import Queue
from gevent.pool import Group
def merge_generators(*args):
def enqueue(generator):
for item in generator():
@matthewleon
matthewleon / mpd-theremin.log
Created March 11, 2011 04:07
mpd 15 versus Theremin
A quick TCP log of a local MPD server chatting it up with Theremin.
~: socat -v tcp4-l:12345 tcp4:localhost:6600
< 2011/03/10 23:04:28.238351 length=14 from=0 to=13
OK MPD 0.15.0
> 2011/03/10 23:04:28.238800 length=9 from=0 to=8
commands
< 2011/03/10 23:04:28.239075 length=1176 from=14 to=1189
command: add
command: addid
@matthewleon
matthewleon / sortedListToBST.hs
Created November 30, 2010 01:09
Convert a sorted list to a balanced binary search tree
{-# LANGUAGE PackageImports #-}
import "mtl" Control.Monad.State
data BinTree a = Tip | Node (BinTree a) a (BinTree a) deriving Show
conv :: Int -> State [a] (BinTree a)
conv 0 = return Tip
conv len = liftM3 Node leftTree pop rightTree
where leftTree = conv mid