Skip to content

Instantly share code, notes, and snippets.

@jennifersmith
jennifersmith / gist:1558084
Created January 4, 2012 02:11
Weird non lazy behaviour
;; I thought map was lazy and that first only took the first thing but ...
(first (map (fn [x] (print "XXXX" x "XXXX") x) [1 2 3 4])) ;; XXXX 1 XXXXXXXX 2 XXXXXXXX 3 XXXXXXXX 4 XXXX1
;; Unless it is a list
(first (map (fn [x] (print "XXXX" x "XXXX") x) '(1 2 3 4)));; XXXX 1 XXXX1
;; deffing it gives no output
(def foo (map (fn [x] (print "XXXX" x "XXXX") x) [1 2 3 4]))
;; but this does
@jennifersmith
jennifersmith / gist:1789863
Created February 10, 2012 14:17
redis_resource.clj
(ns stats.redis-resource
(:import
(org.joda.time DateTime))
(:require
[clj-time.coerce]
[clj-redis.client :as redis]))
;; This is not particularly groundbreaking (I am sure abstractions exist around redis I just didnt find them when I looked).
;; More interested in whether using reify was the best approach
(ns clojuredojo.core)
(defn palindrome-detector [thing] (= (reverse thing) (seq thing)) )
(def __ palindrome-detector)
(false? (__ '(1 2 3 4 5)))
(true? (__ "racecar"))
(true? (__ [:foo :bar :foo]))
(true? (__ '(1 1 3 3 1 1)))
@jennifersmith
jennifersmith / organ_cornet.clj
Created March 17, 2012 03:23
Cornet organ stop
(use 'overtone.live)
(defcgen triangle-osc [freq phase {:default 0.0} harmonics {:default 40}]
(:ar (let
[
harmonic-numbers (take harmonics (iterate (partial + 2) 1))
cosines (set (map #(- (* 4 %) 1) (range 1 harmonics)))]
(klang [
(map #(* freq %) harmonic-numbers) ;; harmonics
(map #(/ 1.0 (* % %)) harmonic-numbers) ;; inverse square ampl
(map #(+ phase %) (map #(if (cosines %) (. Math PI) 0.0) harmonic-numbers))])))) ;; conditional phase shift by pi
# if you already have postgres installed
mkdir /tmp/postg
sudo mv /usr/include/pg* /tmp/postg
gem uninstall pg
bundle install
#Installing postgres on the LION!
brew update
brew install postgresql
/* jslint
adsafe: false,
bitwise: true,
browser: true,
cap: false,
continue: false,
css: true,
debug: false,
devel: true,
eqeq: false,
@jennifersmith
jennifersmith / body.txt
Created June 10, 2012 13:52 — forked from mneedham/neo_loading.rb
Loading stuff into neo via the batch API
[ {
"method" : "POST",
"to" : "/node",
"body" : {
"name" : "Jen"
},
"id" : 1111
}, {
"method" : "POST",
"to" : "/index/node/people",
@jennifersmith
jennifersmith / hacky_data_stuff.clj
Created June 18, 2012 20:48
hacky_data_stuff.clj
(ns git-charts.core
(:use [incanter.core] [incanter.zoo])
(:require (incanter stats charts io)))
(defn read-dataset []
(incanter.io/read-dataset "/Users/jen/Dropbox/legacy codebase/ove-gitstats/lines_of_code.dat" :delim \space))
(defn clean-dataset [ds]
(incanter.core/col-names ds [:Date :Locs]))
1169071810 0
1169138071 6294
1169143071 23245
1169143580 23245
1169144084 23275
1169145926 23275
1169149435 31231
1169150235 34922
1169153198 47651
1169153433 30684
1) Download cloc, chmod it and have it on your path somewhere (as cloc)
2) get the scan-history script
curl https://raw.github.com/rhunter/git-scan-history/master/bin/git-scan-history > ~/bin/git-scan-history
3) chmod it
chmod +x ~/bin/git-scan-history