I hereby claim:
- I am tiegz on github.
- I am tiegz (https://keybase.io/tiegz) on keybase.
- I have a public key whose fingerprint is 0D92 1FF5 1FB8 69AB 5B84 469D BDFF 2F6F 0895 870F
To claim this, I am signing this object:
This file contains hidden or 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 'json' | |
require 'pp' | |
class UniqloProductFetcher | |
attr_accessor :json | |
# eg 135779 is pocketable shorts | |
def initialize(product_id: "135779") | |
@product_id = product_id | |
end |
This file contains hidden or 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
# http://sztyled.en.made-in-china.com/product/SqUmJxylhbhK/China-24-Key-Infrared-RGB-Manual-Flash-Controller-APA-1616-.html | |
# or | |
# http://www.dhgate.com/store/product/advanced-micro-control-unit-24-keys-rgb-led/128629434.html | |
IR Receiver Notes | |
F700FF BRIGHT HI | |
F7807F BRIGHT LO | |
F7408F OFF | |
F7C03F ON | |
F720DF R1 |
This file contains hidden or 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 'benchmark' | |
GC.disable | |
x = {:a => 1} | |
ms1 = 1000 * Benchmark.realtime { 1_000_000.times { x.dup } } | |
ms2 = 1000 * Benchmark.realtime { 1_000_000.times { x.clone } } | |
puts [ |
This file contains hidden or 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
# config/initializers/profile_assets_middleware.rb | |
Kickstarter::Application.config.middleware.insert_before "Ksr::AuthenticatedRaindrops", | |
"ProfileAssetsMiddleware" |
This file contains hidden or 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
get_size = ->(memo,val) { | |
memo + case val | |
when String | |
val.bytes.size | |
when Hash | |
val.map { |k,v| get_size[0, k] + get_size[0, v] }.sum | |
when Array | |
val.map { |v| get_size[0, v] }.sum | |
when nil, true, false, Fixnum, Symbol | |
0 |
This file contains hidden or 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
# There could likely be some false positives from this | |
Rails.application.routes.routes.select do |r| | |
name = r.defaults[:controller].to_s.classify + "Controller" | |
klass = name.constantize rescue nil | |
if klass.nil? | |
name = r.defaults[:controller].to_s.classify.pluralize + "Controller" | |
klass = name.constantize rescue nil | |
end |
This file contains hidden or 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
> ((((Nokogiri::HTML(open("http://en.wikipedia.org/wiki/The_Expendables_(film_series)#Cast_and_characters").read) / "#Cast_and_characters").first.parent.next_element) / "tr")[1..-1].map { |tr| (tr / "td").map { |td| td['colspan'].to_i > 0 ? ([td.text] * td['colspan'].to_i) : td.text } }).map(&:flatten).tap { |a| (0..2).map { |i| a.map { |row| row[i].blank? ? 0 : 1 }.sum }.tap { |a| puts "1->2: #{(a[1] - a[0]) / a[0].to_f}%"; pus "2->3: #{(a[2] - a[1]) / a[1].to_f}%" } } nil | |
1->2: 0.0 | |
2->3: 0.26666666666666666 |
This file contains hidden or 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 ObjectSpace | |
def self.profile(&blk) | |
require 'objspace' | |
enable_gc = GC.disable | |
ObjectSpace.trace_object_allocations(&blk) | |
objs = Hash.new(0) | |
ObjectSpace.each_object { |o| | |
if (file = ObjectSpace.allocation_sourcefile(o)) && (line = ObjectSpace.allocation_sourceline(o)) | |
objs["#{file}:#{line}:#{o.class.name}"] += 1 |