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
@thesephist
thesephist / loading.css
Last active June 15, 2021 05:12
Animated loading bar as used in Lucerne, Merlot, and Kin (Ink Codebase Browser)
.loading {
width: 100%;
flex-grow: 1;
margin: 0;
height: 3px;
position: relative;
background: var(--hover-bg);
overflow: hidden;
}
@thesephist
thesephist / calc.js
Created July 10, 2021 08:32
Add/subtract calculator in JavaScript
/**
* Takes a string representing addition/subtractions on numbers and outputs the
* resulting number. Ignores any non-valid input characters like whitespace,
* and does not consider negative numbers.
*
* Behavior is undefined if two operators next to each other, or operator on
* either end of string.
*/
function performCalcuation(input) {
const inputWithoutInvalidChars = input.replaceAll(/[^\d+\-]+/g, '');
@thesephist
thesephist / bmp.oak
Last active March 21, 2022 07:05
Mandelbrot set renderer and BMP image encoder in Oak (https://oaklang.org/)
// libbmp implements a basic image encoder for the BMP format
{
map: map
} := import('std')
{
join: join
} := import('str')
// utility function for splitting a large number > 16^2 into a 4-byte list

Augment 📜

Annotating documents on the web from an extensible backend of data sources.

Use cases:

  • Fact checking (current)
  • I'm researching x86 and ARM CPU microarchitectures. Instead of keeping my notes in a separate data source, I keep it in an Augment-connected notes app and it colocates my notes with relevant topics on any page I'm reading.
  • Founders of a startup are fundraising and looking for investors. They use backends from Linkedin and Crunchbase with their contacts while reading tech industry reports to find connections to specific investors and firms of interest.
@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')
@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 / 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 / ackermann.oak
Last active November 21, 2024 07:04
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 / 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 / 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