NaN payloads in Ruby

Run Settings
LanguageRuby
Language Version
Run Command
require 'fiddle' require 'json' def encode msg Object.new.tap do |o| fp = Fiddle::Pointer.new o.__id__ * 2 fp[0, 16] = "d\b\0\0\0\0\0\0" + [Float.__id__ * 2].pack('Q') fp[16, 8] = "#{msg}\xFF\x7F" end end def decode nan Fiddle::Pointer.new(nan.__id__ * 2)[16, 6] end a = encode 'foobar' b = encode 'a test' p [a, decode(a)] p [b, decode(b)]
Editor Settings
Theme
Key bindings
Full width
Lines