Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am trevorc on github.
  • I am toc (https://keybase.io/toc) on keybase.
  • I have a public key ASBMnVMcKtYb0Z1Q7WqbxqLRANTY5lPzmZqDjiCZiE1y8Ao

To claim this, I am signing this object:

View ping_server.sh
#!/bin/sh
set -eu
count=$1
server=$2
latency=$(ping -nqc${count} ${server} |
sed -nE 's,^round[^=]*=[^/]*/([[:digit:]]+\.[[:digit:]]+).*,\1,p')
echo "${latency} ${server}"
View Watcher.java
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.WatchEvent;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Stream;
View rpn.hs
{-# LANGUAGE TupleSections #-}
module RPN (main) where
import Control.Applicative ((<$>))
import Control.Monad (forM_, unless)
import Control.Monad.Instances ()
import Data.List (find, intercalate)
import Data.Maybe (listToMaybe)
import System.IO (stdout, hFlush)
View init.el
;;;;;;;;;;;;;;;;;;;;
;; Initialization ;;
;;;;;;;;;;;;;;;;;;;;
(require 'cl)
(defmacro* dolist* ((iterator list &optional return-value) &rest body)
"Like `dolist' but `destructuring-bind's the elements of LIST.
If ITERATOR is a symbol then dolist* is just like `dolist' except
View .vimrc
set autowriteall
set backspace=indent,eol,start
set cinoptions=Ws,(0,t0
set directory=~/.config/vim/swap,/tmp
set encoding=utf-8
set expandtab
set formatoptions=q
set hidden
set hlsearch
set incsearch
View gist:2341940
#!/bin/sh
app=/Applications/Emacs.app/Contents/MacOS/Emacs
for arg; do
case $arg in
-version|--version|-f|-l|-eval|-batch|-nw) exec $app "$@"
esac
done
View htpinstaller.sh
#!/bin/sh
set -eu
DISTRIBUTE_SETUP=https://raw.github.com/gist/2308340/d2c2899afa9894be579f48a7a6d4193e84a55b6b/distribute_setup.py
sudo -k
which easy_install &> /dev/null || wget -qO- $DISTRIBUTE_SETUP | sudo python
sudo easy_install django
sudo easy_install dotcloud
View distribute_setup.py
#!python
"""Bootstrap distribute installation
If you want to use setuptools in your package's setup.py, just include this
file in the same directory with it, and add this to the top of your setup.py::
from distribute_setup import use_setuptools
use_setuptools()
If you want to require a specific version of setuptools, set a download
View defwith.clj
(defmacro defwith [name finalizer]
(let [bindings-sym (gensym "bindings")
body-sym (gensym "body")]
`(defmacro ~name [~bindings-sym & ~body-sym]
(cond
(empty? ~bindings-sym) `(do ~@~body-sym)
(symbol? (~bindings-sym 0))
`(let ~(subvec ~bindings-sym 0 2)
(try
(~'~name ~(subvec ~bindings-sym 2) ~@~body-sym)