Skip to content

Instantly share code, notes, and snippets.

View timjb's full-sized avatar

Tim Baumann timjb

View GitHub Profile
anonymous
anonymous / BKTree.hs
Created March 7, 2010 19:25
module Data.BKTree (
BKTree,
MetricSpace(..),
empty,
null,
size,
singleton,
insert,
query,
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@igstan
igstan / state-monad.js
Created May 1, 2011 23:09
State Monad in JavaScript
var push = function (value) {
return function (stack) {
var newStack = [value].concat(stack);
return { value:undefined, stack:newStack };
};
};
var pop = function () {
return function (stack) {
var value = stack[0];
@inportb
inportb / operationengine.py
Created May 9, 2011 06:00
operational composition and transformation in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
## Copyright (C) 2011 by Jiang Yio <http://inportb.com/>
## The latest code is available at <https://gist.github.com/962122>
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@aristidb
aristidb / OpTransVec.agda
Created February 5, 2012 15:42
Simple Operational Transformation in Agda
module OpTransVec where
open import Data.Vec
open import Data.Nat
open import Data.Product
open import Relation.Binary.PropositionalEquality
open import Function using (_∘_)
data Op (A : Set) : ℕ → ℕ → Set where
ε : Op A 0 0
@copumpkin
copumpkin / Routing.agda
Last active October 2, 2015 07:38
Routing
module Routing where
open import Function hiding (type-signature)
open import Data.Bool hiding (_≟_)
open import Data.Maybe
open import Data.Char hiding (_≟_)
open import Data.String as String
open import Data.List as List hiding ([_])
open import Data.Product hiding (curry; uncurry)
@copumpkin
copumpkin / Nicomachus.agda
Last active August 6, 2024 08:32
Nicomachus's theorem
module Nicomachus where
open import Function
open import Relation.Binary.PropositionalEquality
import Relation.Binary.EqReasoning as EqReasoning
open import Data.Nat
open import Data.Nat.Properties
-- http://en.wikipedia.org/wiki/Nicomachus%27s_theorem
@fge
fge / gist:3231325
Created August 1, 2012 22:37
draftv4 candidate, unfit for release
Internet Engineering Task Force K. Zyp, Ed.
Internet-Draft SitePen (USA)
Intended status: Informational G. Court
Expires: February 3, 2013 August 2, 2012
A JSON Media Type for Describing the Structure and Meaning of JSON
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@billdozr
billdozr / distributed-ping.hs
Last active October 8, 2015 18:08
Distributed ping (with boilerplate code, i.e. without Template Haskell)
{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
import System.Environment (getArgs, getProgName)
import Control.Monad (forM_, replicateM_)
import Data.Binary (Binary, encode, decode)
import Data.Typeable (Typeable)
import Data.ByteString.Lazy (ByteString)
import Control.Concurrent (threadDelay)
import Data.Rank1Dynamic (toDynamic)
import Control.Distributed.Static
( Static