Skip to content

Instantly share code, notes, and snippets.

View bluerogue251's full-sized avatar

Teddy Widom bluerogue251

View GitHub Profile
#!/usr/bin/env bash
echo "Total number of words:"
cat /usr/share/dict/american-english | wc -w
echo ""
# To fix this, you need to filter the dictionary words
echo "Number of words containing the string 'auto':"
cat /usr/share/dict/american-english | FILL_ME_IN | wc -w
echo ""
// Passenger 1 is 1/100 likely to randomly pick passenger two's seat.
// Passenger 2 is 1/100 likely to have been displaced by passenger 1.
// Passenger 3 is 1/100 likely to have been displaced by passenger 1.
// Passenger 3 is (1/100 * 1/99) likely to have been displaced by passenger 2. Because Passenger 2 was 1/100 likely to have been displaced by passenger 1, and if displaced 1/99 likely to have randomly chosen passenger 3's seat.
// All in all, Passenger 3 is (1/100 + (1/100 * 1/99)) likely to have been displaced.
// Passenger 4 is (1/100 + (1/100 * 1/99) + (1/100 * 1/99 * 1/98)) likely to have been displaced
@bluerogue251
bluerogue251 / city.rb
Created February 4, 2014 19:11
Rails models for geographic domain data
class City < ActiveRecord::Base
self.primary_keys = :country_name, :subregion_name, :name
belongs_to :subregion, foreign_key: [:country_name, :subregion_name]
default_scope { order('name') }
end
namespace :db do
desc 'Move data from the carmen gem into the database'
task load_geo_data: :environment do
puts '-----------About to load geo-data from Carmen gem into the database----------------'
Carmen::Country.all.each do |country|
new_country = Country.create(name: country.name)
country.subregions.each do |subregion|