Tokyo Ruby Kaigi

Tokyo Ruby Kaigi

My talk from Tokyo Ruby Kaigi

F29327647a9cff5c69618bae420792ea?s=128

Aaron Patterson

May 28, 2016
Tweet

Transcript

  1. 1.
  2. 5.
  3. 8.
  4. 16.

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

    they do • Are they worth any money? • Plus many more!
  5. 18.
  6. 30.
  7. 32.
  8. 36.

    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
  9. 37.

    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
  10. 39.
  11. 50.
  12. 51.
  13. 52.
  14. 56.
  15. 58.
  16. 61.
  17. 62.
  18. 64.
  19. 66.
  20. 67.

    ྠֲΛݟ͚ͭΔ 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
  21. 68.
  22. 69.
  23. 71.
  24. 72.

    ଟ֯ܗΛݟ͚ͭΔ approx = max.approx_poly(:method => :dp, :recursive => true, :accuracy

    => 0.02 * peri) x = approx.convex_hull2.to_a clockwise_points = clockwise x.reverse
  25. 73.
  26. 74.

    ಁࢹม׵ͷߦྻ 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)
  27. 76.
  28. 78.
  29. 81.
  30. 84.
  31. 85.
  32. 88.
  33. 90.
  34. 92.
  35. 93.
  36. 94.
  37. 98.
  38. 100.
  39. 102.
  40. 106.

    ഑ྻ 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
  41. 107.

    ࿈૝഑ྻ 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
  42. 109.

    Objects require 'phuby' class RubyKaigi def where puts "౦ژ" end

    end Phuby::Runtime.php do |runtime| runtime['kaigi'] = RubyKaigi.new runtime.eval("$kaigi->where();") # => ౦ژ end
  43. 110.
  44. 111.
  45. 112.

    scientists were so preoccupied with whether or not they could

    that they didn't stop to think if they should.
  46. 119.

    GC

  47. 121.

    ໰୊ 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 # => []
  48. 122.

    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", ... ]
  49. 125.
  50. 127.
  51. 129.
  52. 131.
  53. 132.
  54. 140.
  55. 142.
  56. 143.
  57. 144.

    Modern advocates of homeopathy have proposed a concept of "water

    memory", according to which water "remembers" the substances mixed in
  58. 147.
  59. 149.
  60. 154.
  61. 155.
  62. 156.
  63. 159.
  64. 162.