Skip to content

Instantly share code, notes, and snippets.

(ns ezducerdemo)
;;
;; 1st take
;;
(defn ezducer [constructor]
(fn [reducer]
(let [steps (fn [a vs]
;; Use loop/recur instead of reduce to avoid reduce's
@ghadishayban
ghadishayban / functional_interfaces.clj
Last active February 4, 2019 17:52
SAM inference helpers
(import '[java.lang.reflect Method Modifier])
(set! *warn-on-reflection* true)
(defn- samsig
"Given a SAM interface, returns the j.l.reflect.Method of the abstract method"
[sym]
(let [kls (resolve sym)]
(if (and (class? kls) (.isInterface ^Class kls))
(let [mid (fn [^Method m] [(.getName m) (vec (.getParameterTypes m))])
@ghadishayban
ghadishayban / vendor_asm.sh
Created February 12, 2018 01:46
a script that vendors asm and writes itself as git commit 'transaction data'
#!/bin/bash
# author Ghadi Shayban <gshayban@gmail.com>
set -e
if [ -z ${1+x} ]
then
echo provide an asm git sha / ref
exit 1
fi
@devn
devn / todo.exs
Last active December 1, 2017 22:38
do todo
defmodule Do do
def dont think, about, it, but, please do
[think, about, it, please]
end
end
Do.dont :worry, :about, :grouping, :any, :arguments
=> [:worry, :about, :grouping, :arguments]
@pjstadig
pjstadig / core.clj
Created March 20, 2017 13:06
A little type hint hint
(ns typehint.core)
;; A little type hint hint...
(set! *warn-on-reflection* true)
;; There are two ways to type hint the return value of a function, but one is
;; (technically) wrong:
(defn ^String as-string0
@noprompt
noprompt / strum.clj
Created December 22, 2016 19:52
Macro for defining instrumented functions which verify their arguments and return values against specs.
(ns strum.core
(:refer-clojure :exclude [defn])
(:require
[clojure.spec :as spec]
[clojure.spec.test :as spec.test]))
;; ---------------------------------------------------------------------
;; Prelude
;; HACK: Currently, as of Clojure 1.9.0-alpha14, there is a bug with
@lrascao
lrascao / gist:f57312ff33b799c4c0db56b10e80fe26
Created March 31, 2016 16:19
Export/Import datadog dashboards
dash_id=xxxx
api_key=xxx
app_key=xxx
# 1. export
curl -X GET "https://app.datadoghq.com/api/v1/dash/${dash_id}?api_key=${api_key}&application_key=${app_key}" > dash.json
# 2. edit dash.json
move "graphs", "title", "description" up one level in the json hierarchy, from being beneath "dash" to being at the same level