This file contains hidden or 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 DataLiteral | |
| refine Hash do | |
| def to_data(name = nil) | |
| if name | |
| unless Object.const_defined?(name) | |
| Object.const_set(name, Data.define(*keys)) | |
| end | |
| Object.const_get(name).new(*values) | |
| else |
This file contains hidden or 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 hidden or 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 hidden or 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 | |
| unless Object.const_defined?(class_name) | |
| Object.const_set(class_name, Struct.new(*keys)) | |
| end | |
| Object.const_get(class_name).new(*values) | |
| else |
This file contains hidden or 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 hidden or 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 |