Skip to content

Instantly share code, notes, and snippets.

@mullr
mullr / gist:1223758
Created September 17, 2011 08:33
So many vecs!
(partial reduce
(fn [acc n]
(if (= (first (last acc)) n)
(vec (conj (vec (butlast acc)) (conj (last acc) n)))
(vec (conj acc [n]))))
[])
@mullr
mullr / jinja.coffee
Created February 17, 2012 15:36
jinja.coffee: a minuscule DI container for javascript/coffeescript
# jinja.coffee: a minuscule DI container for javascript/coffeescript
#
# Put your class dependencies under meta.needs and needs_modules, and
# you'll get a hash of whan you asked for as a constructor parameter. A
# useful idiom is to stash the whole thing in a property named 'd',
# for dependencies.
#
# class A
# @meta:
# needs: ["someParam"]
# let's have a race! the app needs to start before the testRunner hits it
app = require '../app'
app.start()
v = vows.describe('main json api').addBatch
'when requesting a bad top level':
topic: -> request "#{baseUrl}/bogus", @callback ; return
'it 404s':
(err, res, body) -> assert.equal res.statusCode, 404
@mullr
mullr / gist:2841816
Created May 31, 2012 08:13
A sane winston logging setup
winston = require 'winston'
level = 'info'
level = 'debug' if process.env.NODE_ENV is 'development'
levels =
debug: 0
info: 1
warn: 2
error: 3
@mullr
mullr / fixTemplates.rb
Created June 25, 2012 01:55
Remove headers from xCode templates
#!/usr/bin/ruby
require 'fileutils'
include FileUtils
files = `find /Applications/Xcode.app -path *.xctemplate/*.h -o -path *.xctemplate/*.m`.split("\n")
backupDir = File.expand_path "~/.xcTemplateBackup"
mkdir backupDir unless File.exists? backupDir
@mullr
mullr / gist:3042515
Created July 3, 2012 19:53
Add a pre-compile step in leiningen
(use 'robert.hooke)
(use ['leiningen.compile :rename {'compile 'compile-task}])
(prepend compile-task
(prn "hello"))
(defproject ...)
// hard-coded imperialism
if(! lang.equals("en")){
return;
}
@mullr
mullr / gist:4108781
Created November 19, 2012 03:24
Bring xcode to front
#! /usr/bin/env osascript
tell application "Xcode"
activate
end tell
(ns xml-test
(:use [clojure.test]
[clojure.data.zip.xml])
(:require [clojure.xml :as xml]
[clojure.zip :as zip]))
(defn parse-str [s]
(zip/xml-zip (xml/parse (new org.xml.sax.InputSource
(new java.io.StringReader s)))))