Skip to content

Instantly share code, notes, and snippets.

@logankoester
logankoester / simple_ar_benchmark.rb
Created August 17, 2011 20:18
Simple benchmarking for ActiveRecord Queries in rails console
# Give it two procs to compare
def bm(o, n); reload!; puts "Running 10 times"; Benchmark.bmbm(10) { |x| x.report('Old Query:') { @olr = o.call }; x.report('New Query:') { @nr = n.call } }; reload!; puts 'Old Result:' ; table(@olr); puts 'New Result'; table(@nr); end
@logankoester
logankoester / Gemfile
Last active December 25, 2015 04:19
Serving static nanoc output with Unicorn instead of WEBrick for faster development.
source 'https://rubygems.org'
gem 'unicorn'
gem 'rack'
gem 'rack-rewrite'
@logankoester
logankoester / precompute.underscore.coffee
Created September 29, 2013 03:28
Recursively map any functions to their returned value. This function will modify the passed object.
# Recursively map any functions to their returned value.
# This function will modify the passed object.
_.mixin
precompute: (object) ->
functions = @functions object
try
keys = @keys object
objects = @filter keys, (key) =>
@isObject(object[key])
catch
@logankoester
logankoester / Gruntfile.coffee
Created July 31, 2013 07:17
Splitting an overgrown Gruntfile into multiple files
#global module:false
module.exports = (grunt) ->
# Inject project configuration from files
gruntConfigDir = __dirname + '/grunt/'
require('fs-walk').walkSync gruntConfigDir, (baseDir, filename, stat) ->
if match = filename.match(/^(.*)\.coffee$/)
grunt.config.set(match[1], require(baseDir + filename)(grunt))
, (err) -> if err then console.log(err)
# This configuration should feel familiar to screen & vi users.
# split windows like vim
# vim's definition of a horizontal/vertical split is reversed from tmux's
bind s split-window -v
bind v split-window -h
# move around panes with hjkl, as one would in vim after pressing ctrl-w
bind h select-pane -L
bind j select-pane -D
# This configuration should feel familiar to screen & vi users.
# split windows like vim
# vim's definition of a horizontal/vertical split is reversed from tmux's
bind s split-window -v
bind v split-window -h
# move around panes with hjkl, as one would in vim after pressing ctrl-w
bind h select-pane -L
bind j select-pane -D
@logankoester
logankoester / adb-record.sh
Last active October 14, 2015 14:13
Record, merge, and accelerate Android screen capture
#!/usr/bin/env bash
# Repeatedly records Android screen capture to files 180 seconds in length
# until Ctrl+C, then pulls those files to the desktop, merges them into
# one video, generates an additional 8x speed version (*-8x.mp4) and cleans
# up the intermediary files.
# Depends on: ffmpeg, adb
# Usage: $ adb-record <name> # => ./name.mp4
@logankoester
logankoester / hydra spinner 23x16
Created November 30, 2012 15:01
hydra spinners
<style>
#facebookG{
width:23px}
.facebook_blockG{
background-color:#F27521;
border:1px solid #D8D8D9;
float:left;
height:16px;
margin-left:1px;

Wizard Island 2012

We will be camping Friday and Saturday night at sites 87 & 88 on Lake George's Long Island, one of the southernmost islands 4.41 miles by kayak from the Village.

Date Friday September 21st - Sunday September 22nd

Cost $98/person

Limit 8 wizards

@logankoester
logankoester / sandboxed_ads.html
Created June 14, 2012 03:33
Sandboxing 3rd-party ad code
<html>
<head>
<script type="text/javascript" src="//caja.appspot.com/caja.js"></script>
<script type="text/javascript">
caja.initialize({ cajaServer: 'https://caja.appspot.com/', debug: true });
// Force all network requests to use HTTPS.
// Prevents Insecure Content errors when the host page was loaded securely.
var uriPolicy = {
rewrite: function(uri) { return( uri.replace(/^http:/, 'https:') ); }