Skip to content

Instantly share code, notes, and snippets.

@gdvalle
gdvalle / extract_cleanup.py
Created June 23, 2019 16:14
Delete extracted mkv files alongside rar parts.
#!/usr/bin/env python3
import os
import sys
assert sys.version_info[:2] >= (3, 6), "Requires Python 3.6+"
def walk_dir(directory):
for root, dirs, files in os.walk(directory):
@gdvalle
gdvalle / nginx_stub_status.lua
Created June 24, 2019 15:14
Record Prometheus metrics from nginx stub_status module using https://github.com/knyar/nginx-lua-prometheus
-- A module to export Prometheus metrics from nginx stub_status module.
local ngx = ngx
local ngx_var = ngx.var
local prometheus = prometheus
local select = select
local tonumber = tonumber
local find = string.find
local capture = ngx.location.capture
local log = ngx.log
local ERR = ngx.ERR
@gdvalle
gdvalle / atomcat.sh
Last active May 23, 2021 18:26
An atomic file updater in shell.
#!/bin/sh
set -u
PROG="${0##*/}"
# Default temp file suffix
SUFFIX="${SUFFIX-.tmp$$}"
usage() {
printf 'usage: echo foo | %s <file> [lockfile] [tempfile]\n' "$PROG" >&2
@gdvalle
gdvalle / putty-monokai.reg
Created December 2, 2012 05:24
Monokai style theme for PuTTY; colors copied from ST2's theme
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\monokai]
"Colour21"="255,255,255"
"Colour20"="245,222,179"
"Colour19"="200,240,240"
"Colour18"="0,217,217"
"Colour17"="179,146,239"
"Colour16"="174,129,255"
"Colour15"="122,204,218"