This file contains hidden or 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
source ~/.git-completion.sh | |
source ~/.bash_colors.sh | |
git_prompt_info() { | |
git_branch_prompt=$(__git_ps1 " | %s") | |
if [ -n "$git_branch_prompt" ]; then | |
if [ "changed" = $(git_status) ]; then | |
branch_prompt=$(__git_ps1 "${ESC}[${BRIGHT};${FG_RED}m %s") | |
elif [ "pending" = $(git_status) ]; then | |
branch_prompt=$(__git_ps1 "${ESC}[${BRIGHT};${FG_YELLOW}m %s") |
This file contains hidden or 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
gem "thoughtbot-clearance", :version => "0.6.3", :source => "http://gems.github.com", :lib => "clearance" | |
gem "aslakhellesoy-cucumber", :version => "0.3.0", :source => "http://gems.github.com", :lib => "cucumber" | |
gem "giraffesoft-resource_controller", :version => "0.6.1", :source => "http://gems.github.com", :lib => "resource_controller" | |
generate "cucumber" | |
generate "clearance" | |
generate "clearance_features" |
This file contains hidden or 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
$("form").each(function(idx, form) { | |
console.log("looping through forms"); | |
var submitFunction = $(form).attr("onsubmit"); | |
if(typeof(submitFunction) !== undefined) { | |
delete(form.onsubmit); | |
var anonymousSubmit = new Function(submitFunction); | |
$(form).submit(anonymousSubmit); | |
} |
This file contains hidden or 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
$("form").each(function(idx, form) { | |
var onsubmit = $(form).attr("onsubmit"); | |
if(typeof(onsubmit) !== undefined) { | |
$(form).removeAttr("onsubmit"); // this properly removes the attribute; nothing within this is triggered | |
$(form).submit(function() { | |
alert("submitted!"); // this doesn't get called | |
}); | |
} | |
}); |
This file contains hidden or 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
def self.private_attributes(*args) | |
@@private_attributes = [args].flatten | |
class_eval do | |
def method_missing_with_private_accessor(call, *args) | |
method_missing_without_private_accessor(call, *args) unless @@private_attributes.map(&:to_sym).include?(call.to_sym) | |
end | |
alias_method_chain :method_missing, :private_accessor | |
end |
This file contains hidden or 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
# Problem 1: 234168 | |
(1..1000).select {|i| i % 3 == 0 || i % 5 == 0}.inject(:+) | |
# Problem 2: 4613732 | |
def fib(x) | |
return 0 if x == 0 | |
cache = Array.new(x) | |
cache[0], cache[1] = 0, 1 | |
2.upto(x) do |i| | |
cache[i] = cache[i - 1] + cache[i - 2] |
This file contains hidden or 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
--type-add=ruby=.haml,.rake,.rsel,.builder | |
--type-add=html=.html.erb,.html.haml | |
--type-add=js=.js.erb | |
--type-add=css=.sass | |
--type-set=cucumber=.feature | |
--ignore-dir=vendor | |
--ignore-dir=log | |
--ignore-dir=tmp | |
--ignore-dir=doc | |
--ignore-dir=coverage |
This file contains hidden or 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
# This allows generation of "codes"... namely for part-numbers and unique identifiers for records | |
# It's especially effective with FactoryGirl's sequences. | |
# | |
# Examples: | |
# Factory.define :whatever do |whatever| | |
# whatever.sequence(:unique_code) {|n| generate_code(n, :length => 4, :numeric => true) } | |
# # ... | |
# end | |
# | |
# Factory.define :another do |another| |
This file contains hidden or 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
# autocompletion for ruby_test | |
# # works with tu/tf aliases | |
# # see also ~/bin/ruby_test.rb | |
_ruby_tests() { | |
if [[ -n $words[2] ]]; then | |
compadd `ruby_test -l ${words[2]}` | |
fi | |
} | |
compdef _ruby_tests ruby_test | |
alias tu="ruby_test unit" |
This file contains hidden or 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
module PercentBase | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def has_percent(attribute_name = :pretty_percent, column = :percent) | |
raise(ArgumentError, "Cannot name attribute and column the same") if attribute_name.to_s == column.to_s | |
class_eval <<-END |