Skip to content

Instantly share code, notes, and snippets.

View metaskills's full-sized avatar
🧠
Adding Digital Intelligence

Ken Collins metaskills

🧠
Adding Digital Intelligence
View GitHub Profile
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
@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.
/*!
* 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
*
@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
@cowboy
cowboy / HEY-YOU.md
Last active September 25, 2025 09:25
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
# Using MacPort libs for all RVM rubie installs.
export CC='/usr/bin/gcc-4.2'
export CFLAGS='-O2 -arch x86_64'
export LDFLAGS='-L/opt/local/lib'
export CPPFLAGS='-I/opt/local/include'
rvm install saidrubie -C --with-opt-dir=/opt/local
ejb-mbp2:activerecord-sqlserver-adapter ebryn$ ruby test/benchmark/query_sqlserver.rb
-- create_table(:test_benchmarks, {:force=>true})
-> 0.0715s
Query Sqlserver
===============
Author: Erik Bryn
Date: October 19, 2010
Summary: Benchmark SQL Server Queries
System Information
Time.utc(1999, 12, 30, 23, 45, 00, 123000).strftime("%L") # => "123"
Time.utc(1999, 12, 30, 23, 45, 00, 123000).strftime("%3N") # => "123" millisecond (3 digits)
Time.utc(1999, 12, 30, 23, 45, 00, 123000).strftime("%6N") # => "123000" microsecond (6 digits)
Time.utc(1999, 12, 30, 23, 45, 00, 123000).strftime("%9N") # => "123000000" nanosecond (9 digits)
Time.utc(1999, 12, 30, 23, 45, 00, 123000).to_f # => 946597500.123
Time.utc(1999, 12, 30, 23, 45, 00, 123000).usec # => 123000
require 'date'
require 'rational'
[datetime] => SYBDATETIME
61 1753-01-01T00:00:00.000 y:1753, m:1, d:1 h:0, m:0, s:0 MS:0 tz:1550134876
62 9999-12-31T23:59:59.997 y:9999, m:12, d:31 h:23, m:59, s:59 MS:997 tz:1550134876
63 2010-01-01T12:34:56.123 y:2010, m:1, d:1 h:12, m:34, s:56 MS:123 tz:1744847616
[smalldatetime] => SYBDATETIME4
231 1901-01-01T15:45:00.000Z days:365 minutes:945 (since 1/1/1900, since midnight)
232 2078-06-05T04:20:00.000Z days:65169 minutes:260 "
[datetime2_7] => SYBCHAR
71 0001-01-01T00:00:00.0000000Z 0001-01-01 00:00:00.0000000
# result = @client.execute('SELECT 1 AS [one]')
# result.cancel
# result.cancel
write.c:136:tds_put_string converting 17 bytes of "SELECT 1 AS [one]"
write.c:164:tds_put_string wrote 34 bytes
util.c:162:Changed query state from QUERYING to PENDING
net.c:779:Sending packet