Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am julienfantin on github.
  • I am julienfantin (https://keybase.io/julienfantin) on keybase.
  • I have a public key whose fingerprint is 9908 AE54 127E DDF0 313F 0C7A 9FEC 2886 1FF2 0ED1

To claim this, I am signing this object:

@julienfantin
julienfantin / gist:6f283d6f59ac1fdc7339
Created June 6, 2014 23:47
Gotta love FP - Hamming distance in Java vs Clojure
(defn distance [a b]
(->> (map not= a b)
(filter true?)
count))
@julienfantin
julienfantin / gist:8806365
Created February 4, 2014 15:56
Carmine caching
(ns beta-api.utils.cache
(:require [taoensso.carmine :as car]
[clj-time.coerce :as tc]
[clj-time.core :as time]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Redis
(def conn-spec {:host "127.0.0.1"
:port 6379
@julienfantin
julienfantin / gist:7538496
Created November 19, 2013 01:14
Proper nesting of jdbc transactions
(do
(jdbc/db-transaction [con db-spec]
(jdbc/insert! con :user {:name "test" :email "test"})
;; the key here is to derive the inner transaction from the outer connection
(jdbc/db-transaction [con2 con]
(jdbc/insert! con2 :user {:name "test2" :email "test2"})
;; now this rolls back both inserts
(jdbc/db-set-rollback-only! con2)))
(println (jdbc/query db-spec ["select * from user"])))
@julienfantin
julienfantin / leinrc
Created November 17, 2013 01:44
~/.lein files
LEIN_JAVA_CMD=${LEIN_JAVA_CMD-drip}
#########################
# .gitignore file for Xcode4 / OS X Source projects
#
# Version 2.0
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
# 2013 updates:
# - fixed the broken "save personal Schemes"
#
# NB: if you are storing "built" products, this WILL NOT WORK,