Skip to content

Instantly share code, notes, and snippets.

View damieng's full-sized avatar
🏠
Working from home

Damien Guard damieng

🏠
Working from home
View GitHub Profile
@damieng
damieng / plus3ramtest.asm
Created February 23, 2026 07:06
Full 64KB banked memory test for the Spectrum +3
DEVICE ZXSPECTRUM128
ORG $4800 ; Bank 5 (display bank)
; ---------------------------------------------------------
; All-RAM mode 0 ($1FFD=01): Banks 0,1,2,3 at $0000/$4000/$8000/$C000.
;
; Strategy:
; • Bootstrap runs in Bank 5. Prints title/banks to display.
; ULA always reads Bank 5, so display is visible throughout the test.
; • Copies this code to Bank 1 (via $7FFD paging), then enables All-RAM.
#!/usr/bin/env node
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
let input = '';
process.stdin.on('data', chunk => input += chunk);
process.stdin.on('end', () => {
const data = JSON.parse(input);
@damieng
damieng / ts-parse-examples.py
Last active February 16, 2026 16:48
Tree-Sitter Example Parser
import glob
import subprocess
import os
import shutil
import re
import sys
import argparse
from concurrent.futures import ProcessPoolExecutor, as_completed
from ruamel.yaml import YAML
@damieng
damieng / ym2aytap.py
Created February 10, 2026 21:06
Convert Atari ST YM files to ZX Spectrum TAP files
#!/usr/bin/env python3
"""
ym2aytap.py - Convert YM music files to ZX Spectrum .tap for AY playback.
Reads YM2/YM3/YM5/YM6 files (LHA compressed or raw) and generates a .tap
with a compact Z80 player that writes AY registers at 50Hz using HALT.
14 bytes/frame × 50Hz = 700 bytes/sec → 46s (48K) or ~2:40 (128K).
Damien Guard, MIT License, 2026
@damieng
damieng / linctoch8.cs
Last active December 7, 2025 12:45
Convert LINC manual charset octets to Speccy CH8 file
using System.Collections.Generic;
using var outFile = File.OpenWrite("linc.ch8");
for (var x = 32; x < 128; x++)
{
byte[] c = [0, 0, 0, 0, 0, 0, 0, 0];
if (CharacterPatterns.Patterns.TryGetValue(Convert.ToChar(x), out var pattern))
{
c = CharacterPatterns.MapPatternToRaw(pattern);
@damieng
damieng / zx-to-ttf.py
Last active December 2, 2025 14:44
Spectrum font conversion in FontLab 5
#FLM: ZX Conversion
# Create TTF from 8x8 ZX BDF
## Set metadata
import os
font = fl.font
# Base name on filename
fontName = os.path.basename(os.path.splitext(font.file_name)[0]).strip()
@damieng
damieng / glob_match.sql
Created May 7, 2025 16:20
PostgreSQL glob matching
CREATE OR REPLACE FUNCTION glob_match(text, text) RETURNS boolean AS $$
DECLARE
input_string text := $1;
glob_pattern text := $2;
double_star_pos integer;
prefix text;
suffix text;
prefix_regex text;
suffix_regex text;
path_regex text;
@damieng
damieng / nuxt.config.js
Created May 13, 2024 10:08
How to delete the content.db for Nuxt2 SSG
{
// Inside your nuxt.config.js
hooks: {
"generate:done": (builder) => {
const options = builder.nuxt.options
const hash = options.publicRuntimeConfig.content.dbHash
const fileName = resolve(options.generate.dir, '_nuxt', 'content', `db-${hash}.json`)
console.log('Deleting content database file:', fileName)
unlinkSync(fileName)
},
@damieng
damieng / US-Damien-Alt-Custom.klc
Created January 21, 2024 09:32
My custom US Windows keymap with right alt symbol support for pound etc.
KBD USDamAlt "US Custom Alt-Symbols"
COPYRIGHT "None"
COMPANY "None"
LOCALENAME "en-US"
LOCALEID "00000409"
@damieng
damieng / info.json
Created January 20, 2024 12:01
My Mehkee96 layout
{
"keyboard_name": "mehkee96",
"url": "",
"maintainer": "qmk",
"layouts": {
"LAYOUT": {
"layout": [
{ "label": "Esc", "x": 0, "y": 0 },
{ "label": "F1", "x": 1, "y": 0 },
{ "label": "F2", "x": 2, "y": 0 },