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 Ova | |
| # autovivifying map from [class][method][signature] to Method | |
| @@Ova = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) } | |
| # Wrap #respond_to? for parity with Class#===. | |
| Responder = Struct.new(:method) do | |
| def === obj | |
| obj.respond_to?(method) | |
| end | |
| 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
| #!/usr/bin/env ruby | |
| class HSPAL | |
| # Enforce unsigned 16-bit data by clamping all entries. | |
| class Stack < Array | |
| def << val | |
| super [0, val, 0xFFFF].sort[1] | |
| end | |
| 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
| $fns = 0 | |
| # Automatically curry all functions for slightly greater legibility. | |
| # Keep track of how many functions end up getting created (for laughs). | |
| # Get to use the fancy symbol everywhere. | |
| def λ | |
| $fns += 1 | |
| proc.curry | |
| 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
| class Fixnum | |
| def call prog | |
| return unless self == 4 | |
| unless prog = prog.delete(' ')[/\A3\.(\d*)4\z/, 1] | |
| raise SyntaxError, "Program must begin '3.' and end '4'.", caller | |
| end | |
| arity = [3, 3, 3, 3, 0, 1, 2, 1, 1, 0] | |
| cells = [i = pc = 0] * 100 | |
| insns, loops, stack = [], {}, [] |
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
| def Process.gsub pat, sub | |
| mem = File.open('/proc/self/mem', 'r+') | |
| maps = File.open('/proc/self/maps') | |
| maps.each do |map| | |
| from, to, perms, offset = map.scan(/(\h+)-(\h+) (\S+) (\h+)/)[0] | |
| if perms['rw'] | |
| from, to = [from, to].map { |addr| addr.hex + offset.hex } | |
| data = mem.tap { |m| m.seek from }.read(to - from) rescue next |
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
| #!/bin/sh | |
| gem search --no-vers | parallel -j0 -I$ 'curl -O `curl https://rubygems.org/api/v1/gems/$.json | jq -r .gem_uri`' |
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
| diff --git a/enum.c b/enum.c | |
| index 4b1e119..c717540 100644 | |
| --- a/enum.c | |
| +++ b/enum.c | |
| @@ -1043,7 +1043,7 @@ enum_sort_by(VALUE obj) | |
| return ary; | |
| } | |
| -#define ENUMFUNC(name) rb_block_given_p() ? name##_iter_i : name##_i | |
| +#define ENUMFUNC(name, argc) argc ? name##_eqq : rb_block_given_p() ? name##_iter_i : name##_i |
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 Enumerable | |
| def all? p = nil | |
| pred = block_given? ? proc : -> x { p ? p === x : x } | |
| each { |obj| return false unless pred[obj] } | |
| true | |
| end | |
| 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
| module Composable | |
| extend self | |
| def extended klass | |
| klass.send :attr_reader, :val | |
| end | |
| def method_missing klass | |
| f, g = self, const_get(klass) |
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 'socket' | |
| s = TCPSocket.new 'irc.freenode.net', 6667 | |
| s.puts "NICK slowlag" | |
| s.puts "USER slowlag 0 * :slowlag" | |
| s.puts "JOIN #ruby-offtopic" | |
| all = File.read('all').split("\n") | |
| can = all.dup |
OlderNewer