Skip to content

Instantly share code, notes, and snippets.

@alexdelorenzo
alexdelorenzo / get-cflags.sh
Last active February 11, 2023 01:32
Get native CFLAGS for your host device. This will list the flags that are enabled on your hardware that are not enabled on the parent arch. https://alexdelorenzo.dev/notes/cflags
#!/usr/bin/env bash
# See: https://alexdelorenzo.dev/notes/cflags
# Requires `strs` package for Python: https://github.com/alexdelorenzo/strs/
# License: AGPLv3
export detectedArch="$(gcc -march=native -Q --help=target | grep march | str col 1 | str nth 0)"
export arch="${1:-$detectedArch}"
get-diff() {
diff \
#!/usr/bin/env bash
export SCRIPT="${1:-airsonic.script}"
export TITLE="Airsonic Podcasts"
export SQL_REGEX="'https?://[^ ,]+','[^']*"
export TABLE="podcast_channel"
export NAME_SEP="','" QUOTE="'"
export FIRST=0 SECOND=1 JOBS=4
@alexdelorenzo
alexdelorenzo / to_opml.sh
Last active November 2, 2022 03:21
Generate an OPML file from Airsonic podcast subscriptions https://alexdelorenzo.dev/notes/airsonic-opml
#!/usr/bin/env bash
# License: GPLv3
export SCRIPT="${1:-airsonic.script}"
export TITLE="Airsonic Podcasts"
export SQL_REGEX="'https?://[^ ,]+','[^']*"
export TABLE="podcast_channel"
export DELIM=','
export TAG_FMT="<outline type='rss' xmlUrl='%s' text='%s' />"
@alexdelorenzo
alexdelorenzo / find-mirrors.sh
Last active September 12, 2022 10:11
Find Ubuntu repository mirrors for ARM (armhf & arm64), RISC-V (riscv64), PPC (ppc64el), IBM Z (s390x), and more. For more information and documentation, see: https://alexdelorenzo.dev/notes/ubuntu-mirrors
#!/usr/bin/env bash
# Requires: Bash, GNU grep and parallel, htmlq, and httpie or xh.
# Usage:
# ./find-mirrors.sh ARCH DISTRO REPOSITORY PROTOCOL JOBS
# Example:
# ./find-mirrors.sh armhf focal main https 6
#
# Copyright 2022 Alex DeLorenzo. Licensed under the GPLv3.
#
export ARCH="${1:-${ARCH:-amd64}}"
@alexdelorenzo
alexdelorenzo / install_ff.sh
Last active April 10, 2022 02:28
Install Firefox with Global Menu patches on Ubuntu derived Linux distributions. https://alexdelorenzo.dev/notes/firefox-global-menu
#!/usr/bin/env bash
# Copyright 2022 Alex DeLorenzo. Licensed under the AGPLv3.
#
# This script requires Bash, byobu, curl, and pup. You can find the latter here:
# https://github.com/ericchiang/pup
# For more information, see https://alexdelorenzo.dev/notes/firefox-global-menu
#
# Usage:
# $ ./install_ff.sh amd64
readonly ARCH="${1:-amd64}"
@alexdelorenzo
alexdelorenzo / noMobile.userscript.js
Created February 8, 2022 01:50
Force desktop interface on Wikipedia and disable Wikipedia's mobile UI
// ==UserScript==
// @name Force desktop Wikipedia
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Disable Wikipedia's mobile UI in favor of its desktop UI
// @author Alex DeLorenzo <AlexDeLorenzo.dev>
// @match https://*.m.wikipedia.org/*
// @grant none
// @license GPL-3.0
// ==/UserScript==
@alexdelorenzo
alexdelorenzo / pyclean.py
Last active February 4, 2022 06:09
Clean up Python caches and packaging artifacts. See https://alexdelorenzo.dev/notes/pyclean
#!/usr/bin/env python3
## Author: Alex DeLorenzo
## Homepage: alexdelorenzo.dev
## License: GPLv3
from __future__ import annotations
from typing import Final, AsyncIterable
from shutil import rmtree
from sys import argv
from asyncio import (
gather, to_thread, run, Task,
@alexdelorenzo
alexdelorenzo / cc-audio.py
Last active March 23, 2021 23:22
Convert a video file's audio so it's Chromecast compatible
#!/usr/bin/env python3
#
# License: AGPLv3
# Copyright 2021 Alex DeLorenzo
# Requires Python 3.10+ and ffmpeg
#
from typing import Final
from subprocess import run
from pathlib import Path
from sys import argv
@alexdelorenzo
alexdelorenzo / popcorntime-vpn.sh
Created April 20, 2018 07:19 — forked from Schnouki/popcorntime-vpn.sh
OpenVPN for a single application using network namespaces -- helper scripts
#!/usr/bin/env zsh
# Initialize VPN
sudo vpnns up
sudo vpnns start_vpn
# Popcorn time!
sudo ip netns exec frootvpn sudo -u $USER popcorntime
# Cleanup

Why Python is Making a Comeback

Since the advent of nodeJS, you may have experienced something called Javascript-fatigue: the natural exhaustion one feels in response to the influx of new Javascript modules and developers putting Javascript everywhere - your phone, your car, your toaster - instead of just the web. For a while, it seemed that Javascript would eat the world.

However, over the past few years, an underdog has silently established itself as a cogent solution in both mainstream and niche spaces. Not only has it proved its mettle seemingly overnight, developers are adopting it fast.

Growth of Popular Programming Languages Over a Six Year Period - Courtesy of StackOverflow

Enter Python. A dynamic, strongly-typed programming language with a well-deserved reputation of having a beautifully concise, yet expressive, syntax. One might even say that Python code is executable pseudocod