Skip to content

Instantly share code, notes, and snippets.

View dannypurcell's full-sized avatar

Danny Purcell dannypurcell

  • Traveling the US
View GitHub Profile
@dannypurcell
dannypurcell / maven_install_lwjgl.sh
Created January 10, 2015 16:34
Installs an LWJGL3 snapshot to the local maven repo. See: http://www.lwjgl.org/download
#!/usr/bin/env bash
function usage {
cat <<USAGE
Usage: $0 <lwjgl_zip_url>
Arguments:
lwjgl_zip_url - url pointing to the lwjgl zip archive to download and install in the local m2/repository
USAGE
}
@dannypurcell
dannypurcell / InvokeClojure.java
Created April 14, 2014 13:18
Example Java static for calling Clojure functions
import clojure.lang.IFn;
import clojure.lang.RT;
public class Clojure {
public static Object invokeCLJ(String ns, String fn, Object... args) throws NoSuchMethodException {
clojure.lang.Compiler.eval(RT.readString("(require '" + ns + " :reload-all)"));
clojure.lang.IFn f = (IFn) RT.var(ns, fn).deref();
if (f == null) {
throw new NoSuchMethodException("Could not find " + fn + " in " + ns + " or could not load " + ns);
@dannypurcell
dannypurcell / trailing-slash-middleware
Created January 2, 2014 05:30
Ring middleware fn. Removes a trailing slash from the uri before calling the handler.
(defn ignore-trailing-slash
"Modifies the request uri before calling the handler.
Removes a single trailing slash from the end of the uri if present.
Useful for handling optional trailing slashes until Compojure's route matching syntax supports regex.
Adapted from http://stackoverflow.com/questions/8380468/compojure-regex-for-matching-a-trailing-slash"
[handler]
(fn [request]
(let [uri (:uri request)]
(handler (assoc request :uri (if (and (not (= "/" uri))