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
# Testing exception_notifier the easy way: | |
class ActionController::Base | |
alias :rescue_action_locally :rescue_action_in_public | |
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
# Cycling Through A Set of Strings With Sequency | |
# | |
# It's pretty easy to use Sequency (http://github.com/commondream/sequency) to cycle through a set of | |
# strings when creating factories. | |
# | |
# I got this data from the US Social Security Administration website (http://www.ssa.gov/OACT/babynames/) | |
Sequence.define(:first_name) do |i| | |
names = %w( Jacob Emily Michael Isabella Ethan Emma Joshua Ava Daniel Madison Christopher | |
Sophia Anthony Olivia William Abigail Matthew Hannah Andrew Elizabeth ) |
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
-- Script to display the names of files that are missing from your iTunes Library | |
-- Adapted from the script at http://www.macosxhints.com/article.php?story=2007031309145927 | |
tell application "iTunes" | |
set thePlaylist to library playlist 1 | |
set musicFiles to the file tracks of thePlaylist | |
repeat with mf in musicFiles | |
--the name of mf as string | |
set hasLoc to "" |
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
# Getting postgres gem to install on OS X requires that you have the ARCHFLAGS environment variable set | |
# correctly | |
sudo env ARCHFLAGS="-arch i386" gem install postgres |
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
# Reusable mocking of ActiveResource | |
# | |
# I use this technique when I need to mock ActiveResource in several tests and it gets a bit too keyboard | |
# heavy to use the default mechanism. | |
# Shortcut for typing ActiveResource::HttpMock.respond_to | |
def ar_mock(&block) | |
ActiveResource::HttpMock.respond_to(&block) | |
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
I'm thinking that the syntax for Industrial Revolution will be something like this: | |
Defining a Factory | |
================== | |
Factory.for Cat do | |
defaults do | |
cat = Cat.new | |
cat.name = "Mr. Whiskers" | |
cat.color = "Yellow" |
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
# My my.cnf file on my local system. Keeps me from having to type in -u root every time I run MySQL | |
[client] | |
user=root |
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
# My command prompt, ripped from someone online that I don't have a link for. Sorry! | |
function git_current_branch { | |
git branch 2>/dev/null | awk '/^\* /{print " " $2}' | |
} | |
function git_dirty { | |
git status 2>/dev/null | wc -l | awk '{if ($1 > 2) print "*"}' | |
} | |
export PS1="[\w\$(git_current_branch)\$(git_dirty)]: " |
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
# Using mk-table-checksum | |
# Setting up the checksums from the master | |
mk-table-checksum --replicate maatkit.checksum localhost | |
# Checking the checksums on the slave | |
mk-table-checksum --replicate maatkit.checksum --replcheck localhost |
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
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; | |
NSDateComponents *comps = [[NSDateComponents alloc] init]; | |
[comps setDay:-7]; | |
NSDate *weekAgo = [calendar dateByAddingComponents:comps toDate:self.currentDate options:0]; |
OlderNewer