Skip to content

Instantly share code, notes, and snippets.

# Add this as an initializer or to environments/development.rb for nicer logger output (thanks epitron for helping with this idea)
# Usage: logger.red "Blah"
# Shows messages in your log with a red background and bold, white text
class ActiveSupport::BufferedLogger
def red(m)
emphasized = "\e[1;1m\e[41m #{m} \e[0m"
debug(emphasized)
end
end
# Test from @jimweirich - make this test pass using Bindings
# hint: implement the ref method
def test_ref
x = :Hi
change_x_to_bye(ref{:x})
assert_equal :Bye, x
end
---
:verbose: true
:update_sources: true
:sources:
- http://gems.rubyforge.org/
- http://gems.github.com
:backtrace: false
:bulk_threshold: 1000
:benchmark: false
gem: --no-rdoc --no-ri
#!/usr/bin/env ruby
#
# usage: script/passenger_restarter
#
# ** Fork of Jonathan Penn's server_restarter to work with Passenger.
# Joe Fiorini (http://www.faithfulgeek.org)
#
# Rails autoloading, while nice in theory, frequently doesn't work. Since Rails 2.3+
# is so fast when completely reloading the server, I wrote this script to listen to the
# given directories, and kill/restart the server when any file is changed.
nnoremap <leader>m :call RunTestsForFile('')<cr>:redraw<cr>:call JumpToError()<cr>
function! RunTests(target, args)
silent ! echo
exec 'silent ! echo -e "\033[1;36mRunning tests in ' . a:target . '\033[0m"'
set makeprg=spec\ --require\ make_output_formatter\ --format\ Spec::Runner::Formatter::MakeOutputFormatter
silent w
exec "make " . a:target . " " . a:args
endfunction
#!/bin/bash
set -e
update_google_chrome() {
get_latest_revision_number
download_latest_revision
extract_code
install_chrome
}
#!/bin/bash
set -e
BUILD_URL='http://build.chromium.org/buildbot/snapshots/sub-rel-mac/'
update_google_chrome() {
get_latest_revision_number
download_latest_revision
extract_code
#!/usr/bin/env ruby
w3_dir = ARGV[0]
`cd #{ARGV[0]}`
`ctags --recurse=yes -f TAGS --totals=yes --exclude='*.html' --exclude='*.js' .`
module TraceCalls
def following(*syms, &block)
syms.each do |sym|
hook_method = "__#{sym}__hooked__"
self.class.send :alias_method, hook_method, sym
#private hook_method
self.class.send :define_method, sym do |*args|
puts "==> Calling #{sym} with #{args.inspect}"
result = send "__#{sym}__hooked__", *args

Introduction

Forward

One of Guido’s key insights is that code is read much more often than it
is written. The guidelines provided here are intended to improve the
readability of code and make it consistent across the wide spectrum of
Python code. As PEP 20 says, “Readability counts”.

A style guide is about consistency. Consistency with this style guide is