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
# config/initializers/trailing_slash.rb | |
Rails.configuration.before_initialize do | |
ActionController::Base.module_eval do | |
before_filter :enforce_trailing_slash | |
protected | |
def enforce_trailing_slash |
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
#! /usr/bin/env ruby | |
# this script can create a static build from virtually any rails' project. it | |
# has two simple requirements. | |
# | |
# 1) you have | |
# | |
# gem 'passenger' | |
# | |
# in your Gemfile |
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
#! /usr/bin/env ruby | |
# usage | |
# | |
usage = <<-__ | |
dot/ify | |
keep *all* your dot files in one directory. link them back into your home | |
dir. for example |
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
curl \ | |
-i \ | |
-u "$account:$token" \ | |
-H "Content-Type: application/json" \ | |
-H "Accept: application/json" \ | |
-X PUT \ | |
-d@- \ | |
"$api/v1/credit_cards/:id" <<-__ | |
{"credit_card":{"month":7}} |
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 BatonPass | |
Fattr(:window){ Rails.env.production? ? 24.hours : 10.seconds } | |
def BatonPass.rollup! | |
# | |
counts = Map.new | |
window = BatonPass.window | |
# | |
to_rollup = BatonPass.where(:auto => true) |
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
#! /usr/bin/env ruby | |
# it's trivial ot make a ruby program run once. | |
# | |
status = DATA.flock(File::LOCK_EX|File::LOCK_NB) | |
unless status == 0 | |
puts "another process has the lock" | |
exit(42) |
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
#alias rb='rbenv' | |
# path setup | |
# | |
# paths=`cat ~/.paths.sh` | |
# PATH=`ruby -e' PATH=ENV["PATH"].split(/:/); \ | |
# ARGV.reverse.each{|path| PATH.delete(path); PATH.unshift(path)};\ | |
# PATH.map!{|path| File.expand_path(path)};\ | |
# PATH.uniq!; print(PATH.join(":")) ' '~/bin' "$paths" "$PATH" 2>/dev/null` |
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
#! /bin/sh | |
# file : ~/bin/favicon | |
# | |
# usage: favicon foo.png | |
convert "$@" -resize 16x16 favicon-16.png | |
convert "$@" -resize 32x32 favicon-32.png | |
convert "$@" -resize 64x64 favicon-64.png | |
convert "$@" -resize 128x128 favicon-128.png |
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
// | |
s3Uploader.content_type_for = function(file_input, file_name, content_type){ | |
content_type = content_type || 'application/octet-stream'; | |
try{ | |
content_type = jQuery(file_input).prop('files')[0]['type'] | |
} catch(e) {}; | |
if(!content_type){ | |
var parts = file_name.split('.'); |
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
# this code _must_ return a hash since the result hash is used to log information about the job run. | |
# | |
# by using catch/throw via 'return_result' it's easy to control the return value while still decorating | |
# it with key info, such as 'elapsed' time. | |
# | |
def run |