Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@guyboertje
guyboertje / dci-builder.rb
Created March 2, 2012 19:51
DCI: Builder approach
module RoleExtender
def new properties = {}
include_roles nil, properties
end
private
def include_roles roles, properties
instance = allocate()
var WeightedMarkerClusters;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
(function($, w) {}, WeightedMarkerClusters = (function() {
function WeightedMarkerClusters(jq_element, options) {
this.ele = jq_element;
this.opts = options;
this.markerCluster = null;
this.entity_id = this.ele.parent().find(".context").eq(0).data("entityId");
this.map = this.ele.find(this.opts.map_selector).eq(0);
this.map.gmap3({
@guyboertje
guyboertje / Entity_sales_doc.txt
Created April 17, 2012 13:51
Entity related Sales
Regards the building of collections of documents for entity reporting.
Prerequisites:
Import of entities
Import of products
Import of users
Actions:
Import of historic sales
Import of joining/leaving mailinglists
@guyboertje
guyboertje / gist:3788293
Created September 26, 2012 14:13
virtus hacks console output
h = {description: 'blah', id: '1046d670-e9ff-012f-5d84-38f6b11b6fe1', images: [1,2,3], name: 'bob', owner_id: '1005bc90-e9ff-012f-5d84-38f6b11b6fe1', creating_user_id: '1005bb10-e9ff-012f-5d84-38f6b11b6fe1', summary: 'aasdasd', tags: [1,2,3], upc: 333222}
=> {:description=>"blah", :id=>"1046d670-e9ff-012f-5d84-38f6b11b6fe1", :images=>[1, 2, 3], :name=>"bob", :owner_id=>"1005bc90-e9ff-012f-5d84-38f6b11b6fe1", :creating_user_id=>"1005bb10-e9ff-012f-5d84-38f6b11b6fe1", :summary=>"aasdasd", :tags=>[1, 2, 3], :upc=>333222}
1.9.3p194 :002 > h[:digital_commodities] = [{asset_id: '1046e450-e9ff-012f-5d84-38f6b11b6fe1', commodity_id: '10552d90-e9ff-012f-5d84-38f6b11b6fe1', from_warehouse: false, meta_data_changed: false, meta_data: {}, tags: []}]
=> [{:asset_id=>"1046e450-e9ff-012f-5d84-38f6b11b6fe1", :commodity_id=>"10552d90-e9ff-012f-5d84-38f6b11b6fe1", :from_warehouse=>false, :meta_data_changed=>false, :meta_data=>{}, :tags=>[]}]
1.9.3p194 :003 > h[:public_copy_missing] = [1,2,3,4]
https://gist.github.com/guyboertje/9f092038311c4777f453
@guyboertje
guyboertje / some_model.rb
Last active August 29, 2015 14:19
Streaming Json parsing: implest class to build from Oj.saj_parse and JrJackson::Json.sj_parse
class SomeModel
def null(*) end
ATTRS = ['v_string', 'v_num', 'v_boolean', 'v_decimal']
attr_accessor *ATTRS.map(&:to_sym)
METHODMAP = Hash.new(instance_method(:null))
ATTRS.each {|attr| METHODMAP[attr] = instance_method("#{attr}=") }
def self.load(hash) new.load(hash); end
def load(hash)
@guyboertje
guyboertje / Ruby.tmLanguage
Created July 9, 2015 14:05
Ruby.tmLanguage
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>comment</key>
<string>
TODO: unresolved issues
text:
"p &lt;&lt; end
@guyboertje
guyboertje / logstash-pipe-bench.txt
Last active August 29, 2015 14:25
Logstash pipeline bench report
For all below, this applies...
ruby -v
jruby 1.7.20 (1.9.3p551) 2015-05-04 3086e6a on Java HotSpot(TM) 64-Bit Server VM 1.8.0_45-b14 +jit [darwin-x86_64]
1) As a baseline for experimentation I substitute the JSON parser and generator for 'perfect' simulations.
So for parse I simply return a new Hash and for generate I return a new String with 1 interpolation.
yes '{"test": 1}' | bin/logstash -e 'input{stdin{codec => json_lines}} filter{clone{}} output{stdout{codec => json_lines}}' | pv -Wlart > /dev/null
01:00 [89.3k/s] [ 89k/s]
@guyboertje
guyboertje / cabin_mocking.rb
Last active August 29, 2015 14:27
Cabin mocking - it can be done
class LogTracker
def cache()
@cache ||= Hash.new{|h,k| h[k] = []}
end
def <<(hash)
hash.each{|k,v| cache[k].push(v) }
end
end
@guyboertje
guyboertje / cabin_helper.rb
Created August 19, 2015 08:51
cabin mocking version 2
class LogTracker
def filter(&block)
cache.detect(&block)
end
def cache()
@cache ||= []
end
def <<(hash)