Skip to content

Instantly share code, notes, and snippets.

@0x0dea
Created January 27, 2016 19:50
Show Gist options
  • Select an option

  • Save 0x0dea/6a06310137042bcb98f0 to your computer and use it in GitHub Desktop.

Select an option

Save 0x0dea/6a06310137042bcb98f0 to your computer and use it in GitHub Desktop.

Revisions

  1. 0x0dea created this gist Jan 27, 2016.
    13 changes: 13 additions & 0 deletions foo.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    require 'open3'

    i, o = Open3.popen2 'ruby repl.rb'
    line = nil

    puts 'Gimme Ruby expressions to evaluate (in another process).'

    Thread.new do
    i.puts line while line = gets
    i.close
    end

    puts line while line = o.gets
    4 changes: 4 additions & 0 deletions repl.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    while line = gets
    p eval line
    $stdout.flush
    end