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
#The locations and naming of these files is by convention spec/fixtures/fixture_loader/*_fixture.rb | |
let(:bin_group) { Fabricate(:bin_group) } | |
let(:external_bin) { Fabricate(:bin_type, bin_group: bin_group, :is_external => true) } | |
let(:internal_bin1) { Fabricate(:bin_type, bin_group: bin_group, :is_external => false) } | |
let(:internal_bin2) { Fabricate(:bin_type, bin_group: bin_group, :is_external => false) } | |
let(:postpaid_bag) { Fabricate(:bin_type, bin_group: bin_group, :is_bag => true, :charged_on_delivery => false) } | |
let(:prepaid_bag) { Fabricate(:bin_type, bin_group: bin_group, :is_bag => true, :charged_on_delivery => 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
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776 | |
$ cd /usr/src | |
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz | |
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz | |
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz | |
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz | |
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz |
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
db.users.group({ key: { name:true }, | |
cond: { "created_at"}, | |
initial: { count: 0 }, | |
reduce: function(obj,out) { out.count ++ ; }}); | |
/* | |
Note1: make sure you put the initial declaration above reduce or else the count variable never gets set | |
Note2: group() can't handle more than 10000 unique keys, so for large dbs you are better off using straight up map reduce. | |
*/ |
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
db.users.group({ key: { name:true }, | |
cond: { "created_at"}, | |
initial: { count: 0 }, | |
reduce: function(obj,out) { out.count ++ ; }}); | |
/* | |
Note1: make sure you put the initial declaration above reduce or else the count variable never gets set | |
Note2: group() can't handle more than 10000 unique keys, so for large dbs you are better off using straight up map reduce. | |
*/ |
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
require 'rspec' | |
require 'rails' | |
require 'shoulda-matchers' | |
CORRECT_ARRAY = %w(one two three) | |
WRONG_ARRAY = %w(wrong array) | |
class Nothing |
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
Apr 26, 2012 4:54:28 PM org.apache.catalina.core.StandardServer await | |
INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance. | |
Apr 26, 2012 4:54:28 PM org.apache.coyote.AbstractProtocol pause | |
INFO: Pausing ProtocolHandler ["http-bio-8080"] | |
Apr 26, 2012 4:54:28 PM org.apache.coyote.AbstractProtocol pause | |
INFO: Pausing ProtocolHandler ["ajp-bio-8009"] |
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
module ETL #:nodoc: | |
module Transform #:nodoc: | |
# Transform which looks up the value and replaces it with another previously seen in the pipline | |
class PipelineLookupTransform < ETL::Transform::Transform | |
class DuplicateKeyError < ETLError #:nodoc: | |
end | |
# The resolver to use if the foreign key is not found in the collection | |
attr_accessor :resolver | |
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/ruby | |
require 'rubygems' | |
dir = ARGV.first | |
unless dir | |
puts "must supply a directory" unless dir | |
puts "USAGE:" | |
puts "music_convert directory" |
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
# -*- encoding : utf-8 -*- | |
class Object | |
def scott_trace | |
now = Time.now | |
$last_scott_trace ||= now | |
diff = now - $last_scott_trace | |
notify = diff > 1 ? "!!!!!!!!!!!!!!" : "" | |
puts "#{notify} RAM USAGE: #{`ps -o rss= -p #{$$}`.to_f / 1000.0} MB TIME:#{now - $last_scott_trace}, CALLER: #{CallChain.caller_info.inspect}" | |
$last_scott_trace = now |
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 RolloverIndex | |
attr_accessor :max, :count | |
def initialize max, start = 0 | |
self.max = max | |
self.count = start | |
end | |
def inc | |
if (self.count + 1) == max |
NewerOlder