Skip to content

Instantly share code, notes, and snippets.

View mikebroberts's full-sized avatar

Mike Roberts mikebroberts

View GitHub Profile
@mikebroberts
mikebroberts / gist:6890170
Created October 8, 2013 19:30
Create db-spec for accessing a remote Heroku database. Works with at least [org.clojure/java.jdbc "0.2.3"] .
(defn remote-heroku-db-spec [host port database username password]
{:connection-uri (str "jdbc:postgresql://" host ":" port "/" database "?user=" username "&password=" password
"&ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory")})
@mikebroberts
mikebroberts / spit-to-stream
Created October 1, 2013 19:17
Clojure spit always uses a Writer, so is no good for binary content. This spits to a stream so does work for binary.
(defn spit-to-stream [f content]
(with-open [w (clojure.java.io/output-stream f)]
(.write w content)))
@mikebroberts
mikebroberts / gist:6595266
Last active December 23, 2015 06:39
Clojure code to authenticate against Instagram's API. Requires clj-http (tested against [clj-http "0.7.0"]).
(ns instagram
"Functions to authenticate against Instagram's API.
See http://instagram.com/developer/authentication/ for parameter details."
(:require [clj-http.client :as client]))
(defn create-auth-url [client-id redirect-uri]
(str "https://api.instagram.com/oauth/authorize/?client_id=" client-id
"&redirect_uri=" redirect-uri
"&response_type=code"))