This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I use this on Linux: | |
#!/bin/bash | |
# e - launch emacsclient or server. | |
ps ax | grep "emacs --daemon" | grep -v "grep" | |
if [ "$?" -eq "1" ] | |
then | |
/usr/bin/emacs --daemon | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* guessit | |
* Itty-bitty mastermind type game. | |
* | |
* OBJECT: | |
* | |
* The object of the game is to guess what the computer has choosen. | |
* | |
* The computer starts out by randomly selecting a number of symbols. Your job | |
* is to figure out what the symbols are. You have a limited number of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# passadd | |
if [ -z "$PASSFILE" ] | |
then | |
echo "PASSFILE doesn't exist" | |
exit 1 | |
fi | |
if [ $# -ne 1 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn qsort | |
[[x & r]] | |
(let [xs #(for [y r :when (% y x)] y)] | |
(when x | |
(concat (qsort (xs <=)) [x] (qsort (xs >)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Deriving something like generators, but I didn't really feel like doing that exactly. | |
;; This applys a function across a range from 0 to x. | |
(define (apply-to-range f x) | |
(let loop ((i 0)) | |
(if (< i x) | |
(begin | |
(f i) | |
(loop (+ 1 i)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Deriving something like generators, but I didn't really feel like | |
;; doing exactly that. | |
;; It doesn't, for instance, support sending back into the generator | |
;; This applys a function across a range from 0 to x. | |
(define (apply-to-range f i x) | |
(when (< i x) | |
(f i) | |
(apply-to-range f (+ 1 i) x))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
from com.google.common.base import Function | |
except ImportError: | |
Function = None | |
class _FunctionTemplate(object): | |
def __init__(self, f): | |
self._func = f | |
def apply(self, *args): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro match | |
"shitty pattern matching macro | |
Example: | |
(def eval [exp] | |
(match exp | |
(:var v) v | |
(:abstraction arg body) (create-procedure arg body) | |
(:application operator operand) (operator operand))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
def jsonp(view_func): | |
"""Wrap a json response in a callback, and set the mimetype (Content-Type) header accordingly | |
(will wrap in text/javascript if there is a callback). If the "callback" or "jsonp" paramters | |
are provided, will wrap the json output in callback({thejson}) | |
Usage: | |
@jsonp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for n in `curl http://www.classes.cs.uchicago.edu/current/22610-1/docs/ | awk '{FS="\">"} {print $3}' | awk '{FS="\""} {print $2}' | egrep "^[a-zA-Z]"`; do wget http://www.classes.cs.uchicago.edu/current/22610-1/docs/$n; done |