Skip to content

Instantly share code, notes, and snippets.

View vimrc
function! RunTests(filename)
" Write the file and run tests for the given filename
if match(a:filename, '\.feature$') != -1
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
exec ":!bundle exec cucumber " . a:filename
elseif match(a:filename, '\.coffee$') != -1
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
exec "!jasmine-headless-webkit " . a.filename
View datomic setup gist
WARNING: Final GC required 5.030329259746849 % of runtime
Evaluation count : 322200 in 60 samples of 5370 calls.
Execution time mean : 204.316059 µs
Execution time std-deviation : 23.252812 µs
Execution time lower quantile : 185.144721 µs ( 2.5%)
Execution time upper quantile : 267.418129 µs (97.5%)
Overhead used : 1.833968 ns
View err.clj
(deftype Failure [f])
(defn unwrap-fail [^Failure fail]
((.f fail)))
(defn fail? [potential-fail]
(isa? (class potential-fail) Failure))
;;TODO: extract into a new namespace, maybe an OS project?
(defmacro err->>
View gist:167461
def woopfordocstrings():
'''this is a docstring'''
print "sausages"
View Text-munger.clj
; Answers
(defn text-munger [string]
(for [word (re-split #"\s" string)]
(if (> (count word) 3)
(let [start (first word)
end (last word)]
(str start (reduce str (shuffle (drop 1 (take (- (count word) 1) word))))
end)) word)))
View clojure-mode-test-from-implimentation.el
(defun my-run-tests ()
(let ((test-buffer (find-buffer-visiting (format "%stest/%s-test.clj"
(locate-dominating-file buffer-file-name "src/")
(file-name-nondirectory (file-name-sans-extension buffer-file-name))))))
(with-current-buffer test-buffer
(sit 1)
View gist:276535
(defun flash-modeline (color)
(setq old-background-face (copy-face 'modeline 'old-background-face))
(setq old-buffer-id-face (copy-face 'modeline-buffer-id 'old-buffer-id-face))
(set-face-to-one-color 'modeline color)
(set-face-to-one-color 'modeline-buffer-id color)
(sit-for 1)
(set-face-background 'mode-line (face-background old-background-face))
(set-face-foreground 'mode-line (face-foreground old-background-face))
(set-face-background 'mode-line-buffer-id (face-background old-buffer-id-face))
(set-face-foreground 'mode-line-buffer-id (face-foreground old-buffer-id-face))
View gist:277709
a Java array
agt an agent
coll a collection
expr an expression
f a function
idx an index
r a ref
v a vector
val a value
pred a predicate
View string_calculator.clj
(ns string_calculator
(:use clojure.contrib.str-utils))
(defn add-numbers [s]
(reduce + (map #(check-num %)
(filter #(not= "" %) (re-split #"," s)))))
(defn check-num [i]
(let [intr (Integer. i)]
(if (> 0 intr)
View xml quicksort
<defun name="qsort">
<required-arg name="lis" />
<optional-arg name="less" default="nil"/>
<optional-arg name="greater" default="nil"/>