Skip to content

Instantly share code, notes, and snippets.

View tavisrudd's full-sized avatar

Tavis Rudd tavisrudd

View GitHub Profile
@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);
@n1k0
n1k0 / gist:1501173
Created December 20, 2011 10:44 — forked from fbuchinger/gist:1501115
PhantomJS: Capturing single dom elements as png files
var page = new WebPage(),
address, output, size;
//capture and captureSelector functions adapted from CasperJS - https://github.com/n1k0/casperjs
capture = function(targetFile, clipRect) {
var previousClipRect;
var clipRect = {top: 0, left:0, width: 40, height: 40};
if (clipRect) {
if (!isType(clipRect, "object")) {
throw new Error("clipRect must be an Object instance.");
@michaelcontento
michaelcontento / lxc-ubuntu.sh
Created January 3, 2012 20:45 — forked from dkulchenko/lxc-ubuntu
Script to generate LXC containers for EC2
#!/bin/bash
#
# Template script for generating ubuntu container for LXC with the same
# ubuntu relase as the host
#
# This script is based on lxc-debian for EC2 (Daniil Kulchenko <[email protected]>)
# wich itself is based on lxc-debian (Daniel Lezcano <[email protected]>)
#
@forsakendaemon
forsakendaemon / gist.clj
Created January 20, 2012 09:00
A Clojure Gist that allows you to load a Gist by id.
;requires clj-http (https://github.com/dakrone/clj-http) and clojure.data.json (https://github.com/clojure/data.json) to be available
(require '[clj-http.client :as client] '[clojure.data.json :only (read-json) :as json])
(defn getfiles [id] (get (json/read-json (get (client/get (str "https://api.github.com/gists/" id)) :body)) :files))
(defn getcontent [files] (get (get files (first (keys files))) :content))
(defn loadgist [id] (load-string (getcontent (getfiles id))))
@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():