This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# ActiveSupport has a more modern syntax now. Pipe any old-style | |
# ActiveSupport::TestCase suites into this file and have the syntax | |
# updated. For when you can't use Shoulda or RSpec but you still | |
# want to look sexy. | |
# | |
# Before: | |
# | |
# def test_guy_can_do_stuff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias djgoatboy="curl -L `curl -s http://twitter.com/statuses/user_timeline/djgoatboy.rss | grep "title>djgoatboy:" | head -n 1 | cut -c 23-47` > djgoatboy.mp3; afplay djgoatboy.mp3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby1.9 | |
# | |
# In Javascript you can add a function to an object like so: | |
# | |
# obj.perform = function(){ ... stuff to do ...} | |
# | |
# But in Ruby 1.8 there's always been a problem where a method | |
# defined with `define_method` won't be able to take a block. | |
# So you'd never be able to do something like this: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(sent to Jack in the Box contact address) | |
Ahoy! | |
My name is Jack. It's a pretty good name. I love to eat at | |
Jack in the Box and I'd extra-double love to wear the oversized | |
Jack™ head around town here in Seattle. | |
Could you send me a huge Jack™ head that I can wear as I go | |
from cafe to cafe (I work for a startup and it's all telecommuting)? | |
I'd be happy to abide by any rules of conduct you might have for | |
wearing the Jack™ head. I'd be willing to sign something to that effect. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// USAGE: | |
// preloadImage('/images/something_over.png') | |
// preloadImage('/images/other_over.gif') | |
// preloadImage.load() | |
preloadImage = (function(){ | |
var images = [] | |
var placeholder = new Image() | |
var instantiate = function(idx){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :hoptoad do | |
desc "Makes all Rake (production) errors go to Hoptoadapp.com" | |
task :catch do | |
class Rake::Task | |
def execute_with_hoptoad(*args) | |
execute_without_hoptoad(*args) | |
rescue => e | |
require File.expand_path(File.dirname(__FILE__)+'/../../config/environment') | |
HoptoadNotifier.notify e | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from: http://pivotallabs.com/users/alex/blog/articles/865-monkey-patch-du-jour | |
module ActiveRecord | |
module ConnectionAdapters | |
class AbstractAdapter | |
def log_info(sql, name, ms) | |
if @logger && @logger.debug? | |
@logger.debug("#{sql}, #{name}, #{ms}") | |
c = caller.detect{|line| line !~ /(activerecord|active_support|__DELEGATION__|\/lib\/|\/vendor\/plugins|\/vendor\/gems)/i} | |
c.gsub!("#{File.expand_path(File.dirname(RAILS_ROOT))}/", '') if defined?(RAILS_ROOT) | |
name = '%s (%.1fms) %s' % [name || 'SQL', ms, c] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this in your ~/.irbrc | |
class Object | |
def console_reminder | |
puts "You're not in Terminal. CMD-} until you're out of the console." | |
end | |
# replace these with your common terminal commands | |
%w{gs gp gl cd l rake}.each do |cmd| | |
eval "alias #{cmd} console_reminder" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'faker' | |
require 'faker' | |
account_id = 4 | |
randomize = 'PostgreSQL' == ActiveRecord::Base.connection.adapter_name ? 'RANDOM()' : 'RAND()' | |
# Makes a bunch of different types of events per day at a random time during work hours | |
(30.days.ago.to_date..90.days.from_now.to_date).each do |date| | |
rand(3).times do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for source in `find app test lib config -name *.rb`; do | |
if [ 2 = `egrep -c -v "(^#)|(^\s*$)" $source` ]; then | |
echo $source is an empty class or module definition; | |
fi; | |
done; |
OlderNewer