Skip to content

Instantly share code, notes, and snippets.

View stellard's full-sized avatar
🇺🇦

Scott Ellard stellard

🇺🇦
View GitHub Profile
@stellard
stellard / example_fixture.rb
Created January 3, 2015 20:24
KujiFixtureLoader "name to be changed"
#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) }
@stellard
stellard / installation.sh
Created August 15, 2012 14:46 — forked from mikhailov/installation.sh
nginx+passenger (real production config)
# 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
@stellard
stellard / dupscript.js
Created May 29, 2012 21:14 — forked from csanz/dupscript.js
Looking for duplicates / Simple script example
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.
*/
@stellard
stellard / dupscript.js
Created May 29, 2012 21:14 — forked from csanz/dupscript.js
Looking for duplicates / Simple script example
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.
*/
@stellard
stellard / ensure_inclusion_of_spec.rb
Created May 26, 2012 20:59
ensure_inclusion_of_spec.rb
require 'rspec'
require 'rails'
require 'shoulda-matchers'
CORRECT_ARRAY = %w(one two three)
WRONG_ARRAY = %w(wrong array)
class Nothing
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"]
@stellard
stellard / pipeline_lookup_transform.rb
Created April 11, 2012 16:57
pipeline lookup transform
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
@stellard
stellard / music_converter.rb
Created April 5, 2012 22:59
Convert music files
#!/usr/bin/ruby
require 'rubygems'
dir = ARGV.first
unless dir
puts "must supply a directory" unless dir
puts "USAGE:"
puts "music_convert directory"
@stellard
stellard / scott_trace.rb
Created March 23, 2012 09:46
Scott Trace
# -*- 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
@stellard
stellard / array_counter.rb
Created May 25, 2011 00:45
Counter of mixed base
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