How-to: Images

Remove background nix shell nixpkgs#rembg --command rembg i -m bria-rmbg input.jpg output.jpg Removes background using bria-rmbg, a state-of-the-art background removal model by BRIA AI. It yielded the best results for me, but try out the other models as well!

January 10, 2026 · 1 min · Abdelrahman Abdelhafez

I don't have Python installed

Just ran into a Python script out in the wild 1. Had to run it, but I have neither a Python interpreter on my machine nor the packages which the script depends on. Wasn’t a problem, though. To run this asciicast without javascript, use asciinema play https://abdelrahman.sh/2025/11/i-do-not-have-python-installed/nix-shell.cast with Asciinema To set up the hacs_waste_collection_schedule integration on Home Assistant, you must run a Python script that prompts you for your home address, which it then uses to compute the parameters with which you can set up the integration. ↩︎ ...

November 16, 2025 · 1 min · Abdelrahman Abdelhafez

How-to: PDFs

OCR nix shell nixpkgs#ocrmypdf --command ocrmypdf --language deu --force-ocr input.pdf output.pdf OCRs the German text in the scanned document and overlays the OCRed text onto it. Deskew nix shell nixpkgs#ocrmypdf --command ocrmypdf --deskew input.pdf output.pdf Deskews crooked pages. Fake duplex nix shell nixpkgs#pdfcpu --command pdfcpu merge -mode zip output.pdf front.pdf back.pdf Produces a 2-sided document by interleaving the given odd- and even-numbered pages (scanned by a non-duplex scanner). Extract images nix shell nixpkgs#poppler_utils --command pdfimages -j -png input.pdf sample Extracts the JPEGs from the given document as PNGs.

September 14, 2025 · 1 min · Abdelrahman Abdelhafez

Shell we Nix?

Ever wanted a way to quickly & temporarily install an amusing command-line tool that you read about on the interwebz? I certainly needed something like that since forever. Every now and then I gotta compress a JPEG using imagemagick, format a markdown file using prettier, or demonstrate to my colleagues that [,,,].length is a valid JavaScript expression, while not having Node.js installed on my machine. Second best thing I had was Homebrew. I’d brew install the tool, take it for a spin, and hopefully remember to brew uninstall it afterwards - or else it’ll not only bloat my system, but also slow down brew upgrades even more for the forseable future until I factory-reset my machine next Spring cleaning. ...

March 9, 2025 · 2 min · Abdelrahman Abdelhafez