Skip to content

Instantly share code, notes, and snippets.

View arnab's full-sized avatar

Arnab Deka arnab

View GitHub Profile
the_clone = p.clone
the_dup = p.dup
require 'benchmark'
require 'logger'
class LoggerBenchmark
def initialize
@logger = Logger.new("/dev/null")
end
def benchmark
n = 10000
@arnab
arnab / octopress_migration.sh
Last active December 11, 2015 10:08
Things I had to do "differently" to migrate site to octopress
# Without setting thr LANG, I'd get errors from Ruby like this:
# YAML Exception reading 2012-09-23-state-of-e-commerce-in-india.md: invalid byte sequence in US-ASCII
# /Users/arnabdeka/Dropbox/websites/arnab.github.com/plugins/backtick_code_block.rb:13:in `gsub': invalid byte sequence in US-ASCII (ArgumentError)
# from /Users/arnabdeka/Dropbox/websites/arnab.github.com/plugins/backtick_code_block.rb:13:in `render_code_block'
# ...
# I got the idea while reading this rubygems issue: https://github.com/rubygems/rubygems/issues/314
export LANG=en_US.utf-8
@arnab
arnab / setup.sh
Created June 11, 2012 10:49
Set up Rails 3.2 with Rspec and Cucumber
# Works with Rails 3.2.x (and this keeps changing due to the large amounts of gems and their author's philosophies differing all the time)
# 1. Create new Rails app
rails new <thing> --skip-testunit
# 2. Add the following to Gemfile:
group :development, :test do
gem 'rspec-rails'
gem 'cucumber-rails', :require => false
@arnab
arnab / get-emacs-starter-kit.sh
Created June 3, 2012 10:29
Emacs setup steps (for GNU Emacs with Clojure and CommonLisp). See http://www.arnab-deka.com/notes/emacs-setup/
mv ~/.emacs.d ~/.emacs.d.bak
cd ~/.emacs.d
git clone <your-clone-of-esk>
@arnab
arnab / .travis.yml
Created March 25, 2012 20:11
set up test db before running tests in travis.ci
before_script: "bundle exec rake db:migrate"
@arnab
arnab / show_available_errors.rb
Created February 23, 2012 17:29
Show available errors in a Ruby environment (so you know to raise the right error)
# From http://weblog.jamisbuck.org/2007/3/7/raising-the-right-exception
exceptions = []
tree = {}
ObjectSpace.each_object(Class) do |cls|
next unless cls.ancestors.include? Exception
next if exceptions.include? cls
next if cls.superclass == SystemCallError # avoid dumping Errno's
exceptions << cls
cls.ancestors.delete_if {|e| [Object, Kernel].include? e }.reverse.inject(tree) {|memo,cls| memo[cls] ||= {}}
def some_method(other_method, args)
puts "before"
other_method.call args
puts "after"
end
def other_method(stuff)
puts "other_method called with #{stuff.inspect}"
end
@arnab
arnab / .tmux.conf
Created January 25, 2012 20:23
My dotfiles
# set-option -g prefix C-a
bind-key C-b last-window
unbind % # Remove default binding since we’re replacing
bind | split-window -h
bind - split-window -v
# Set status bar
set -g status-bg black
set -g status-fg white