Skip to content

Instantly share code, notes, and snippets.

@balki
balki / systemd-search.sh
Created October 18, 2022 16:43
Get Systemd directive help
#!/usr/bin/bash
# Usage:
# systemd-search.sh WorkingDirectory
word=$1
get_doc() {
exec {awkfd}<<AWKS
/^ ((${word}=(, [A-Z])?)|(([^ ]+=, )+${word}=))/ , /^[^ ]/ {
@balki
balki / Makefile
Last active August 15, 2022 18:31
Makefile to keep python virtualenv up to date
# Usage:
# python3 -m venv pytools
# cp Makefile pytools/
# cd pytools
# make lock && make install
# ln -snf /path/to/pytools/bin/some_useful_cli_tool ~/bin/
# Runs all commands in a target in a single shell. Otherwise each line is run in a seperate shell
.ONESHELL:
@balki
balki / show-podcast.sh
Created July 30, 2022 06:23
Shows latest entires in podcast as a table in commandline
#!/bin/bash
# Dependencies:
# yq - https://github.com/mikefarah/yq
# xsv - https://github.com/burntsushi/xsv
# Usage:
# ❯ ./show-podcast.sh https://gotime.fm/rss
# This exec statement puts the script to a free file descriptor. i.e. to a in-memory temporary file whose path is /dev/fd/$fd
@balki
balki / example.py
Last active November 3, 2022 20:08
httpx tqdm example
"""
Run as below:
❯ pip install pex
❯ pex httpx tqdm -- ./example.py
"""
import asyncio, tqdm, httpx
async def get_chunks_with_progress(response: httpx.Response):
total = int(response.headers["Content-Length"])