This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| require "rubygems" | |
| require "rbench" | |
| require "set" | |
| RANGE = (1..1000) | |
| ARRAY = RANGE.to_a | |
| SET = Set.new(ARRAY) | |
| HASH = ARRAY.inject({}) {|m, x| m[x] = true; m} | |
| WORST_CASE_COMPLEXITY = ARRAY.size + 1 |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| As a strategic consulting firm focused on Innovation and Growth Strategies, I wanted to take an opportunity to introduce myself and our firm. I understand that you and your colleagues may be in the midst of evaluating new initiatives in this area, hence the timing of this introduction. | |
| I would like to present Harrison Hayes‘ approach to the creation and validation of market growth strategies and how our methodologies may fit your objectives at Twitter. | |
| At Harrison Hayes, our suite of service includes: | |
| Whitespace Opportunity Identification / Disruptive Ideation | |
| Market Access/Market Landscaping / Emerging Market Analysis | |
| Technology Scouting / New Product Validation | |
| Market Adjacency Mapping |
| # source 'http://rubygems.org' | |
| source :gemcutter | |
| gem 'rails', '3.1.0.beta1' | |
| # Asset template engines | |
| gem 'json' | |
| gem 'sass' | |
| gem 'coffee-script' | |
| gem 'uglifier' |
| class LcmFinder | |
| attr_accessor :seen, :factors | |
| def initialize | |
| @seen = Set.new | |
| @factors = Hash.new(0) | |
| end | |
| def factor(n) | |
| cur = n |
| class Numeric | |
| SCALE_TO_WORD = Hash.new do |h, i| | |
| " * 10^#{i * 3}" | |
| end.merge({ 1 => " thousand", | |
| 2 => " million", | |
| 3 => " billion", | |
| 4 => " trillion" | |
| }) | |
| # in my unscientific test, no one really found names beyond trillion useful. |
| ls .rvm/gems/ree-1.8.7-2010.02/gems/ | perl -ne 's/(.*)-[.\d]+/$1/; print' | sort | uniq >~/gems | |
| ...change to a different ruby... | |
| cat ~/gems | xargs gem install |
| main = print (take 1000 hamming) | |
| hamming = 1 : map (2*) hamming ~~ map (3*) hamming ~~ map (5*) hamming | |
| where | |
| xxs@(x:xs) ~~ yys@(y:ys) -- To merge two streams: | |
| | x==y = (x : xs~~ys) -- if the heads are common, take that | |
| | x<y = (x : xs~~yys) -- otherwise, take the smaller one | |
| | x>y = (y : xxs~~ys) -- and proceed to merge the rest | |
| (defun n-hammings (twos threes fives tail n out) | |
| (if (= n 0) |
| /* | |
| * Fabrizio Calderan, twitter @fcalderan, 2010.11.02 | |
| * I had an idea: could Inception movie be explained by a few javascript closures | |
| * and variable resolution scope (just for fun)? | |
| * | |
| * Activate javascript console =) | |
| */ | |
| <script> | |
| console.group("inception movie"); |
| module Stop | |
| module CantTouchThis | |
| def self.included(mod) | |
| %w[instance_variable_get instance_variable_set].each do |m| | |
| send(:protected, m) | |
| end | |
| eigenclass = class << mod; self; end | |
| %w[const_set class_variable_get class_variable_set public_class_method attr attr_reader attr_writer].each do |m| |