Skip to content

Instantly share code, notes, and snippets.

iOS tall PDF to multi-page PDF

This Python 3 script, built with the pypdf library, converts a single extremely tall PDF—such as one created by an iOS browser’s full-page screenshot feature—into a multi-page document:

  • Aspect-ratio slicing It cuts the original page into consecutive slices that keep the same aspect ratio as A4 paper (≈ 1 : √2), regardless of the actual width.
  • Overlap control Each new page starts slightly higher than the previous slice end, leaving a configurable overlap (e.g., 10 mm) so content isn’t split awkwardly.
  • Fully offline Everything happens locally; no external services or GUI frameworks are required.
  • Customisable You can change the overlap size, shrink or crop the width if it exceeds A4, and wrap the logic in a CLI or GUI if needed.

How to Route Only Specific Address Ranges Through VPN Using openfortivpn

Purpose: This guide explains how to configure routing so that only necessary IP address ranges go through the VPN interface (ppp0), while the default internet traffic uses the regular network interface (eth0). This avoids routing all traffic through the VPN and limits VPN usage to required subnets.

Steps:

  1. Change the default route to go through the main network interface (eth0) instead of the VPN interface (ppp0):

Generate slimmed down WSL ubuntu image

example for ifuse

Safe Package Removal Script with Protection Check

Purpose

This script automates the removal of packages listed in one file (to_be_removed.txt), but skips removal if doing so would also remove any "protected" packages listed in another file (keep.txt). It ensures important packages are not accidentally uninstalled.

Usage

  1. Prepare two text files:

Auto-Sort Downloads by Creation Month

Purpose

To automatically organize all files and folders in the Downloads directory into subfolders named by their creation year and month (format: YYYYMM).

Method

  • The script scans all items in the ~/Downloads folder.
  • If an item is not already in a correctly named folder for the current or past month, it is moved.

Accessing iPhone File System on Windows via WSL2 Using usbipd and ifuse

Adding memtest86+ to a Linux Live USB

Assuming you have already created an Ubuntu Live USB using Rufus, this guide explains how to add memtest86+ to the grub boot menu on that USB.

Item Value
Media Ubuntu 24.04 x86_64
Live USB Creation Method Rufus ISO mode

In Rufus ISO mode, a FAT partition is created on the USB, and the Ubuntu boot files and grub files are placed there.

How to convert Google Chrome's reading list to bookmarks in one go

If you want to organize your Google Chrome Reading List, this time we will introduce how to convert the entire Reading List into bookmarks at once. Using this method, you can save the hassle of creating bookmarks individually.

Step 1: Export Your Reading List Using Google Takeout

First, export your Reading List using Google Takeout.

  1. Go to Google Takeout.
  2. In the "Select data to include" section, click "Deselect all."