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
# usage: ruby timecard.rb path branch name-of-graph-file-not-including-extension | |
# e.g.: ruby timecard.rb . master timecard #=> produces timecard.png | |
require 'rubygems' | |
# This requires the 'cyberfox-gchart' gem (0.5.4), as the standard | |
# gchart gem is woefully broken for this kind of graph. Broken to the | |
# point that it's an inherent design choice that doesn't work well for | |
# this kind of chart. I'm sure that the cyberfox-gchart gem won't |
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
#Deploy and rollback on Heroku in staging and production | |
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
namespace :deploy do | |
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU' | |
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU' | |
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag] | |
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on] |
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
# Sample implementation of quicksort and mergesort in ruby | |
# Both algorithm sort in O(n * lg(n)) time | |
# Quicksort works inplace, where mergesort works in a new array | |
def quicksort(array, from=0, to=nil) | |
if to == nil | |
# Sort the whole array, by default | |
to = array.count - 1 | |
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
function number_to_currency(number, options) { | |
try { | |
var options = options || {}; | |
var precision = options["precision"] || 2; | |
var unit = options["unit"] || "$"; | |
var separator = precision > 0 ? options["separator"] || "." : ""; | |
var delimiter = options["delimiter"] || ","; | |
var parts = parseFloat(number).toFixed(precision).split('.'); | |
return unit + number_with_delimiter(parts[0], delimiter) + separator + parts[1].toString(); |
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
/** | |
* Get parent node for given tagname | |
* @param {Object} node DOM node | |
* @param {String} tagname HTML tagName | |
* @return {Object} Parent node | |
*/ | |
function getParentByTagName(node, tagname) { | |
var parent; | |
if (node === null || tagname === '') return; | |
parent = node.parentNode; |
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
# Usage | |
# DJ config | |
require Rails.root.join('lib', 'dj_plugin.rb') | |
Delayed::Worker.plugins << Delayed::Plugins::EmailNotify | |
# lib/dj_plugin.rb | |
require 'exception_notification' |