This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/planck | |
(ns scripts.edn2json | |
(:require [cljs.reader :as r] | |
[planck.core :refer [slurp *command-line-args* *in* line-seq]])) | |
(defn last-n-chars [n s] | |
(apply str (reverse (take n (reverse s))))) | |
(let [s (first *command-line-args*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro defshell (name cmd) | |
`(defun ,name () | |
(interactive) | |
(insert (shell-command-to-string ,cmd)))) | |
(defmacro defshellonreg (name cmd &optional replace) | |
`(defun ,name (beg end) | |
(interactive "r") | |
(shell-command-on-region beg end ,cmd | |
(if ,replace (current-buffer) nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun htm2clj-region (beg end) | |
(interactive "r") | |
(shell-command-on-region beg end | |
"html2clj" | |
(current-buffer) | |
t)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun xml->clj-region (beg end) | |
(interactive "r") | |
(shell-command-on-region beg end | |
"xmlclj" | |
(current-buffer) | |
t)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn keywordize [s] | |
(-> (str/lower-case s) | |
(str/replace "_" "-") | |
(str/replace "." "-") | |
(keyword))) | |
(defmethod aero/reader 'env | |
[opts tag value] | |
(get env (keywordize (str value)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 [])] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Verifying that +rplevy is my blockchain ID. https://onename.com/rplevy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[cemerick.pomegranate :refer [add-dependencies]]) | |
(add-dependencies | |
:coordinates '[[clj-http "0.6.3"] | |
[swiss-arrows "0.5.1"]] | |
:repositories {"clojars" "http://clojars.org/repo"}) | |
(require '[clj-http.client :as client] | |
'[swiss-arrows.core :refer [-<>]] | |
'[clojure.string :as str] | |
'[clojure.java.shell :refer [sh]]) |