Skip to content

Instantly share code, notes, and snippets.

View AshKyd's full-sized avatar
🐳
a frood who really knows where his towel is

Ash Kyd AshKyd

🐳
a frood who really knows where his towel is
View GitHub Profile
@AshKyd
AshKyd / sqlite-debug.js
Created December 18, 2025 12:47
Print a markdown schema for a sqlite database
import sqlite from 'node:sqlite';
const DB_PATH = "/home/ash/KoboReader.sqlite";
function printSchema() {
try {
const db = new sqlite.DatabaseSync(DB_PATH);
// Query for all tables and their SQL creation statements
const schema = db.prepare(`
{
"workbench.colorTheme": "GitHub Light",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.rulers": [
{
"column": 80
},
{
"column": 120
@AshKyd
AshKyd / kindaSortaVh.js
Last active August 22, 2025 06:47
Returns a value that's safe enough to use in iPadOS webview browsers
/**
* Due to assorted bugs in iPadOS webview browsers (Firefox, Brave), `vh` and `lvh`
* units change unpredictably and can cause content to shift.
*
* This utility provides an approximation of `100vh` in the browser. In most
* browsers it will be exactly `100vh`, but in Safari iPad browsers it will
* be clamped at either `100dvh` or `100vh` depending on the state of the browser
* address bar at the time.
*
* Use this to size elements in the page flow in a way that won't trigger
@AshKyd
AshKyd / photos.js
Last active May 20, 2025 06:07
Delete photos, videos, and reviews from the Google Maps desktop site. Huge disclaimer: these will probably get out of date at some point and may not work. You should read and understand the code before you do anything with it.
// delete photos from Google Maps
(async () => {
const sleep = (time) => new Promise(resolve => setTimeout(resolve,time));
const go = async () => {
// click the kebab
document.querySelector('button[jsaction*="pane.photo.actionMenu"]:not([aria-hidden="true"])').click();
await sleep(200);
// click the delete menu item
document.querySelector('#action-menu div[role="menuitemradio"]').click();
@AshKyd
AshKyd / typeahead.svelte
Created March 10, 2025 07:35
Svelte native-ish typeahead
<script lang="ts">
import { untrack } from 'svelte';
let { values = [], value = [], disabled, onChange = () => {} } = $props();
const uniqueId = 'list' + (Math.random() * 10e15).toString(16);
let selectedValues = $state<string[]>(value);
let isFocused = $state(false);
let inputElement = $state<HTMLInputElement>();
let inputValue = $state('');
@AshKyd
AshKyd / abcnews-tidy.js
Last active February 23, 2025 01:10
Tampermonkey scripts to remove US politics from ABC News and Brisbane Times
// ==UserScript==
// @name Tidy up news homepage
// @namespace http://tampermonkey.net/
// @version 2025-02-03
// @description try to take over the world!
// @author You
// @match https://www.abc.net.au/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=abc.net.au
// @grant none
// ==/UserScript==
@AshKyd
AshKyd / gist:750c81d436badedb809fdb1f2c4eb3fc
Created July 15, 2024 04:43
Update NPM dependencies to latest
npx npm-check-updates -u
function cancellable() {
let isRunning = true;
const p = new Promise((resolve, reject) => {
setTimeout(() => {
if (!isRunning) return reject();
resolve();
}, 1000)
});
@AshKyd
AshKyd / methodSpy.js
Created May 29, 2024 01:38
Spy on video element methods and log when & where they're called from
['pause', 'play'].forEach(method => {
const oldMethod = video[method];
video[method] = function () {
console.log(`${method} (dom call)`, { video, e: new Error('here') });
return oldMethod.apply(video);
};
});