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 | |
abort 'MJIT needs to be enabled' unless RubyVM::MJIT.enabled? | |
# make private constants available at top-level | |
# | |
constants = | |
Symbol.all_symbols.select do | |
RubyVM::MJIT.private_constant _1 rescue next | |
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 'async' | |
module Enumerable | |
module Async | |
[Array, Hash, Range, Struct].each do |collection| | |
refine collection do | |
def each(&block) | |
super do |value| | |
Async do | |
block.call(value) |
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
module StructLiteral | |
refine Hash do | |
def to_struct(class_name = nil) | |
if class_name | |
Object.const_set(class_name, Struct.new(*keys)) | |
Object.const_get(class_name).new(*values) | |
else | |
Struct.new(*keys).new(*values) | |
end | |
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 | |
class Enumerator | |
class Memoized < Enumerator | |
INTERRUPT = defined?(IRB::Abort) ? IRB::Abort : Interrupt | |
private_constant :INTERRUPT | |
def initialize(enum) | |
@original_inspect = enum.inspect | |
@enum = cloned(enum) |
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
#!/usr/bin/env python2 | |
# coding=utf-8 | |
from math import * | |
from time import sleep | |
import os | |
import random | |
import sys | |
write = sys.stdout.write |