Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Tokyo Ruby Kaigi

Tokyo Ruby Kaigi

My talk from Tokyo Ruby Kaigi

Aaron Patterson

May 28, 2016
Tweet

More Decks by Aaron Patterson

Other Decks in Technology

Transcript

  1. ࢲͷ໰୊ (Χʔυͷத਎) • Too many cards • Don’t know what

    they do • Are they worth any money? • Plus many more!
  2. Executor Pool class ThreadExecutor def initialize size @queue = Queue.new

    @size = size @pool = size.times.map { |i| Thread.new { while job = @queue.pop; job.run end } } end def execute job = Proc.new promise = Promise.new job @queue << promise promise end def shutdown @size.times { @queue << nil } @pool.each(&:join) end end
  3. Queue up work promise = @executor.execute do @http_pool.with_connection do |conn|

    uri = URI 'http://gatherer.wizards.com/Pages/Default.aspx' response = conn.request uri # save the response end end # some time later promise.value
  4. ྠֲΛݟ͚ͭΔ contours = [] contour_node = processed.find_contours( :mode => OpenCV::CV_RETR_TREE,

    :method => OpenCV::CV_CHAIN_APPROX_SIMPLE) while contour_node unless contour_node.hole? contours << contour_node end contour_node = contour_node.h_next end
  5. ଟ֯ܗΛݟ͚ͭΔ approx = max.approx_poly(:method => :dp, :recursive => true, :accuracy

    => 0.02 * peri) x = approx.convex_hull2.to_a clockwise_points = clockwise x.reverse
  6. ಁࢹม׵ͷߦྻ to = [ OpenCV::CvPoint2D32f.new(0, 0), OpenCV::CvPoint2D32f.new(width, 0), OpenCV::CvPoint2D32f.new(width, height),

    OpenCV::CvPoint2D32f.new(0, height), ] from = polygon_points transform = OpenCV::CvMat.get_perspective_transform(from, to)
  7. ഑ྻ require 'phuby' Phuby::Runtime.php do |runtime| runtime.eval "$cars = array('Toyota',

    'Honda', 'BMW');" p runtime['cars'][0] # => Toyota p runtime['cars'][1] # => Honda p runtime['cars'][2] # => BMW end
  8. ࿈૝഑ྻ require 'phuby' Phuby::Runtime.php do |runtime| runtime.eval "$e = array('foo'

    => 'bar', 'bar' => 'baz');" p runtime['e']['foo'] # => 'bar' p runtime['e']['bar'] # => 'baz' end
  9. Objects require 'phuby' class RubyKaigi def where puts "౦ژ" end

    end Phuby::Runtime.php do |runtime| runtime['kaigi'] = RubyKaigi.new runtime.eval("$kaigi->where();") # => ౦ژ end
  10. scientists were so preoccupied with whether or not they could

    that they didn't stop to think if they should.
  11. GC

  12. ໰୊ require 'phuby' require 'openssl' p OpenSSL::Cipher.ciphers # => ["AES-128-CBC",

    "AES-128-CBC-HMAC-SHA1", ... ] Phuby::Runtime.php do |runtime| runtime.eval("$hi = 'Hello World';") end p OpenSSL::Cipher.ciphers # => []
  13. Solution: fork require 'phuby' require 'openssl' p OpenSSL::Cipher.ciphers # =>

    ["AES-128-CBC", "AES-128-CBC-HMAC-SHA1", ... ] Process.waitpid fork { Phuby::Runtime.php do |runtime| runtime.eval("$hi = 'Hello World';") end } p OpenSSL::Cipher.ciphers # => ["AES-128-CBC", "AES-128-CBC-HMAC-SHA1", ... ]
  14. Modern advocates of homeopathy have proposed a concept of "water

    memory", according to which water "remembers" the substances mixed in