Skip to content

Instantly share code, notes, and snippets.

(setq c-default-style "gnu")
(defun my-indent-setup ()
(c-set-offset 'arglist-intro '+))
(add-hook 'java-mode-hook 'my-indent-setup)
(ns leiningen.hooks.expand-resource-paths
(:use [clojure.java.io :only [as-file]])
(:import [java.io File])
(:require [robert.hooke]
[leiningen.javac]
[org.satta.glob :as glob]))
(defmulti nan->keyword class :default :default)
(defmethod nan->keyword java.util.Map [m]
(if (instance? clojure.lang.IRecord m)
(nan->keyword (into {} (seq m)))
(let [f (fn [[k v]] [k (if (and (number? v) (Double/isNaN v)) :DoubleNaN v)])]
(expectations.clojure.walk/postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m))))
(defmethod nan->keyword java.util.List [m]
(map #(if (and (number? %) (Double/isNaN %)) :DoubleNaN %) m))
@jaycfields
jaycfields / some.clj
Created December 23, 2013 19:54
let can be the first binding to doseq, and it will be executed exactly 1 time.
(doseq [:let [a (do (println 1) 99)]
x [11 12]]
(println x a))
;; output:
;; 1
;; 11 99
;; 12 99
(expect (interaction (one "hello" {:a :b :c {:dd :ee :ff :gg}}))
(do
(one "hello")
(one "hello" "world" "here")
(one "hello" {:a 1 2 3})))
(given [the-answer]
(expect (= 42 the-answer))
42)
;;; or, if you want to define more context
(given [x y]
(expect x (* 2 y))
42 84
20 (inc (dec 10)))
(given [the-answer]
(expect (= 42 the-answer))
42)
(declare *the-answer*) ; outside of a describe
(around [it]
(binding [*the-answer* 42]
(it)))
(it "knows the answer"
(should= 42 *the-answer*))
(define-clojure-indent
(expect 'defun)
(expect-let 'defun)
(given 'defun)
(context 1)
(freeze-time 1)
(redef-state 1)
(from-each 1))
@jaycfields
jaycfields / e.el
Last active December 18, 2015 00:59
;; clojure.core
;; 141 false greek: ⊥ - http://en.wikipedia.org/wiki/Tautology_(logic)
;; 163 -> key-chord: kl
;; 217 true greek: ⊤ - http://en.wikipedia.org/wiki/Tautology_(logic)
;; 255 nil greek: ∅ - http://en.wikipedia.org/wiki/Null_(mathematics)
;; 316 :keys key-chord: kk, greek: ӄ
;; testing
;; 224 interaction greek: ι
;; 265 no-op greek: ⒩