Skip to content

Instantly share code, notes, and snippets.

View tavisrudd's full-sized avatar

Tavis Rudd tavisrudd

View GitHub Profile
@roman
roman / Example.hs
Last active August 29, 2015 14:03
Example of an "Actor-Like" Reactive Extension management in Haskell
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Rx.Actor
( GenericEvent, EventBus
, ActorBuilder, ActorM, ActorDef, Actor, RestartDirective(..), InitResult(..)
, SupervisorBuilder, SupervisorStrategy, SupervisorDef, Supervisor
-- ^ * Actor Builder API
, defActor, actorKey, preStart, postStop, preRestart, postRestart
, onError, desc, receive
@roman
roman / CircuitBreaker.hs
Last active August 29, 2015 14:23
Prototype of CircuitBreaker interface using Type Families to compile valid transations of a CircuitBreaker state
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
module Main where
import Data.Time (UTCTime, getCurrentTime)
data CircuitData = CircuitData {}
@tbielawa
tbielawa / do_tags
Created March 1, 2011 01:20
a way to generate etags of all installed python libraries!!!
#!/bin/bash
# Originally written at: http://code.google.com/p/python-etags/
# You may need to augment your PYTHONPATH before this works.
#
# For example, for my locally checked out libraries:
# $ PYTHONPATH=/home/tbielawa/rhat/nushus/src/nushus_client
# $ PYTHONPATH=$PYTHONPATH:/home/tbielawa/rhat/nushus/src/nushus
# $ export PYTHONPATH
# $ do_tags
#
@hugoduncan
hugoduncan / gist:1103191
Created July 24, 2011 22:30
clojurescript minor mode
;;; clojurescript-mode.el --- Minor mode for clojurescript code
;; Copyright (C) 2011 Hugo Duncan
;;
;; Authors: Hugo Duncan
;; Version: 0.1.0
;; Keywords: languages, lisp, javascript
;; To run the compiler every time a cljs file is saved:
(defn my-last [xs]
(cond
(empty? (rest xs)) (first xs)
:otherwise (recur (rest xs))))
(println
(my-last '(a b c d)))
(defn my-but-last [xs]
(cond
(empty? (rest (rest xs))) xs
@atiw003
atiw003 / crunchbase-api-v1.md
Created September 21, 2011 07:10 — forked from dominicsayers/crunchbase-api-v1.md
CrunchBase API v1

CrunchBase API v1 Documentation

Overview

The CrunchBase API provides JSON representations of the data found on CrunchBase. The API currently supports three actions: "show", "search", and "list", which are each described below.

The v/1/ components of the URLs below refer to the current version of the API, which is 1.

@roman
roman / iteratee.clj
Created October 22, 2011 02:18
Haskell Iteratees in clojure (naive impl)
(ns iteratee
(:require [clojure.contrib.types :as adt]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(adt/defadt ::stream
eof
(chunks xs))
(adt/defadt ::iteratee
@dcousineau
dcousineau / raphael.centroid.js
Created November 15, 2011 17:16
RaphaëlJs approximate centroid extension, should work with arbitrary paths.
Raphael.el.getCentroid = function() {
var centroid = { x: 0, y: 0 }
, area = 0
, length = this.getTotalLength()
, lengthSegment = length / 100.00;
for (var i = 0; i < length; i += lengthSegment) {
var curr = this.getPointAtLength(i)
, next = this.getPointAtLength(i + lengthSegment);
@wolever
wolever / parameterized.py
Created January 27, 2012 21:49
Decorator implementing parameterized tests with nose
import re
import new
import inspect
from functools import wraps
from nose.tools import nottest
from unittest import TestCase
def _terrible_magic_get_defining_classes():
@alandipert
alandipert / flp.clj
Created March 20, 2012 04:18
Function-level programming a la Backus
(ns flp
"Function-level programming a la Backus; see
http://www.stanford.edu/class/cs242/readings/backus.pdf"
(:refer-clojure :exclude [/]))
;;; Functional Forms - combine existing functions to form new ones.
(def ^{:doc "Composition"} ° comp)
(defn / [f]