Skip to content

Instantly share code, notes, and snippets.

View daveliepmann's full-sized avatar

Dave Liepmann daveliepmann

View GitHub Profile
(defn setup []
(frame-rate 4)
(no-fill)
(stroke 0 0 0 128)
(smooth))
(def rotor (atom 0))
(def zoomer (atom 200))
(def zoomer-flag (atom 1))
@daveliepmann
daveliepmann / pyrgiometry.clj
Last active July 10, 2017 21:57
"Πυργεωμετρία ('Pyrgi-ometry')", a Processing sketch using Clojure and Quil. Inspired by artwork in the village of Pyrgi on the Greek island Chios: https://daveliepmann.exposure.so/pyrgi
;; "Πυργεωμετρία ('Pyrgi-ometry')", a Processing sketch using Clojure and Quil
(ns livecode.pyrgi
(:use quil.core))
(def stripe-height 50)
(def canvas-height (* 9 stripe-height))
(def canvas-width (* canvas-height (/ 3 2)))
;; Color conversion, courtesy of Jack Rusher
(defn hex-to-color [hex]
@daveliepmann
daveliepmann / nyt-monkeys.clj
Created January 27, 2014 01:59
A port of Jer Thorp's New York Times API demo (https://github.com/blprnt/dataart/tree/master/1_Data_and_Aesthetic/Code/NYT_ArticleSearch_v2) from Processing to Clojure using Quil
(ns dataartclj.nyt-monkeys
(:use quil.core)
(:use ring.util.codec)
(:require [cheshire.core :refer :all]))
(def api-key "removed")
(def base-url "http://api.nytimes.com/svc/search/v2/articlesearch.json?")
(def w 1280)
(def h 720)
@daveliepmann
daveliepmann / csv-to-sexp.clj
Last active August 29, 2015 13:56
Clojurey and CSV-oriented version of Jack Rusher's elispy tsv-to-sexp: https://gist.github.com/jackrusher/5467833
(defn csv-to-sexp
"Parses the string `csv` as a comma-separated-value file,
returning a sexp containing the values with strings converted to
numbers where appropriate."
[csv]
(map (fn [s] (map #(let [i (string/trim %)
r-s (read-string i)]
(if (number? r-s) r-s i)) (string/split s #",")))
(string/split-lines csv)))
@daveliepmann
daveliepmann / stopwatch.cljs
Created August 19, 2014 13:18
ClojureScript stopwatch
(ns stopwatch)
(defn seconds-to-time
[secs]
(let [d (js/Date. (* secs 1000))]
{:hours (.getUTCHours d)
:minutes (.getUTCMinutes d)
:seconds (.getUTCSeconds d)}))
(defn display-time
@daveliepmann
daveliepmann / demo.clj
Last active August 29, 2015 14:05
Draft of minimal demonstration of uploading more than one file at a time to AWS S3. Complete finished repo at https://github.com/daveliepmann/aws-s3-upload-clj
(ns aws-s3-upload-clj.demo
(:use [hiccup page]
[ring.util.codec])
(:import (javax.crypto Mac)
(javax.crypto.spec SecretKeySpec))
(:require [compojure.core :refer [GET defroutes]]
[clj-time.core :as time]
[clj-time.format :as time-f]
[clojure.data.json :as json]
[compojure.route :as route]
@daveliepmann
daveliepmann / localstorage.cljs
Created September 23, 2014 08:23
HTML5 localStorage utility functions for ClojureScript. I find it makes for cleaner code when I wrap the native JS.
(ns localstorage)
(defn set-item!
"Set `key' in browser's localStorage to `val`."
[key val]
(.setItem (.-localStorage js/window) key val))
(defn get-item
"Returns value of `key' from browser's localStorage."
[key]
@daveliepmann
daveliepmann / aws-lambda-clj.sh
Created September 1, 2015 13:24
Tim Wagner and Bryan Moffatt's AWS Lambda walkthrough for Clojure (https://aws.amazon.com/blogs/compute/clojure/) says "You can invoke and test from the command line".
aws lambda invoke \
--function-name clj-hello \
--payload \"Dave\" \
output
# or...
aws lambda invoke --function-name clj-hello --payload \"Dave\" output
# either way, the response from your function goes in the file "output"
@daveliepmann
daveliepmann / irises.md
Last active July 21, 2023 12:08
Implementing Sugar & James’ paper, "Finding the number of clusters in a data set: An information theoretic approach" in Clojure — Part 1

Implementing the k-means jump method: Part One

This paper:

Finding the number of clusters in a data set: An information theoretic approach

CATHERINE A. SUGAR AND GARETH M. JAMES

>Marshall School of Business, University of Southern California

@daveliepmann
daveliepmann / irises.clj
Last active July 12, 2017 14:11
Clojure source code for Part 1 of "Implementing the k-means jump method" — see https://gist.github.com/daveliepmann/88fcf516acc264714de69081ef0c076b
(ns jump-sugar-james.irises
(:require [incanter.core :as i]
[incanter.stats :as incs]
[incanter.charts :as incc]
[incanter.datasets :as incd]
[clj-ml.clusterers :as mlc]
[clj-ml.data :as mld]))
;;;; This paper:
;; Finding the number of clusters in a data set: An information theoretic approach