Skip to content

Instantly share code, notes, and snippets.

View lambda-fairy's full-sized avatar

Chris Wong lambda-fairy

View GitHub Profile
@lambda-fairy
lambda-fairy / parse.rs
Last active January 2, 2016 08:49
Prototype shunting-yard regex parser
/// Shunting-yard regex parser
#[derive(Debug)]
pub enum Token {
Empty,
Lit(char),
Op(Op)
}
@lambda-fairy
lambda-fairy / main.rs
Last active January 1, 2016 08:29
ICE test case
#[allow(dead_code)];
mod parse;
/*
AAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@lambda-fairy
lambda-fairy / grammar.peg
Last active December 31, 2015 02:49
Pinkie grammar
# Grammar for the algorithmic language Pinkie
block = (stmt (nl stmt)*)?
stmt
= name space "=" space expr
/ expr
expr = atom (space atom)*
@lambda-fairy
lambda-fairy / Stuff.agda
Created December 5, 2013 23:52
Random proofs
module Stuff where
-- False is defined as a type with no values.
data ⊥ : Set where -- empty
-- Not-A is defined as A implying false.
¬ : Set → Set
¬ A = A → ⊥
-- Double negation. Some theorems in classical logic are not provable in
@lambda-fairy
lambda-fairy / pinkie.markdown
Last active December 28, 2015 06:29
Pinkie bikeshedding

Pinkie bikeshedding

Property syntax

Lookup

obj.prop
@lambda-fairy
lambda-fairy / main.c
Last active December 27, 2015 19:49
Test C program
/* This program is not valid C. */
#include <stdio.h>
int main() {
puts("Hello, world!");
return 0;
}
@lambda-fairy
lambda-fairy / isms.markdown
Last active December 26, 2015 09:39
Epic one-liners

That's hotter than an iron refinery.

Your reasoning is tighter than a whore on her first night.

Sexy, sexy non sequitur.

If a crystal grows to exactly 1609.344 meters in length... is it a milestone?

You shoot yourself in the foot, but the compiler notices you're already dead inside and optimizes it away.

@lambda-fairy
lambda-fairy / Sleepsort.hs
Created October 23, 2013 03:20
Sleep sort, in Haskell
module Sleepsort (sleepsort) where
import Control.Applicative
import Control.Concurrent
import Control.Monad
import System.IO.Unsafe (unsafeInterleaveIO)
sleepsort :: [Int] -> IO [Int]
sleepsort xs = do
ronald <- newChan
@lambda-fairy
lambda-fairy / fuzzy-checkboxes.js
Created September 24, 2013 07:30
Fuzzy checkboxes
jQuery.fn.extend({
fuzzyCheckboxes: function (selector) {
this.on('click', selector, function () {
$(this).find(':checkbox').click()
})
this.on('click', selector + ' :checkbox', function (e) {
e.stopPropagation()
})
}
})
@lambda-fairy
lambda-fairy / fix.py
Created September 21, 2013 05:54
Fun with fix-point combinators
#!/usr/bin/env python3
from functools import wraps
def fix(f):
@wraps(f)
def inner(*args, **kwds):
return f(fix(f), *args, **kwds)
return inner