Skip to content

Instantly share code, notes, and snippets.

@bohford
bohford / Config.groovy
Created June 28, 2015 21:06
Add t2, m4, c4, d2 instances to Asgard config
customInstanceTypes = [
new InstanceTypeData(linuxOnDemandPrice: 5.520, hardwareProfile:
new HardwareProfile(instanceType: 'd2.8xlarge',
family: 'Storage Optimized', group: 'd2',
size: 'Octuple Extra Large', arch: '64-bit', vCpu: '36', ecu: '116',
mem: '244.0', storage: '24 x 2000', ebsOptim: 'Yes',
netPerf: '10 Gigabit'
)
),
new InstanceTypeData(linuxOnDemandPrice: 2.760, hardwareProfile:
@bohford
bohford / apple_device_identifier_to_name.rb
Created January 14, 2014 19:56
Ruby hash mapping Apple iOS model identifiers to human-readable device names. Maybe someone, somewhere will find this useful because I sure as shit loved typing all this in myself.
APPLE_DEVICE_IDENTIFIER_TO_NAME = {
"iPad1,1" => "iPad 1 (2010)",
"iPad2,1" => "iPad 2 Wi-Fi (2011)",
"iPad2,2" => "iPad 2 Wi-Fi+GSM (2011)",
"iPad2,3" => "iPad 2 Wi-Fi+CDMA (2011)",
"iPad2,4" => "iPad 2 Wi-Fi (2012)",
"iPad3,1" => "iPad 3 Wi-Fi (2012)",
"iPad3,2" => "iPad 3 Wi-Fi+CDMA (2012)",
"iPad3,3" => "iPad 3 Wi-Fi+GSM (2012)",
"iPad3,4" => "iPad 4 Wi-Fi (2012)",
@bohford
bohford / stupid_jruby_tricks.rb
Created December 1, 2011 08:10
Stupid JRuby tricks
# JRuby 1.6.5 + Java 6
# 01 - Small Array Instantiation
# A new, empty array preallocates memory for 16 elements
# An array that starts non-empty and is subsequently cleared will only have memory allocated for one element
# Ergo, if you know your array will stay small, define with [nil].clear
empty_array = [] # 152 bytes
cleared_array = [nil].clear # 32 bytes
@bohford
bohford / redis_monitor_parser.rb
Created July 14, 2011 08:40
Redis monitor log parser
# redis-cli monitor > log.redis
puts "Scanning redis log..."
ops = Hash.new(0)
lines = File.readlines('log.redis'); true
start_time = Time.at(lines[1].split(' ').first.to_f)
end_time = Time.at(lines.last.split(' ').first.to_f)
@bohford
bohford / tmux.conf
Created January 23, 2011 03:22
My terrible tmux config, a work in progress for sure
set -g prefix C-q
unbind C-b
bind C-q send-prefix
# C-a u split window vetically
bind u split-window
# C-a i split window horizontally
bind i split-window -h
# C-a o donk off pane
bind o kill-pane
@bohford
bohford / zpop.diff
Created December 21, 2010 14:44
ZPOP and ZREVPOP for Redis 2.2.0 series
diff --git a/src/help.h b/src/help.h
index 51613c9..196f90e 100644
--- a/src/help.h
+++ b/src/help.h
@@ -632,7 +632,17 @@ struct commandHelp {
"destination numkeys key [key ...] [WEIGHTS weight] [AGGREGATE SUM|MIN|MAX]",
"Add multiple sorted sets and store the resulting sorted set in a new key",
4,
- "1.3.10" }
+ "1.3.10" },
module AutoloadMissingConstants
# Automatically loads constants that Ruby doesn't know about when unmarshalling in the given block. This triggers
# Rails/ActiveSupport's smart autoloading code via constantize. Adapted from cache_fu/cache_methods.rb:214
#
# ==== Parameters
#
# &block:: Unmarshalling block.
#
# ==== Raises
// Given the following javascript code:
function countdown (num) {
for (var i = 0; i <= num; i += 1) {
setTimeout(function () {
alert(num - i);
}, i * 1000);
}
}
@bohford
bohford / have_error_on.rb
Created August 3, 2010 19:31
An RSpec2 matcher for ActiveModel errors.
# Hey look, a matcher for RSpec2 that will check for an error on an ActiveModel attribute, given a I18n key and interpolation options.
#
# I feel like this should exist somewhere already, I am probably wrong though.
#
# @foo.should have_error_on(:bar, :bar_is_too_baz, :quux => :corge)
#
module RSpec
module Matchers
class HaveErrorOn
@bohford
bohford / carbon.md
Created November 5, 2009 21:53 — forked from defunkt/carbon.md

Vim

autocmd BufWritePre * :%s/\s\+$//e

Emacs

(add-hook 'before-save-hook 'delete-trailing-whitespace)

Textmate