Skip to content

Instantly share code, notes, and snippets.

module MethodModifiers
def privatize
on_method_defined do |klass, method| klass, method
def memoize
on_method_defined do |klass, method| klass, method
jswanner / v2.3.18-v3.0.0.diff
Created April 28, 2014 22:46
Rails diff of v2.3.18 to v3.0.0
diff -Nr -U 1000 tmp/generated/v2.3.18/.gitignore tmp/generated/v3.0.0/.gitignore
--- tmp/generated/v2.3.18/.gitignore 1969-12-31 16:00:00.000000000 -0800
+++ tmp/generated/v3.0.0/.gitignore 2014-02-21 19:34:53.000000000 -0800
@@ -0,0 +1,4 @@
diff -Nr -U 1000 tmp/generated/v2.3.18/Gemfile tmp/generated/v3.0.0/Gemfile
--- tmp/generated/v2.3.18/Gemfile 1969-12-31 16:00:00.000000000 -0800
require 'redcarpet'
desc "generate index.html from"
file "index.html" => "" do |task|
puts "Processing to generate a new index.html..."
# `r` means we're using the "read" mode with the file
# we need a String for Redcarpet, it doesn't accept File objects.
string =, 'r') { |file| }
markdown =, extensions = {})
var ctrlKey = 17,
ctrlDown = false,
vKey = 86,
allowCtrlPaste = function(e){
if (ctrlDown && e.keyCode == vKey) {

This function automatically grabs the latest git tag and, based on keyword (major, minor, patch), adds a new tag. (e.g. git_tag patch for v1.2.0 would create v1.2.1)

Drop this into your ~/.bash_profile and run source ~/.bash_profile to use it.

You can find all of my dotfiles here:

jswanner / canary.rb
Last active August 29, 2015 14:06 — forked from mclosson/canary.rb
# SpiderOak now maintains a warrant canary so they can passively let their users know
# if they have been served a National Security Letter or other legal tool which
# prevents them from actively disclosing to their users that they are being coerced
# or forced into compromising the security or privacy of their userbase.

Keybase proof

I hereby claim:

  • I am jswanner on github.
  • I am jswanner ( on keybase.
  • I have a public key whose fingerprint is 1140 8F9C EAD0 C993 1C96 63E6 C154 4A94 D2DC 2F30

To claim this, I am signing this object:

class AddCategories < ActiveRecord::Migration
def self.up
add_column :tasks, :category, :string
def self.down
remove_column :tasks, :category
# last version had a bug:
# instead of inserting 1 million docs,
# it inserted 8000 docs then updated them 125 times
require 'rubygems'
require 'patron'
require 'json'
COUCH.timeout = 120
This example shows how to setup an environment running Rails 3 beta under 1.9.2-head with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell)) or do 'rvm reload'
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.2-head
# Switch to 1.9.2-head and gemset rails3, create if it doesn't exist.
∴ rvm --create use 1.9.2-head@rails3