Skip to content

Instantly share code, notes, and snippets.

View smartwatermelon's full-sized avatar
🏠
Working from home permanently

Andrew Rich smartwatermelon

🏠
Working from home permanently
View GitHub Profile
@smartwatermelon
smartwatermelon / transmission.conf
Last active November 17, 2024 00:08
nginx config to make Transmission accept https connections from internal network without password prompt
server {
listen 443 ssl;
server_name YOUR_TRANSMISSION_HOST_NAME;
ssl_certificate /usr/local/etc/nginx/ssl/nginx.crt;
ssl_certificate_key /usr/local/etc/nginx/ssl/nginx.key;
# you should create a self-signed cert:
# sudo mkdir -p /usr/local/etc/nginx/ssl
# sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /usr/local/etc/nginx/ssl/nginx.key -out /usr/local/etc/nginx/ssl/nginx.crt
@smartwatermelon
smartwatermelon / newYearsDay
Last active January 2, 2025 22:01
@cassidoo's interview question from December 30, 2024, in Bash
$ newYearsDay(){ date -v "${1:-$(date +"%Y")}y" -v 01m -v 01d +"%A"; }
$ newYearsDay 2025
Wednesday
$ newYearsDay 2024
Monday
$ newYearsDay # default value is current year
Wednesday
@smartwatermelon
smartwatermelon / permute.sh
Created January 6, 2025 19:52
@cassidoo's interview question from January 5, 2025, in Bash
#!/usr/bin/env bash
set -eu -o pipefail
# Generate all permutations of a given string
# Usage: permutate "string"
permutate() {
local string=$1
local prefix=${2:-}
local result=()
local len=${#string}
@smartwatermelon
smartwatermelon / calculateIngredients
Last active April 21, 2025 23:37
@cassidoo's interview question from April 20, 2025, in Bash
# one-liner in Bash
$ target=3; for i in "flour:200" "sugar:100" "eggs:2"; do echo "${i%%:*}:$(( ${i##*:} * target ))"; done
flour:600
sugar:300
eggs:6
@smartwatermelon
smartwatermelon / config
Last active April 30, 2025 18:07
my yt-dlp config
# this file is $HOME/.config/yt-dlp/config
# https://github.com/yt-dlp/yt-dlp?tab=readme-ov-file#readme
# Output location
--paths "temp:/tmp"
--paths "home:/Volumes/DSMedia/Media/Download"
# Process metadata first
--parse-metadata "title:%(title)s"
@smartwatermelon
smartwatermelon / doLaundry.sh
Created August 19, 2025 19:14
@cassidoo's interview question from August 17, 2025
#!/usr/bin/env bash
set -uo pipefail
cycles=("done" "dry" "spin" "rinse" "wash" "soak")
createLaundryItem() { echo "5"; }
nextCycle() {
echo "${cycles[$1]}"
(($1 > 0)) && return $(($1 - 1)) || return 0