Skip to content

Instantly share code, notes, and snippets.

View mtso's full-sized avatar
shipping

Matthew mtso

shipping
View GitHub Profile
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) {
"use strict";
var C;
(function (C) {
C[C["NOWALL"] = 0] = "NOWALL";
C[C["NOP"] = 1] = "NOP";
C[C["WALL"] = 2] = "WALL";
C[C["DOT"] = 3] = "DOT";
C[C["P1"] = 4] = "P1";
C[C["P2"] = 5] = "P2";
})(C || (C = {}));
@mtso
mtso / README.md
Last active March 4, 2022 02:40
Dots 'n' Boxes is a text console game for two players. https://mtso.io/dots-n-boxes

dots-n-boxes

Dots 'n' Boxes is a text console game for two players.

The game starts with an empty grid of dots. Two players take turns adding a single horizontal or vertical line between two unjoined adjacent dots specified by algebraic notation (e.g. A1-B1). A player who completes the fourth side of a 1×1 box earns one point and takes another turn.

Buffer Shots

4x4 Game

{"data":{"stackProfile":{"id":"101231778457248879","slug":"airbnb","name":"Airbnb","path":"/airbnb/airbnb","websiteUrl":"https://nerds.airbnb.com/","private":false,"imageUrl":"https://img.stackshare.io/stack/2/default_04dd469129d2bfe4f9fbe36583faac05993d6643.jpeg","description":"Founded in August 2008 and based in San Francisco, California, Airbnb is a trusted community marketplace for people to list, discover, and book unique spaces around the world – online or from a mobile phone. Airbnb connects people to unique travel experiences, at any price point, in more that 26,000 cities and 192 countries. ","viewCount":423779,"amIOwner":false,"toolsAvatars":{"react":{"avatarsCount":1,"avatarsUrls":["https://img.stackshare.io/user/299852/default_e6c5c079eeed2f178ff111094f79fc759338903b.png"]},"mysql":{"avatarsCount":1,"avatarsUrls":["https://img.stackshare.io/user/299852/default_e6c5c079eeed2f178ff111094f79fc759338903b.png"]}},"embedUrl":"https://embed.stackshare.io/stacks/embed/d8fece976fadc2","stackMatchPercentage