Skip to content

Instantly share code, notes, and snippets.

View superstes's full-sized avatar
🎯
Focusing

René Rath superstes

🎯
Focusing
View GitHub Profile
@superstes
superstes / nftables_tproxy_example.nft
Created August 20, 2023 21:17 — forked from NiceRath/nftables_tproxy_example.nft
NFTables TPROXY - proxy input and output
#!/usr/sbin/nft -f
# see also:
# https://wiki.nftables.org/wiki-nftables/index.php/Netfilter_hooks
# https://docs.kernel.org/networking/tproxy.html
# https://powerdns.org/tproxydoc/tproxy.md.html
# http://git.netfilter.org/nftables/commit/?id=2be1d52644cf77bb2634fb504a265da480c5e901
# http://wiki.squid-cache.org/Features/Tproxy4
# https://serverfault.com/questions/1052717/how-to-translate-ip-route-add-local-0-0-0-0-0-dev-lo-table-100-to-systemd-netw
# https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/net/netfilter/nft_tproxy.c
@superstes
superstes / iptables_tproxy_example.sh
Created August 20, 2023 21:17 — forked from NiceRath/iptables_tproxy_example.sh
IPTables TPROXY - proxy input and output
#!/bin/bash
# target: squid-openssl 4.13 with listener "http_port 127.0.0.1:3129 tproxy"
# see also:
# https://docs.kernel.org/networking/tproxy.html
# https://blog.cloudflare.com/mmproxy-creative-way-of-preserving-client-ips-in-spectrum/
# https://latest.gost.run/en/tutorials/redirect/#forwarding-chain_1
# you might need to enable some iptables/nftables kernel modules:
@superstes
superstes / golang_compile.sh
Last active December 4, 2023 09:43
Golang - script to compile binaries for many target systems
#!/bin/bash
set -euo pipefail
PROJECT_NAME='test'
# inside '/scripts/' directory
# change to directory from where we can run 'go build'
cd "$(dirname "$0")/../main"
@superstes
superstes / github_download_latest_release.sh
Last active December 4, 2023 10:37
Script to download latest GitHub release
#!/bin/bash
# tested for downloading golang binaries
set -euo pipefail
GH_USER='superstes'
GH_REPO='geoip-lookup-service'
FILTER=''
FILTER_EXCLUDE='$%&'
@superstes
superstes / wireguard_client_server.conf
Last active December 22, 2023 20:00
Basic WireGuard Client/Server Config
### BASIC ###
GEN KEYS: wg genkey | tee privatekey | wg pubkey > publickey
ADD CONFIG: /etc/wireguard/<CONFIG>.conf
ADD SERVICE: systemctl start wg-quick@<CONFIG>.service
EN SERVICE: systemctl enable wg-quick@<CONFIG>.service
### SERVER ###
[Interface]
Address = 10.0.1.1/24
@superstes
superstes / circular-progress-css.js
Last active April 3, 2024 15:50
Minimalistic Circular Progress using CSS & vanilla JS
// NOTE: this can be used to create a minimalistic version of these:
// https://github.com/tigrr/circle-progress
/* HTML
<!DOCTYPE html>
<html>
<head>
<title>Circular Progress</title>
<link rel="stylesheet" type="text/css" href="prog.css">
</head>
@superstes
superstes / threejs-point-in-front-of-camera.js
Created April 7, 2024 14:37
ThreeJS - Check if point is in front of camera (inside FOV)
/*
NOTES:
basic source: https://discourse.threejs.org/t/detect-if-target-is-behind-the-camera-bis/219/2
you could also use a frustum: https://threejs.org/docs/index.html#api/en/math/Frustum.containsPoint
we assume the InFrontOfCamera will be called many times each frame - so we want to prepare the camera values it uses to lower processing cost
*/
const CAM_FOV = 60;
const CAM_FOV2 = (Math.PI / 360) * (360 - CAM_FOV);
@superstes
superstes / threejs-html-element-follow-point.js
Last active April 7, 2024 21:42
ThreeJS - Let HTML-Element follow point (<model-viewer> annotation-like)
/*
NOTES:
basic source: https://codepen.io/lamb_1128/pen/xxQogxj
this functionality can be compared to the annotations seen at: https://modelviewer.dev/examples/annotations/index.html
but this has a very minimalistic approach
*/
/* css
.annotation {
position: absolute;
@superstes
superstes / google_takeout_mail_analysis.sh
Created April 17, 2024 18:15 — forked from NiceRath/google_takeout_mail_analysis.sh
Script to analyze Google Workspace/Gmail Mailboxes (Mailing Lists, Top Senders)
#!/bin/bash
set -eo pipefail
# NOTES:
# to use on backup files created by Google Takeout: https://support.google.com/accounts/answer/3024190?hl=en
# creates lists of top N mail senders & distribution-lists @ /tmp
# can be used to create Google Vault retentions to clean-up old mails or spam: https://support.google.com/vault/answer/2990828?hl=en
if [-z "$1" ]
#!/bin/bash
set -euo pipefail
# NOTES:
# as Apple is not able to provide any good option to force updates on managed clients - you might want to notify users to install them
# will be silent if no updates are available
# see also: https://ss64.com/osx/softwareupdate.html