Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / st.html
Last active March 16, 2022 12:25
Sierpiński triangle
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Sierpiński triangle</title>
<link rel="stylesheet" href="style.css">
<script>
document.addEventListener('DOMContentLoaded', (event) => {
const canvas = document.getElementById('canvas');
var ctx = canvas.getContext("2d");
@vrdhn
vrdhn / this.js
Last active March 21, 2022 11:37
What is this
const root = (typeof window === 'undefined') ? global : window;
function LambdaClosure() {
return () => {
if ( this == root )
console.log('Closure: this is global/window');
else
console.log('Closure: this is ', this.name);
@vrdhn
vrdhn / disposable-postgres.sh
Created July 3, 2022 14:13
Disposable postgres installtions for testing .. don't bother with docker etc.
#!/bin/bash
PGDATADIR=pgdata
mkdir -p $PGDATADIR
usage () {
echo "** Disposable postgres installtions for testing **"
echo ""
echo "$0 <cmd> [ args .... ] "
echo " =cmd= =args...="
@vrdhn
vrdhn / tmux-run.sh
Created July 7, 2022 12:54
ensure a named windows on tmux exists, and run commands in it.
#!/bin/sh
## tmux-run <window-name> <cmd args ...>
## start if session not running
if [ "x$TMUX" = "x" ] ;
then
tmux new -As0 \; detach-client
fi
implementation("org.apache.logging.log4j:log4j-api:2.19.0")
implementation("org.apache.logging.log4j:log4j-core:2.19.0")
private static final Logger LOG = LogManager.getLogger(Main.class);
private static void setLogLevel(Level level) {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);