Skip to content

Instantly share code, notes, and snippets.

@johntrimble
johntrimble / RESULTS.md
Last active Aug 29, 2015
ClojureScript Collections Performance
View RESULTS.md

Using V8, I got the following results when compiling performance.cljs with advanced mode:

[data array-data], (js/sumXsAndYsJs data), 1000 runs, 41 msecs
[data array-data], (sumsXsAndYsWithDotimesOnArrayNativeFieldAccessAndMutableLocals data), 1000 runs, 114 msecs
[data array-data-records], (sumsXsAndYsWithDotimesOnArrayNativeFieldAccessAndMutableLocals data), 1000 runs, 124 msecs
[data vec-data-records], (sumsXsAndYsWithDotimesNativeFieldAccessAndMutableLocals data), 1000 runs, 362 msecs
[data vec-data-records], (sumXsAndYsWithLoopAndNativeFieldAccess data), 1000 runs, 1115 msecs
[data vec-data-records], (sumXsAndYsWithLoop data), 1000 runs, 2065 msecs
[data vec-data-array-map], (sumXsAndYsWithLoop data), 1000 runs, 2530 msecs
@johntrimble
johntrimble / install-sixaxis.sh
Last active Aug 9, 2018
PS3 DualShock 3 controller on the Raspberry Pi
View install-sixaxis.sh
#!/bin/sh
#############################################################################
# This script installs the sixad driver for the Sixaxis PS3 Controller on a
# fresh install of the official Raspbian image (2014-01-07) for the Raspberry
# Pi.
#
# Setup:
# Attach a compatible Bluetooth adapter to the Pi. You can find a list of
# compatible adapters at <http://elinux.org/RPi_USB_Bluetooth_adapters>. I
# use the Sabrent BT-USBT and it works fine.
@johntrimble
johntrimble / useful-git-commands.md
Last active Jan 3, 2016
These are useful Git commands I keep forgetting.
View useful-git-commands.md

Listing branches by most recent commit:

git for-each-ref --sort=-committerdate refs/heads/

Listing branches not yet merged:

git branch --no-merged <BRANCH_NAME>
@johntrimble
johntrimble / generate-ubuntu-ami-mapping.py
Created Jun 21, 2012
Python script for generating a mapping of regions to the latest AMI for a given Ubuntu distribution and instance type for use in CloudFormation template.
View generate-ubuntu-ami-mapping.py
#!/usr/bin/env python
import urllib2
import json
import itertools
import sys
import argparse
def groupby(data, key):
kf = lambda x: x[key]
result = itertools.groupby(sorted(data,None,kf), kf)
@johntrimble
johntrimble / gist:1954826
Created Mar 2, 2012
Wrapping functions in Java sucks.
View gist:1954826
public <A,B> Function<Function<A,B>, Function<A,B>> requiresTx() {
return new Function<Function<A,B>, Function<A,B>>() {
@Override
public Function<A,B> apply(final Function<A,B> f) {
return new Function<A,B>() {
public B apply(final A a) {
return txService.required(new Callable<B>() {
public B call() throws Exception {
return f.apply(a);
};