/*
*= require "application/all"
*/
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 | |
SECONDS_IN_DAY = (24*60*60) | |
REPORT_ROOT = File.expand_path("~/Documents/Business/Accounts/iTunes Finance Reports") | |
# I group US and WW on the same invoice as they are both in USD | |
INVOICE_GROUPS = [%w{AU}, %w{CA}, %w{GB}, %w{EU}, %w{US WW}, %w{JP}] | |
one_month_ago = Time.now - (30 * SECONDS_IN_DAY) | |
# My "fetch_finance_reports" script puts reports in a sub-dir e.g. 2010-09-Aug |
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
/*! | |
* jQuery Tiny Pub/Sub - v0.X - 11/18/2010 | |
* http://benalman.com/ | |
* | |
* Original Copyright (c) 2010 "Cowboy" Ben Alman | |
* Dual licensed under the MIT and GPL licenses. | |
* http://benalman.com/about/license/ | |
* | |
* Made awesome by Rick Waldron | |
* |
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 of version 1.1.2, Propane will load and execute the contents of | |
~Library/Application Support/Propane/unsupported/caveatPatchor.js | |
immediately following the execution of its own enhancer.js file. | |
You can use this mechanism to add your own customizations to Campfire | |
in Propane. | |
Below you'll find two customization examples. |
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 | |
... | |
# FORCE to implement content_for in controller | |
def view_context | |
super.tap do |view| | |
(@_content_for || {}).each do |name,content| | |
view.content_for name, content | |
end | |
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
class Merchant < ActiveRecord::Base | |
def foobarable? | |
# ... | |
end | |
end | |
class Customer < ActiveRecord::Base | |
belongs_to :merchant | |
def foobar=(something_else) | |
self[:foobar] = something_else if merchant.foobarable? |
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
module MigrationHelper | |
#options are: | |
# :pk_table_name | |
# :pk_column_name | |
# :cascade_delete | |
# :cascade_update | |
def add_fk(fk_table_name, fk_column_name, options = {}) | |
fk_table_name = fk_table_name.to_s | |
fk_column_name = fk_column_name.to_s | |
pk_table_name = options[:pk_table_name] || fk_column_name[0, fk_column_name.index("_id") || fk_column_name.length].pluralize |
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
/** | |
* Simply compares two string version values. | |
* | |
* Example: | |
* versionCompare('1.1', '1.2') => -1 | |
* versionCompare('1.1', '1.1') => 0 | |
* versionCompare('1.2', '1.1') => 1 | |
* versionCompare('2.23.3', '2.22.3') => 1 | |
* | |
* Returns: |
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
# RubyGems has this functionality built-in. Just specify | |
# the particular version you want to use as the first argument | |
# of the command, surrounded by underscores. | |
$ gem install rails --version 3.0.9 | |
... | |
$ gem install rails --pre | |
... | |
$ rbenv rehash | |
$ rails --version |
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 self.read_barcode_from_image path | |
# Call the barcode reader - and get a response of multiple lines | |
ls = `/usr/bin/zbarimg '#{path}'`.lines | |
# Handle a variety of unexpected responses that we have seen and debugged quickly over time | |
ls = [ls] if ls.is_a?(String) | |
barcodes = [] | |
return barcodes if ls.nil? || ls == 0 | |