Skip to content

Instantly share code, notes, and snippets.

View zentrope's full-sized avatar

Keith Irwin zentrope

  • Portland, Oregon
View GitHub Profile
@zentrope
zentrope / get-bars.clj
Last active December 12, 2015 03:32
Stringing out XML blobs
#!/usr/bin/env clj
(defn get-bars
[xml]
(loop [xml xml
bars []]
(if (clojure.string/blank? xml)
bars
(let [[_ bar xml2 :as r] (clojure.string/split xml #"<bar>|</bar>" 3)]
(if (nil? bar)
@zentrope
zentrope / Vagrantfile
Created October 23, 2015 03:50
Vagrant file for FreeBSD on OS X
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.guest = :freebsd
config.vm.box = "freebsd/FreeBSD-10.2-RELEASE"
@zentrope
zentrope / cipher.sh
Last active October 21, 2015 04:06
nginx, mont and shell for running and monitoring a java process on a unix (FreeBSD) system
#!/bin/sh
app="cipher"
version="0.9.2"
java="/usr/local/bin/java"
daemon="/usr/sbin/daemon"
app_home="/home/vagrant/apps/${app}"
jar="${app}-${version}-standalone.jar"
@zentrope
zentrope / Makefile
Last active September 6, 2015 17:54 — forked from rauhs/Makefile
Compiling clojurescript + figwheel without boot nor leiningen. Using leiningen to manage dependencies.
CLJ_NREPL_PORT:=22340
CLJS_JAR_VERSION:=1.7.48
CLJS_JAR_URL:=https://github.com/clojure/clojurescript/releases/download/r$(CLJS_JAR_VERSION)/cljs.jar
.PHONY: def_target
def_target : null
# http://blog.jgc.org/2015/04/the-one-line-you-should-add-to-every.html
@zentrope
zentrope / alpha3-fail.txt
Last active August 31, 2015 02:53
Stacktrace when compiling ClojureScript 1.7.122 with Clojure 1.8.0-alpha3 (also alpha4). Alpha2 works. Same error with JDK7 or 8.
Compiling ClojureScript...
Exception in thread "main" java.lang.VerifyError: (class: cljs/util$last_modified, method: invokeStatic signature: (Ljava/lang/Object;)Ljava/lang/Object;) Can only throw Throwable objects, compiling:(util.cljc:142:1)
at clojure.lang.Compiler$DefExpr.eval(Compiler.java:468)
at clojure.lang.Compiler.eval(Compiler.java:6948)
at clojure.lang.Compiler.load(Compiler.java:7390)
at clojure.lang.RT.loadResourceScript(RT.java:372)
at clojure.lang.RT.loadResourceScript(RT.java:363)
at clojure.lang.RT.load(RT.java:453)
at clojure.lang.RT.load(RT.java:419)
at clojure.core$load$fn__5436.invoke(core.clj:5869)
@zentrope
zentrope / gambit-3.clj
Last active August 29, 2015 14:17
file-atom: core.async, promises, atomic-reference
(ns afile.gambit-3
(:refer-clojure :exclude [deref])
(:require
[clojure.edn :as edn]
[clojure.pprint :refer [pprint]]
[clojure.core.async :refer [go <! put! chan]]
[clojure.test :refer [deftest is run-tests]]))
(defn- load-file!
[file init-value]
@zentrope
zentrope / gambit-1.clj
Created March 20, 2015 04:11
agent version of file based atom
(ns afile.gambit-1
(:refer-clojure :exclude [deref])
(:require
[clojure.edn :as edn]
[clojure.pprint :refer [pprint]]
[clojure.test :refer [deftest is run-tests]]))
(defn- load-file!
[file init-value]
(if (.exists file)
@zentrope
zentrope / file-backed-atom2.clj
Last active August 29, 2015 14:17
file-backed-atom2.clj
(ns afile.core
(:refer-clojure :exclude [deref])
(:require
[clojure.edn :as edn]
[clojure.pprint :refer [pprint]]
[clojure.test :refer [deftest is run-tests]]))
(defn- load-file!
[fname init-value]
(let [f (java.io.File. fname)]
@zentrope
zentrope / file-backed-atom.clj
Created March 18, 2015 01:25
File backed atom.
(ns afile.core
(:require
[clojure.edn :as edn]
[clojure.pprint :refer [pprint]]
[clojure.test :refer [deftest is run-tests]]))
(defn- load-file!
[fname init-value]
(let [f (java.io.File. fname)]
(if (.exists f)
@zentrope
zentrope / offscreen.js
Created January 18, 2015 17:09
three.js detect off-screen objects?
var frustum = new THREE.Frustum();
var cameraViewProjectionMatrix = new THREE.Matrix4();
// every time the camera or objects change position (or every frame)
camera.updateMatrixWorld(); // make sure the camera matrix is updated
camera.matrixWorldInverse.getInverse( camera.matrixWorld );
cameraViewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
frustum.setFromMatrix( cameraViewProjectionMatrix );