Skip to content

Instantly share code, notes, and snippets.

View arbal's full-sized avatar
👌
new Adaptor(this); // new Adaptor(_humans[].Behavior);

Arbal arbal

👌
new Adaptor(this); // new Adaptor(_humans[].Behavior);
  • Los Angeles, CA
  • 02:46 (UTC -07:00)
View GitHub Profile
@arbal
arbal / decode-dyn-uti.swift
Created January 8, 2025 21:09 — forked from jtbandes/decode-dyn-uti.swift
Dynamic UTI decoding
/// Decodes a dynamically-generated Uniform Type Identifier for inspection purposes. (**NOT FOR PRODUCTION USE!**)
/// Many, many thanks to http://alastairs-place.net/blog/2012/06/06/utis-are-better-than-you-think-and-heres-why/
///
/// <https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html#//apple_ref/doc/uid/TP40001319-CH202-BCGCDHIJ>
func decodeDynUTI(_ uti: String) -> String?
{
let vec = Array("abcdefghkmnpqrstuvwxyz0123456789")
let encoded = Array(uti).suffix(from: 5)
var result: [UInt8] = []
@arbal
arbal / diskusage_by_ext.sh
Created January 8, 2025 16:37 — forked from dannyNK/diskusage_by_ext.sh
Lists disk usage of files in the current folder by file extension
# Based on answer from Yuval here: https://askubuntu.com/a/1214458/687179
# output pairs in the format: `filename size`.
# I used `nawk` because it's faster.
find . -type f -print0 | xargs -0 stat -f'%N %z' | awk '
{
split($1, a, "."); # first token is filename
ext = a[length(a)]; # only take the extension part of the filename
size = $2; # second token is file size
total_size[ext] += size; # sum file sizes by extension
}
@arbal
arbal / doh_test.sh
Created December 13, 2024 00:07 — forked from dtmsecurity/doh_test.sh
DNS over HTTPS (DoH) Resolver GET Test Script
#!/bin/bash
printf "===START dns.google.com===\n"
curl -k -H "accept: application/dns-json" "https://dns.google.com/resolve?name=example.com&type=AAAA"
printf "\n===END dns.google.com===\n"
printf "===START cloudflare-dns.com===\n"
curl -k -H "accept: application/dns-json" "https://cloudflare-dns.com/dns-query?name=example.com&type=AAAA"
printf "\n===END cloudflare-dns.com===\n"
printf "===START 1.1.1.1===\n"
curl -k -H "accept: application/dns-json" "https://1.1.1.1/dns-query?name=example.com&type=AAAA"
printf "\n===END 1.1.1.1===\n"
@arbal
arbal / installmicrok8s.md
Created December 11, 2024 16:15 — forked from Monarch73/installmicrok8s.md
Install microk8s in proxmox

Installing microk8s in an LXC container (i.e.: proxmox)

This is an roundition of https://gist.github.com/acj/3cb5674670e6145fa4f355b3239165c7 which got a bit messy

  1. Create a LXC container through the Proxmox web interface (ie.: ubuntu.23-10-lts)
    • untick "unpriviledged" container
    • in memory, set swap to 1024
    • set mem to at least 4096
    • in network, make sure you assign static ip-adress to the container
  • create container but don't start it.

How to install dlib v19.9 or newer (w/ python bindings) from github on macOS and Ubuntu

Pre-reqs:

  • Have Python 3 installed. On macOS, this could be installed from homebrew or even via standard Python 3.6 downloaded installer from https://www.python.org/download. On Linux, just use your package manager.
  • On macOS:
    • Install XCode from the Mac App Store (or install the XCode command line utils).
    • Have homebrew installed
  • On Linux:
@arbal
arbal / slash.sh
Created June 23, 2024 19:34 — forked from luciomartinez/slash.sh
Add or Remove trailing slash in bash
### Add trailing slash if needed
STR="/i/am/a/path"
length=${#STR}
last_char=${STR:length-1:1}
[[ $last_char != "/" ]] && STR="$STR/"; :
echo "$STR" # => /i/am/a/path/
@arbal
arbal / README.md
Created June 19, 2024 23:30 — forked from disler/README.md
Use these Prompt Chains to build HIGH QUALITY AI Agents (Agentic Building Blocks)

Setup

  1. Create a new directory with these three files (requirements.txt, main.py, README.md)
  2. python -m venv venv
  3. source venv/bin/activate
  4. pip install -r requirements.txt
  5. python main.py
  6. Update main() to run the example prompt chains
#!/usr/bin/env bash
echo 'net.ipv4.ip_forward = 1' | sudo tee /etc/sysctl.d/20-tailscale.conf
echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.d/20-tailscale.conf
sudo sysctl -p /etc/sysctl.d/20-tailscale.conf
printf '#!/bin/sh\n\nethtool -K %s rx-udp-gro-forwarding on rx-gro-list off \n' "$(ip route show 0/0 | cut -f5 -d" ")" | sudo tee /etc/networkd-dispatcher/routable.d/50-tailscale
sudo chmod 755 /etc/networkd-dispatcher/routable.d/50-tailscale
sudo /etc/networkd-dispatcher/routable.d/50-tailscale
@arbal
arbal / docker-swarm-architecture.md
Created May 21, 2024 02:31 — forked from scyto/docker-swarm-architecture.md
My Docker Swarm Architecture
@arbal
arbal / ubuntu_22.04_motd.md
Created April 13, 2024 00:18 — forked from jfeilbach/ubuntu_22.04_motd.md
Make Ubuntu 22.04 less annoying. Remove ESM Ubuntu Advantage

Ubuntu 22.04 Annoyances

Here are a few collected ways I like to customize Ubuntu 22.04 servers. I used to love Ubuntu, but I hate auto updates and snaps. They also put ads and other usless ads diguised as "news" in MOTD. ESM FUD is spread throughout the OS including simple apt functions. You do not need ESM and thus Ubuntu 22.04 has become super annoying. unattended-upgrade is an automatic installation of security (and other) upgrades without user intervention. Consider the ramifications of disabling this service.

Disable unattended upgrades

The Unattended Upgrades feature is enabled by default and it runs at system boot without the user's permission. The configuration is stored in /etc/apt/apt.conf.d/20auto-upgrades

Disable: sudo dpkg-reconfigure unattended-upgrades then a TUI will come up, select "No"

This will not permantently disable the function. After an update it will be enabled. In the file /etc/apt/apt.conf.d/20auto-upgrades change these values from 1 to 0. Even doing this it will