Created
November 14, 2013 20:13
-
-
Save funkotron/7473555 to your computer and use it in GitHub Desktop.
GitHub API Language Count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns crash-course-clojure.github | |
(:require [clj-http.client :as http] | |
[cheshire.core :refer [parse-string]] | |
[clojure.pprint :refer [pprint]])) | |
(defn query-github | |
"Run an arbitrary query agains Github's API." | |
[query] | |
(parse-string (:body (http/get "https://api.github.com/users/funkotron/repos" | |
{:query-params {:q query}})) | |
true)) | |
(defn myrepos | |
[] | |
(query-github nil)) | |
(defn lang-count | |
[lang] | |
(count (filter #(= (:language %) lang) (myrepos)))) | |
(print (lang-count "Python")) | |
(print (lang-count "Clojure")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment