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 states_collection | |
| [ | |
| ['Alabama', 'AL'], | |
| ['Alaska', 'AK'], | |
| ['Arizona', 'AZ'], | |
| ['Arkansas', 'AR'], | |
| ['California', 'CA'], | |
| ['Colorado', 'CO'], | |
| ['Connecticut', 'CT'], | |
| ['Delaware', 'DE'], |
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
| jQuery.fn.capitalize_word = function() { | |
| $(this).each(function() { | |
| $(this).bind("keyup", function() { | |
| $(this).val($(this).val().toLowerCase().replace(/\b[a-z]/g, function(letter) { | |
| return letter.toUpperCase(); | |
| })); | |
| }) | |
| }) | |
| } |
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
| .formtastic { | |
| ol, ul { | |
| list-style-type: none; | |
| li { | |
| font-family: "Lucida Grande", Lucida, Verdana, sans-serif; | |
| margin-bottom: 10px; | |
| label { | |
| display: block; |
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 visit_the page_to | |
| visit page_to | |
| end | |
| def method_missing(method, *args, &block) | |
| if method.to_s =~ /_page$/ | |
| route_path = method.to_s.gsub /_page$/, "_path" | |
| __send__ route_path, *args | |
| else | |
| super |
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 AdminSetup | |
| def self.included(base) | |
| base.send :include, InstanceMethods | |
| end | |
| module InstanceMethods | |
| protected | |
| def declarative_devise_scope | |
| :admin |
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
| # RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
| # defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
| module Player | |
| describe MovieList, "with optional description" do | |
| it "is pending example, so that you can write ones quickly" | |
| it "is already working example that we want to suspend from failing temporarily" do | |
| pending("working on another feature that temporarily breaks this one") |
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
| require "rr" | |
| Cucumber::Rails::World.send(:include, RR::Adapters::RRMethods) |
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
| require 'benchmark' | |
| RSpec::Matchers.define :take_less_than do |n| | |
| chain :seconds do; end | |
| match do |block| | |
| @elapsed = Benchmark.realtime do | |
| block.call | |
| end | |
| @elapsed <= n |
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
| function rgb2hex(rgb) { | |
| rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); | |
| function hex(x) { | |
| return ("0" + parseInt(x).toString(16)).slice(-2); | |
| } | |
| return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]); | |
| } |
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
| jQuery.fn.exists = function() { return jQuery(this).length>0; } |