Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ConorOBrien-Foxx's full-sized avatar

Conor O'Brien ConorOBrien-Foxx

View GitHub Profile
@ConorOBrien-Foxx
ConorOBrien-Foxx / ElectronBurner.cpp
Last active May 2, 2022 02:13
C++ just lets you do this
#include <iostream>
#include <vector>
class ElectronBurner {
public:
std::vector<int> stack { 0 };
size_t size() { return stack.size(); }
ElectronBurner& operator++() {
if(size() < 1) return *this;
++stack.back();
@ConorOBrien-Foxx
ConorOBrien-Foxx / sample-codepage.py
Created December 16, 2021 18:34
Sample implementation of a basic codepage.
codepage = "⊙⊚⊛⊡⋄∘⨕⨖⨞⫇⫈αβγδεζηθι !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~←↑→↓" #...
unicode_result = ""
with open("sample.txt", "rb") as f:
while (byte := f.read(1)):
unicode_result += codepage[ord(byte)]
print(unicode_result)
@ConorOBrien-Foxx
ConorOBrien-Foxx / enumerator.js
Created March 19, 2019 19:09
Sane enumerators for JavaScript using Generators
// 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 March 18, 2019 04:49
Duel Links DeckListGen
#!/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 November 7, 2018 01:43
morse code in powershell
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 August 19, 2018 02:46
input for the cat challenge
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...
# meta operators: meta<op>
# ! EXCLAMATION MARK
# factorial
# " QUOTATION MARK
# (list of characters)
# # NUMBER SIGN
??{#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] + "]"
@ConorOBrien-Foxx
ConorOBrien-Foxx / encode.rb
Created March 5, 2018 23:21
TIO encoding
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
alert([...document.querySelectorAll(".active-question-content__prompt p")].map((e,i)=>(a=e.textContent,(a.search(++i)?"":i+". ")+e.textContent)).join`
`)