Skip to content

Instantly share code, notes, and snippets.

@aabccd021
aabccd021 / tsconfig.json
Created September 6, 2025 22:38
tsconfig cheatsheet
{
"compilerOptions": {
// Environment Settings
"module": "preserve",
"lib": ["esnext"],
"target": "esnext",
"types": ["bun"],
// Output
"noEmit": true,
@aabccd021
aabccd021 / paddle.ts
Last active September 10, 2025 23:52
const headers = new Headers({
Authorization: `Bearer ${process.env.PADDLE_SANDBOX_APIKEY}`,
});
// const response = await fetch("https://sandbox-api.paddle.com/customers", {
// method: "post",
// headers,
// body: JSON.stringify({
// email: "[email protected]"
// }),
@aabccd021
aabccd021 / cdp.js
Created September 5, 2025 12:19
Simple Chrome Devtools Protocol Example
import * as fs from "node:fs";
import * as os from "node:os";
import * as child_process from "node:child_process";
function send(ws, pending, req) {
return new Promise((resolve) => {
const reqId = id++;
pending.set(reqId, resolve);
ws.send(JSON.stringify({ id: reqId, ...req }));
});
@aabccd021
aabccd021 / foreign_key.sql
Created August 5, 2025 05:42
Detect foreign key constraint fail on sqlite using trigger
PRAGMA foreign_keys = ON;
CREATE TABLE parent (id TEXT PRIMARY KEY) STRICT;
INSERT INTO parent (id) VALUES ("PARENT_FOO");
CREATE TABLE school (id TEXT PRIMARY KEY) STRICT;
INSERT INTO school (id) VALUES ("SCHOOL_FOO");
CREATE TABLE child (
parent_id TEXT,
@aabccd021
aabccd021 / action.ts
Created July 27, 2025 08:49
Netero playwright
import * as fs from "node:fs";
import type { Locator, Page } from "playwright";
export type FormInput =
| {
type: "text";
value: string;
}
| {
type: "radio";
@aabccd021
aabccd021 / mock_host.c
Created July 25, 2025 04:22
Mock domain/host with LD_PRELOAD
#define _GNU_SOURCE
#include <dlfcn.h>
#include <netdb.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
@aabccd021
aabccd021 / demo_time.js
Last active July 27, 2025 01:50
Mock time in unix process
console.log("System time is:", new Date().toISOString());
import * as xpath from 'xpath';
import * as xmldom from '@xmldom/xmldom';
const xml = `<book><title foo="bar">Harry Potter</title></book>`;
const doc = new xmldom.DOMParser().parseFromString(xml, 'text/xml') as any as Node;
const [ firstTitleText ] = xpath.select("//title/text()", doc);
console.assert(firstTitleText.nodeValue === "Harry Potter");
const result: xpath.SelectSingleReturnType = xpath.select1("//title/text()", doc);
file=$1
outdir=$(mktemp -d)
printf "original: "
ls -l "$file" | awk '{print $5}'
nix run nixpkgs#gzip -- -9 -c "$file" > "$outdir/file.gzip"
printf "gzip: "
ls -l "$outdir/file.gzip" | awk '{print $5}'
fd -e nix -e ts -x sed -i ':a;N;$!ba;s/\([{[(]\)\n/\1/g' {}