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 Position < ActiveRecord::Base | |
attr_protected :account_id, :created_at, :updated_at | |
belongs_to :account | |
#### Option 1 #### | |
attr_restricted :job_id | |
# assigns attribute if this method returns true | |
def allow_job_id_assignment?(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
(function($) { | |
$.fn.delayedObserver = function(delay, callback) { | |
return this.keyup(function() { | |
var element = this, $element = $(this); | |
if(!$element.data('delayedObserver')) { | |
$element.data('delayedObserver', setTimeout(function() { | |
callback.apply(element); | |
$element.removeData('delayedObserver'); | |
}, delay * 1000)); |
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
// easy refresh-css keybinding to alt-w | |
// alt-r was taken in IE, so consider this a CSS Weefresh | |
// original code from http://paulirish.com/2008/how-to-iterate-quickly-when-debugging-css/ | |
$(document).keyup(function(e){ | |
if (e.which == 87 && e.altKey) { | |
$('link').each(function() { | |
if((/stylesheet/i).test(this.rel) && this.href) { | |
var href = this.href.replace(/(&|\?)forceReload=\d+/,''); | |
this.href = href + ((/\?/).test(href) ? '&' : '?' ) + 'forceReload=' + new Date; |
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 Address < DataMapper::Type | |
include DataMapper::Resource | |
property :address, String | |
property :city, String | |
property :state, String | |
property :zip, Integer | |
end | |
class User | |
include DataMapper::Resource |
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
require 'rubygems' | |
require 'harvest' | |
require 'tinder' | |
@harvest = Harvest( | |
:email => "email", | |
:password => "password", | |
:sub_domain => "subdomain" | |
) |
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
# Just drop this little diddy in your app to get some (not perfect) information on query times and such | |
# This will eventually become an official plugin but for those who can't wait, enjoy. | |
if defined?(NewRelic) | |
module MMNewRelicTracing | |
def self.included(model) | |
model.metaclass.class_eval do | |
add_method_tracer :find, 'Database/#{self.name}/find' | |
add_method_tracer :find!, 'Database/#{self.name}/find!' | |
add_method_tracer :paginate, 'Database/#{self.name}/paginate' | |
add_method_tracer :first, 'Database/#{self.name}/first' |
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
jQuery(function() { | |
$.cookie('tz', (new Date()).getTimezoneOffset()); | |
}); |
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
// jQuery.fn.or | |
// | |
// $('.dont-exist').or('.does-exist') //=> [.does-exist]; | |
// $('.does-exist').or('.dont-exist') //=> [.does-exist]; | |
$.fn.extend({ | |
or: function(selector, context) { | |
if ($(this).length > 0) { | |
return $(this); | |
} else { |
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
after 'deploy:update_code', 'solr:symlink' | |
after 'deploy:restart', 'solr:restart' | |
namespace :solr do | |
task :symlink do | |
run "ln -nfs #{shared_path}/solr #{release_path}/solr" | |
end | |
task :reindex, :roles => :app do | |
run "cd #{current_path} && rake sunspot:solr:reindex RAILS_ENV=#{rails_env}" | |
end | |
task :start, :roles => :app do |
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 Hash | |
def rmerge!(other_hash) | |
merge!(other_hash) do |key, oldval, newval| | |
oldval.class == self.class ? oldval.rmerge!(newval) : newval | |
end | |
end | |
def rmerge(other_hash) | |
r = {} | |
merge(other_hash) do |key, oldval, newval| |