Skip to content

Instantly share code, notes, and snippets.

@alexdelorenzo
alexdelorenzo / noMobile.userscript.js
Created Feb 8, 2022
Force desktop interface on Wikipedia and disable Wikipedia's mobile UI
View noMobile.userscript.js
// ==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 / find-mirrors.sh
Last active Sep 12, 2022
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
View find-mirrors.sh
#!/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}}"
View to_opml.sh
#!/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 / pyclean.py
Last active Feb 4, 2022
Clean up Python caches and packaging artifacts. See https://alexdelorenzo.dev/notes/pyclean
View pyclean.py
#!/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 Mar 23, 2021
Convert a video file's audio so it's Chromecast compatible
View cc-audio.py
#!/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 / install_ff.sh
Last active Apr 10, 2022
Install Firefox with Global Menu patches on Ubuntu derived Linux distributions. https://alexdelorenzo.dev/notes/firefox-global-menu
View install_ff.sh
#!/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 / get-cflags.sh
Last active May 19, 2022
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
View get-cflags.sh
#!/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 2 | str nth 0)"
export arch="${1:-$detectedArch}"
get-diff() {
diff \
@alexdelorenzo
alexdelorenzo / to_opml.sh
Last active Apr 10, 2022
Generate an OPML file from Airsonic podcast subscriptions https://alexdelorenzo.dev/notes/airsonic-opml
View to_opml.sh
#!/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 / popcorntime-vpn.sh
Created Apr 20, 2018 — forked from Schnouki/popcorntime-vpn.sh
OpenVPN for a single application using network namespaces -- helper scripts
View popcorntime-vpn.sh
#!/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
View WhyPython.md

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