Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Downey hiredman

View GitHub Profile
View gist:9943493
∵ turjan ~/src/clojure ∴ rlwrap java -server -Xmx1G -Xms1G -jar /Users/hiredman/src/clojure/target/clojure-1.6.0-master-SNAPSHOT.jar
Clojure 1.6.0-master-SNAPSHOT
user=> (deftype Foo [hello-world])
user.Foo
user=> (alter-var-root #'default-data-readers assoc 'foo (fn [x] (Foo. x)))
{foo #<user$eval6$fn__7 user$eval6$fn__7@2f953efd>, inst #'clojure.instant/read-instant-date, uuid #'clojure.uuid/default-uuid-reader}
user=> #foo "1"
CompilerException java.lang.IllegalArgumentException: No matching field found: hello-world for class user.Foo, compiling:(NO_SOURCE_PATH:0:0)
user=>
View gist:10489794
(ns com.thelastcitadel.pipeline
(:require [clojure.core.async :refer
[chan >!! <!! <! close! go thread go-loop]]))
(defn pipeline [things]
{:pre [(or (even? (count things))
(every? #(and (vector? %)
(= 2 (count %))) things))]}
(let [x (->> (if (vector? (first things))
things
View gist:11194485
(ns com.thelastcitadel.pipeline
(:require [clojure.core.async :refer
[chan >!! <!! <! close! go thread go-loop]]))
(defn pipeline [things]
{:pre [(or (even? (count things))
(every? #(and (vector? %)
(= 2 (count %))) things))]}
(let [x (->> (if (vector? (first things))
things
View gist:406e39a200223aa4a77e
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View gist:16bfaa4e41177bd76bd0
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View gist:f178a690718bde773ba0
user=> (println (no.disassemble/disassemble (fn [] (loop [b 0] (recur (loop [a 1] a))))))
// Compiled from form-init3799259731606797504.clj (version 1.5 : 49.0, super bit)
public final class user$eval1692$fn__1693 extends clojure.lang.AFunction {
// Field descriptor #7 Ljava/lang/Object;
public static final java.lang.Object const__0;
// Method descriptor #9 ()V
// Stack: 2, Locals: 0
public static {};
View gist:aeb55c7b54c4a6b48ca1
(defn ^URL resources
([n] (resource n (.getContextClassLoader (Thread/currentThread))))
([n ^ClassLoader loader] (.getResources loader n)))
View join.clj
;; 18. All warfare is based on deception.
(ns pullrequest.join
(:require [clojure.core.reducers :as r]
[clojure.core.protocols :as p])
(:import (java.util.concurrent.atomic AtomicLong)))
(defn update-index [key-fn h i]
(update-in h [(key-fn i)] (fnil conj #{}) [0 i]))
(defn probe
View youtube-mpd.sh
#/bin/sh
if which jot; then
# osx, bsd
PORT=`jot -r 1 60000 65000`
else
# linux
PORT=`shuf -i 60000-65000 -n 1`
fi
View repl.clj
(ns com.manigfeald.sofp.repl
(:require [com.stuartsierra.component :as component]
[clojure.tools.logging :as log]
[clojure.tools.nrepl.server :refer [start-server stop-server]]))
(defrecord Repl [signals exec]
component/Lifecycle
(start [this]
(log/trace "starting repl")
(let [run? (atom true)