Skip to content

Instantly share code, notes, and snippets.

View hiredman's full-sized avatar

Kevin Downey hiredman

View GitHub Profile
∵ 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=>
(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
(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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 {};
(defn ^URL resources
([n] (resource n (.getContextClassLoader (Thread/currentThread))))
([n ^ClassLoader loader] (.getResources loader n)))
@hiredman
hiredman / join.clj
Created August 22, 2014 01:12
clojure join
;; 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
#/bin/sh
if which jot; then
# osx, bsd
PORT=`jot -r 1 60000 65000`
else
# linux
PORT=`shuf -i 60000-65000 -n 1`
fi
(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)