Skip to content

Instantly share code, notes, and snippets.

flyingmachine / hang.clj
Created Oct 14, 2014
http-kit client hanging
View hang.clj
(defn app [req]
{:status 200
:headers {"Last-Modified" "Wed, 28 May 2014 19:41:37 GMT", "Content-Length" "2"}
:body "ok"})
(org.httpkit.server/run-server app {:port 7071})
@(org.httpkit.client/get "http://localhost:7071" {:timeout 500})
; => {:opts {:url "http://localhost:7071", :method :get, :timeout 500}, :error #<TimeoutException org.httpkit.client.TimeoutException: read timeout: 500ms>}
View works.clj
(div :class "filters"
(loop-tpl :bindings [name ["bob" "joe"]]
(h3 (text "~{name}"))))
(loop-tpl :bindings [attr ["a" "b"]]
(li (text "~{attr}")))))
View ex.clj
(div :class "filters"
(loop-tpl :bindings [name ["bob" "joe"]]
(h3 (text "~{name}"))
(loop-tpl :bindings [attr ["a" "b"]]
(li (text "~{attr}")))))))
flyingmachine / defnpd.clj
Last active Dec 18, 2015
This macro lets you easily create functions with default positional arguments
View defnpd.clj
(defmacro defnpd
;; defn with default positional arguments
[name args & body]
(let [unpack-defaults
(fn [args]
(let [[undefaulted defaulted] (split-with (comp not vector?) args)
argcount (count args)]
(loop [defaulted defaulted
argset {:argnames (into [] undefaulted)
:application (into [] (concat undefaulted (map second defaulted)))}
flyingmachine / gist:5735498
Last active Dec 18, 2015
Woohoo! Wrote my first emacs key binding!
View gist:5735498
(defun nrepl-start-http-server ()
(nrepl-set-ns (nrepl-current-ns))
(nrepl-interactive-eval "(def server (-main)) (println server)"))
(eval-after-load 'nrepl
'(define-key clojure-mode-map (kbd "C-c C-v") 'nrepl-server))
flyingmachine /
Last active Jan 10, 2020
How I set up my Android development environment
  1. Download the SDK from
  2. Unpack the ZIP file (named adt-bundle-<os_platform>.zip)
  3. Move the directory adt-bundle-<os_platform> to /Applications/Android: `mv adt-bundle-<os_platform> /Applications/Android
  4. Rename "eclipse" to "Android": mv /Applications/Android/eclipse/ /Applications/Android/eclipse/
  5. Start the Android app
  6. Go to Window->Android SDK Manager
  7. Install packages:
    • Intel x86 Atom System Image
    • Google APIs
    • Intel x86 Emulator Accelerator (HAXM) # this is toward the bottom
flyingmachine / dissipation.clj
Created Feb 6, 2013
dissipation in two languages
View dissipation.clj
(defn dissipation
(let [size (count decrements)]
(loop [acc []
sum size
acc-position 0
decrements decrements]
(= size (count acc))
View sql_pairs.rb
#!/usr/bin/env ruby
# Simple, not robust script for pairing sql fields to values
# example usage: pbpaste | ./sql_pairs.rb
sql =
# sql = %{INSERT INTO "users" ("username", "email") VALUES ('joe schmoe', '')}
flyingmachine / ns
Created Jan 21, 2013
A few YASnippet snippets for clojure's nrepl-mode
View ns
#name: ns
# --
(in-ns '${1:name})