Skip to content

Instantly share code, notes, and snippets.

View tavisrudd's full-sized avatar

Tavis Rudd tavisrudd

View GitHub Profile
@tavisrudd
tavisrudd / clojure-ignore-form.el
Created January 27, 2012 19:31
A handy elisp function for inserting, toggling or moving Clojure's #_ reader macro.
(defun dss/clojure-ignore-form ()
"Inserts, toggles, or moves Clojure's #_ ignore-next-form reader macro."
(interactive)
(flet ((in-string-p () (eq 'string (syntax-ppss-context (syntax-ppss))))
(in-comment-p () (eq 'comment (syntax-ppss-context (syntax-ppss)))))
(skip-chars-forward " ")
(while (in-string-p)
(backward-char))
(cond
;; switch from a comment to an ignore form, if paredit is enabled
@tavisrudd
tavisrudd / dss-buffer-and-window-handling.el
Created March 8, 2012 07:22
a collection of handy emacs window management functions and a few for buffers
(require 'ibuffer)
(defalias 'list-buffers 'ibuffer)
(require 'ibuffer-vc)
(setq ibuffer-formats
'(
(mark dss-modified vc-status-mini " "
(name 35 35 :left :elide)
;; " " (mode 10 10 :left :elide)
" " filename-and-process)
@tavisrudd
tavisrudd / cocoa_keypress_monitor.py
Created July 6, 2012 22:45 — forked from ljos/cocoa_keypress_monitor.py
Showing how to listen to all keypresses in OS X through the Cocoa API using Python and PyObjC
# cocoa_keypress_monitor.py by Bjarte Johansen is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
from AppKit import NSApplication, NSApp
from Foundation import NSObject, NSLog
from Cocoa import NSEvent, NSKeyDownMask
from PyObjCTools import AppHelper
class AppDelegate(NSObject):
def applicationDidFinishLaunching_(self, notification):
mask = NSKeyDownMask
@tavisrudd
tavisrudd / generative.clj
Created July 20, 2012 18:25 — forked from cemerick/generative.clj
"Integrating" clojure.test and test.generative
;; My good-enough glomming together of clojure.test and test.generative
(ns cemerick.generative
(:require [clojure.test.generative.generators :as gens]
[clojure.test.generative :as gen])
(:use clojure.test))
;; Too bad last-report isn't sent an action upon success as well.
;; Perhaps this should just be replaced with a try/catch/rethrow
;; around the body in defspectest
@tavisrudd
tavisrudd / lxc-ubuntu.sh
Created July 22, 2012 07:17 — forked from michaelcontento/lxc-ubuntu.sh
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 <daniil@kulchenko.com>)
# wich itself is based on lxc-debian (Daniel Lezcano <daniel.lezcano@free.fr>)
#
@tavisrudd
tavisrudd / phantom_buster.js
Created November 5, 2012 18:24
phantom.js buster test runner capture script with retry logic
var system = require('system'),
captureUrl = 'http://localhost:1111/capture';
if (system.args.length==2) {
captureUrl = system.args[1];
}
var captured = false;
var locked = false;
var captureAttempts = 0;
var page = new WebPage();
@tavisrudd
tavisrudd / Witness.hs
Last active October 12, 2015 18:11
Messing around with type elaboration from ADT -> GADT
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ExistentialQuantification #-}
;; ## Changes from cljs.repl.browser
;;
;; * Multiple concurrent browser-REPLs can be safely used
;; * The browser-REPL's HTTP server is now always-on
;; * Each browser-REPL session supports a new top-level "entry" URL that
;; can be used to easily start the REPL in a browser or other JS runtime
;; (i.e. you don't need to have a separate webapp running to initiate the
;; browser-REPL connection)
;; * The entry (and REPL) URLs are available in slots on the browser-REPL's
;; environment, making it trivial to automate browser-REPL sessions
@tavisrudd
tavisrudd / Cheetah_CHANGELOG
Last active January 20, 2016 04:22
The old CHANGES file from the Cheetah project.
2.0 (Oct 12, 2007)
!!!THIS RELEASE REQUIRES RECOMPILATION OF ALL COMPILED CHEETAH TEMPLATES!!!
- fixed exception handling issue in the C implemenation of NameMapper
[patch from Eric Huss]
- fixed filtering of #included subtemplates
[patch from Brian Bird]
See the release notes from 2.0b1-5 and 2.0rc1-8 for other changes since
@tavisrudd
tavisrudd / Lazy infinite streams in Bash
Last active May 23, 2017 14:30
Lazy, infinite recursive sequences in Bash (like in Haskell, if you squint). The result is ugly but interesting.
Lazy, infinite recursive sequences in Bash (like in Haskell, if you squint).
I was inspired by the beautiful Haskell zipWith implementation of the Fibonacci sequence `fibs = 0 : 1 : zipWith (+) fibs (tail fibs)`
to find an equivalent in bash using 'coroutines' and recursive pipes.
My original experiments were https://twitter.com/tavisrudd/status/367164339716751360
"fun w/ recursive pipes: e=echo;mkfifo fib;{ $e 0 1 1 >fib &};{ while read i j k; do $e $i >&2; $e $j $k $(($j+$k));sleep .4; done;}<fib>fib"
and https://twitter.com/tavisrudd/status/367142071489937408
"o=ouro;b=boros;mkfifo $o$b;e=echo; { $e $o > $o$b & }; { while read s;do $e $s>&2;case $s in $o)$e $b;;*)$e $o; esac; done; }<$o$b >$o$b"