Skip to content

Instantly share code, notes, and snippets.

View mikebroberts's full-sized avatar

Mike Roberts mikebroberts

View GitHub Profile
@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"))
@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: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")})
before_install: cd clojurenote
language: clojure
lein: lein2
before_install: cd clojurenote
script: lein2 expectations
jdk:
- openjdk7
- oraclejdk7
@mikebroberts
mikebroberts / slack.clj
Created March 17, 2014 18:02
Send a message to Slack incoming webhook in Clojure.
(ns slack
(:require [clj-http.client :as client]
[clojure.data.json :as json]))
(defn send-to-slack
"Sends a simple message to slack using an 'incoming webhook'.
url will be of form: https://myapp.slack.com/services/hooks/incoming-webhook?token=mytoken .
(Exact url you should use will appear on the slack integration page)
text will be any valid message.
This implementation could be expanded if you wanted to specify channel, username, etc.
@mikebroberts
mikebroberts / keybase.md
Created March 22, 2014 16:04
Keybase proof

Keybase proof

I hereby claim:

  • I am mikebroberts on github.
  • I am mikebroberts (https://keybase.io/mikebroberts) on keybase.
  • I have a public key whose fingerprint is 9105 8C88 AD43 7EF2 0EDF 0B75 8242 7D3F 6D4F E458

To claim this, I am signing this object:

@mikebroberts
mikebroberts / s3mr.clj
Created June 16, 2014 22:23
Copy S3 objects while updating metadata and permissions
; Should eventually create a pull-request for https://github.com/weavejester/clj-aws-s3
(defn- create-copy-request [src-bucket src-key dest-bucket dest-key metadata permissions]
(let [req (CopyObjectRequest. src-bucket src-key dest-bucket dest-key)]
(when metadata
(.setNewObjectMetadata req (map->ObjectMetadata metadata)))
(when permissions
(.setAccessControlList req (create-acl permissions)))
req))
package io.symphonia;
public class SimplestLambda {
public void handler(String s) {
System.out.println("Hello, " + s);
}
}
public SimplestLambda() {
}