Skip to content

Instantly share code, notes, and snippets.

View cblanc's full-sized avatar
🐇

Christopher Blanchard cblanc

🐇
View GitHub Profile
=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')
#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)
@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
@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
<textarea name="my-xml-editor" data-editor="xml" rows="15"></textarea>
...
<textarea name="my-markdown-editor" data-editor="markdown" rows="15"></textarea>
...
<script src="//d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js"></script>
<script>
// Hook up ACE editor to all textareas with data-editor attribute
$(function () {
### Keybase proof
I hereby claim:
* I am cblanc on github.
* I am cablanchard (https://keybase.io/cablanchard) on keybase.
* I have a public key whose fingerprint is 4729 E526 B7E5 6D56 C66D 7A94 B587 6CD9 B123 1A48
To claim this, I am signing this object:
http://www.ensl.org/sounds/gather-1.mp3
http://www.ensl.org/sounds/gather-2.mp3
http://www.ensl.org/sounds/gather-3.mp3
http://www.ensl.org/sounds/gather-4.mp3
http://www.ensl.org/sounds/gather-5.mp3
@cblanc
cblanc / outcodes_and_parliamentary_constituencies.csv
Created November 13, 2015 13:55
select outcode, array_to_string(array_agg(distinct parliamentary_constituency),',') from postcodes group by outcode
AB10 Aberdeen North,Aberdeen South
AB11 Aberdeen North,Aberdeen South
AB12 Aberdeen North,Aberdeen South,West Aberdeenshire and Kincardine
AB13 Aberdeen South,West Aberdeenshire and Kincardine
AB14 Aberdeen South,West Aberdeenshire and Kincardine
AB15 Aberdeen North,Aberdeen South,West Aberdeenshire and Kincardine
AB16 Aberdeen North
AB21 Aberdeen North,Gordon,West Aberdeenshire and Kincardine
AB22 Gordon
AB23 Aberdeen North,Gordon
@cblanc
cblanc / outcodes_and_parliamentary_constituencies.csv
Created November 13, 2015 13:55
select outcode, array_to_string(array_agg(distinct parliamentary_constituency),',') from postcodes group by outcode
AB11 Aberdeen North,Aberdeen South
AB12 Aberdeen North,Aberdeen South,West Aberdeenshire and Kincardine
AB13 Aberdeen South,West Aberdeenshire and Kincardine
AB14 Aberdeen South,West Aberdeenshire and Kincardine
AB15 Aberdeen North,Aberdeen South,West Aberdeenshire and Kincardine
AB16 Aberdeen North
AB21 Aberdeen North,Gordon,West Aberdeenshire and Kincardine
AB22 Gordon
AB23 Aberdeen North,Gordon
@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