➜ psd.rb git:(master) ✗ bundle exec ruby examples/export_layer_images.rb benchmark_small.psd
user system total real
1.370000 0.490000 1.860000 ( 1.861384)
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
# We create an index to store all of the comments in the tree, | |
# indexed by ID. This lets us quickly build out the comment structure | |
# as we iterate over each comment. | |
node_index = ActiveSupport::OrderedHash.new | |
nodes.each do |node| | |
node_index[node.id] = { | |
node: node, | |
parent: nil, | |
reply_to: nil, | |
children: [] |
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
# We use includes(:member) to solve one of the N+1 issues by loading | |
# all of the members in a single query. | |
serialized_comments = article. | |
comments. | |
includes(:member). | |
arrange_serializable do |comment, children| | |
# This block is invoked for every node in the tree, which lets us | |
# build out a tree of serialized comments. | |
Api::V1::CommentSerializer.new(comment, children: children) | |
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
# Is there a better way to achieve this without having to define #orig_foo in each subclass? | |
class A | |
def orig_foo | |
self.class.superclass == Object ? foo : method(:foo).super_method.call | |
end | |
def foo | |
"foo" | |
end | |
end |
I hereby claim:
- I am meltingice on github.
- I am ryanlefevre (https://keybase.io/ryanlefevre) on keybase.
- I have a public key whose fingerprint is BEA0 C90A 92D1 C161 2ED8 4DF4 BDEC 0849 9B28 19A8
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
10/15/14 2:41:17.987 PM Sonos[80437]: (SCLib) msrch(1): Expect self m-search | |
10/15/14 2:41:17.987 PM Sonos[80437]: (SCLib) msrch(0): Failed to setup MSearchNotifyHandler. |
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
9/16/14 9:48:24.752 AM Sonos[20995]: (SCLib) msrch(0): Failed to setup MSearchNotifyHandler. | |
9/16/14 9:48:24.753 AM Sonos[20995]: (SCLib) msrch(1): Expect self m-search |
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
class Object | |
def self.inherited(subclass) | |
subclass.send(:prepend, Module.new do | |
def inspect | |
"naw bawg" | |
end | |
end) | |
super | |
end | |
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
class ParentClass | |
@foo = "bar" | |
class << self | |
attr_accessor :foo | |
def inherited(subclass) | |
subclass.instance_variable_set :@foo, "bar" | |
super | |
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
module Async | |
def async(method) | |
prepend(Module.new { | |
define_method(method) do |*args| | |
Thread.new(*args) do |*args| | |
puts Thread.current.object_id.to_s(16) | |
super(*args) | |
end | |
end | |
}) |