Skip to content

Instantly share code, notes, and snippets.

@vpag
vpag / Dockerfile
Last active April 29, 2023 13:25
python3-slim + gqlalchemy -- aux docker container
# syntax=docker/dockerfile:1
#
# Since that:
# Make large dependencies optional #235
# https://github.com/memgraph/gqlalchemy/pull/235
# See also (doc upd):
# Update installation prerequisites #233
# https://github.com/memgraph/gqlalchemy/pull/233
#
import csv
import re
from collections import Counter as C
from pathlib import Path as P
import dateutil.parser as dp
def foo(s):
if m := p.match(s.strip()):
@vpag
vpag / nginx-logs-to-csv.py
Last active September 30, 2022 20:17
nginx log related
import bz2
import csv
import gzip
from datetime import datetime
from pathlib import Path
# from ngxlogz_namdtup import NgxAccessLine, NgxErrLine # obsoleted; for comparison
from ngxlogz import NgxAccessLine, NgxErrLine
@vpag
vpag / ubmodule_addroute.py
Last active May 8, 2021 21:34
Unbound python demo module, add route on DNS reply
"""Unbound python demo module, add route on DNS reply.
Related article: https://vp.ag/posts/2021-04-15-dns-based-routing/
Reference: https://nlnetlabs.nl/documentation/unbound/pythonmod/
"""
def init(id, cfg):
return True
def deinit(id):
@vpag
vpag / dirhashing.py
Last active May 13, 2021 19:09
hasing directories to find same contents
"""Searching for dupicate directories.
The main idea is to define customizable* hash function for a directory,
that returns the same result for directories with equal (*or similar)
contents.
"""
from collections import Counter as C
from hashlib import sha256 as H
from pathlib import Path as P
@vpag
vpag / fishnet-performance.md
Last active May 8, 2021 22:04
fishnet for lichess performance at different machines

Common environment properties

  • lscpu excerpt:
    Architecture:    x86_64
    CPU op-mode(s):  32-bit, 64-bit
    Byte Order:      Little Endian
    NUMA node(s):    1
    
@vpag
vpag / scramble-dev-foo.sh
Last active May 8, 2021 22:24
secure data scrambler using process substitution
function scramble {
# Famous example rewritten in more secure way by passing random password using a pipe
openssl enc -aes-256-ctr -pbkdf2 -nosalt \
-pass file:<(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64) \
</dev/zero 2>/dev/null \
| sudo dd status=progress iflag=fullblock bs=8M of=$1 oflag=direct
}
## Usage sample
# for (( i = 3 ; i ; i-- ))
@vpag
vpag / autogenerate-demo-sample.qvs
Last active November 26, 2020 21:08
Qlik qvs formulae
// AutoGenerate() demo-sample
t:
NoConcatenate LOAD
10 + RowNo() - 1 as t
, RecNo() as g
, (6 + RecNo()) * 1e3 + IterNo() - 1 as v
AutoGenerate 7 While IterNo() <= 10;
@vpag
vpag / scaleway-tricks.md
Created August 6, 2019 12:50
scaleway tricks

initrd/Linux

  • Schema (boot timeline)
  • Features
  • Boot options
  • Boot-modes

Mind the tag

INITRD_POST_SHELL=1
@vpag
vpag / parseHostPort.cmd
Created February 5, 2017 00:06
parse host port from strings like "host[:port]" or URL
@ECHO off
SETLOCAL EnableDelayedExpansion
::
:: samples.txt
:: -----------
:: hostname.or.ip
:: hostname.or.ip:80
:: hostname.or.ip/11
:: hostname.or.ip:80/11
:: xx://hostname.or.ip