Skip to content

Instantly share code, notes, and snippets.

View coezbek's full-sized avatar

Christopher Özbek coezbek

View GitHub Profile
@coezbek
coezbek / test_async.rb
Created October 31, 2021 20:41
Testing async with HTTParty and Async gem
require 'async'
require 'benchmark'
require 'open-uri'
require 'httparty'
n = 3
Benchmark.bm(20) do |b|
b.report "Sequential" do
n.times do |i|
@coezbek
coezbek / Writeable.rb
Created July 22, 2019 07:25
System method added to Flammarion::Writeable to spawn subprocesses in Flammarion
module Flammarion::Writeable
# Run the given program using Open3.popen3 and redirects output to the subpane("out") (STDOUT and STDERR).
#
# This method does not block, but returns after the program has been started.
#
# Caution: By default most program run via Open3.popen3 assume they are started in non PTY mode and will buffer their output.
# To tell the program to be interactive use something like 'script -qefc \"<program>\" /dev/null' as command.
# See https://stackoverflow.com/questions/1401002/trick-an-application-into-thinking-its-stdout-is-a-terminal-not-a-pipe
#
# +*cmd+:: cmd string to pass to Open3.popen3