Skip to content

Instantly share code, notes, and snippets.

View chrisbraddock's full-sized avatar

Chris Braddock chrisbraddock

View GitHub Profile
@chrisbraddock
chrisbraddock / javascript_argument_default_value.js
Last active December 14, 2015 01:19
Set a default parameter value for a JavaScript function
// http://stackoverflow.com/questions/894860/set-a-default-parameter-value-for-a-javascript-function
function foo(a, b)
{
a = typeof a !== 'undefined' ? a : 42;
b = typeof b !== 'undefined' ? b : 'default_b';
...
}
# http://hocuspokus.net/2009/07/add-git-and-svn-branch-to-bash-prompt/ and http://railstips.org/blog/archives/2009/02/02/bedazzle-your-bash-prompt-with-git-info/
parse_git_branch () {
#git name-rev HEAD 2> /dev/null | sed 's#HEAD\ \(.*\)# (git::\1)#'
#git branch 2> /dev/null | grep "" | sed -e 's/*//g'
#git branch 2> /dev/null| sed -n '(^\*/s/^\* //p'
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo " (git::"${ref#refs/heads/}")"
}
# detect whether any changesets are stashed
@chrisbraddock
chrisbraddock / gist:1817923
Created February 13, 2012 16:13
rvm get head
chris@local:/Users/chris:rvm get head
Original installed RVM version:
rvm 1.9.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]
remote: Counting objects: 371, done.
remote: Compressing objects: 100% (291/291), done.
remote: Total 371 (delta 51), reused 190 (delta 34)
Receiving objects: 100% (371/371), 860.58 KiB, done.
@chrisbraddock
chrisbraddock / gist:1511475
Created December 22, 2011 19:15
Write Better Cukes
# question regarding http://blog.steveklabnik.com/2011/12/20/write-better-cukes-with-the-rel-attribute.html
#
When /^I choose to edit the article "([^"]*)"$/ do |article_name|
article = Article.find_by_name(article_name)
find("//a[@href='#{edit_article_path article}']").click
end
str = javascript_include_tag '/vendor/javascripts/jquery/jquery-1.6.1.js'
str += "\n"
str += javascript_include_tag '/vendor/javascripts/jquery-ujs/rails.js'
str += "\n"
str += javascript_include_tag '/vendor/javascripts/jquery-ui/jquery-ui-1.8.13.custom.min.js'
str += "\n"
str
chris@local:/Users/chris/foo:bundle check
The Gemfile's dependencies are satisfied
chris@local:/Users/chris/foo:rails s
/Users/chris/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems.rb:900:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /Users/chris/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems.rb:248:in `activate'
from /Users/chris/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems.rb:1276:in `gem'
from /Users/chris/.rvm/gems/ruby-1.9.2-head@foo/bin/rails:18:in `<main>'
chris@local:/Users/chris/foo: