Skip to content

Instantly share code, notes, and snippets.

@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
@bitzesty
bitzesty / github-repos-talker-plugin.js
Created December 15, 2009 15:51
talker plugin for formatting github repos
plugin.onMessageInsertion = function(event){
var github_status_expression = /https*:\/\/github.com\/(.*)\/(.*)/i;
var last_anchor = Talker.getLastInsertion().find('a');
var last_href = last_anchor.attr('href') || '';
if (github_status_expression.test(last_href)){
var author = last_href.match(github_status_expression)[1];
@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 / 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 / enviroment.rb
Created December 26, 2009 23:20
rails metal to be used with carrierwave (gridfs) and MongoMapper
config.metals = ["Gridfs"]
@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 / config.enviroment.rb
Created January 4, 2010 22:58
Getting up and running with MongoDB/MongoMapper
# config/enviroment.rb
config.gem 'mongo'
config.gem 'mongo_mapper'
# remove AR
config.frameworks -= [ :active_record, :active_resource ]
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"
#
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
{
'name': 'Joe Bloggs',
'emails': ['[email protected]', '[email protected]'],
'phone_numbers': [{'type':'work',
'number':'+447872456173'
},
{'type':'mobile',
'number':'+447273456679'
}]
}