Skip to content

Instantly share code, notes, and snippets.

View andrewmd5's full-sized avatar
💭
🖤

Andrew Sampson andrewmd5

💭
🖤
View GitHub Profile
@andrewmd5
andrewmd5 / Asyncify.swift
Created November 22, 2025 02:14
Asyncify for WasmKit
import Foundation
import WasmKit
/// Asyncify state machine states
private enum AsyncifyState: UInt32 {
case none = 0
case unwinding = 1
case rewinding = 2
}
@andrewmd5
andrewmd5 / sample.c
Created August 25, 2025 13:55
JavaScriptCore ECMAScript modules (C API)
#include <stdio.h>
#include <string.h>
#include <JavaScriptCore/JavaScript.h>
// Main module that imports JSON files
static const char* MAIN_MODULE =
"import config from './config.json' with { type: 'json' };\n"
"import data from './data.json' with { type: 'json' };\n"
"\n"
"export function getConfig() { return config; }\n"
@andrewmd5
andrewmd5 / benchmark.txt
Last active June 19, 2025 13:55
Bebop C examples
Bebop Jazz Library Performance Benchmark
========================================
Iterations per test: 10000
Warming up...
Warmup complete.
Predicted size: 307 bytes, Actual size: 307 bytes
=== Optimized Encoding Benchmark ===
Iterations: 10000
@andrewmd5
andrewmd5 / hako.go
Created April 13, 2025 14:38
hako in go
package main
import (
"fmt"
"os"
"github.com/bytecodealliance/wasmtime-go/v31"
)
// Default memory configuration (matching JavaScript defaults)
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "https://json.schemastore.org/bebop",
"title": "JSON schema for the Bebop compiler's configuration file",
"type": "object",
"properties": {
"generators": {
"$ref": "#/definitions/generatorsDefinition/properties/generators"
},
"include": {
@andrewmd5
andrewmd5 / README.md
Last active May 30, 2023 19:57
decipher this text, get $100

Can you crack the secret message hidden within this cipher? I've taken a phrase and encoded it into a string of words that look like "meatball". It's a bit tricky, but I believe in your skills!

Cipher Text:

mEaTbALLmEAtBALLmEATbALL, mEATBalLmEAtBALLmEATbAlL mEAtbalLmEATbaLlmEAtbAlL mEATbaLLmEATbAlLmEATballmEAtbAlLmEATbaLl mEATbaLLmEAtBAlLmEAtbalLmEATbaLlmEATbAll! mEaTbALLmEAtbalLmEAtBALlmEATbAll mEAtbalL mEAtBaLlmEAtBALLmEAtbaLl? mEaTbALLmEAtbAlL'mEATbaLlmEAtbAlL mEAtBallmEAtBalLmEATbaLlmEAtBalLmEAtBALlmEAtbALL: mEAtbalLmEAtBALlmEAtbAllmEATbaLlmEAtbAlLmEATbALL@mEAtbaLlmEAtbAlLmEATbAllmEATbALLmEAtBalLmEATBallmEATbAllmEAtBAllmEAtbalLmEAtbaLlmEATbaLL.mEAtbaLLmEAtBALLmEAtBAlL

Prize

@andrewmd5
andrewmd5 / AsciiChecker.cs
Created March 15, 2023 18:28
Detect if a byte-array or ReadOnlySpan<byte> contains only ASCII characters
using System;
using System.Buffers;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;
using System.Text;
namespace idk
{
@andrewmd5
andrewmd5 / example.ts
Created February 7, 2022 17:43
Convert JSON to and from Bebop
#!/usr/bin/env node
import * as fs from "fs";
import * as ts from "typescript";
import { checkSchema } from "bebop-tools";
import path = require("path");
import child_process = require("child_process");
let usage = [
"",
@andrewmd5
andrewmd5 / DelegateBuddy.cs
Created February 6, 2022 02:46
A rough implementation of how you can create your own methods similar to that of Minimal APIs mapping function with arbitrary delegates
using System.Reflection;
using Gateway.Core.Http.Models;
using Microsoft.AspNetCore.Http;
namespace Gateway.Core.Utils;
internal static class DelegateBuddy
{
private static readonly NullabilityInfoContext NullabilityContext = new();
@andrewmd5
andrewmd5 / knytt.bin.rs
Created July 29, 2019 08:28
Tiny Rust program to parse a knytt.bin file, printing its contents.
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
fn main() -> std::io::Result<()> {
if let Ok(mut file) =
File::open("E:/Knytt Stories/Test/Drakkan - Training Groundv3rev.knytt.bin")
{
let mut files = HashMap::new();