Skip to content

Instantly share code, notes, and snippets.

cd /path/to/dir/with/Vagrantfile
VBoxManage controlvm $(cat .vagrant | awk 'BEGIN { FS = ":" } { print $3 }' | sed 's/["\}]//g') poweroff
@rplevy
rplevy / gist:54ba1146160be418e67d
Last active August 29, 2015 14:03
failing _validation, but _search works
curl -s -XGET 'http://localhost:9200/4af9aae4-7ec1-458d-8c50-692ddb0f2c6d/msg,file,file-info/_validate/query?explain=true' -d '{"fields":["id"],"filter":{"not":{"and":[{"numeric_range":{"msg-size":{"gte":1000}}},{"query":{"prefix":{"content-type.verbatim":"application/"}}}]}}}' | python -mjson.tool
{
"_shards": {
"failed": 0,
"successful": 1,
"total": 1
},
"explanations": [
{
"error": "org.elasticsearch.index.query.QueryParsingException: [4af9aae4-7ec1-458d-8c50-692ddb0f2c6d-0] request does not support [fields]",
@rplevy
rplevy / keybase.md
Created September 28, 2014 04:07
keybase.md

Keybase proof

I hereby claim:

  • I am rplevy on github.
  • I am rplevy (https://keybase.io/rplevy) on keybase.
  • I have a public key whose fingerprint is 6382 805E 6D33 870C 9A42 40B3 73C5 7C51 49A3 C990

To claim this, I am signing this object:

Verifying that +rplevy is my Bitcoin username. You can send me #bitcoin here: https://onename.io/rplevy
Verifying that +rplevy is my blockchain ID. https://onename.com/rplevy
@rplevy
rplevy / example.clj
Last active June 11, 2016 05:13
temporal higher-order contract with clojure.spec
(require '[clojure.spec :as s])
(defn enforce [spec data-value]
(let [r (s/conform spec data-value)]
(if (= r :clojure.spec/invalid)
(throw (ex-info (str r) (s/explain-data spec data-value)))
data-value)))
(defn call-with-temporal-contract [f g contract-on-g]
(let [function-calls (atom [])]
@rplevy
rplevy / aero-env.clj
Created June 15, 2016 00:47
integrate environ with aero
(defn keywordize [s]
(-> (str/lower-case s)
(str/replace "_" "-")
(str/replace "." "-")
(keyword)))
(defmethod aero/reader 'env
[opts tag value]
(get env (keywordize (str value))))
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
I verify that I am rplevy on mastodon.social
-----BEGIN PGP SIGNATURE-----
Version: Keybase OpenPGP v2.0.68
Comment: https://keybase.io/crypto
wsFcBAABCgAGBQJY4xcwAAoJEHPFfFFJo8mQ7LoQANVwr+sfT8tzZWCuyNsdLpsc
hPK3SmUTCLRYa/8Olvq2MO/ZWTyuHfhDiRWqmksSIdAoR5oyiz0RC4fCpuZY4QeZ
# in my .bashrc
xmlclj() { planck -D funcool/tubax:0.2.0 -e "(require '[tubax.core :as tubax]) (require '[planck.core :refer [slurp]]) (require '[cljs.pprint :refer [pprint]])"'(pprint (tubax/xml->clj (slurp "'$1'")))'; }
# example: xmlclj /tmp/foo.xml
@rplevy
rplevy / xml->clj-region.el
Last active August 18, 2017 23:45
elisp wrapper on cljs script
(defun xml->clj-region (beg end)
(interactive "r")
(shell-command-on-region beg end
"xmlclj"
(current-buffer)
t))