Skip to content

Instantly share code, notes, and snippets.

🎣
Gone fishin'

Max Penet mpenet

🎣
Gone fishin'
Block or report user

Report or block mpenet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:fa611105b4a0a38126c5ba8ffe60d8a7
(clojure.spec.alpha/def ::asd (clojure.spec.alpha/keys :req [::foo]))
(clojure.spec.alpha/valid? ::asd {})
false
(clojure.spec.alpha/valid? ::asd {::foo 1})
true
;; ::foo was never declared
View deterministic_sampler.clj
(defn deterministic-sampler
[rate]
(let [bound (Integer/divideUnsigned -1 rate)] ;; -1 as int is 0xffffffff
(fn [s]
(pos? (Integer/compareUnsigned bound (hash s))))))
View gist:35451344629372b34bdb2280aade387e
(defn until
[p]
(fn [rf]
(let [p? (volatile! false)]
(fn
([x] (rf x))
([x y]
(if @p?
x
(do
@mpenet
mpenet / .scaffolding.clj
Created Jul 11, 2018
just a hack to use deps.edn dependencies in lein/boot projects without having to rely on half working plugins + versioning from git tags
View .scaffolding.clj
(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)
View i3.config
# 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 Feb 5, 2018
like clojure.core sequence but without chunking
View gist:674c13bb8cc3b6fefa23f08bbea5446f
(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))
View specx.clj
(defmacro ns-local
"Creates a locally aliased namespace matching supplied symbol"
[k]
`(alias ~k (create-ns (symbol (str *ns* "." (str ~k))))))
View erlang-slim.mk
# 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
View gist:4ba85df7020aa534914f
[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
View gist:43b3e33a6cdb529f92a1
(defn foo
[{:keys [x]
:or {x (println :set-default)}}]
x)
user> (foo {:x 1})
:set-default
1
You can’t perform that action at this time.