Skip to content

Instantly share code, notes, and snippets.

@jvarn
jvarn / sudo.sh
Last active March 8, 2026 12:21
Dummy sudo for proot-distro
#!/bin/bash
# -----------------------------------------------------------------------------
# sudo.sh
#
# Description:
# A lightweight "dummy" sudo wrapper designed for proot-distro, Termux, or
# containerized environments where the standard sudo binary is missing.
#
# Behaviour:
# - If running as root (EUID 0): Executes commands immediately and silently.
@jvarn
jvarn / wakeonlan.sh
Created March 5, 2026 12:30
Send a Wake-on-LAN (WOL) packet to a target machine via an always-on Linux host
#!/usr/bin/env zsh
# -----------------------------------------------------------------------------
# wakeonlan.sh
#
# Send a Wake-on-LAN (WOL) packet to a target machine via an always-on
# Linux host.
#
# Many computers that are powered off cannot receive WOL packets from
# outside their local network, e.g. when using Zerotier or Tailscale
# VPN. This script solves that problem by SSHing into a machine that
@jvarn
jvarn / getmacaddress.sh
Created March 5, 2026 12:11
Retrieve the MAC address of a network interface on a local or remote host (macOS or Linux)
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# getmacaddress.sh
#
# Retrieve the MAC address of a network interface on a local or remote host.
#
# The script connects to the specified host (via SSH if the host is not the
# local machine) and attempts to retrieve the MAC address of the specified
# network interface.
#
@jvarn
jvarn / getaudible.sh
Last active February 21, 2026 12:16
Quick setup for audible-cli on macOS (setup then download and convert)
#!/usr/bin/env bash
set -euo pipefail
OUTDIR="converted"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
# Load .env if present (simple KEY=VALUE lines)
ENV_FILE="$SCRIPT_DIR/.env"
@jvarn
jvarn / Instructions.txt
Created February 18, 2026 08:36
Fix the Arabic letter order in Arabic PowerPoint converted from PDF
Step-by-Step Instructions (macOS)
PowerPoint on Mac hides the coding tools by default. Here is how to set it up and use the script:
1. Enable the Developer Tab
Open PowerPoint.
Click PowerPoint in the top menu bar (top left of your screen) and select Preferences...
Click on Ribbon & Toolbar.
@jvarn
jvarn / usr-local-bin-weather
Created January 4, 2026 04:52
Weather from terminal
# https://github.com/chubin/wttr.in
# sudo nano /usr/local/bin/weather
# sudo chmod +x /usr/local/bin/weather
# ------- paste below then run with `weather` ------- #
#!/bin/bash
curl wttr.in
@jvarn
jvarn / .zshrc
Created December 14, 2025 12:28
zsh usability essentials (macOS)
# History prefix search
bindkey '^[[A' history-search-backward
bindkey '^[[B' history-search-forward
# Colourised commands
alias ls='ls -G'
alias grep='grep --color=auto'
alias diff='diff --color=auto'
export LESS='-R'
export LSCOLORS=GxFxCxDxBxegedabagaced
@jvarn
jvarn / reinstall_zotero.sh
Created October 23, 2025 05:37
Reinstall Zotero When the Safari Extension Disappears
#!/usr/bin/env bash
set -euo pipefail
APP_NAME="Zotero.app"
APP_PATH="/Applications/${APP_NAME}"
TMP_DMG="/tmp/Zotero_latest.dmg"
DOWNLOAD_URL="https://www.zotero.org/download/client/dl?channel=release&platform=mac"
# Quit Zotero if running
@jvarn
jvarn / extract_text_from_image_live_text_ocr.applescript
Last active March 11, 2025 04:31
These AppleScripts use the "Live Text" OCR feature available in Preview in recent versions of macOS to extract text from single or multiple images. One version runs from the command line, while the other version is for Finder Quick Action integration using Automator. Adapted from: https://stackoverflow.com/questions/71104893/macos-how-to-access-…
-- Automator version
-- usage:
-- 1. Create new Quick Action in macOS Automator
-- 2. Workflow receives current "image files" in "Finder"
-- 3. Add "Run Applescript"
-- 4. Paste this code
-- 5. Now you can right-click on an image or multiple images in Finder to extract the text to .txt files.
use framework "Vision"
use framework "Foundation"
@jvarn
jvarn / apply_ssl_cert_to_WD_my_cloud_nas.md
Last active August 26, 2024 06:54
Apply SSL cert to WD My Cloud NAS

How to apply your wildcard SSL certificate to a WD My Cloud NAS device

I have tested this on WD My Cloud EX4 (an obsolete model).

  1. Enable SSH access through the NAS web interface, choosing a suitable password when prompted.

  2. Copy the certificates over from where they are stored.

cd /home/user/certs # e.g.