Skip to content

Instantly share code, notes, and snippets.

View Null.java
public class Null {
public static void main(String args[]) {
new String((String)null);
}
}
@shepmaster
shepmaster / gist:9137965
Created February 21, 2014 16:47
record calling its own protocol functions
View gist:9137965
(defprotocol Foo
(alpha [this a])
(beta [this a]))
(defrecord Bar []
Foo
(alpha [_ a]
(inc a))
(beta [this a]
(inc (alpha this a))))
View lazy_reemvoweler.clj
(ns reemvoweler.sync)
(defn build-sentence [orig-tree tree words chars consonants vowels]
(lazy-seq
(if tree
(concat
(if-let [[c & consonants] (seq consonants)]
(build-sentence orig-tree (get tree c) words (conj chars c) consonants vowels))
(if-let [[v & vowels] (seq vowels)]
(build-sentence orig-tree (get tree v) words (conj chars v) consonants vowels))
@shepmaster
shepmaster / gist:10877484
Created April 16, 2014 13:43
Allow dabbrev to use symbols for non-symbols and vice-versa
View gist:10877484
(defun dabbrev-allow-symbols ()
(setq-local dabbrev-abbrev-skip-leading-regexp ":"))
(add-hook 'ruby-mode-hook 'dabbrev-allow-symbols)
(add-hook 'clojure-mode-hook 'dabbrev-allow-symbols)
@shepmaster
shepmaster / gist:69b0333fc9c1927c7b34
Created April 30, 2014 17:54
Abridged output of `docker history`
View gist:69b0333fc9c1927c7b34
CREATED BY SIZE
/bin/sh -c chown -R bree /srv/www 204.1 MB
/bin/sh -c #(nop) ADD dir:1ba5e606b64673a429a6e41f22dd80c96f6b9fafb5e9988d813202ac9fd17ef0 in /srv/www 204.1 MB
/bin/sh -c sudo -u bree bundle install --deployment --without development test doc 203.2 MB
View gist:17fbd13920b1698e53ab
CREATED BY SIZE
/bin/sh -c #(nop) VOLUME /srv/www/public 0 B
/bin/sh -c #(nop) EXPOSE map[3000/tcp:{}] 0 B
/bin/sh -c #(nop) VOLUME /srv/www/log 0 B
/bin/sh -c #(nop) CMD [rails server] 0 B
/bin/sh -c #(nop) ENTRYPOINT [bundle exec] 0 B
/bin/sh -c bundle exec rake bower:install['--quiet --config.interactive=false'] assets:precompile 4.984 MB
/bin/sh -c #(nop) USER bree
View gist:c7f1912da24fba07e088
$(this).each -> that.load that._.defaults options, into: $(this)
@shepmaster
shepmaster / code.clj
Created May 4, 2014 14:39
Picking between Cows and Pigs
View code.clj
(ns typed.core
(:require [clojure.core.typed :as t :refer [ann ann-form def-alias declare-names]]))
(def-alias Cow '{:type ':cow})
(def-alias Pig '{:type ':pig})
(def-alias Animal (U Cow Pig))
(t/ann in-the-barn '[Animal Animal *])
(def in-the-barn [{:type :cow} {:type :pig}])
@shepmaster
shepmaster / orig.clj
Created May 4, 2014 14:46
last and non-empty
View orig.clj
Type Error (NO_SOURCE_FILE:18:1) Type mismatch:
Expected: (U Long Integer BigInteger BigInt Byte Short (Value :empty))
Actual: (U Long Integer BigInteger BigInt Byte Short (Value :empty) nil)
in: (if (seq c) (last c) :empty)
Type Error (NO_SOURCE_FILE:18:1) Type mismatch:
Expected: (Fn [(t/Coll t/AnyInteger) -> (U t/AnyInteger (Value :empty))])
View demo.clj
(defmethod evaluate-one :assignment [system stmt]
(let [[_ name val] stmt
_ (assert val) ;; <--- Removing this removes the error
val (evaluate system val)]
(swap! (:variables system) var/add-binding name val)))