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
function gdist { | |
basename="$1" | |
basesha="git merge-base HEAD $basename" | |
git diff "$basesha" "$basename" | |
} |
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
#!/bin/sh | |
# check for where the latest version of IDEA is installed | |
IDEA=`ls -1d /Applications/IntelliJ\ * | tail -n1` | |
wd=`pwd` | |
# were we given a directory? | |
if [ -d "$1" ]; then | |
# echo "checking for things in the working dir given" | |
wd=`ls -1d "$1" | head -n1` |
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
(function(){ | |
var options = { | |
yesMessage: "YES!", | |
noMessage: "No", | |
target: document.getElementById("isitlaksatime"), | |
wrapper: document.body, | |
day: 5, // 5 for friday | |
hour: 12 // 12 for noon! | |
}; |
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
# Some handy-dandy sub-domain steps for use with Capybara if you're using SubdomainFu | |
def get_base_url | |
# NOTE: I'm defining SITE_URL higher up somewhere. You might want to change that piece. | |
base_url = SITE_URL.split('.').reject { |piece| SubdomainFu.mirrors.include? piece }.join('.') | |
end | |
When /^(?:|I )visit (.+) for the subdomain "([^\"]*)"$/ do |new_path, subdomain| | |
new_url = get_base_url | |
new_url = subdomain + "." + new_url if subdomain.present? |
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
# Determines if a particular ActiveRecord model or form object has errors on it. | |
# The method returns: | |
# - false if the object doesn't respond to #errors | |
# - true if the array of errors on the object is not empty | |
# - false in all other cases. | |
# | |
# You can optionally scope the check to look for specific errors. | |
# - In the case of a symbol, it will return a subset of errors as returned by the ActiveRecord::Errors#on(model) method | |
# - In the case of a String or Regexp, The errors array will be reduced by selecting only those who have keys containing the specified string/regexp to match. | |
# |
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
<html> | |
<body> | |
<div id="wrapper"> | |
<%# Huzzah! I can render messages way outside the bounds of my content structure! %> | |
<div id="messages"> | |
<%= yield :messages %> | |
</div> | |
<section id="main"> | |
<nav class="sidebar"> |
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
// You can try running these in FireBug console on the above html file. | |
$x("//li[@id='two']//preceding::li") | |
// => [ li#first, li#second, li#third, li#one ] | |
$x("//li[@id='two']//preceding-sibling::li") | |
// => [ li#one ] | |
$x("//ul[@class='outside']/li[1]//preceding::li") |
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
string = "this is a string" | |
string.split("is") #=> ["th", " ", " a string"] | |
string.split("is a") #=> ["this ", " string"] | |
first, last = string.split("is a") | |
puts first #=> "this " | |
puts last #=> " string" |
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
Feature: Application live validations | |
I want validation errors to appear as soon as they can be | |
In order to give feedback to the user as quickly as possible | |
Background: # features/application_live_validations.feature:5 | |
Given a user exists with email: "[email protected]", first_name: "Test", last_name: "Man" # features/step_definitions/pickle_steps.rb:4 | |
[2010-07-14 08:38:38] INFO WEBrick 1.3.1 | |
[2010-07-14 08:38:38] INFO ruby 1.8.7 (2009-06-12) [universal-darwin10.0] | |
[2010-07-14 08:38:38] INFO WEBrick::HTTPServer#start: pid=47066 port=9887 | |
And I log in as that user # features/step_definitions/user_steps.rb:21 |
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
# Now I can do stuff like this! | |
# ... | |
When I follow "Personal Details" | |
Then I should see an inline error "can't be blank" for the following formtastic fields: | |
| label | within | | |
| Full Name | .identity | | |
| Date of birth | .identity | | |
| Gender | .identity | | |
| Marital status | .citizenship | | |
And I should see an inline error "must be selected" for the formtastic field "Title" within ".identity" |