Skip to content

Instantly share code, notes, and snippets.

class Company
include Mongoid::Document
has_many :projects
end
class Project
include Mongoid::Document
has_many :project_zones
has_many :incidents
has_many_related :safety_inspectors
require 'geoip'
module Rack
# Rack::GeoIPCountry uses the geoip gem and the GeoIP database to lookup the country of a request by its IP address
# The database can be downloaded from:
# http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
#
# Usage:
# use Rack::GeoIPCountry, :db => "path/to/GeoIP.dat"
#
@bitzesty
bitzesty / no_www.rb
Created December 29, 2009 13:48 — forked from trevorturk/no_www.rb
class NoWWW
STARTS_WITH_WWW = /^www\./i
def initialize(app)
@app = app
end
def call(env)
if request.get? && env['HTTP_HOST'] =~ STARTS_WITH_WWW
@bitzesty
bitzesty / push_unique.rb
Created December 23, 2009 14:42 — forked from jnunemaker/push_unique.rb
MM push_unique
require 'pp'
require 'rubygems'
require 'mongo_mapper'
MongoMapper.database = 'testing'
class Site
include MongoMapper::Document
key :domain, String
key :authorizations, Array
@bitzesty
bitzesty / embedded_uniqueness_validations.rb
Created December 23, 2009 14:40 — forked from jnunemaker/embedded_uniqueness_validations.rb
MM embedded_uniqueness_validations
require 'pp'
require 'rubygems'
require 'mongo_mapper'
MongoMapper.database = 'testing'
class Rating
include MongoMapper::EmbeddedDocument
key :user_id, ObjectId
@bitzesty
bitzesty / _README.md
Created December 13, 2009 20:36 — forked from kneath/_README.md

GitHub Javascript Strategy

Unless otherwise necessary (such as mobile development), the GitHub javascript codebase is based off jQuery. You can safely assume it will be included on every page.

File naming

  • All jquery plugins should be prefixed with jquery, such as jquery.facebox
  • All github-specific jquery plugins should be prefixed with jquery.github. Like jquery.github.repo_list.js
  • All page-specific files (that only run on ONE page) should be prefixed with page. page.billing.js