Skip to content

Instantly share code, notes, and snippets.

@vrdhn
vrdhn / package.json
Last active February 9, 2022 06:14
Disposable Postgresql instance for nodejs testing
"pg:initpg" : "TZ=Etc/UTC initdb --auth-host password -D pgdata --encoding UTF8 --locale=C -U postgres --pwfile=<(echo postgres) || true",
"pg:start" : "pg_ctl -D pgdata -o '-h localhost' -o -i -o '-k \"\"' -l pg.log start || true ",
"pg:stop" : "pg_ctl -D pgdata stop || true ",
"pg:init-role": "psql postgresql://postgres:postgres@localhost:5432/postgres -c \"CREATE ROLE myapp_dev LOGIN PASSWORD 'myapp_dev';\"",
"pg:init-db" : "psql postgresql://postgres:postgres@localhost:5432/postgres -c \"CREATE DATABASE myapp_dev OWNER myapp_dev\"",
"pg:init" : "pnpm pg:init-role ; pnpm pg:init-db",
"pg:psql" : "psql postgresql://myapp_dev:myapp_dev@localhost:5432/myapp_dev",
"pg:go" : "pnpm pg:initpg ; pnpm pg:start ; pnpm pg:init ",
"pg:clean" : "pnpm pg:stop ; rm -fr pgdata ",
"pg:log" : "tail -F pg.log"
@vrdhn
vrdhn / dedupe.md
Last active November 22, 2021 04:32

Flow

  • A 'Master' store : which all the files are to be moved to permanently
  • Several 'Source' stores : where all the files are currently, and need to be empties

The Master store is external, cloud or removable storage, so it's not scanned completely. By construction, there will be no duplicated files on it, and there will be a check ( which can be costly with cloud storage ).

The master store will have a db storing size, sample-hash , full-hash etc.

@vrdhn
vrdhn / run-gitea.sh
Last active October 17, 2021 09:29
simple script to run gitea, and do backups every time.
#!/bin/bash
## run-gitea.sh (C) Vardhan Varma <vrdhn0@gmail.com>
## SPDX-License-Identifier: AGPL-3.0-or-later
##
## Features:
## (1) run gitea server for LAN usage
## (2) make encrypted archive on stopping.
## (3) backup archive to usb with label USBBACKUP
##
@vrdhn
vrdhn / launcher
Created December 18, 2014 16:27
a dmenu+xdotool launcher which can paste to terminal and show often used commands at top
#!/usr/bin/python3
# launcher (C) vrdhn0@gmail.com
# A dmenu & xdotool based launcher
# Features
# * Select from previously entered commands, or enter new one
# * Listing sorted by usage frequency
# * pasted to application using xdotool
# * terminate by '&' to launch as X application
# * manipulate ~/.config/launcher.db to add/remove/bump usage count
/**
** Print time taken by various clocks
--- resolutions ---
CLOCK_BOOTTIME : 0.000000001
CLOCK_MONOTONIC : 0.000000001
CLOCK_MONOTONIC_COARSE : 0.003333333
CLOCK_MONOTONIC_RAW : 0.000000001