Git log between production and master

Before deploying code, I like to see exactly what the deploy is going to contain. To facilitate that, I run a git log command to show me the differences. Color highlights are added to make the output more readable.

git log --format="%Cgreen%h%Creset %C(yellow)%aN%Creset: %s" --no-merges heroku/master..origin/master

If I want to see the logs for few directories in particular:

git log --format="%Cgreen%h%Creset %C(yellow)%aN%Creset: %s" --no-merges heroku/master..origin/master -- app/{models,controllers,views}

Eucledean distance in Clojure

When implementing collaborative filtering algorithms in a project, I couldn’t find any decent implementations of the Euclidean Distance algorithm.

For those unfamiliar:

In Cartesian coordinates, if x = (x1, x2,…, xn) and y = (y1, y2,…, yn) are two points in Euclidean n-space, then the distance from x to y, or from y to x is given by:


So I decided to be that reference I was looking for earlier. Here is the implementation in Clojure:

(defn square [x]
  (* x x))

(defn euclidean-distance [x y]
  (Math/sqrt (->> (map - y x) (map square) (reduce +))))

(/ 1 (+ 1 (euclidean-distance [0 0 0 0 0] [10 10 10 1 1])))