Skip to content

Instantly share code, notes, and snippets.


Maciej Leśniewski leshniak

View GitHub Profile
leshniak / odns
Last active Sep 6, 2022
A simple script that overrides /etc/resolv.conf to custom one on per-app basis (Linux only)
View odns
set -e
trap clean TERM INT EXIT
clean() {
rm -f -- "$tmp_resolv_conf"
leshniak / adjust-srt.awk
Created Feb 4, 2022
Adjusts SRT subtitles by a factor or moves them by a shift in milliseconds
View adjust-srt.awk
#!/usr/bin/env -S awk -f
## Adjusts SRT subtitles by a factor or moves them by a shift in milliseconds
## Usage:
## ./adjust-srt.awk [-v SCALE=<factor>] [-v SHIFT=<ms>] >
## Useful scales: 25/23.97=1.04297, 23.97/25=0.9588, 25/29.97=0.834168, 29.97/25=1.1988
function convert(timestamp, hh, mm, ss, sss, adjusted){
leshniak /
Last active Aug 5, 2020
Building Raspberry Pi kernel

Making a custom ARM64 kernel for Raspberry Pi

install dependencies

sudo apt install build-essential libgmp-dev libmpfr-dev libmpc-dev libisl-dev libncurses5-dev bc git-core bison flex

build cross-binutils

leshniak /
Created Feb 4, 2020
Fish greeting for printing MOTD on byobu init
function fish_greeting
set -l motd "/run/motd.dynamic"
status --is-login
if test $status -ne 0;
and test -n $BYOBU_TTY;
and test $TMUX_PANE = '%1';
and test -f $motd
cat $motd
leshniak / 20-rpi
Last active Feb 5, 2022
Raspberry Pi MOTD, with TBW for Samsung SSDs (requires smartmontools) and WAN IP from DNS query (requires dig tool)
View 20-rpi
UP_SECONDS=`/usr/bin/cut -d. -f1 /proc/uptime`
SECS=$(($UP_SECONDS % 60))
MINS=$(($UP_SECONDS / 60 % 60))
HOURS=$(($UP_SECONDS / 3600 % 24))
DAYS=$(($UP_SECONDS / 86400))
UPTIME=`printf "%d days, %02dh %02dm %02ds " "$DAYS" "$HOURS" "$MINS" "$SECS"`
PROCESSES=`ps ax | wc -l | tr -d " "`
leshniak / proxy.js
Created Jul 6, 2018
Simple HTTP(S) node proxy
View proxy.js
const httpProxy = require('http-proxy');
const http = require('http');
const net = require('net');
const hostRegExp = /^(?<host>[^:]+)(:(?<port>[0-9]+))?$/;
const proxy = httpProxy.createProxyServer({});
const server = http.createServer(function (req, res) {
const { protocol, host } = new URL(req.url);
const target = `${protocol}//${host}`;
leshniak /
Created Aug 17, 2016
simple http-monitor
# -- init
cleanup ()