Commit 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 p = (p1, p2,…, pn) and q = (q1, q2,…, qn) are two points in Euclidean n-space, then the distance from p to q, or from q to p is given by:

equation

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 [p q]
  (Math/sqrt (->> (map - q p) (map square) (reduce +))))

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