Skip to content

Instantly share code, notes, and snippets.

@zenparsing
zenparsing / slot-map.js
Created January 6, 2020 00:41
SlotMap from private fields
/*
A map class, implemented with private slots, which has the following properties:
- The presence of a mapping k => v in a SlotMap does not by itself make k or v reachable
- For each mapping k => v in a SlotMap m (whether m is reachable or not), if k is reachable then v is reachable
*/
const DELETED = {};
@zenparsing
zenparsing / hex-to-sorted-raw-encoding.rb
Created May 18, 2020 16:23
Hex to sorted raw encoding in Ruby
hex_values = ['626f6f74', '72616365', '626c6168', '6f6f7073']
packed_list = hex_values.map { |item| [item].pack('H*') }.sort().join()