This file contains hidden or 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
named_scope :conditions, lambda { |args| {:conditions => args} } | |
named_scope :filter, lambda{ |options| | |
options ||= {} | |
options.stringify_keys! | |
scope = scoped(Hash.new) | |
unless options['active'].blank? | |
scope = scope.conditions :active => options['active'] | |
end |
This file contains hidden or 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 A | |
def a_method | |
"a_method" | |
end | |
@@a_class_attribute = "A::a_class_attribute" | |
def a_class_attribute | |
@@a_class_attribute | |
end | |
This file contains hidden or 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
/* | |
* Extend the Ajax.Autocompleter | |
* | |
* Defaults to using a json response. | |
* | |
* If the response looks like html, send it to the updateChoices() function. | |
* Otherwise assume it is json and build the unordered list from the json array. | |
* If you set the header to 404 when there are no results, the onComplete() function is not called. | |
*/ |
This file contains hidden or 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
[user] | |
name = | |
email = | |
[github] | |
user = | |
token = | |
[sendemail] | |
smtpuser = | |
smtpencryption = tls | |
smtpserver = smtp.gmail.com |
This file contains hidden or 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
bash "install #{name} gems" do | |
cwd "/tmp/#{name}" | |
code <<-end_code | |
for gem_file in `ls *.gem` | |
do | |
gem install ./$gem_file | |
done | |
end_code | |
end |
This file contains hidden or 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
## https://gist.github.com/977188 | |
# | |
# If your workers are inactive for a long period of time, they'll | |
# lose their MySQL connection. | |
# | |
# This hack ensures we re-connect whenever a connection is lost. | |
# | |
# From: https://gist.github.com/238999 | |
# | |
# Added retrying to prevent infinite loop. |
This file contains hidden or 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
gem install hijack | |
ps aux | grep ruby | |
# andrew 10879 0.0 2.4 2538948 100668 ?? S 10:30AM 0:03.09 ruby .../node_modules/nack/bin/nack_worker .../config.ru /tmp/nack.56823.5122799426.sock | |
hijack 10879 |
This file contains hidden or 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 ApplicationController < ActionController::Base | |
rescue_from ActiveRecord::RecordNotFound, :with => :resource_not_found | |
rescue_from ActionController::RoutingError, :with => :check_request_uri_and_method | |
rescue_from AbstractController::ActionNotFound, :with => :page_not_found | |
rescue_from ActionController::MethodNotAllowed, :with => :method_not_allowed |
This file contains hidden or 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
# As used with CanCan and Devise | |
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
include ErrorResponseActions | |
rescue_from CanCan::AccessDenied, :with => :authorization_error | |
rescue_from ActiveRecord::RecordNotFound, :with => :resource_not_found | |
before_filter :authenticate! |
This file contains hidden or 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
#!/usr/bin/env ruby | |
filename = ARGV.pop | |
urls = [] | |
processing_method = {} | |
File.open filename do |f| | |
while l = f.gets | |
if l =~ /.* prism rails\[([0-9]+)\]: .* Processing .* \[([A-Z]+)\]/ | |
processing_method[$1] = $2 | |
end |