Skip to content

Instantly share code, notes, and snippets.

Avatar
💰
absconding with my hoard

Conor O'Brien ConorOBrien-Foxx

💰
absconding with my hoard
View GitHub Profile
@ConorOBrien-Foxx
ConorOBrien-Foxx / enumerator.js
Created Mar 19, 2019
Sane enumerators for JavaScript using Generators
View enumerator.js
// for compatibility with bignumbers/regular numbers
// getZero(5n) = 0n
// getZero(5) = 0
let getZero = function (entity) {
return entity - entity;
}
let getOne = function (entity) {
let zero = getZero(entity);
zero++;
return zero;
@ConorOBrien-Foxx
ConorOBrien-Foxx / compile.rb
Last active Mar 18, 2019
Duel Links DeckListGen
View compile.rb
#!/usr/bin/env ruby
# == Duel Links DeckListGen ==
# by Conor S. O'Brien
#
# == Licensing ==
# Please note this code is licensed under CC BY-SA 4.0 (see the gist for the
# full text). This program is a tool, and thus the resulting images are not
# licensed. Do not claim the results of this program as your own work, and
# if you use these images in a stream, video, image compilation, etc., please
# credit me in the relevant content description with the expanded title of
@ConorOBrien-Foxx
ConorOBrien-Foxx / morse.csv
Last active Nov 7, 2018
morse code in powershell
View morse.csv
Symbol Sequence
A 01
B 1000
C 1010
D 100
E 0
F 0010
G 110
H 0000
I 00
@ConorOBrien-Foxx
ConorOBrien-Foxx / input.xxd
Last active Aug 19, 2018
input for the cat challenge
View input.xxd
00000000: 5468 6973 2069 7320 616e 2065 7861 6d70 This is an examp
00000010: 6c65 2069 6e70 7574 2064 6573 6967 6e65 le input designe
00000020: 6420 746f 2073 7472 6573 7320 6120 6361 d to stress a ca
00000030: 7420 696e 7465 7270 7265 7465 722e 0a49 t interpreter..I
00000040: 7420 696e 636c 7564 6573 206e 6577 6c69 t includes newli
00000050: 6e65 7320 2822 5c6e 2229 2c20 7175 6f74 nes ("\n"), quot
00000060: 6573 2028 225c 2222 292c 2061 6e64 2075 es ("\""), and u
00000070: 6e62 616c 616e 6365 6420 6272 6163 6573 nbalanced braces
00000080: 2028 2829 2e0a 0a41 7320 7765 6c6c 2061 (()...As well a
00000090: 7320 656d 7074 7920 6c69 6e65 732e 0a00 s empty lines...
View operators
# meta operators: meta<op>
# ! EXCLAMATION MARK
# factorial
# " QUOTATION MARK
# (list of characters)
# # NUMBER SIGN
View histogram.@
??{#Unique[±_<:BinBelow!#_:>Sum]}
data := Random[
range := 10
inner := Chunk[Sort[data], Floor@`/&range]
keys ' values := Tr[inner]
size := Max[Size => keys] + 3
width := size + 2
format_key[key] := "[" + Center[String[key], size] + "]"
View encode.rb
require 'zlib'
require 'base64'
FIELD_SEPARATOR = "\xff"
def deflate(str)
Zlib::Deflate.deflate(str,9)[2..-5]
end
def finalize(state_string)
compressed = deflate(state_string)
encoded = Base64.encode64 compressed
View asdf.js
alert([...document.querySelectorAll(".active-question-content__prompt p")].map((e,i)=>(a=e.textContent,(a.search(++i)?"":i+". ")+e.textContent)).join`
`)
View -3.md

-3

Here's the gist.

Memory

Memory is a map of tapes, where the keys are strings and values are arbitrary-sized integers.

Additionally, there is a set of labels, where the program can jump to.

There is a stack, which contains the operands, which are strings.

@ConorOBrien-Foxx
ConorOBrien-Foxx / matrix_readable.rb
Last active Jan 20, 2018
Readable matrix printing
View matrix_readable.rb
require 'matrix'
module ReadableArrays
def readable(factor: 1, method: :rjust)
repr = to_a.map { |row|
row.map(&:inspect)
}
column_widths = repr.transpose.map { |col|
col.map(&:size).max + factor