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
# Resque::Reattempt | |
# | |
# The simplest auto-retry on failure (ala DJ) for Resque | |
# | |
# Just extend your job with the module and then instead of defining perform, | |
# define `perform_with_reattempt`: | |
# | |
# class MyReattemptJob | |
# extend Resque::Reattempt | |
# |
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
require 'test_helper' | |
class UsersTest < ActionController::IntegrationTest | |
setup do | |
reset! | |
@conn = Faraday::Connection.new do |b| | |
b.adapter :action_dispatch, @integration_session | |
b.response :rails_json | |
end | |
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
function convertDateTimeSelectTo12Hour() { | |
var translate = {"00":"Midnight","01":"1am","02":"2am","03":"3am","04":"4am","05":"5am","06":"6am","07":"7am","08":"8am","09":"9am","10":"10am","11":"11am","12":"Noon","13":"1pm","14":"2pm","15":"3pm","16":"4pm","17":"5pm","18":"6pm","19":"7pm","20":"8pm","21":"9pm","22":"10pm","23":"11pm"}; | |
$("select[name$='(4i)]'] option").each(function() { | |
$(this).text(translate[$(this).text()]); | |
}); | |
} |
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
# 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. Because, really. why not? | |
# | |
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar) | |
# | |
# From: | |
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/ |
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
def find_and_replace_in_source_files(find, replace) | |
extensions = %w[.rhtml .rxml .erb .builder .rb .css .js .rake] | |
files = Dir["**/*"] | |
files.each do |file_name| | |
next if (file_name =~ /^vendor/) || !extensions.include?(File.extname(file_name)) | |
text = File.open(file_name, 'r'){ |file| file.read } | |
changed = text.gsub!(find, replace) | |
File.open(file_name, 'w'){|file| file.write(changed)} if changed | |
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
# | |
# Lunar/Moon phases ruby class | |
# | |
# Code is based upon Bradley E. Schaefer''s moon phase algorithm. | |
# Ruby version based on JavaScript Phase Calculator by Stephen R. Schmitt | |
class Moon | |
attr_reader :epoch, :phase, :days, :icon, :dist, :ll | |
# Return the current (or input a date) moon. | |
# Moon.new |
NewerOlder