I hereby claim:
- I am jszmajda on github.
- I am jszmajda (https://keybase.io/jszmajda) on keybase.
- I have a public key whose fingerprint is 31BD 2FD8 F4D2 2B00 BBF1 7FAB 7E77 C933 FF4A 472B
To claim this, I am signing this object:
| # Multiple inheritance with Modules as an alternative to injected composition | |
| # from Sandi Metz's talk [Nothing is Something](http://confreaks.tv/videos/bathruby2015-nothing-is-something) | |
| # Like Sandi's 'direct' DI method this has behavior outside of the base class | |
| # that gets composed together. However in this gist I compose modules in class | |
| # definitions instead of injecting collaborators. | |
| # Tradeoffs between this and Sandi's version are that in this case the API consumer doesn't | |
| # have to know how to make a RandomEchoHouse (no `house = House.new(formatter: Whatever.new)`), | |
| # but also the API consumer can't make anything not already accounted for either. |
I hereby claim:
To claim this, I am signing this object:
| module MongoMapper | |
| module Associations | |
| class InArrayProxy < Collection | |
| def set_parent(parent, options={}) | |
| self.each do |k| | |
| k.set_parent(parent) | |
| if (!options.has_key?(:recursive) or options[:recursive] == true) and k.send( reflection.name ).size > 0 | |
| k.send( reflection.name ).set_parent(k, options) | |
| end | |
| end |
| # in lib/asset_tag_helper_ext.rb | |
| module ActionView | |
| module Helpers | |
| module AssetTagHelper | |
| alias :orig_javascript_include_tag :javascript_include_tag | |
| def javascript_include_tag(*sources) | |
| options = sources.extract_options!.stringify_keys | |
| rkey = '__scripts' | |
| request[rkey] ||= [] |
| # based on http://code.activestate.com/recipes/528911-barcodes-convert-upc-e-to-upc-a/ | |
| class Upc | |
| def self.convert_upc_e_to_upc_a(upce=nil) | |
| return upce if upce.nil? or upce.length < 6 or upce.length > 8 # not a UPC-E | |
| upce = case upce.length | |
| when 6 | |
| upce | |
| when 7 | |
| upce[0,6] |
| # manifest-entry-field => [ search-method, product-data-source, link-weight ] | |
| # search-method: is the name of a function [fuzzy_search | manufacturer_search | exact] | |
| # OR a lambda which receives ( the value of manifest-entry-field, the value of product-data-source ) | |
| # and returns the matching product or nil | |
| LINKING_COLUMNS = { | |
| :title => [:fuzzy_search, | |
| :title, | |
| 5], | |
| #:description => [:fuzzy_search, :description, 10], |
| $('#bidding .editable').editable('/loads/<%=@load.id%>/manifest_entries/edit_in_place.ajax', { | |
| 'id': 'elementid', | |
| 'name': 'elementname', | |
| 'callback': function(result,settings){ | |
| var field = $(this).attr('class').split(/ /).pop(); | |
| if(field.match(/_cents$/)){ | |
| $(this).html(result.manifest_entry.manifest_entry[field]/100).formatCurrency(); | |
| } else { | |
| $(this).html(result.manifest_entry.manifest_entry[field]); | |
| } |
| require 'rubygems' | |
| require 'httparty' | |
| require 'curb' | |
| require 'net/http' | |
| require 'benchmark' | |
| include Benchmark | |
| RUNS = 1000 | |
| url = 'http://localhost:4567/' |
| var stepTime = 1; | |
| var col = undefined; | |
| var Cell = Backbone.Model.extend({ | |
| x: -1, | |
| y: -1, | |
| alive: false, | |
| nextAlive: false, | |
| initialize: function() { |
Conway's Game of Life in Erlang, in 2 hours, with 0 Erlang experience, in 20 lines of code.
1337 h4x0rs: