Skip to content

Instantly share code, notes, and snippets.

View hlship's full-sized avatar

Howard M. Lewis Ship hlship

View GitHub Profile
$ lein do clean, uberjar ; java -jar target/fan-0.0.1-standalone.jar
Compiling fan.auth.main
Compiling fan.auth.main
Created /Users/hlship/workspaces/fexco/fan-suite/target/fan-0.0.1.jar
Created /Users/hlship/workspaces/fexco/fan-suite/target/fan-0.0.1-standalone.jar
17:30:12.313 [main] INFO fan.auth.main - Startup 5 nil
~/workspaces/fexco/fan-suite
$
$ lein uberjar ; java -jar target/fan-0.0.1-standalone.jar
Created /Users/hlship/workspaces/fexco/fan-suite/target/fan-0.0.1.jar
Created /Users/hlship/workspaces/fexco/fan-suite/target/fan-0.0.1-standalone.jar
17:31:35.663 [main] INFO fan.auth.main - Startup 5 nil
(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"]
@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)
@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 / 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
(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 / 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"]
@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}})
acquirer:
uuid: ${ACQ_UUID}