Skip to content

Instantly share code, notes, and snippets.

Avatar
🐇

Christopher Blanchard cblanc

🐇
View GitHub Profile
View capybara cheat sheet
=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')
View rspec_rails_cheetsheet.rb
#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 Apr 22, 2014
grep for all non-ASCII Characters
View gist:11184617
grep --color='auto' -P -n "[\x80-\xFF]" file.csv
View gist:0d450af1bd7158053716
#!/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
View progressive-ace.htm
<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 () {
View gist:ea2a142fbab6f9551e7a
### 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:
View gist:776bc5d7d911c49c5c36
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 Nov 13, 2015
select outcode, array_to_string(array_agg(distinct parliamentary_constituency),',') from postcodes group by outcode
View outcodes_and_parliamentary_constituencies.csv
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 Nov 13, 2015
select outcode, array_to_string(array_agg(distinct parliamentary_constituency),',') from postcodes group by outcode
View outcodes_and_parliamentary_constituencies.csv
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 Aug 12, 2013
Gravatar Image Helper Function. Provide an email, it will return image_tag for corresponding gravatar. Pass in options hash as usual
View Rails - Gravatar Image Helper
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