Skip to content

Instantly share code, notes, and snippets.

@bitzesty
bitzesty / gist:379214
Created April 26, 2010 11:13
xml2json.heroku.com example with the pivotal tracker API
$.ajax({
type: "GET",
url: 'http://xml2json.heroku.com',
data:'url=https://www.pivotaltracker.com/services/v3/projects/'+projectId+'/iterations/current?token='+trackerToken,
dataType: 'jsonp',
success: function(data) {
console.log(data);
}
});
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
Daemons.run_proc('navvy_worker', :dir => Rails.root.join('tmp/pids')) do
logger = Logger.new Rails.root.join('log/navvy.log')
# encoding: utf-8
require 'carrierwave/processing/mini_magick'
class PicUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader
storage :grid_fs
{
'name': 'Joe Bloggs',
'emails': ['[email protected]', '[email protected]'],
'phone_numbers': [{'type':'work',
'number':'+447872456173'
},
{'type':'mobile',
'number':'+447273456679'
}]
}
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 / 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 ]
@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 / enviroment.rb
Created December 26, 2009 23:20
rails metal to be used with carrierwave (gridfs) and MongoMapper
config.metals = ["Gridfs"]
@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