Skip to content

Instantly share code, notes, and snippets.

View davidlj95's full-sized avatar

David LJ davidlj95

View GitHub Profile
@davidlj95
davidlj95 / dated-files-renamer.sh
Last active September 7, 2023 17:31
File with dates renamer. From (YYYY.MM.DD). From YYYYMMDD. To YYYY-MM-DD. Replaces _ with -
#!/bin/sh
[ $# -eq 0 ] && >&2 echo "❌ No files provided as arguments" && exit 1
NOSPACES_FILE_REGEXP="^([0-9]{4})([0-9]{2})([0-9]{2})(.*)$"
PARENTHESES_FILE_REGEXP="^\(([0-9]{4})\.([0-9]{2})\.([0-9]{2})\)(.*)$"
for filename in "$@";
do
new_filename="$filename"
printf "\"$filename\""
# No spaces
@davidlj95
davidlj95 / make-for-root-guard.ts
Created December 20, 2023 18:31
Angular `makeForRootGuard` helper
import {
FactoryProvider,
InjectionToken,
Optional,
SkipSelf,
Type,
} from '@angular/core'
/**
* Helps to make a `forRoot` guard to ensure a module is not imported
@davidlj95
davidlj95 / http-security-headers-response.http
Last active May 5, 2024 15:48
HTTP response with all security headers for a CSR/SSR/SSG Angular app - davidlj95.com
HTTP/2 200
date: Sun, 05 May 2024 15:39:06 GMT
content-type: text/html; charset=utf-8
cache-control: public, max-age=0, must-revalidate
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=ZNcUyO8%2FNm1megeD0GbqGongpd3IiRZ7OizUiPtTDwjeFbtsiQmY%2F0xbwB%2F87Vpm1IK6Oje3JneArNv6fSQad3wC37ZwuqNjIunCyd4nh9p2YX0pLnBTXiM8TafWlw%2Fz"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
vary: Accept-Encoding
cf-cache-status: DYNAMIC
strict-transport-security: max-age=15552000; preload
expect-ct: max-age=86400, enforce
@davidlj95
davidlj95 / print-renovate-config.sh
Last active June 4, 2024 14:22
Print Renovate configuration
# Local
LOG_LEVEL=debug pnpm dlx renovate \
--platform local \
--print-config true
# GitHub hosted
REPO="user/repo"
LOG_LEVEL=debug pnpm dlx renovate \
--dry-run extract \
--print-config true \
@davidlj95
davidlj95 / luarocks-install.sh
Created June 18, 2024 18:03
LuaJIT + luarocks in macOS with brew
luarocks install --tree=$(brew --prefix)/lib/lua/5.1 luasocket
@davidlj95
davidlj95 / udpgroforwarding.service
Created April 28, 2025 20:45
Raspberry Pi + Tailscale exit node: UDP GRO config
[Unit]
Description= UDPGroForwarding
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
ExecStart=/sbin/ethtool -K eth0 rx-udp-gro-forwarding on rx-gro-list off
[Install]