Skip to content

Instantly share code, notes, and snippets.

View hiredman's full-sized avatar

Kevin Downey hiredman

View GitHub Profile
(defn async-iteration [from-process
to-process
output-channel
& {:keys [values-selector some? init]
:or {values-selector vector
some? some?}}]
(async/go
(async/>! to-process init)
(loop [value (async/<! from-process)]
(if (some? value)
(defn topo [graph]
(when-not (empty? graph)
(lazy-seq
(let [n (first (for [[node s] graph
:when (not (seq s))]
node))]
(assert n "if this fails there is a cycle")
(cons n (topo (into {} (for [[node deps] graph
:when (not= n node)]
[node (disj deps n)]))))))))
@hiredman
hiredman / boot.cljs
Created March 15, 2013 04:43
clojurescript drag and drop
(defn handle-file-select [evt]
(.stopPropagation evt)
(.preventDefault evt)
(let [files (.-files (.-dataTransfer evt))]
(dotimes [i (.-length files)]
(let [rdr (js/FileReader.)
the-file (aget files i)]
(set! (.-onload rdr)
(fn [e]
(let [file-content (.-result (.-target e))
(ns com.manigfeald.yield
(:require [clojure.tools.analyzer :as an]
[clojure.tools.analyzer.ast :as ast]
[clojure.tools.analyzer.env :as env]
[clojure.tools.analyzer.jvm :as an-jvm]
[clojure.tools.analyzer.passes :refer [schedule]]
[clojure.tools.analyzer.passes.jvm.annotate-loops
:refer [annotate-loops]]
[clojure.tools.analyzer.passes.jvm.emit-form :as e]
[clojure.tools.analyzer.passes.jvm.warn-on-reflection
;; (load-file "/home/kevin/src/pi.clj")
(require '[clojure.pprint :as pp]
'[clojure.java.io :as io])
(def grammar
[[:program [:process 'eof?]]
[:process [:receive]]
[:process [:send]]
[:process [:par]]
(require '[clojure.set :as set])
(def info
[{:year 2017
:month 4
:data "x"}
{:year 2017
:month 4
:data "y"}
(defn send-repl [& [obj]]
(let [in-in (java.io.PipedInputStream.)
in-out (java.io.PipedOutputStream. in-in)
out-in (java.io.PipedInputStream.)
out-out (java.io.PipedOutputStream. out-in)
err-in (java.io.PipedInputStream.)
err-out (java.io.PipedOutputStream. err-in)]
(tap> {:repl/in (clojure.java.io/writer in-out)
:repl/out (clojure.java.io/reader out-in)
(defmacro letfn- [fn-bindings & body]
(let [fn-names (map first fn-bindings)
fn-gensyms (into {} (for [f fn-names]
[f (gensym f)]))
delayed-bindings (for [f fn-names
x [(fn-gensyms f)
`(delay (~f ~@fn-names))]]
x)
forced-bindings (for [[n v] fn-gensyms
x [n `(force ~v)]]
#!/bin/sh
#_(
true; exec clj -J-Xmx256M -J-XX:-OmitStackTraceInFastThrow -Sdeps "`sed -n -e '/;;(DEPS$/,/;;DEPS)$/p' $0`" -M -i $0 -e '(user/main)'
)
(ns user
#?(:cljs (:require-macros [user :as m]))
(:require
#?@(:clj ([cljs.build.api :as cljs]
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
SERVER=
CLIENT_NAME=
CLIENT_ID=
CLIENT_SECRET=
AUTH_CODE=
ACCESS_TOKEN=