Skip to content

Instantly share code, notes, and snippets.

View mickey's full-sized avatar

Michael Bensoussan mickey

View GitHub Profile
{
"theme": "Soda Dark.sublime-theme",
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
"drawWhiteSpace": true,
"font_size": 12,
"highlight_modified_tabs": true,
"matchBracketsAngle": true,
"matchBracketsBraces": true,
"matchBracketsSquare": true,
"rulers": [80],

Tips and tricks

ri documentation

With RVM:

#> rvm docs generate      # => takes some time ^^
#> ri Array
#> ri Array.push
@mickey
mickey / gist:3105697
Created July 13, 2012 16:06
LIC::Recorder
module LIC
class Recorder
# If the file doesn't exists, dump the response body to a file.
# If it does and the response body is different than what is in the file
# prints a nice diff.
def self.record_to file
require 'yaml'
require 'differ'
require 'colored'
require 'rubygems'
require 'yaml'
require 'base64'
require 'openssl'
require 'net/https'
require "rexml/document"
class CloudfrontInvalidator
def initialize(cf_id, *urls)
@batch = "purging " + Time.now.to_s
$("#image_id").load(function(){
// stuff to do after the image is loaded
});
@user.activities
def self.batch_add(users, activity_type, target)
return false if users.blank? or activity_type.blank? or target.blank?
inserts = []
users.each {|user| inserts.push "('#{user.id}', '#{activity_type}', '#{target.id}', '#{target.class}', UTC_TIMESTAMP())" }
sql = "INSERT INTO activities (`user_id`, `activity_type`, `target_id`, `target_type`, `created_at`) VALUES #{inserts.join(", ")}"
ActiveRecord::Base.connection.execute sql
end
def batch_add(users, activity_type, target)
return false if users.blank? or activity_type.blank? or target.blank?
inserts = []
users.each {|user| inserts.push "('#{user.id}', '#{activity_type}', '#{target.id}', '#{target.class}', UTC_TIMESTAMP())" }
sql = "INSERT INTO activities (`user_id`, `activity_type`, `target_id`, `target_type`, `created_at`) VALUES #{inserts.join(", ")}"
ActiveRecord::Base.connection.execute sql
end
class AuditionObserver < ActiveRecord::Observer
# ACTIVITY OBSERVER : new audition posted
def after_create(audition)
if audition.actor
Activity.add(audition.actor.user, Activity::AUDITION_POSTED, audition)
end
end
end
class AuditionObserver < ActiveRecord::Observer
# ACTIVITY OBSERVER : new audition posted
def after_create(audition)
if audition.actor
Activity.add(audition.actor.user, Activity::AUDITION_POSTED, audition)
end
end
end