Skip to content

Instantly share code, notes, and snippets.

View sums.rb
# method that takes two inputs (an array, a target sum)
# outputs an array of pairs that sum to the target sum
# ([1,2,3,4], 5) => [[1,4], [2,3]]
def sum_pairs(array, target)
matches = []
i = 0
array.each do |first|
i += 1
array[i..-1].each do |second|
View transaction.rb
class Transaction
attr_accessor :amount, :success
def initialize(amount, success)
@amount = amount
@success = success
end
def success?
@success
View markets.csv
1 People's Co-op Farmers Market 30th and Burnside Portland Multnomah Oregon 97202
2 Silverdale Farmers Market 98383 Silverdale Kitsap Washington 98383
3 Dolgeville Farmer's Market (Parking Lot) Between Main St. and Helmer Ave Dolgeville Herkimer New York 13329
4 Preston Farmers’ Market #1 Route 164 Preston New London Connecticut
5 Quincy Farmers Market 0 Denis Ryan Parkway Quincy Norfolk Massachusetts 2169
6 Jefferson City Farmer's Market 000 Main Street Jefferson City Cole Missouri 0
7 Petaluma Evening Farmers' Market 1 2nd Street Petaluma Sonoma California 94952
8 Charlestown Farmers Market 1 Austin Street, Thompson Square at Austin & Main Streets Boston Massachusetts 2129
9 Farmers Market at Christopher Newport University 1 Avenue of the Arts Newport News Newport News Virginia 23606
10 Saratoga Farmers' Market 1 Bayberry Drive Ballston Sp Saratoga New York 12020
View dateedge-api.json
{
"users": [{
"id": 1
}, {
"id": 2
}, {
"id": 3
}]
}
View keybase.md

Keybase proof

I hereby claim:

  • I am bookis on github.
  • I am bookis (https://keybase.io/bookis) on keybase.
  • I have a public key whose fingerprint is B13D 02A2 3B45 C0A8 19EB B24D DD94 A361 4A5D AC98

To claim this, I am signing this object:

@bookis
bookis / backup_heroku_db.rake
Created Feb 20, 2011
Making a rake tasks to capture Heroku pgbackup and push to S3
View backup_heroku_db.rake
namespace :backup do
desc "backup db from heroku and send to S3"
task :push_to_s3 => :environment do
Rake::Task[:environment].invoke
require 'aws/s3'
require 'heroku'
APP_NAME = 'luna-sandals' # put your app name here
BACKUP_BUCKET = "#{APP_NAME}-db-backups" # put your backup bucket name here
file_name = "backup-#{Time.now.strftime('%s')}.dump"
@bookis
bookis / mysql2 error
Created Apr 24, 2011
MySQL rails 3 and rvm : Library not loaded: libmysqlclient.18.dylib (LoadError)
View mysql2 error
/Users/Bookis/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `require': dlopen(/Users/Bookis/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/Bookis/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/Bookis/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
from /Users/Bookis/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `<top (required)>'
from /Users/Bookis/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /Users/Bookis/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/Bookis/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
from /Users/Bookis/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `block in require'
from /Users/Bookis/.rvm
@bookis
bookis / consumer_template.rb
Created Jan 2, 2012
Homesteading Consumer App Template
View consumer_template.rb
# Put template stuff here
@bookis
bookis / bookis_rails_template.rb
Created May 13, 2012
Spork + Guard + Bootstrap Rails Template
View bookis_rails_template.rb
run "echo TODO > README"
run "rvm use 1.9.2"
run "rvm gemset create #{app_name}"
create_file ".rvmrc", "rvm use 1.9.2@#{app_name}"
gem "rspec-rails" , :group => [ :development, :test ]
gem "guard-rspec" , :group => [ :development, :test ]
gem "spork", "> 0.9.0.rc" , :group => [ :development, :test ]
gem "guard-spork" , :group => [ :development, :test ]
gem "factory_girl_rails" , :group => [ :development, :test ]
@bookis
bookis / notes.mdown
Created Dec 13, 2012
Notes for Norawas
View notes.mdown

Norawas Notes

Website

  • What components are needed now?
  • What components will be desired in the next 2 years?
    • Editable content
    • Blog
    • Take Donations
    • Photo Gallery