Skip to content

Instantly share code, notes, and snippets.

View mtso's full-sized avatar
shipping

Matthew mtso

shipping
View GitHub Profile
GOAL: Make each pair of (n) lines match
(0) this is a pair of lines
(0) this is a pair of lines
(1) this is a pair of lines
@mtso
mtso / ipv6.sh
Created November 19, 2024 02:05
cURL IPv6 address
dig aaaa example.com
curl -6 "http://[2606:2800:21f:cb07:6820:80da:af6b:8b2c]" -H "Host: example.com"
^[A-Za-z0-9-_:.,;!?~*'()/=+&%@#]+$
b64:e3I9MTAwMCxyMj0xMDAwLHUxPTEwMCx1Mj0yMDB9
const std = @import("std");
const Duck = struct {
name: []const u8,
grade: u8 = undefined,
};
const DuckGrader = struct {
pub fn grade(_: *DuckGrader, duck: *Duck) void {
duck.grade = if (duck.name.len > 1) duck.name[0] else 'Z';
pub const Account = packed struct {
id: u128,
/// Opaque third-party identifier to link this account (many-to-one) to an external entity.
user_data: u128,
/// Reserved for accounting policy primitives.
reserved: [48]u8,
ledger: u32,
/// A chart of accounts code describing the type of account (e.g. clearing, settlement).
code: u16,
flags: AccountFlags,
{
"title": "Double left_shift to become caps_lock",
"rules": [
{
"description": "Double left_shift to become caps_lock.",
"manipulators": [
{
"conditions": [
{
"name": "left_shift pressed",
{
"title": "Double left_command to become caps_lock",
"rules": [
{
"description": "Double left_command to become caps_lock.",
"manipulators": [
{
"conditions": [
{
"name": "left_command pressed",
@mtso
mtso / serde.lua
Created April 10, 2022 01:58
pico-8 serialization / deserialization for bit-packing cartdata
function ser(n1,n2,n3,n4)
return (n1&0xff)<<8 | n2&0xff |
(n3&0xff)>>8 | (n4&0xff)>>16
end
function deser(n)
return {
(n>>8) & 0xff,
n&0xff,
(n<<8) & 0xff,
@mtso
mtso / lisp-parser.js
Created March 8, 2022 18:53
Lisp Parser - Write code that takes some Lisp code and returns an abstract syntax tree. The AST should represent the structure of the code and the meaning of each token. For example, if your code is given "(first (list 1 (+ 2 3) 9))", it could return a nested array like ["first", ["list", 1, ["+", 2, 3], 9]].
// input "" -> null
// input "()" -> []
// input "(1)" -> [1]
// 0123456
// const input = "(first (list 1 (+ 2 3) 9))"
// example out: ["first", ["list", 1, ["+", 2, 3], 9]]
// (+ 2 3) -> ["+", 2, 3]
// (list 1 (+ 2 3) 9) -> ["list", 1, ["+", 2, 3], 9]
function parse(input) {