Skip to content

Instantly share code, notes, and snippets.

View anildigital's full-sized avatar
:octocat:

Anil Wadghule anildigital

:octocat:
View GitHub Profile
@anildigital
anildigital / pless.sh
Created November 12, 2008 17:34 — forked from defunkt/pless.sh
# my new favorite bashrc function
# quickly inspect source files in style
function pless {
pygmentize $1 | less -r
}
class Array
def second
self[1]
end
end
@anildigital
anildigital / gist:28382
Created November 24, 2008 04:56 — forked from lifo/gist:23541
require 'rubygems'
require 'ruby-prof'
RubyProf.measure_mode = RubyProf::PROCESS_TIME
RubyProf.start
require 'config/environment'
results = RubyProf.stop
File.open "loading-graph.html", 'w' do |file|
RubyProf::GraphHtmlPrinter.new(results).print(file)
@anildigital
anildigital / .vimrc
Created November 26, 2008 20:59 — forked from defunkt/.vimrc
set foldmethod=syntax
set foldlevelstart=1
set foldnestmax=5
let javaScript_fold=1
set textwidth=0
"set foldclose=all
"colorscheme torte
" os x backspace fix
require "benchmark"
Benchmark.bm do |x|
5.times do
x.report do
o = Object.new
10000.times do
def o.method; end
end
end
end
@anildigital
anildigital / scaling.rb
Created December 20, 2008 05:03 — forked from lifo/scaling.rb
# Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
class Scaling
def self.call(env)
if env["PATH_INFO"] =~ /^\/scaling/
[200, {"Content-Type" => "text/html"}, ["Hello, World!"]]
else
[404, {"Content-Type" => "text/html"}, ["Not Found"]]
end

Note to Self

Be Confident

Tests build confidence. Write 'em. They'll save your ass, and they'll let you take a chainsaw to your code without being afraid of unintended consequences.

Be Lazy

# SUPER DARING APP TEMPLATE 1.0
# By Peter Cooper
# Link to local copy of edge rails
inside('vendor') { run 'ln -s ~/dev/rails/rails rails' }
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
##
# command aliases
##
alias die="killall"
alias ls="ls -G" # default settings for list (colors)
alias l="ls -GFh"
alias ll="ls -lFGh"
alias la="ls -laFGh"
alias dir="ls -asGh" # setup dir command just in case ;)
@anildigital
anildigital / evil.rb
Created January 13, 2009 11:38 — forked from lifo/evil.rb
module Rack
class Evil
def initialize(app)
@app = app
end
def call(env)
catch(:response) { @app.call(env) }
end
end