Skip to content

Instantly share code, notes, and snippets.

@moquist
moquist / clojure-destructuring-demos
Created March 20, 2018 21:15
silly clojure map destructuring examples
(let [
{
:as blerp
:strs [i-am-a-string i-am-a-thread]
:keys [my-brain my-heart]
;;my-brain :my-brain
;;my-heart :my-heart
;;i-am-a-string "i-am-a-string"
;;i-am-a-thread "i-am-a-thread"
@moquist
moquist / scboot
Created October 6, 2015 20:29 — forked from kanaka/scboot
scboot
#!/bin/bash
# $Id: scboot 64763 2008-11-15 14:29:58Z rwoodscorwin $
usage() {
echo "
Usage: $(basename $0) [options]
Boot the nodes of a SiCortex system.
ARG ENV VARIABLE DESCRIPTION
Sat Feb 21 14:29:06 EST 2015 [worker-1] ERROR - POST /classes
java.lang.IllegalArgumentException: Vector arg to map conj must be a pair
at clojure.lang.APersistentMap.cons(APersistentMap.java:35)
at clojure.lang.RT.conj(RT.java:562)
at clojure.core$conj.invoke(core.clj:83)
at clojure.core$merge$fn__4314.invoke(core.clj:2759)
at clojure.core$reduce1.invoke(core.clj:903)
at clojure.core$reduce1.invoke(core.clj:894)
at clojure.core$merge.doInvoke(core.clj:2759)
at clojure.lang.RestFn.invoke(RestFn.java:421)
@moquist
moquist / clj-repl
Last active August 29, 2015 14:15 — forked from vzaharee/clj-repl
(defun ensure-clj-repl ()
"Start a clojure repl using inferior-lisp mode"
(inferior-lisp "clojure-repl")
(set-syntax-table clojure-mode-syntax-table)
(clojure-font-lock-setup)
(supplement-clojure-font-lock))
(defun clj-repl ()
"Switch to existing clojure repl or start a new one"
(interactive)
@moquist
moquist / index.html
Last active August 29, 2015 14:15
FDG
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.node {
stroke: #fff;
stroke-width: 1.5px;
}
.link {
@moquist
moquist / lein-profiles.clj
Created January 27, 2015 19:23
leiningen profile with voom
;; put this in ~/.lein/profiles.clj
{:user {:plugins [[lein-voom "0.1.0-20140716_032004-g85e4c9b"]]}}
@moquist
moquist / map_stateful.clj
Last active August 29, 2015 14:13
map-stateful is like map-indexed, but passes a state value into and out from the work fn
(defn map-stateful
"Takes a state value and calls f with the current state value and each
item in coll. The state value may be updated and must be returned as
the first item in f's result vector.
@moquist
moquist / clojure-repl
Created October 7, 2014 16:30
Yet another Clojure REPL starter (supports a project .classpath file)
#!/bin/bash
# Put this in your $PATH and call it "clojure-repl", and (setq clojure-inf-lisp-command "clojure-repl") if you're into the whole Emacs thing and you want to use inferior-lisp.
# Walk from $PWD up to /, looking for a .classpath file.
# If found, cat its contents for capture.
function find_dot_classpath {
local target_dir="$PWD"
local d="$target_dir"
while [[ "/" != $(command cd -P $d && \pwd) ]]; do
def tokenize(str):
# regex:
# 1. zero or more (forgotten) spaces or commas followed by one of
# 2. ~@ [ ] { } ( ) ' ` ~ ^ @
# --OR--
# 3. a double-quoted string of any length (with newlines?)
# --OR--
# 4. a comment (forgotten)
# --OR--
# 5. any one-or-more char token that doesn't have any of: whitespace [ ] { } ( ) ' " ` @ , ;
@moquist
moquist / realias.sh
Created February 13, 2014 22:28
recursively renaming dependency aliases
# Match dependency aliases like [navigator.thing :as a-thing]
# and recursively substitute a-thing with n-thing.
for alias in $(grep -r "navigator\.[^ ]\+ \+:as a-" * | awk '{print $NF}' | sed 's/[^a-z0-9-]//g' | sort -u); do
new=${alias/a-/n-}
find * -type f -exec sed -i "s/$alias/$new/g" \{\} \;
done