Skip to content

Instantly share code, notes, and snippets.

View const_lookup.rb
class Outer
puts Module.nesting
A = 'outer'
end
puts Outer::A #=> outer
class Outer
class Inner
puts Module.nesting
puts A #=> outer
@campbell
campbell / run-git-bisect-function.md
Created Mar 31, 2015
Automated GIT BISECT Bash function
View run-git-bisect-function.md

Use this script to automatically find where a SPEC fail was introduced. You can add it to .bash_profile.

Syntax: run_git_bisect <bad SHA> <good SHA> <failing test file:number>

function run_git_bisect() {
  [ "$#" -eq 3 ] || die "You must provide the bad SHA, good SHA and the failing test filename[:number]"
  
  git bisect reset
@campbell
campbell / gist:6041801
Created Jul 19, 2013
Database management for Heroku production apps. Backup locally and restore to either the local or production database.
View gist:6041801
namespace :msc do
namespace :db do
APP = 'fake-app-namer'
desc 'Backup the Postgres db'
task :backup => :environment do
`heroku pgbackups:capture --app #{APP}`
`curl -o #{backup_filename} \`heroku pgbackups:url --app #{APP}\``
end
View .tmux.conf
# remap prefix to Control + q
set -g prefix C-q
unbind C-b
bind C-a send-prefix
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
# quick pane cycling
View .vimrc with Vundle
" Install Vundle first:
" git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
"
" Launch vim and run :PluginInstall
" http://stackoverflow.com/questions/10778078/vim-colorscheme-executing-but-not-changing-colors
set t_Co=256
" https://github.com/tpope/vim-pathogen
View .bash_profile
#!bash
echo 'Applying ~/.git-completion.bash code-completion stuff...'
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.