Skip to content

Instantly share code, notes, and snippets.

View thesephist's full-sized avatar
🍷
Ridin' in a getaway car

Linus Lee thesephist

🍷
Ridin' in a getaway car
View GitHub Profile

As someone who worked on parsers it's kind of interesting that you picked this particular version of a parsing problem b/c it involves operator precedence, which introduces a fair bit of complexity. The "canonical" solution to operator precedence is Pratt parsing, a variation of which is used in my language parsers. I also just find that algorithm neat, conceptually. But it is kind of hard to wrap your mind around it b/c of its generality.

Two things about parsers, focusing on Pratt parsers, that I have enjoyed

The latter is where I learned how to do Pratt parsing. The former is just a generally very very good blog about PL stuff.


@thesephist
thesephist / README.md
Created July 26, 2022 17:03 — forked from mzabriskie/README.md
Check git status of multiple repos

If you're like me you have a dir like ~/Workspace/Github where all your git repos live. I often find myself making a change in a repo, getting side tracked and ending up in another repo, or off doing something else all together. After a while I end up with several repos with modifications. This script helps me pick up where I left off by checking the status of all my repos, instead of having to check each one individually.

Usage:

git-status [directory]

This will run git status on each repo under the directory specified. If called with no directory provided it will default to the current directory.

@thesephist
thesephist / min-char-rnn.py
Created May 23, 2022 08:08 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@thesephist
thesephist / codecols.oak
Created March 30, 2022 01:17
Count and plot histograms of line length in source code
// codecols designed after Rasmus Andersson's linelen_hist.sh
// https://gist.github.com/rsms/36bda3b5c8ab83d951e45ed788a184f4
{
println: println
default: default
map: map
stdin: stdin
range: range
filter: filter
@thesephist
thesephist / output.txt
Created March 20, 2022 04:53
A CLI for listing out times and dates in time zones I care about
$ times
US Eastern 0:52 3/20 -4h
US Pacific 21:52 3/19 -7h
Korea 13:52 3/20 +9h
Ukraine 6:52 3/20 +2h
France 5:52 3/20 +1h
Germany 5:52 3/20 +1h
UK 4:52 3/20 +0h
@thesephist
thesephist / toc.js.oak
Last active March 17, 2022 11:13
DOM TreeWalker API from Oak
{
loop: loop
} := import('std')
// headingsList takes some container <div> and returns a list of all headings
// within that section of the page, in order
fn headingsList(div) {
walker := document.createTreeWalker(
div
NodeFilter.SHOW_ELEMENT
@thesephist
thesephist / ackermann.oak
Last active March 10, 2022 23:22
Ackermann function calculator
#!/usr/bin/env oak
std := import('std')
str := import('str')
fmt := import('fmt')
math := import('math')
cli := import('cli')
// ackermann computes the Ackermann function of m, n
fn ackermann(m, n) if {
@thesephist
thesephist / browser.js
Last active May 11, 2022 00:40
Instagram Saved Photos downloader
{
const UserID = '1227062513';
const PAGE_N = 1000;
function wait(timeout) {
return new Promise(res => setTimeout(res, timeout * 1000));
}
function createURL(after = '') {
const QUERY_HASH = '2ce1d673055b99250e93b6f88f878fde'; // seems to be a unique URL per GraphQL query type
@thesephist
thesephist / lisp.oak
Last active March 18, 2022 17:42
An interpreter for Klisp (Scheme-like lisp flavor) in ~500L of Oak.
#!/usr/bin/env oak
// A Klisp written in Oak
// ported over from the Ink implementation at thesephist/klisp.
{
println: println
default: default
clone: clone
slice: slice
@thesephist
thesephist / levenshtein.oak
Created October 13, 2021 06:18
Levenshtein edit distance
{
slice: slice
} := import('std')
{
split: split
} := import('str')
{
min: min
round: round
} := import('math')