Skip to content

Instantly share code, notes, and snippets.

View hamin's full-sized avatar

Haris Amin hamin

  • Currently ionq.co. Previously symbiont.io, getpager.com, itsglimpse.com, dailburn.com
  • New York,NY
View GitHub Profile
@hamin
hamin / event.rb
Created June 29, 2010 16:04 — forked from stengland/event.rb
Multi Param Atrributes for MongoMapper ruby 1.8 and ruby 1.9 compliant
class Event
include MongoMapper::Document
include MultiParameterAttributes
key :name, String, :required => true
key :start_date, Date, :required => true
key :start_time, Time, :required => true
end
@hamin
hamin / gist:535041
Created August 18, 2010 15:04 — forked from cheald/gist:535026
MongoMapper CarrierWave adapter
require 'mongo_mapper'
module CarrierWave
module MongoMapper
include CarrierWave::Mount
##
# See +CarrierWave::Mount#mount_uploader+ for documentation
#
def mount_uploader(column, uploader, options={}, &block)
# We need to set the mount_on column (or key in MongoMapper's case)
@hamin
hamin / gist:632799
Created October 18, 2010 18:57
Rvm version in your shell
# Put this at the end of your user's .profile file or .bash_profile file
# NOTE: Here '/Users/hamin/' is MY user folder, replace with yours
if [[ -s /Users/hamin/.rvm/scripts/rvm ]] ; then source /Users/hamin/.rvm/scripts/rvm ; fi
PS1="[\h:\$(~/.rvm/bin/rvm-prompt)]\W \u\$"
group :development do
if RUBY_VERSION =~ /1.9/
gem "ruby-debug19"
else
gem "ruby-debug"
end
end
@hamin
hamin / mongomapper_rails3_template.rb
Created January 20, 2011 22:41
A Rails 3 Application template for MongoMapper
# Some basic flags
use_mongomapper = false
use_compass = false
use_simplenavigation = false
rails3_branch = false
run "cp config/database.yml config/database.example.yml"
# Remove redundant files
remove_file "public/index.html"
@hamin
hamin / pub_sub_able.rb
Created March 21, 2011 21:50
A convenience lib for dealing with PubSub with XMPP4R
require "xmpp4r"
require "xmpp4r/pubsub"
module PubSubAble
include Jabber
def anon_connect_to_server(anonymous_user,host,port)
jid = Jabber::JID.new("#{anonymous_user}@#{host}")
client = Client.new(jid)
client.connect(host,port)
@hamin
hamin / mongomapper_replica_sets.rb
Created April 16, 2011 21:52
How to get replica sets to work with MM...just use the Ruby driver!!!!!
# In your config/initializers/mongo.rb where you initialize your connection with Mongo:
MongoMapper.connection = Mongo::Connection.multi([["db3", 27017], ["db3", 27018]])
# of course you can read the replica set info from a simple YAML file.
@hamin
hamin / bdsm_nginx_error.log
Created April 28, 2011 02:47
bdsm_nginx_error.log
> modules/bash/core/cli 203 $ [[ -n '' ]]
> modules/bash/core/cli 203 $ [[ -n '' ]]
> modules/bash/core/cli 9 $ (( 2 > 0 ))
> modules/bash/core/cli 11 $ token=nginx
> modules/bash/core/cli 11 $ shift
> modules/bash/core/cli 13 $ case "$token" in
> modules/bash/core/cli 85 $ [[ -z '' ]]
> modules/bash/core/cli 86 $ [[ -d /usr/local/bdsm/extensions/nginx ]]
> modules/bash/core/cli 87 $ extension=nginx
> modules/bash/core/cli 185 $ (( parse_break == 1 ))
@hamin
hamin / canvas_arrows.html
Created May 9, 2011 22:44
Drawing HTML5 Up and Down Arrows
<p>
<canvas id="downArrow" style="border:0px solid;background-color:#ffecb0;" width="20" height="22">Your web browser does not supports HTML5!</canvas>
<canvas id="upArrow" style="border:0px solid;background-color:#ffecb0;" width="20" height="22">Your web browser does not supports HTML5!</canvas>
</p>
<script type="text/javascript" charset="utf-8">
function drawDownArrow() {
var canvas = document.getElementById('downArrow');
var context = canvas.getContext('2d');
@hamin
hamin / mongoose.coffee
Created August 21, 2011 07:21
mongoose.coffee
Message = new Schema({content: String,nickname: String,created_at: Date})
Picture = new Schema({user: ObjectId,title: String,url: String,start_at: Date,end_at: Date,messages: [Message],created_at: Date,updated_at: Date})
PhotoAccount = new Schema({token: String,token_secret: String,provider: String,username: String,domain: String,avatar: String})
User = new Schema({token: String,token_secret: String,username: String,domain: String,avatar: String,created_at: Date,updated_at: Date,photo_accounts: [PhotoAccount]})
picture = mongoose.model('Picture', Picture)