Skip to content

Instantly share code, notes, and snippets.

@TTy32
TTy32 / tree.sh
Created February 12, 2025 10:44
tree: limit number of files for each directory
tree -L 3 | awk '
BEGIN {
last_prefix = ""
count = 1
}
{
# Extract indentation
prefix = $0
sub(/[^│├└─]+$/, "", prefix)
@TTy32
TTy32 / gist:9967ce973e7397588d01a555cb24077d
Created September 24, 2024 15:17
OpenWrt: Change single LAN port to WAN port, and enable SSH + web interface
# Tried and tested method
# First enable web interface
# From: https://openwrt.org/docs/guide-user/luci/luci.secure#allow_https_access_from_internet
uci add firewall wan_https_allow
uci set firewall.wan_https_allow=rule
uci set firewall.wan_https_allow.name='Allow HTTP, HTTPS from WAN'
uci set firewall.wan_https_allow.src='wan'
uci set firewall.wan_https_allow.proto='tcp'
@TTy32
TTy32 / zzopencv.sh
Created August 15, 2024 11:25
Updated zzopencv.sh for OpenCV 4.10 (CUDA 12.x) + cURL correction + HDF disabled
#!/bin/bash
# install opencv
set -e
ROOTDIR=${ZZROOT:-$HOME/app}
NAME1="opencv"
NAME2="opencv_contrib"
TYPE=".tar.gz"
FILE1="$NAME1$TYPE"
FILE2="$NAME2$TYPE"
@TTy32
TTy32 / expand_flatdict_to_tree.py
Created November 4, 2021 09:25
A generic function to expand flat dicts
def expand_flatdict_to_tree(dict, sep = '_', to_lower = True):
tree = {}
for src, val in dict.items():
ref = tree
if to_lower:
src = src.lower()
@TTy32
TTy32 / index.html
Created March 17, 2021 10:08
Dynamic runtime baseURL for angular prod builds
<!-- Replace `<base baseHref="/">` in `index.html` with: -->
<!-- Dynamic base href -->
<base id="baseHref"> <!-- Don't fill baseHref otherwise you'll first get a request with invalid URLs -->
<script>
document.getElementById('baseHref').href = (function() {
// NOTE: URI in app module does not need a / suffix. URI in index.html does!
uri = window.location.pathname;
uri = uri.replace('index.html', '');