- Threadless gift certificates
- iTunes store credit
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 parse_git_branch { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo "("${ref#refs/heads/}")" | |
} | |
e=`printf "\033"` | |
end="$e[0m" | |
red="$e[1;31m" | |
green="$e[1;32m" | |
yellow="$e[1;33m" |
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
# Write some classes to keep track of an artist's discography. Start by creating an | |
# artist, then an album, then songs. Add songs to the album and then add the | |
# album to the artist. Finally, call the discography method on the artist | |
# to print out a nice formatted string detailing that artist's discography. | |
# You should be able to use it like this: | |
nebyoolae = Artist.new('Nebyoolae') | |
cs13 = Album.new('Clocks Striking 13') |
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
class Artist | |
attr_reader :name | |
attr_accessor :albums | |
def initialize(name) | |
@name = name | |
@albums = [] | |
end |
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
class Foo < ActiveRecord::Base | |
# assume Foo has an attribute called "title" | |
before_save :my_callback | |
def my_callback | |
self.title = "Prefix: #{self.title}" # this doesn't work if you remove "self" - why? | |
end | |
end |
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 getRandomInt(min, max) { | |
return Math.floor(Math.random() * (max - min + 1) + min); | |
} | |
function getRandomDemandCountArray() { | |
var demandCount, | |
digitCount = getRandomInt(1, 6), | |
maxDigits = 6, | |
demandCountArray = []; |
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
# determining where a method was defined | |
module Organic | |
def organic? | |
true | |
end | |
end | |
class Fruit | |
def edible? |
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
[rvm 1.9.2] ~/Code $ mkdir gittest | |
[rvm 1.9.2] ~/Code $ cd gittest/ | |
[rvm 1.9.2] ~/Code/gittest $ git init | |
Initialized empty Git repository in /Users/jimmy/Code/gittest/.git/ | |
[rvm 1.9.2] ~/Code/gittest (master)$ touch foo | |
[rvm 1.9.2] ~/Code/gittest (master)$ git add foo | |
[rvm 1.9.2] ~/Code/gittest (master)$ git ci -a -m "initial commit" | |
[master (root-commit) 700ec02] initial commit | |
0 files changed, 0 insertions(+), 0 deletions(-) | |
create mode 100644 foo |
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
// http://jimmycuadra.com/posts/screencast-default-form-values-with-jquery | |
$('form').submit(function (evt) { | |
$(evt.currentTarget).find('input, textarea').each(function (index, element) { | |
var $element = $(element); | |
if ($element.val() == $element.data('default')) { | |
$element.val(''); | |
} | |
}); |
OlderNewer