Skip to content

Instantly share code, notes, and snippets.

rplevy /
Last active November 6, 2022 10:22
minimal paper wallet generator
#!/usr/bin/env python3
import binascii
from bip_utils import Bip38PubKeyModes, Bip38Encrypter
from bitcoin import *
from qrcode import *
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
rplevy /
Created October 2, 2018 01:58 command-line example
export SHA=$(git rev-parse HEAD)
tar czfv $SHA.tgz resources/public/
curl --request POST --data-binary "@${SHA}.tgz" -H "filename: "$SHA.tgz -H "bin: "$SHA
export T=$(curl -s$SHA | grep \?t= | tail -n 1 | sed -e 's/^.*zip.t=//' | cut -c1-8)
curl -s$SHA/$SHA.tgz?t=$T --output $SHA.tgz
tar -xzf $SHA.tgz
View continuationlike-debugging-style.clj
(defmacro persist-scope
"local scope -> atom"
`(do ~@(map (fn [v] `(swap! ~a assoc (keyword '~v) ~v))
(keys (cond-> &env (contains? &env :locals) :locals)))))
(def scope-atom (atom {}))
(let [foo 1] (persist-scope scope-atom))
rplevy / README.txt
Last active February 3, 2022 07:09
twitter archive
View README.txt
tweets from my twitter archive but in order
rplevy /
Last active April 1, 2021 00:15
bitclout fees
echo "<html><table><tr><th>type</th><th>amount</th><tr>" > /tmp/transactions.html; cat /tmp/transactions | egrep "^(Transaction Type:|Fees:).*" | while read l ; do if [[ "$l" =~ ^Transaction.*$ ]]; then export transaction=$(echo $l | sed -e 's/^.*://'); else echo "<tr><td>"$transaction"</td><td>"$(echo $(echo $l | sed -e 's/^.*://')" * 154.87" | bc )"</td></tr>"; fi ; done >> /tmp/transactions.html ; echo "</table></html>" >> /tmp/transactions.html
rplevy / two-useful-macros.clj
Created June 29, 2012 23:29
with and within
View two-useful-macros.clj
(defmacro with
"do things with the first expression passed,
and produce the result"
[expr & body]
`(let [~'% ~expr] ~@body))
(defmacro within
"do things with the first expression passed (for side effects),
but produce the value of the first expression"
[expr & body]
rplevy / ticket-sentiment.clj
Last active January 18, 2020 01:28
View ticket-sentiment.clj
(ns ticket-sentiment.core
(:require [ :as csv]
[ :as io]
[clojure.pprint :refer [pprint]]
[damionjunk.nlp.cmu-ark :as ark]
[damionjunk.nlp.stanford :as nlp]))
(defn mean [coll]
(let [sum (apply + coll)
count (count coll)]
rplevy / clj->org.clj
Last active May 29, 2019 23:15
takes a sequence of rows of clojure data and a sequence of fns (keys for example) that produce the columns, and generates an org table
View clj->org.clj
(defn clj->org
[data-rows col-fns]
(doseq [line (map (apply juxt col-fns) data-rows)]
(println (str "|" (clojure.string/join "|" line) "|"))))
;; edit: use print-table, and support col headers
;; I never realized print-table is an org-table!!
(defn clj->org
[data-rows col-fns & [headers]]
rplevy /
Last active May 2, 2019 00:47

command-line scripting with plk & clj

what to write scripts in?



why not clojure?

why not?

bash/perl etc pre-installed

unorthodox installation requirements sometimes not worth it

this is actually a pretty good reason not to
View profiles2env.cljs
#!/usr/bin/env plk -Sdeps {:deps,{inflections,{:mvn/version,"0.13.0"}}}
;; profiles2env profiles.clj > ~/cc-vars
;; . ~/cc-vars
(ns scripts.profiles2env
(:require [cljs.reader :as r]
[clojure.string :as str]