Skip to content

Instantly share code, notes, and snippets.

View mpenet's full-sized avatar
🪲
breeding bugs

Max Penet mpenet

🪲
breeding bugs
View GitHub Profile
(defn until
[p]
(fn [rf]
(let [p? (volatile! false)]
(fn
([x] (rf x))
([x y]
(if @p?
x
(do
@mpenet
mpenet / .scaffolding.clj
Created July 11, 2018 15:08
just a hack to use deps.edn dependencies in lein/boot projects without having to rely on half working plugins + versioning from git tags
(require
'[clojure.java.shell :as sh]
'[clojure.edn :as edn])
(set! *warn-on-reflection* true)
(defn next-version [version]
(when version
(let [[a b] (next (re-matches #"(.*?)([\d]+)" version))]
(when (and a b)
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:terminus 10
@mpenet
mpenet / gist:674c13bb8cc3b6fefa23f08bbea5446f
Last active February 5, 2018 11:28
like clojure.core sequence but without chunking
(defn unchunked-sequence [xform coll]
(->> coll
(clojure.lang.RT/iter)
(clojure.lang.TransformerIterator/create xform)
(clojure.lang.IteratorSeq/create)))
;; realizes 10 values
(first
(unchunked-sequence (comp (map #(do (prn %) %))
(partition-all 10))
(defmacro ns-local
"Creates a locally aliased namespace matching supplied symbol"
[k]
`(alias ~k (create-ns (symbol (str *ns* "." (str ~k))))))
# Build and slim Erlang
# Change the line below if you want to use a different version of Erlang
# (Keep in mind that patches may not apply cleanly)
erlang_version=otp_src_R14B03
erlang_source_file:=$(PACKAGE_SOURCES)/$(erlang_version)/$(erlang_version).tar.gz
erlang_root=$(GTH_ERLANG_ROOT)/$(erlang_version)
target_prefix=/opt/erlang
[translation:info] 2.7.9 (default, Mar 8 2015, 00:52:26)
[translation:info] [GCC 4.9.2]
[platform:msg] Set platform with 'host' cc=None, using cc='gcc', version='Unknown'
[translation:info] Translating target as defined by target
[platform:execute] gcc -c -O3 -pthread -fomit-frame-pointer -Wall -Wno-unused /tmp/usession-default-3/gcctest.c -o /tmp/usession-default-3/gcctest.o
[platform:execute] gcc -c -O3 -pthread -fomit-frame-pointer -Wall -Wno-unused /tmp/usession-default-3/gcctest.c -o /tmp/usession-default-3/gcctest.o
[platform:execute] gcc /tmp/usession-default-3/gcctest.o -pthread -Wl,--export-dynamic -lrt -o /tmp/usession-default-3/gcctest
[platform:execute] gcc -c -O3 -pthread -fomit-frame-pointer -Wall -Wno-unused /tmp/usession-default-3/platcheck_0.c -o /tmp/usession-default-3/platcheck_0.o
[platform:execute] gcc /tmp/usession-default-3/platcheck_0.o -pthread -Wl,--export-dynamic -lrt -o /tmp/usession-default-3/platcheck_0
[platform:execute] gcc -c -O3 -pthread -fomit-frame-pointer -Wall -Wno-unuse
(defn foo
[{:keys [x]
:or {x (println :set-default)}}]
x)
user> (foo {:x 1})
:set-default
1
(defn put!
"Takes a `ch`, a `msg`, a fn that enables backpressure, one that disables it,
and a no-arg function which, when invoked, closes the upstream source."
([ch msg suspend! resume! close!]
(let [status (atom ::sending)]
(async/put! ch msg
(fn [result]
(if-not result
(when close! (close!))
(do
@mpenet
mpenet / foami.clj
Last active August 29, 2015 14:07 — forked from ztellman/foami.clj
(ns foami.core
"FOreign Asynchronous Mechanism Interop"
(:require [clojure.core.async :as async]))
(defn put!
"Takes a `ch`, a `msg`, a single arg function that when passed `true` enables backpressure
and when passed `false` disables it, and a no-arg function which, when invoked, closes the
upstream source."
[ch msg backpressure! close!]
(let [status (atom :sending)]