Skip to content

Instantly share code, notes, and snippets.

View metaskills's full-sized avatar
🐙
Being Inkcellent to Each Other

Ken Collins metaskills

🐙
Being Inkcellent to Each Other
View GitHub Profile
@lukeredpath
lukeredpath / process_last_months_finance_reports.rb
Created November 15, 2010 13:28
Loop through each finance report and run it using my process_finance_report script, creating an invoice in FreeAgent.
#!/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
/*!
* 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
*
@protocool
protocool / caveatPatchor.js
Created February 14, 2011 02:29
Sample caveatPatchor.js file for use in Propane 1.1.2 and above
/*
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.
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
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?
@scottjacobsen
scottjacobsen / migration_helper.rb
Created July 30, 2011 11:46
fk migration helpers
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
@alexey-bass
alexey-bass / compare.js
Created July 30, 2011 14:03
JavaScript version compare
/**
* 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:
@sstephenson
sstephenson / gist:1143900
Created August 13, 2011 14:20
Using multiple versions of Rails without gemsets
# 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
anonymous
anonymous / zbarrubyexample.rb
Created August 15, 2011 13:09
Using Zbar barcode reader command line with Ruby
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
@nheinrich
nheinrich / gist:1171939
Created August 25, 2011 21:03
Using Sass & Compass in Rails 3.1

app/assets/stylesheets/application.css

/*
  *= require "application/all"
*/

app/assets/stylesheets/application/_all.sass