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
| cls = "single#{i.zero? ? " first" : i == images.size - 1 ? " last" : ""}" | |
| cls = "single" + {0 => " first", images.size - 1 => " last"}[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
| class Integer | |
| def method_missing meth, *args | |
| super unless meth[/base\d+/] | |
| to_s meth[4,2.0].to_i | |
| 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
| ops = %w[push pop dup copy swap slide add sub mul div mod store load label call jump jz jn ret exit ichr inum ochr onum] | |
| quat = [5, 31, 29, 25, 30, 27, 149, 150, 151, 153, 154, 41, 42, 53, 54, 55, 57, 58, 59, 63, 185, 186, 181, 182] | |
| ops = Hash[ops.zip quat.map { |q| q.to_s(4).tr '123', " \t\n" }] | |
| def encode num | |
| (num < 0 ? "\t" : ' ') + ('%b' % num.abs).tr('01', " \t") + "\n" | |
| end | |
| source = File.read ARGV[0] | |
| source.gsub! /\s*[;#].+/, '' |
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
| push 3 | |
| push 0 | |
| dup | |
| inum | |
| load | |
| 0: | |
| swap | |
| push 3 | |
| mul |
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
| push 0 | |
| dup | |
| inum | |
| load | |
| dup | |
| push 20 | |
| div | |
| 0: | |
| dup |
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 side piece | |
| piece == ' ' ? -1 : piece =~ /[a-z]/ | |
| end | |
| fen = File.read ARGV.shift | |
| board = [*'1'..'8'].reverse.product [*'a'..'h'] | |
| from, to = *ARGV.map { |a| board.index a.reverse.split // } | |
| raise 'Wat.' if from == to | |
| board, act, _ = fen.split |
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
| $stack, $draws = [], {} | |
| def method_missing *args | |
| return if args[0][/^to_/] | |
| $stack << args.map { |a| a or $stack.pop } | |
| $draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
| end | |
| class Array | |
| def +@ |
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 Symbol | |
| def | other | |
| -> arg { arg.send(self).send(other) } | |
| end | |
| end | |
| class Proc | |
| def | other | |
| -> arg { call(arg).send(other) } | |
| end |