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 -S falcon-host | |
| # frozen_string_literal: true | |
| require "falcon/environment/rack" | |
| require "roda" | |
| class App < Roda | |
| route do |r| | |
| r.root { "wombat" } | |
| 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 'optparse' | |
| class Options < Ruby::Box | |
| class Into | |
| class BadKeyError < ArgumentError | |
| def initialize(key) = super("Bad key: #{key.inspect}") | |
| end | |
| def []=(key, value) | |
| global = "$#{key.to_s.delete_prefix('$').tr('-', '_')}" |
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
| class ByteSize extends HTMLElement { | |
| static observedAttributes = ["si"]; | |
| static #binaryUnits = ["B", "KiB", "MiB", "GiB", "TiB"]; | |
| static #siUnits = ["B", "KB", "MB", "GB", "TB"]; | |
| #initialized = false; | |
| #bytes = 0; | |
| get si() { | |
| return this.hasAttribute("si"); |
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 'delegate' | |
| require 'optparse' | |
| class Options < SimpleDelegator | |
| def initialize(argv = ARGV, &) | |
| parser = OptionParser.new(&) | |
| members = members_from parser | |
| values = values_from parser, argv | |
| data = data_from members, values |
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' | |
| require 'async/http/internet/instance' | |
| require 'csv' | |
| require 'zlib' | |
| def stream_zipped_tsv(url, &) | |
| Sync do | |
| response = Async::HTTP::Internet.get(url) | |
| unless response.success? |
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 Curtain | |
| @hooks = [] | |
| @order = 0 | |
| @mutex = Mutex.new | |
| class << self | |
| attr_reader :order | |
| def register(group:, priority: 0, &block) | |
| @mutex.synchronize do |
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 'json' | |
| require 'objspace' | |
| class RubyVM | |
| module Shape | |
| def self.id(obj) | |
| json = ObjectSpace.dump(obj, output: :string) | |
| JSON.parse(json).fetch('shape_id') | |
| 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 'strscan' | |
| require 'bigdecimal' | |
| # This is copied and slightly refactored from BareTest::TabularData | |
| # | |
| # Example | |
| # LiteralParser.parse("nil") # => nil | |
| # LiteralParser.parse(":foo") # => :foo |
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 'fiddle' | |
| module Procify | |
| WORD = Fiddle::SIZEOF_VOIDP | |
| RPROC_OFFSET = 4 * WORD | |
| PROC_FLAG_OFFSET = 32 | |
| PROC_PACKED = [0].pack('Q').freeze | |
| LAMBDA_PACKED = [2].pack('Q').freeze | |
| refine Proc do |
NewerOlder