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
; | |
; Required dependencies: | |
; [org.clojure/clojure-contrib "1.2.0"] | |
; [com.google.api.client/google-api-client "1.4.1-beta"] | |
; [com.google.guava/guava "r09"] | |
; | |
(ns funnyplaces.core | |
(:import (com.google.api.client.auth.oauth OAuthHmacSigner OAuthParameters)) | |
(:import (com.google.api.client.http GenericUrl HttpRequest HttpRequestFactory HttpResponse HttpTransport)) | |
(:import (com.google.api.client.http.javanet NetHttpTransport)) |
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
(fetch :places :q “coloft”) | |
[{:name "Coloft", | |
:address "920 Santa Monica Blvd" | |
:latitude 34.020433, | |
:longitude -118.490092, | |
:postcode "90401", | |
:factual_id "f8458ec1-3b63-48aa-82a1-6a06970d1235", | |
:locality "Santa Monica", | |
:region "CA", |
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
(crosswalk :factual_id "f8458ec1-3b63-48aa-82a1-6a06970d1235") | |
[{:factual_id "f8458ec1-3b63-48aa-82a1-6a06970d1235", | |
:namespace "facebook", | |
:namespace_id "218169018973", | |
:url "http://www.facebook.com/theCoLoft"} | |
{:factual_id "f8458ec1-3b63-48aa-82a1-6a06970d1235", | |
:namespace "foursquare", | |
:namespace_id "1283109", | |
:url "https://foursquare.com/venue/1283109"} |
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
{ | |
"version":"3.0", | |
"response": | |
{ | |
"included_rows":2, | |
"total_row_count":2, | |
"data":[ | |
{ | |
"factual_id":"39599c9b-8943-4c15-999d-c03f6c587881", | |
"last_name":"John", |
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
{ | |
"version":"3.0", | |
"response": | |
{ | |
"included_rows":2, | |
"total_row_count":2, | |
"data":[ | |
{ | |
"factual_id":"39599c9b-8943-4c15-999d-c03f6c587881", | |
"last_name":"John", |
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 datastore-api-server.conf | |
"Configuration utility." | |
(:use [clojure.tools.logging :only (info debug error)]) | |
(:use [fs.core :only (exists?)])) | |
(def DEFAULT-CONF-FILES ["server-conf.clj" "resources/server-conf.clj"]) | |
(defn load-when | |
"If path exists, returns the data structure represented in the | |
file at path. Otherwise returns nil." |
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
When app starts up: | |
... | |
(conf/add-file! some-conf-file)) | |
... | |
Some other ns in app, needs some conf: | |
... | |
(defn redis-host [] | |
((conf/conf) :redis-host)) |
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
(defn slurp-cp [f] | |
(let [loader (java.net.URLClassLoader. (into-array [(jio/as-url (fs/file f))]))] | |
(slurp (jio/resource f loader)))) |
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
;; | |
;; project.clj | |
;; | |
(defproject tabwc "0.0.0-SNAPSHOT" | |
:description "A Clojure Class Assignment! CLI util to validate a TAB file, or do a wc." | |
:main tabwc.core | |
:dependencies [[org.clojure/clojure "1.4.0"]]) | |
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
;; Example 1: a step that uses Crosswalk to add Fatual IDs | |
crosswalked.tab <- uncrossed.tab [c4] | |
;; For all lines where there's no factual_id, | |
;; pull out values from the columns named "foursquare" and "yelp" | |
(:>! factual_id [foursquare yelp] | |
;; Put into the factual_id column (creating if necessary)... | |
(+= "factual_id" | |
;; The result from Crosswalking foursquare, if there's a hit... | |
(or (:factual_id (first (select crosswalk | |
(where |
OlderNewer