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
#!/usr/bin/env ruby
#
# A hook script to verify that only syntactically valid ruby code is commited.
# Called by git-commit with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# Put this code into a file called "pre-commit" inside your .git/hooks
# directory, and make sure it is executable ("chmod +x .git/hooks/pre-commit")
#
file 'Gemfile', <<-GEMS
source 'http://gemcutter.org'
gem "rails", "3.0.0.beta3"
gem "bson_ext"
gem "mongoid", "2.0.0.beta4"
gem "haml", "3.0.0.rc.2"
gem "compass", "0.10.0.rc4"
gem "inherited_resources"
group :test do
file 'Gemfile', <<-GEMS
source 'http://gemcutter.org'
gem "rails", "3.0.0.beta4"
gem "bson_ext"
gem "mongoid", "2.0.0.beta4"
gem "haml", "3.0.0.rc.2"
gem "compass", "0.10.0.rc4"
gem "inherited_resources"
group :test do
@sabman
sabman / deploy.rb
Created January 31, 2011 12:58 — forked from nragaz/deploy.rb
CURRENT_RUBY = 'ree-1.8.7-2010.02'
RUBY_PATH = "/home/rails/.rvm/rubies/#{CURRENT_RUBY}"
GEM_HOME = "/home/rails/.rvm/gems/#{CURRENT_RUBY}"
ssh_options[:paranoid] = false
ssh_options[:forward_agent] = true
default_run_options[:pty] = true
set :stages, %w(staging production)
## Methods dealing with Govtrack's KML exporter for states and congressional districts.
# Used to generate map files for a couple of Sunlight's projects, Politiwidgets and the
# Congress app for Android.
## You can also just download individual maps at GovTrack's page about all this:
# http://www.govtrack.us/embed/googlemaps.xpd
# This script is useful if you want to generate many programmatically.
# It also swaps out the default '0' placemark name for something minimally descriptive.
## This file isn't runnable, and just contains some methods.
require 'devise/strategies/base'
module Devise
module Strategies
# Sign in an user using HTTP authentication.
class HttpAuthenticatableWithContentType < Base
MESSAGE = "Could not authenticate you."
def valid?
request.authorization && mapping.to.respond_to?(:authenticate_with_http)
class VisitorStats
def initialize
@redis = Redis.new
end
# every time there's a hit, increment a counter for the
# day and week, and add the session id to a set of unique
# vistitors for the day/week
def hit(session_id)
today = Date.today
@sabman
sabman / geodatabases.md
Created May 27, 2011 10:23 — forked from kashif/geodatabases.md
GeoDatabases - a discussion

GeoDatabases

What is a GeoDatabase? and how is it diff from a regular db

  • Stores geometries
  • multi-dimensional
  • R-Tree indexing (Query planner uses it?)
  • projections
  • Supports Datums ?
  • Vector and raster support
@sabman
sabman / gist:3361112
Created August 15, 2012 15:45 — forked from koos/gist:921728
validates_each :iban do | record, attr, value |
record.errors.add attr, 'IBAN is mandatory' and next if value.blank?
# IBAN code should start with country code (2letters)
record.errors.add attr, 'Country code is missing from the IBAN code' and next unless value.to_s =~ /^[A-Z]{2}/i
iban = value.gsub(/[A-Z]/) { |p| (p.respond_to?(:ord) ? p.ord : p[0]) - 55 }
record.errors.add attr, 'Invalid IBAN format' unless (iban[6..iban.length-1].to_s+iban[0..5].to_s).to_i % 97 == 1
end
@sabman
sabman / .gitignore
Created September 29, 2012 08:48 — forked from bkeepers/.gitignore
My Sublime settings
*