Skip to content

Instantly share code, notes, and snippets.

View cblanc's full-sized avatar
🐇

Christopher Blanchard cblanc

🐇
View GitHub Profile
@cblanc
cblanc / gist:0d450af1bd7158053716
Created August 21, 2014 16:38
Diff All Files
#!/bin/sh
git diff --name-only "$@" | while read filename; do
git difftool "$@" --no-prompt "$filename" &
done
# Credit: http://blog.codefarm.co.nz/2009/08/git-diff-and-difftool-open-all-files.html
@cblanc
cblanc / gist:11184617
Created April 22, 2014 15:57
grep for all non-ASCII Characters
grep --color='auto' -P -n "[\x80-\xFF]" file.csv
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
$ curl https://api.ideal-postcodes.co.uk/v1/postcodes/ID11QD?api_key=ak_iddqdidkfaidchoppers&callback=foo
# result =>
foo && foo({"result":[
{
"postcode":"ID1 1QD",
"post_town":"LONDON",
"line_1":"Kingsley Hall",
"line_2":"Powis Road",
"line_3":""
@cblanc
cblanc / Rails - Gravatar Image Helper
Created August 12, 2013 16:47
Gravatar Image Helper Function. Provide an email, it will return image_tag for corresponding gravatar. Pass in options hash as usual
def gravatar_image(email, options = {})
gravatar_url = "http://www.gravatar.com/avatar"
gravatar_hash = Digest::MD5.hexdigest(email.downcase.strip)
image_tag "#{gravatar_url}/#{gravatar_hash}", options
end