Skip to content

Instantly share code, notes, and snippets.

@eddieantonio
eddieantonio / local-scope.py
Created October 27, 2023 14:05
What will happen in this Python example? (made while writing this: https://eddieantonio.ca/blog/2023/10/25/python-is-a-compiled-language/)
a = "hello"
def say_a():
print(a)
if False:
a = "goodbye"
say_a()
@eddieantonio
eddieantonio / array vs bytearray.ipynb
Created August 7, 2023 22:26
Comparing `array` vs `bytearray` in performance
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@eddieantonio
eddieantonio / checkerboard.svg
Created August 7, 2023 13:42
Artisanally-crafted checkerboard pattern, as a tiny SVG. Embed this as a CSS background.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@eddieantonio
eddieantonio / load_pyc.py
Created September 2, 2022 19:40
Terrible script to dump CPython bytecode from a .pyc file
"""
Usage:
python3 -i load_pyc.py path/to/file.pyc
"""
import dis
import importlib.util
import marshal
@eddieantonio
eddieantonio / list-processes-listening
Created March 21, 2022 15:40
Filter the output of ss -tulpn and display only relevant information, truncated
#!/bin/sh
ss -tulpn | awk '$2=="LISTEN" {printf "%16s %s\n", $5, substr($7, 1, 80-16)}'
@eddieantonio
eddieantonio / Best Wordle Starter Word.ipynb
Last active January 19, 2022 10:02
My attempt to find a good starter guess for Wordle
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@eddieantonio
eddieantonio / crksyllabics.sty
Last active November 24, 2021 09:54
Get nêhiyawêwin (Plains Cree) syllabics working in XeLaTeX!
% crksyllabics.sty -- use ᓀᐦᐃᔭᐍᐏᐣ in XeLaTeX
%
% Defines font fallbacks for all Plains Cree syllabics.
%
% Uses Euphemia UCAS as the fallback font.
%
% Usage:
%
% 1. place this file in the same folder as your .tex file (upload to same folder in Overleaf)
% 2. Add the following line near the top of your .tex file:
@eddieantonio
eddieantonio / itwewina.bib
Created June 29, 2021 21:01
.bib file for dictionary sources cited in itwewina.altlab.app
@book{CW,
title = {{nēhiýawēwin} : {itwēwina} / {Cree} : Words},
editor = {Arok Wolvengrey},
year = 2001,
publisher = {Canadian Plains Research Center},
address = {Regina, Saskatchewan}
}
@book{MD,
title = {{Maskwacîs} Dictionary of {Cree} Words / Nehiyaw Pîkiskweninisa},
@eddieantonio
eddieantonio / sliceable.py
Created February 21, 2021 22:58
Get the slice[start:stop:step] of any Python iterable
class Sliceable:
def __init__(self, iterable):
self.it = iterable
def __getitem__(self, index):
if isinstance(index, int):
return self.it[int]
start = 0 if index.start is None else index.start
stop = inf if index.stop is None else index.stop
@eddieantonio
eddieantonio / word-break-property.ts
Created July 10, 2020 21:47
Wordbreak property enum values
export const enum WordBreakProperty {
/* 0 */ Other,
/* 1 */ LF,
/* 2 */ Newline,
/* 3 */ CR,
/* 4 */ WSegSpace,
/* 5 */ Double_Quote,
/* 6 */ Single_Quote,
/* 7 */ MidNum,
/* 8 */ MidNumLet,