Skip to content

Instantly share code, notes, and snippets.

@fitzgen
fitzgen / go.js
Created August 30, 2013 20:07
http://swannodette.github.io/2013/08/24/es6-generators-and-csp/ ported to SpiderMonkey (at least until ES6 generators are fully supported, which should be within the next month or so)
function go_(machine, step) {
while(!step.done) {
try {
var arr = step(),
state = arr[0],
value = arr[1];
switch (state) {
case "park":
setImmediate(function() { go_(machine, step); });
{-# Language GADTs #-}
module Homomorphisms where
import Control.Monad
import Control.Applicative
import Data.Monoid hiding (Endo)
import qualified Control.Category as C
@timjb
timjb / AboutMe.mustache
Created December 1, 2013 15:27
Mustache templating in Idris
Hello, my name ist {{name}} and I am {{age}} years old.
@NicolasT
NicolasT / Connection.hs
Last active December 30, 2015 09:09
Compile-time enforced resource exhaustion in OCaml using an indexed state monad.
{-# LANGUAGE RebindableSyntax,
KindSignatures,
DataKinds,
GADTs,
GeneralizedNewtypeDeriving,
StandaloneDeriving,
FlexibleInstances,
Rank2Types #-}
module Connection (
@klutzy
klutzy / hello.rs
Last active April 26, 2016 19:15
Rust with Emscripten
// emscripten uses le32-unknown-nacl triple but rustc doesn't know it now.
// So just use similar target instead.
// `rustc hello.rs --target=i686-unknown-linux --emit-llvm -S --cfg libc`
// `emcc hello.ll -o hello.js`
// no `extern mod`.
#[no_std];
#[feature(macro_rules)];
use core::container::Container;
@jvns
jvns / linkers_101.md
Last active November 18, 2018 14:38
How to understand what's in a binary, with code!

Step 0: A program, and prerequisites

We're going to be dealing with a "Hello, world!" program. Just one. There's going to be a bunch of fruit for discussion here. I'm going to be assuming you're on Linux, because we're gonna be talking about ELF and Macs use Mach-O and I don't know anything about Mach-O.

#include <stdio.h>

char *penguin = "Penguin";
char array[5] = {'a', 'b', 'c', 'd', 'e'};
@jlongster
jlongster / gruntfile.js
Created December 19, 2013 20:38
gruntfile
var fs = require('fs');
var path = require('path');
var sweet = require('sweet.js');
module.exports = function(grunt) {
grunt.initConfig({
sweetjs: {
options: {
modules: ['es6-macros'],
sourceMap: true,
@bobatkey
bobatkey / gadts.sml
Created January 5, 2014 18:34
Encoding of GADTs in SML/NJ
(* This is a demonstration of the use of the SML module system to
encode (Generalized Algebraic Datatypes) GADTs via Church
encodings. The basic idea is to use the Church encoding of GADTs in
System Fomega and translate the System Fomega type into the module
system. As I demonstrate below, this allows things like the
singleton type of booleans, and the equality type, to be
represented.
This was inspired by Jon Sterling's blog post about encoding proofs
in the SML module system:
@yomimono
yomimono / ec2-ebs-ami.sh
Last active June 21, 2016 12:21
Automate creation of an EC2-ready Mirage unikernel.
#!/bin/bash
#set -e
#set -x
fail() {
echo $1
[ -e ${EBS_DEVICE} ] && [ "$VOLUME_ID" != "" ] && [ $REGION != "" ] && {
ec2-detach-volume --region $REGION $VOLUME_ID
ec2-delete-volume --region $REGION $VOLUME_ID
@lmarburger
lmarburger / expr.idr
Last active August 29, 2015 14:02
Extending Idris tutorial 4.4.1 to include a Let operation
data Expr = Var String
| Val Int
| Add Expr Expr
| Let (List (String, Int)) Expr
data Eval : Type -> Type where
MkEval : (List (String, Int) -> Maybe a) -> Eval a
fetch : String -> Eval Int
fetch x = MkEval (\e => fetchVal e) where