Skip to content

Instantly share code, notes, and snippets.

View sabman's full-sized avatar
😀
Building, Shiping, Sharing!

Shoaib Burq sabman

😀
Building, Shiping, Sharing!
View GitHub Profile
@galvez
galvez / 2010-10-02-14-00-test-migration.py
Created October 2, 2010 17:45
A minimalist Python migration management script based on Fabric and sqlwitch
# 2010-10-02 14h00
# Update created field in user_prefs table
def migrate(db):
with db.select('user_id, created', from_='users'):
all_users = db.fetchall()
for user in all_users:
with db.update('user_prefs') as obj:
obj.created = user['created']
db.where('user_id = %s', user['user_id'])
@jittuu
jittuu / gist:792715
Created January 24, 2011 02:19
Test Omniauth Facebook Callback Controllers in Devise with rspec
require 'spec_helper'
describe Users::OauthCallbacksController, "handle facebook authentication callback" do
describe "#annonymous user" do
context "when facebook email doesn't exist in the system" do
before(:each) do
stub_env_for_omniauth
get :facebook
@andruby
andruby / deploy.rb
Created January 26, 2011 19:48
Start and Stop tasks for resque workers, with capistrano deploy hook (without God)
after "deploy:symlink", "deploy:restart_workers"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
cmd = "cd #{fetch(:latest_release)} && #{fetch(:rake, "rake")} RAILS_ENV=#{fetch(:rails_env, "production")} #{rake_cmd}"
# Helpers
def git_update(message)
git :add => ".", :commit => "-m '#{message}'"
end
def git_remove(file)
git :rm => file
end
@mystix
mystix / passenger-nginx-setup.sh
Created March 21, 2011 14:00
Rackspace Ubuntu -- RVM + PostgreSQL + Passenger + NGiNX setup script
# install rvm
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
# install ruby 1.9.2 + some global gems
rvm install 1.9.2
rvm use 1.9.2@global
gem install awesome_print map_by_method wirble bundler builder pg cheat
gem install -v2.1.2 builder
@sabman
sabman / Email Signature
Created March 27, 2011 20:24
Email Signature
--
Co-founder & CEO SpacialDB
p: +49 30 838 75030
w: http://spacialdb.com
t: spacialdb
SpacialDB UG
c/o Freie Universität Berlin
@pirelenito
pirelenito / gist:908126
Created April 7, 2011 16:21
Getting started with RGeo
require 'rgeo'
# factory = RGeo::Geos.factory()
# factory = RGeo::Geographic.spherical_factory()
factory = RGeo::Geographic.simple_mercator_factory()
p1 = factory.point 0, 0
p2 = factory.point 0, 2
p3 = factory.point 2, 2
p4 = factory.point 2, 0
@santosh79
santosh79 / generic_spec_helper.rb
Created April 16, 2011 08:39
A generic spec helper
require 'spork'
ENV["RAILS_ENV"] ||= 'test'
# Patch for RubyMine and Spork
ruby_mines = Dir["/Applications/RubyMine*.app"]
unless ruby_mines.empty?
$LOAD_PATH.unshift "#{ruby_mines.first}/rb/testing/patch/bdd/"
$LOAD_PATH.unshift "#{ruby_mines.first}/rb/testing/patch/common/"
end
@sabman
sabman / print_spacialdb_params.rb
Created May 28, 2011 13:29
print_spacialdb_params.rb
#!/usr/bin/env ruby
# SPACIALDB_USER=username
# SPACIALDB_DB=dbname
# SPACIALDB_PASS=passwd
# SPACIALDB_HOST=beta.spacialdb.com
# SPACIALDB_PORT=9999
url = ENV["SPACIALDB_URL"]
regex = Regexp.new(/(.*):\/\/(.*):(.*)@(.*):([\d]{3,5})\/(.*)/)
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end