Skip to content

Instantly share code, notes, and snippets.

View thanhminhmr's full-sized avatar
😻
I may be slow to respond.

Mai Thanh Minh thanhminhmr

😻
I may be slow to respond.
View GitHub Profile
@thanhminhmr
thanhminhmr / dmesg-24.10.5.txt
Last active April 16, 2026 17:35
Banana Pi R2 OpenWrt `dmesg` dump
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 6.6.119 (builder@buildhost) (arm-openwrt-linux-muslgnueabi-gcc (OpenWrt GCC 13.3.0 r29087-d9c5716d1d) 13.3.0, GNU ld (GNU Binutils) 2.42) #0 SMP PREEMPT Wed Dec 17 21:08:22 2025
[ 0.000000] CPU: ARMv7 Processor [410fc073] revision 3 (ARMv7), cr=10c5387d
[ 0.000000] CPU: div instructions available: patching division code
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] OF: fdt: Machine model: Bananapi BPI-R2
[ 0.000000] earlycon: uart8250 at MMIO32 0x11004000 (options '')
[ 0.000000] printk: bootconsole [uart8250] enabled
[ 0.000000] Memory policy: Data cache writealloc
[ 0.000000] Zone ranges:
@thanhminhmr
thanhminhmr / README.md
Last active January 29, 2026 01:37
Go doesn't have ternary, so created one...

go-ternary

Yes, I know—yet another attempt at bringing a ternary-like experience to Go. But hey, Go doesn’t have one, and I wasn’t around when the last million were written.

Why?

Because Go doesn't have a ternary operator, and according to the official FAQ, it likely never will. The reasoning? To prevent developers from writing "impenetrably complex expressions." But let's be real—poor coding practices exist in all forms. Instead of outright banning a useful construct, wouldn’t compiler warnings for overly complicated ternary expressions have been a more reasonable approach?

Since that's not happening, here’s go-ternary—because sometimes, a one-liner is just nicer than an if-else.

@thanhminhmr
thanhminhmr / pie-camera.service
Created November 24, 2024 10:50
systemd service for streaming camera feed on Raspberry Pi Zero 2w using `ffmpeg` only
[Unit]
Description=Low-res Camera Stream
BindsTo=dev-video0.device
After=dev-video0.device
[Service]
ExecStart=ffmpeg -hide_banner -loglevel warning -i /dev/video0 -listen 1 -c:v h264_v4l2m2m -b:v 1000k -f mpegts http://0.0.0.0:8080
Restart=always
RestartSec=1s
@thanhminhmr
thanhminhmr / hyperv-usb-passthrough-guide.md
Created April 22, 2024 08:40
Hyper-V USB Passthrough using USBIP (afaik the *only* way)
  1. (Optional) Run this to disable "Microsoft Wi-Fi Direct Virtual Adapter" if you planned to passthrough a USB Wifi adapter.
netsh wlan stop hostednetwork
netsh wlan set hostednetwork mode=disallow
  1. Get VendorID and ProductID of the USB device, both are 4 hexadecimal digits. There are many ways to do this, the easy enough way for a noob is to plug it in, open Device Manager, right-click the device and open Properties, choose Details tab, on the Property drop-down, select Hardware Ids. The value should be something like USB\VID_ABCD&PID_1234, that should make the VendorID be ABCD and ProductID be 1234.

  2. Install usbipd-win: https://github.com/dorssel/usbipd-win/

@thanhminhmr
thanhminhmr / string-to-sha1.java
Created January 12, 2020 03:27 — forked from giraam/string-to-sha1.java
Hashing a String with SHA1 in Java
import java.io.*;
import java.util.logging.*;
import javax.xml.bind.DatatypeConverter;
/**
* Hashing with SHA1
*
* @param input String to hash
* @return String hashed
*/