Skip to content

Instantly share code, notes, and snippets.

function! RunTests(filename)
" Write the file and run tests for the given filename
:w
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
else
empty-datomic-mem-db-setup
==============================
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
(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->>
def woopfordocstrings():
'''this is a docstring'''
print "sausages"
; Answers http://www.rubyquiz.com/quiz76.html
(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)))
(defun my-run-tests ()
(interactive)
(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))))))
(save-buffer)
(with-current-buffer test-buffer
(clojure-test-run-tests))
(sit 1)
(if
(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))
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
(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)
<xml>
<defun name="qsort">
<args>
<required-arg name="lis" />
<optional-args>
<optional-arg name="less" default="nil"/>
<optional-arg name="greater" default="nil"/>
</optional-args>
</args>
<cond>