Skip to content

Instantly share code, notes, and snippets.

@leblowl
leblowl / jdbc-sql-vec.clj
Created July 18, 2018 06:37
One way to deal with many params in Clojure JDBC
(defn reduce-sql-vec
"Takes an array of SQL statement vectors and combines
them into a valid clojure.java.jdbc query vector. In each statement vector
you can have parameters at the end just like a jdbc vector. Easier to show
than explain:
take this:
[[\"SELECT * FROM dude\"]
[\" WHERE id = ?\" 1]]
@leblowl
leblowl / snippets.clj
Last active January 31, 2018 04:23
Helpful Clojure Snippets
; List functions of a namespace
; https://stackoverflow.com/questions/2747294/how-to-list-the-functions-of-a-namespace
(keys (ns-publics 'foo))
@leblowl
leblowl / build_init.py
Last active August 29, 2015 14:26
Python startup script for interpreting a build.py file
# build_init.py
# python startup script for interpreting a build.py file
#
# Install:
# download, place this file where you like,
# & then add the path to PYTHONSTARTUP env variable.
# ex:
# export PYTHONSTARTUP=$HOME/.config/python/build_init.py
#
# build.py:
# water polygons
#
wget http://data.openstreetmapdata.com/water-polygons-split-3857.zip
unzip water-polygons-split-3857.zip
shp2pgsql -dID -s 900913 -W Windows-1252 -g the_geom water-polygons-split-3857/water_polygons.shp water_polygons | psql "$@"
rm ./water-polygons-split-3857.zip && rm -rf ./water-polygons-split-3857
# land polygons
#
wget http://data.openstreetmapdata.com/land-polygons-split-3857.zip
@leblowl
leblowl / util_fun
Created May 14, 2015 18:57
Util fun
(defn slurp-edn [f]
(with-open [r (PushbackReader. (io/reader f))]
(let [edn-seq (repeatedly (partial edn/read {:eof :EOF} r))]
(doall (take-while #(not= :EOF %) edn-seq)))))
(defn in?
"true if seq contains elm"
[seq elm]
(some #(= elm %) seq))
(ns overtone.examples.internal-sequencer
(:use [overtone.live]))
;; A fully server-side sample sequencer.
;; =====================================
;; This example demonstrates some of the benefits of moving all synth
;; triggers inside the server itself. For example, it allows you to
;; modify the synthesis with *immediate* effect (rather than waiting for
;; the next bar/chunk to be scheduled) and you can use a global pulse to
@leblowl
leblowl / idb.cljs
Created February 13, 2015 02:00
simple clojurescript interface to IndexedDB for github.com/leblowl/lokate
(def db (atom nil))
(defn error [e]
(.error js/console "An IndexedDB error has occured!" e))
(defn new [cb]
(let [version 1
request (.open js/indexedDB "lokate" version)]
(set! (.-onupgradeneeded request) (fn [e]
(reset! db (.. e -target -result))