Instantly share code, notes, and snippets.

View .vimrc
" Christopher Meiklejohn (cmeiklejohn@devio.us)
" .vimrc -- parts stolen from all over the place.
set nocompatible " We don't want vi compatibility.
set viminfo^=!
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
View perm.rb
#!/usr/bin/ruby
require 'openssl'
require 'base64'
require 'rubygems'
require 'aws'
# Open master s3 connection
master_s3 = Aws::S3.new(
'key',
View .tmux.conf
# Setup status bar
set -g status-bg black
set -g status-fg white
set -g message-bg black
set -g message-fg green
set -g status-left '#[fg=green]#H #S'
# Highlight active window
set-window-option -g window-status-current-attr bright
set-window-option -g window-status-current-fg white
View rails 3 key method deprecation
def to_key
new_record? ? nil : [self.send(self.class.primary_key)]
end
View mongodb index question
> db.collection.getIndexes();
[
{
"name" : "_id_",
"ns" : "test.collection",
"key" : {
"_id" : 1
}
},
{
View AnotherController.rb
# Rails 2 way.
SomeController.new.process( request, response )
# Rails 3 way.
status, headers, body = SomeController.action(:show).call(request.env)
response = ActionDispatch::Response.new(status, headers, body)
self.response_body = response
View microposts_controller.rb
class MicropostsController < ApplicationController
before_filter :set_micropost, :only => [:show, :edit, :update, :create, :new]
before_filter :authenticate, :only => [:create, :destroy] # Same here?
# Omitted.
def destroy
@micropost.destroy
redirect_back_or root_path
View utf8_header.rb
class Utf8Header < Thor
desc "add", "Add Content UTF-8 on top of all .rb/.feature files"
# copy & pasted from https://gist.github.com/738245
def add
files = Array.new
["*.rb", "*.rake","*.feature"].each do |extension|
files.concat(Dir[ File.join(Dir.getwd.split(/\\/), "**", extension) ])
end
files.each do |file|
View parse-me.rb
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'capybara-webkit'
Capybara.run_server = false
Capybara.current_driver = :webkit
Capybara.app_host = 'http://www.google.com'
module MyCapybaraTest
View array_regexp_match.rb
class Array
def include_by_regexp_or_string?(str)
any? do |o|
o.is_a?(Regexp) ? o =~ str : o == str
end
end
end