Skip to content

Instantly share code, notes, and snippets.

@yurrriq yurrriq/
Last active Aug 29, 2015

What would you like to do?
GitHub Languages

GitHub Languages

Prints a JSON map of the languages used in your repos, sorted by frequency in descending order.


lein run -m gh-languages # | hicat
(ns gh-languages
(:require [cheshire.core :as json]
[clojure.pprint :refer [pprint]]
[environ.core :refer [env]]
[org.httpkit.client :as http]))
(def my-repos (str "" (env :gh-user) "/repos"))
(def options {:basic-auth [(env :gh-access-token) "x-oauth-basic"]})
(defn sort-by-val [m]
(let [>val #(compare ((juxt m identity) %2) ((juxt m identity) %1))]
(into (sorted-map-by >val) m)))
(defn -main [& args]
(-> (:body @(http/get my-repos options))
(json/parse-string true)
(->> (remove (comp #{""} :html_url))
(map :languages_url)
(map #(json/parse-string (:body @(http/get % options))))
(apply merge-with +))
(json/generate-string {:pretty true})
{:user {:dependencies [[cheshire "5.4.0"]
[environ "1.0.0"]
[http-kit "2.1.19"]]
:plugins [[lein-environ "1.0.0"]]
:env {:gh-user "YOUR-GITHUB-USERNAME"
:gh-access-token "YOUR-ACCESS-TOKEN"}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.