Skip to content

Instantly share code, notes, and snippets.

View dkam's full-sized avatar

Dan Milne dkam

View GitHub Profile
Loading production environment (Rails 2.3.11)
ree-1.8.7-2011.03 :001 > Product.find_by_gtin("9781854309655")
ArgumentError: time out of range
from /usr/local/rvm/gems/ree-1.8.7-2011.03/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:635:in `local'
from /usr/local/rvm/gems/ree-1.8.7-2011.03/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:635:in `each'
from /usr/local/rvm/gems/ree-1.8.7-2011.03/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:635:in `select'
from /usr/local/rvm/gems/ree-1.8.7-2011.03/gems/activerecord-2.3.11/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
from /usr/local/rvm/gems/ree-1.8.7-2011.03/gems/activerecord-2.3.11/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'
from /usr/local/rvm/gems/ree-1.8.7-2011.03/gems/activerecord-2.3.11/lib/active_record/base.rb:665:in `find_by_sql'
from /usr/local/rvm/gems/ree-1.8.7-2011
@dkam
dkam / babushka.sh
Created November 16, 2011 03:42
Babusha shell provisioner for Vagrant
#!/bin/bash
# In your Vagrant file, add a shell provisioner, pointing to this file:
#
# config.vm.provision :shell, :path => "babushka.sh"
#
# Download and chmod the Babushka installer, if it's not already installed.
which babushka || bash -c "`wget -O - babushka.me/up/hard`"
@dkam
dkam / airvideo.conf
Created January 2, 2012 09:38
Upstart script for AirVideo (http://www.inmethod.com/)
description "Airvideo Server statup script"
author "Dan Milne"
start on startup
stop on shutdown
console output
respawn
@dkam
dkam / mythtv_transcode.sh
Created March 4, 2012 23:52
MythTV transcode
#!/bin/bash
# Arguments - %CHANID% %STARTTIME% %TITLE%
ChanID="${1}"
StartTime="${2}"
Title="${3}"
Subtitle="${4}"
Desc="${5}"
@dkam
dkam / gist:2203157
Created March 26, 2012 05:19
Calculate a signature
def calculate_sig(data, key)
digest = OpenSSL::Digest::Digest.new('sha1')
res = OpenSSL::HMAC.digest(digest, key, data)
sig = [res].pack('m').chomp
return sig
end
=== Pre caching changes ===
Concurrency Level: 5
Time taken for tests: 110.804 seconds
Complete requests: 50
Failed requests: 0
Write errors: 0
Total transferred: 966865 bytes
HTML transferred: 920200 bytes
Requests per second: 0.45 [#/sec] (mean)
irb(main):001:0> a=nil
=> nil
irb(main):002:0> a || "Hello"
=> "Hello"
irb(main):003:0> a="World"
=> "World"
irb(main):004:0> a || "Hello"
=> "World"
@dkam
dkam / gist:2944345
Created June 17, 2012 12:01
Dock sample
Sampling process 280 for 3 seconds with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Analysis of sampling Dock (pid 280) every 1 millisecond
Process: Dock [280]
Path: /System/Library/CoreServices/Dock.app/Contents/MacOS/Dock
Load Address: 0x10f74b000
Identifier: com.apple.dock
Version: 1.8 (1040.39)
Build Info: Dock-1040039000000000~1
Code Type: X86-64 (Native)
@dkam
dkam / gist:3116674
Created July 15, 2012 12:48
Nginx proxy cache config to *not* cache content for bulk requesters such as Google, given limited disk space for cache.
# Create a variable $bulk_agent by matching against $http_user_agent
map $http_user_agent $bulk_agent {
default 0;
~*Google* 1;
~*Wget* 1;
~*Ruby* 1;
~*Java* 1;
}
@dkam
dkam / gist:3748021
Created September 19, 2012 06:33
chaining proxies
dkam@Nervous-Energy ~/Development/Booko/app/models/shops (master) $ curl -I http://imgsrv.booko.com.au:8888/9780307474612
HTTP/1.1 200 OK
Content-Type: image/jpeg
Connection: keep-alive
Status: 200
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11
X-Frame-Options: sameorigin
X-XSS-Protection: 1; mode=block
Cache-Control: public, max-age=60480
Last-Modified: Wed, 29 Aug 2012 06:39:41 GMT