This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VersionParentObserver < ActiveRecord::Observer | |
observe MyModel, MyOtherModel | |
[:create, :update, :destroy].each do |action| | |
define_method("after_#{action}") do |record| | |
increment_version_for_observed(record, action) | |
end | |
end | |
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Blippin | |
def self.included(base) | |
base.class_eval do | |
before_filter :create_blip | |
after_filter :update_blip | |
end | |
end | |
def create_blip | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create_table "blips", :force => true do |t| | |
t.string "uri" | |
t.string "method" | |
t.string "ip_address" | |
t.string "referrer" | |
t.string "user_agent" | |
t.integer "user_id" | |
t.datetime "created_at" | |
t.datetime "updated_at" | |
t.string "login_id" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TouchParentObserver < ActiveRecord::Observer | |
observe MyModel, MyOtherModel | |
[:create, :update, :destroy].each do |action| | |
define_method("after_#{action}") do |record| | |
touch_parents_of_observed(record, action) | |
end | |
end | |
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateModelVersions < ActiveRecord::Migration | |
def self.up | |
create_table :model_versions do |t| | |
t.string :model_name | |
t.integer :version | |
t.timestamps | |
end | |
end | |
def self.down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ModelVersionObserver < ActiveRecord::Observer | |
observe MyReferenceDataModel | |
[:create, :update, :destroy].each do |action| | |
define_method("after_#{action}") do |record| | |
increment_model_version_of_observed(record, action) | |
end | |
end | |
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while true do print "I CAN HAS TEH MACS #{" "*rand(1000)} "; sleep (rand(250.0).to_f/1000.0) end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while true do print "[ **** ] #{" "*rand(50)} "; sleep (rand(50.0).to_f/1000.0) end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var regexpMatcher = /^\/([^\/]|\\\/)+\/[$gim]*$/; | |
function assert(value) { return regexpMatcher.test(value); } | |
function isRegexp(value) { if (!assert(value)) alert("Failed " + value); } | |
function isNotRegexp(value) { if (assert(value)) alert("Failed " + value); } | |
isRegexp("/foo/"); | |
isRegexp("/foo/gim"); | |
isRegexp("/foo/img"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//on Chrome 12 on OSX | |
//after loading in vanilla yepnope js from | |
//https://github.com/SlexAxton/yepnope.js/blob/master/yepnope.js | |
//calling this results in application.js loading into an <img> tag then *executing* despite !preload prefix | |
yepnope("preload!/javascripts/application.js"); | |
//on line 410 of the lib there is a resource.noexec check, but no other refs in the lib to 'noexec' | |
//when setting this to true, the desired load-but-dont-execute behavior works. |
OlderNewer