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
| var countdown = function() { | |
| var index; | |
| function log(){ | |
| console.log(index); | |
| } | |
| function iterate(){ | |
| log(); | |
| if(index>1) setTimeout(iterate, 1000); |
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
| var Card = { | |
| isValid: function(strum) { | |
| var sum = 0, mul = 1, length = strum.length, digit, tproduct | |
| forEach(c in strum.slice(0,17)) { | |
| digit = CC.substring(length-i-1,length-i); | |
| tproduct = parseInt(digit ,10)*mul; | |
| sum += (tproduct >= 10 ? (tproduct % 10) + 1 : tproduct) | |
| mul += (mul == 1 ? 1 : -1) | |
| } |
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
| # Does it have substance? Use .blank? or .present?, it's opposite: | |
| >> " ".blank? | |
| => true | |
| >> nil.blank? | |
| => true | |
| >> [].blank? | |
| => true | |
| >> nil.present? | |
| => false | |
| >> [].present? |
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
| Last login: Fri Aug 19 15:43:53 on ttys006 | |
| You have new mail. | |
| Fri Aug 19 15:44:57 brookr@pridwen.local:~ > ruby -v | |
| ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0] | |
| Fri Aug 19 15:44:59 brookr@pridwen.local:~ > rvm list | |
| rvm rubies | |
| Fri Aug 19 15:45:03 brookr@pridwen.local:~ > rvm install 1.9.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
| class NilClass | |
| def method_missing(method, *args, &block) | |
| nil | |
| end | |
| 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
| gem 'faker' | |
| require 'faker' | |
| I18n.reload! | |
| account_id = 4 | |
| # Makes a bunch of different types of events per day at a random time during work hours | |
| (30.days.ago.to_date..90.days.from_now.to_date).each do |date| | |
| rand(3).times do | |
| start = date.beginning_of_day + 8.hours + (rand(32) * 15).minutes |
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 load_sql_file(file) | |
| config = ActiveRecord::Base.configurations[RAILS_ENV] | |
| database = config['database'] | |
| user = config['username'] | |
| puts `psql -U #{user} -f #{file} #{database}` | |
| end | |
| desc 'Load an SQL file' | |
| task :load_sql => [ENV['FILE'], :environment] do |t| | |
| file = ENV['FILE'] |
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 'rubygems' | |
| require 'utility_belt' | |
| require 'wirble' | |
| class Object | |
| def local_methods | |
| (methods - Object.instance_methods).sort | |
| end | |
| 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
| gem 'faker' | |
| require 'faker' | |
| # Clean out what is there | |
| # Makes a bunch of different types of events per day at a random time during work hours | |
| account_id ||= 1 | |
| (30.days.ago.to_date..90.days.from_now.to_date).each do |date| | |
| rand(5).times do | |
| start = date.beginning_of_day + 8.hours + (rand(32) * 15).minutes |
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 File.dirname(__FILE__) + '/../test_helper' | |
| class SurveysControllerTest < ActionController::TestCase | |
| context 'GET to index' do | |
| setup do | |
| @staff = Factory(:staff) | |
| session['staff'] = @staff.id | |
| get :index | |
| end |