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
(ns com.draines.test) | |
(defmacro casen [n switch] | |
(let [f (fn [m] | |
(let [s (format "x-%d" m) | |
k (keyword s)] | |
[k s])) | |
disps (map f (range 1 (inc n)))] | |
`(case ~switch | |
~@(apply concat disps)))) |
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
(defprotocol Foo | |
(baz [a])) | |
(defprotocol Bar | |
(baz [a])) | |
(extend String | |
Foo {:baz (fn [a] (.toUpperCase a))} | |
Bar {:baz (fn [a] (.toLowerCase a))}) |
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
2009/11/20 drewr becomes a father! | |
AssetAndLiability:Progeny:Son 2 Child | |
GodOnlyKnowsWhereSoulsComeFrom |
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
(ns user) | |
;; loosely inspired by http://book.realworldhaskell.org/read/defining-types-streamlining-functions.html | |
(defprotocol Cons | |
(car [x]) | |
(cdr [x])) | |
(defprotocol List | |
(head [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
(defn make-task [job id] | |
(let [f (fn [context] | |
(try | |
((job :task) job) | |
(catch Exception e | |
(log/error (format "%s %s" (job :name) e)) | |
(mail-error job e))))] | |
(proxy [Task] [] | |
(execute [context] (f context))))) |
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
Delivered-To: [email protected] | |
Received: by 10.151.110.17 with SMTP id n17cs138969ybm; | |
Tue, 15 Dec 2009 10:12:12 -0800 (PST) | |
Received: by 10.101.33.1 with SMTP id l1mr10067540anj.124.1260900732042; | |
Tue, 15 Dec 2009 10:12:12 -0800 (PST) | |
Return-Path: <[email protected]> | |
Received: from smtp1.rs.github.com ([207.97.227.250]) | |
by mx.google.com with ESMTP id 40si147503yxe.130.2009.12.15.10.12.11; | |
Tue, 15 Dec 2009 10:12:12 -0800 (PST) |
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
(ns foo.bar | |
(:use [clojure.core :exclude [bytes]])) | |
(type bytes) ; => clojure.core$bytes__4778 | |
;; why no resolution error? | |
;; oh, the correct way: | |
(ns foo.bar |
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
;; Generate flickr/facebook-style secrets | |
(ns com.draines.genpass) | |
(def MIN 4) | |
(def MAX 4) | |
(defn limit-length [word a b] | |
(if (<= a b) | |
(let [l (count word)] |
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
versionize() { | |
local file=$1 | |
local ver=$(git log --pretty=format:"%ai %h" -1 | perl -p -e 's,(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d) [^ ]+ ([a-z0-9]+),\1\2\3\4\5\6+\7,') | |
local versionedfile=$(echo $file | perl -pe "s,(.*)\.([^.]+)\$,\$1-${ver}.\$2,") | |
cp $file $versionedfile | |
} |
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/sh | |
died=`sh die.sh` | |
case $? in | |
0) echo success;; | |
1) echo warn;; | |
*) echo fail;; | |
esac |