This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro r-> | |
[x & forms] | |
(loop [x x, forms forms] | |
(if forms | |
(let [form (first forms) | |
threaded (with-meta `(let [x# ~x] | |
(if (reduced? x#) | |
x# | |
(~(first form) x# ~@(next form)))) | |
(meta form))] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn set-debug | |
[target-var] | |
(let [metadata (meta target-var) | |
target (::original metadata @target-var) | |
debug-data (:debug-trace metadata (atom []))] | |
;; only one layer of debugging, if we were already debugging, | |
;; just replace the previous layer | |
(when-not (and (:debug-trace metadata) | |
(::original metadata)) | |
(alter-meta! target-var assoc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns noisesmith.chunker | |
(:require [clojure.core.async :refer [alts! <! >! timeout go-loop]])) | |
(defn launch-chunks | |
[chunk-size time-out rq-chan result-chan] | |
(go-loop | |
[acc []] | |
(let [[res c] (alts! [(timeout time-out) | |
rq-chan]) | |
fresh (= c rq-chan) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
justin@borbetomagus: /tmp/aot-test$ cat src/aot_test/core.clj | |
(ns aot-test.core | |
(:gen-class)) | |
(def loaded (java.util.Date.)) | |
(defn -main | |
"I don't do a whole lot ... yet." | |
[& args] | |
(println "loaded at" loaded)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kingfisher.core=> (require 'no.disassemble) | |
nil | |
kingfisher.core=> (no.disassemble/disassemble (fn [] (= 1 1))) | |
"// Compiled from form-init3743260354239398999.clj (version 1.5 : 49.0, super bit)\npublic final class kingfisher.core$eval42227$fn__42228 extends clojure.lang.AFunction {\n \n // Method descriptor #7 ()V\n // Stack: 1, Locals: 1\n public core$eval42227$fn__42228();\n 0 aload_0 [this]\n 1 invokespecial clojure.lang.AFunction() [9]\n 4 return\n Line numbers:\n [pc: 0, line: 1]\n \n // Method descriptor #11 ()Ljava/lang/Object;\n // Stack: 4, Locals: 1\n public java.lang.Object invoke();\n 0 lconst_1\n 1 lconst_1\n 2 invokestatic clojure.lang.Util.equiv(long, long) : boolean [17]\n 5 ifeq 14\n 8 getstatic java.lang.Boolean.TRUE : java.lang.Boolean [23]\n 11 goto 17\n 14 getstatic java.lang.Boolean.FALSE : java.lang.Boolean [26]\n 17 areturn\n Line numbers:\n [pc: 0, line: 1]\n [pc: 2, line: 1]\n Local variable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
phoenix.core=> (user/with-use user (+ 1 1)) | |
2 | |
phoenix.core=> (macroexpand-1 '(user/with-use user (+ 1 1))) | |
(clojure.core/let [help user/help find-name user/find-name non-macros user/non-macros src-dir user/src-dir exercise-coverage user/exercise-coverage apropos-better user/apropos-better] (+ 1 1)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ins)user=> ({1 2 3} 3) | |
RuntimeException Map literal must contain an even number of forms clojure.lang.Util.runtimeException (Util.java:221) | |
3 | |
RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException (Util.java:221) | |
(ins)user=> 2 | |
2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns condor.future-timeout | |
(:require [clojure.core.async :as >]) | |
(:import (java.util Date) | |
(java.util.concurrent CancellationException))) | |
(defn timestamp | |
[] | |
(.getTime (Date.))) | |
(defn timed-future-call |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns foo.bar.async-transducing | |
(:require [clojure.core.async :as >])) | |
(defn run-it | |
[] | |
(let [c (>/chan 20 (partition-all 10))] | |
(>/go-loop [] | |
(when-let [things (>/<! c)] | |
(println "things:" (pr-str things)) | |
(recur))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import (java.net URL)) | |
(defn skipped-url | |
[url byte-skip byte-end] | |
(let [http-connection (.openConnection url)] | |
(.setRequestProperty http-connection | |
"Range" (str "bytes=" byte-skip "-" byte-end)) | |
(.getInputStream http-connection))) |