Skip to content

Instantly share code, notes, and snippets.

@stephenchew
stephenchew / README.md
Created April 2, 2026 15:16
Convert TS to MP4

Fast conversion

ffmpeg -i input.ts -c copy output.mp4

Quick one to one convert

filename="abc"
ffmpeg -i "$filename.ts" -c copy "$filename.mp4"
@stephenchew
stephenchew / hardlink.sh
Last active February 9, 2025 09:55
Create hardlink recursively
@stephenchew
stephenchew / README.md
Created December 31, 2024 15:49
All things about docker-compose

Docker compose

Specify a path for docker volume

docker-compose.yaml

services:
  abc:
 ...
@stephenchew
stephenchew / README.md
Created June 8, 2024 14:21
Headless setup of Raspberry PI

Enable SSH

  1. Locate the partion of the newly flashed Raspberry Pi OS.
  2. Create a new empty file named ssh with no extension in the boot partition.

or

echo '' > ssh
@stephenchew
stephenchew / main.py
Created April 25, 2024 11:14
O(1) way to chunk an array into small pieces in Python
arr = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
chunk_three = chunk(arr, 3)
assert chunk_three == [["a", "b", "c"], ["d", "e", "f"], ["g", "h", "i"], ["j"]]
chunk_default = chunk(arr)
assert chunk_default == [["a", "b", "c", "d"], ["e", "f", "g", "h"], ["i", "j"]]
chunk_max = chunk(arr, 1000)
assert chunk_max == [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']]
@stephenchew
stephenchew / README.md
Created February 14, 2024 09:39
WSL import/export and setting default user

Export a WSL instance

wsl --export <distribution name> <export file name>

e.g.

wsl --export Ubuntu-22.04 D:\wsl-backup\Ubuntu.22.04.tar

Forward port from host to WSL

In PowerShell, run:

netsh interface portproxy add v4tov4 listenport=<host post> listenaddress=0.0.0.0 connectport=<wsl port> connectaddress=<wsl IP address>

e.g. forward port 8080 to port 8080

netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=8080 connectaddress=172.30.144.20
@stephenchew
stephenchew / README.md
Last active January 6, 2024 14:44
Bulk edit photos in Photoprism

Bulk edit photos in Photoprism

Tested to work with builds: -

  • 231011-63f708417
  • 230923-e59851350
  • 230719-73fa7bbe8

Use this workaround until Photoprism implemented bulk-edit feature.

@stephenchew
stephenchew / README.md
Last active October 11, 2023 12:59
All about WSL2

All about WSL2

Docker in WSL2 (without Docker Desktop)

🔗 https://nickjanetakis.com/blog/install-docker-in-wsl-2-without-docker-desktop

Installing Google Chrome

  1. Change directories into the temp folder: cd /tmp
  2. Use wget to download it: sudo wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
  3. Get the current stable version: sudo dpkg -i google-chrome-stable_current_amd64.deb
  4. Fix the package: sudo apt install --fix-broken -y