Skip to content

Instantly share code, notes, and snippets.

View MystPi's full-sized avatar

MystPi

  • 11:21 (UTC -04:00)
View GitHub Profile
@MystPi
MystPi / CHANGELOG.md
Created April 20, 2024 17:49
A Keep a Changelog template

Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog], and this project adheres to [Semantic Versioning].

[Unreleased]

[1.0.0] - 2024-04-20

class RecursiveDescentParser<T extends { type?: string }> {
private readonly tokens: T[];
private current = 0;
constructor(tokens: T[]) {
this.tokens = tokens;
}
/**
* Check if the current token matches one of the given types
@MystPi
MystPi / greet.html
Created January 2, 2023 19:57
Dynamic URLs with Vercel redirects. Very hacky and should not be used in production.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Greet</title>
</head>
<body>
Hello!
@MystPi
MystPi / download_code-server.sh
Created September 17, 2022 14:53
Download the latest code-server binary on your headless Raspberry Pi.
echo Finding latest version...
v=$(curl -s https://api.github.com/repos/coder/code-server/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
echo Downloading binary v$v...
wget -q -O code-server.deb "https://github.com/coder/code-server/releases/download/v$v/code-server_${v}_armhf.deb"
echo "Done! Run run 'sudo dpkg -i code-server.deb' to install"
@MystPi
MystPi / recent_messages.py
Last active July 24, 2021 23:09
Prints out your recent Scratch messages. You will have to provide your Scratch username and password.
from scratchclient import ScratchSession
import re
session = ScratchSession("your_username", "your_password")
ms = session.get_messages()
for m in ms:
if m.type == "addcomment":
frag = re.sub(r"\&\#39;", "'", m.comment_fragment)
frag = re.sub(r"\&quot;", '"', frag)
@MystPi
MystPi / escaped_string_regex.py
Created July 24, 2021 13:07
A regex to parse escaped strings.
import re
regex = re.compile(r'(["\']).*?(?<!\\)(\\\\)*?\1')