This file contains 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
# frozen_string_literal: true | |
require 'concurrent' | |
require 'benchmark' | |
def api_a_call | |
sleep 2 | |
'answer_from_api_a' | |
end |
This file contains 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
# frozen_string_literal: true | |
require 'concurrent' | |
require 'benchmark' | |
def api_a_call | |
sleep 2 | |
'answer_from_api_a' | |
end |
This file contains 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
# frozen_string_literal: true | |
require 'fiber' | |
# Manage packet. | |
class Packets | |
def initialize | |
@packets = [] | |
end |
This file contains 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
# frozen_string_literal: true | |
require 'fiber' | |
# Manage packet. | |
class Packets | |
def initialize | |
@packets = [] | |
end |
This file contains 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
require 'nio' | |
selector = NIO::Selector.new | |
# 1234番ポートでTCPを待ち受ける | |
server = TCPServer.new('localhost', 1234) | |
# 標準出力を取得する。常にwriteが可能な口がほしいだけ | |
stdout = $stdout | |
# セレクタに登録。 |
This file contains 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
require 'nio' | |
require 'fiber' | |
require 'timers' | |
require 'io/nonblock' | |
class Scheduler | |
def initialize | |
@selector = NIO::Selector.new | |
@fibers = {} | |
@timers = Timers::Group.new |
This file contains 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 GildedRose | |
NAME_SULFURAS = 'Sulfuras, Hand of Ragnaros'.freeze | |
NAME_BRIE = 'Aged Brie'.freeze | |
NAME_PASS = 'Backstage passes to a TAFKAL80ETC concert'.freeze | |
MAX_QUALITY = 50 | |
def initialize(items) | |
@items = items | |
end |
This file contains 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
require 'fiddle' | |
libc = Fiddle.dlopen('libc.so.6') | |
printf = Fiddle::Function.new(libc['printf'], | |
[Fiddle::TYPE_VOIDP], | |
Fiddle::TYPE_INT | |
) | |
printf.call "Hello with Fiddle::Function\n" | |
require 'fiddle/import' |
This file contains 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
require 'uri' | |
require 'open-uri' | |
require 'net/http' | |
require 'bundler/inline' | |
require 'securerandom' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'nokogiri' | |
end |
This file contains 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
Set-ExecutionPolicy RemoteSigned -scope CurrentUser | |
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh') | |
scoop install git ruby bison m4 sed patch gzip | |
git clone https://github.com/microsoft/vcpkg | |
.\vcpkg\bootstrap-vcpkg.bat | |
.\vcpkg\vcpkg --triplet x64-windows install openssl zlib | |
win32\configure.bat --without-ext=+,dbm,gdbm,readline --enable-bundled-libffi --with-opt-dir=C:/opt/local/src/github.com/Microsoft/vcpkg/installed/x64-windows |