Skip to content

Instantly share code, notes, and snippets.

@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' {}
a(
{
class: "mx-6 btn bg-white text-black border-[#e5e5e5] mt-4",
href: "/login",
},
[
span({
class: "icon-[logos--google-icon] mr-2",
}),
"Login with Google",
@aabccd021
aabccd021 / debug-vm.nix
Created June 18, 2025 04:46
NixOS debug vm
{ lib, modulesPath, ... }:
{
imports = [ "${modulesPath}/virtualisation/qemu-vm.nix" ];
disko.devices.disk.disk1.device = lib.mkForce "/dev/vda";
services.openssh.settings.PermitRootLogin = "yes";
services.openssh.settings.PermitEmptyPasswords = "yes";
services.openssh.settings.PasswordAuthentication = lib.mkForce true;
@aabccd021
aabccd021 / gist:94504ae7a7d4f395b6ca8f80a097d5a6
Created June 16, 2025 00:17
Show largest nix derivation
nix run nixpkgs#dua -- --count-hard-links --apparent-size /nix/store
@aabccd021
aabccd021 / ssh_sops.sh
Created June 12, 2025 11:38
inser ssh key to sops file
ssh-keygen -f __foo && sops set ./host-secrets.yaml '["node2_ssh_key"]' "$(cat __foo | tr -d '\n' | jq -R '@json')" &&
cat __foo.pub && rm __foo*