Skip to content

Instantly share code, notes, and snippets.

View kwaichanz's full-sized avatar
💻
exploring the old worlds

kwaichan kwaichanz

💻
exploring the old worlds
  • Thailand, Bangkok
  • 06:06 (UTC +07:00)
  • LinkedIn in/kwaichanz
View GitHub Profile
@kwaichanz
kwaichanz / main.ts
Created October 2, 2025 07:34
node-pg connection with reconnect on admin-terminated
const pool = {
connectionString: `postgres://${DATABASE_USER || "kw"}:${DATABASE_PW || "1234"}@${DATABASE_URL || "localhost"}/${DATABASE_NAME || "DBNAME"}`,
max: 1,
};
export var client;
const postgresDBConnect = () => {
const startedAt = new Date().getTime();
client = new Client(pool);
@kwaichanz
kwaichanz / gist:8c626d90c17744ee386d27dd3bc498c0
Created February 26, 2025 07:39
Upgrading PostgeSQL to a new major version in ArchLinux
### Upgrading PostgreSQL to a major version in Archlinux
```
# pacman -S postgresql-old-upgrade
# systemctl stop postgresql.service
```
```
# mv /var/lib/postgres/data /var/lib/postgres/olddata
@kwaichanz
kwaichanz / reset_fw.sh
Created January 7, 2025 11:01
iptables flushed restoration
#!/bin/sh
IPT="/sbin/iptables"
# Set default policies for all three default chains
$IPT -P INPUT ACCEPT
$IPT -P FORWARD ACCEPT
$IPT -P OUTPUT ACCEPT
# Flush old rules, old custom tables
"Typescript React Function Component": {
"prefix": "fc",
"body": [
"import { FC } from 'react'",
"",
"interface ${TM_FILENAME_BASE}Props {",
" $1",
"}",
"",
"const $TM_FILENAME_BASE: FC<${TM_FILENAME_BASE}Props> = ({$2}) => {",