Skip to content

Instantly share code, notes, and snippets.

View hlship's full-sized avatar

Howard M. Lewis Ship hlship

View GitHub Profile
@hlship
hlship / config.yaml
Created June 15, 2015 19:00
/src/config.yaml
acquirer:
uuid: ${ACQ_UUID}
@hlship
hlship / fan-acq-configuration.yaml
Last active August 29, 2015 14:23
dev-resources/fan-acq-configuration.yaml
acquirer:
uuid: d8d821e2-732c-4b3e-958c-1471a8f3c196
acquirer:
uuid: ${ACQ_UUID}
@hlship
hlship / acq.clj
Created June 15, 2015 18:46
Sample startup
(ns fan.acquirer
(:require [schema.core :as s]
[io.aviso/config :as config]
[fan.startup :as startup)
(:gen-class)
(s/defschema ^:private AcquirerSchema
"When an Acquirer is set up, it is registered with the MIX, and an acquirer instance is created in the MIX database.
The Acquirer must reference its UUID when submitting payments."
{:acquirer {:uuid s/Uuid}})
@hlship
hlship / lein deps
Created February 24, 2015 19:26
lein deps
$ lein deps :tree
[cc.qbits/jet "0.5.4" :exclusions [[cheshire]]]
[org.eclipse.jetty.websocket/websocket-client "9.2.6.v20141205"]
[org.eclipse.jetty/jetty-util "9.2.6.v20141205"]
[org.eclipse.jetty.websocket/websocket-server "9.2.6.v20141205"]
[org.eclipse.jetty.websocket/websocket-common "9.2.6.v20141205"]
[org.eclipse.jetty/jetty-servlet "9.2.6.v20141205"]
[org.eclipse.jetty/jetty-security "9.2.6.v20141205"]
[org.eclipse.jetty.websocket/websocket-servlet "9.2.6.v20141205"]
[org.eclipse.jetty.websocket/websocket-api "9.2.6.v20141205"]
(ns docker-utils
"Utilies for starting and stopping a Postgres Docker container."
(:import
[java.io File]
[java.net ServerSocket])
(:require
[io.aviso.ansi :refer [bold]]
[clojure.java.shell :refer [sh]]
[clojure.tools.logging :as l]
[clojure.edn :as edn]
@hlship
hlship / setup.clj
Last active August 29, 2015 14:07
Force all Dates and Timestamps to use UTC
(ns setup
(:import
[java.util Date Calendar TimeZone]
[java.sql PreparedStatement])
(:require
[clj-time.coerce :as coerce]
[clojure.java.jdbc :as jdbc]))
(extend-type Date
@hlship
hlship / gist:0f0c3ff39843059c9ceb
Last active August 29, 2015 14:05
validate-auth updated with cond-let
(defn validate-auth
"Validates the authentication data and returns vector of [error-message user-data]. On success, the error-message will
be nil."
[db-connection user-id user-password]
(cond-let
(str/is-blank? user-id)
["user-id not specified"]
(str/is-blank? user-password)
["password not specified"]
@hlship
hlship / gist:45fd7695a30740bcf0ca
Created August 19, 2014 20:16
Implementation of cond-let macro
(defmacro cond-let
"A merging of cond and let. Each term is either a vector
(in which case, it acts like let) or a condition expression followed by the value
for that expression. An empty cond-let returns nil."
[& forms]
(when forms
(if (vector? (first forms))
`(let ~(first forms)
(cond-let ~@(rest forms)))
(if-not (next forms)
(defn validate-auth
"Validates the authentication data and returns vector of [error-message user-data]. On success, the error-message will
be nil."
[db-connection user-id user-password]
(cond
(str/is-blank? user-id)
["user-id not specified"]
(str/is-blank? user-password)
["password not specified"]