Skip to content

Instantly share code, notes, and snippets.

View bretton's full-sized avatar

bretton bretton

  • Cape Town, South Africa
View GitHub Profile
@bretton
bretton / repair-dude.md
Last active April 25, 2024 08:24
Repair Mikrotik Dude database

If you run a Mikrotik Dude instance on CHR, have a lot of devices and years of activity, problems start to arise with errors like:

server status: db failure: disk image is malformed. stop
server status: db failure: database disk image is malformed. stop

The problem might temporarily be resolved by running

#!/bin/bash
@bretton
bretton / self-hosted-ai.md
Last active January 5, 2024 11:05
Self-hosted AI toolsets

Self-hosted AI toolsets

TabbyML is a self-hosted AI coding assistant, offering an open-source and on-premises alternative to GitHub Copilot.

jan.ai is a self-hosted tool to run different LLMs. github releases

Apple's mlx is an array framework for machine learning on Apple silicon

AUTOMATIC1111's Stable Diffusion web UI is a browser interface for Stable Diffusion.

@bretton
bretton / haproxy-sni.md
Last active December 6, 2023 20:39
haproxy SNI configuration with SSL pass through

This comes from this forum post and adapted with info from this gist

A sample HAproxy configuration using SNI. Using SNI has the advantage that you don't have to mess with the certificates on the HAproxy server itself. Useful with many servers and / or many fast-expiring certificates (letsencrypt).

global
        maxconn         5000
        ulimit-n        16384
        log             127.0.0.1 local0
        uid             99
@bretton
bretton / apple-m2-qemu-libvirt.md
Last active September 10, 2023 21:50
Virtual machines on Apple M2 chips, with Ventura

Virtual machines on Apple M2 chips, with Ventura

Version

This is version 0.1

Requirements

I want to run VMs with custom networking over a bridge.

@bretton
bretton / unix-disk-usage-tools.md
Last active September 3, 2023 17:33
Unix Disk Usage Tools
@bretton
bretton / monthly-income-statement-gnucash.md
Created May 7, 2023 20:44
Create a month-by-month income statement in GnuCash

Create a month-by-month income statement in GnuCash

This works for Gnucash 4.12 on a Mac.

Reports > Multicolumn > Custom Multicolumn Report

Click the Options icon.

Set 12 columns.

@bretton
bretton / optimal-virtualbox-freebsd.md
Last active June 9, 2023 19:42
Optimal Virtualbox on FreeBSD, running FreeBSD virtual machines

Optimal Virtualbox on FreeBSD, running FreeBSD images

For best results:

  • Use only a single core per VM (cpus setting). This is critical, more causes problems.
  • Set the sysctl.conf settings below

Configure sysctl.conf and reboot

Add to /etc/sysctl.conf and reboot

@bretton
bretton / csv2json-onliner.md
Created April 12, 2023 09:44
Bash and python one-liner to convert CSV to JSON

Best method to convert CSV to JSON in bash one-liner

wget http://host/file.csv

# csv to json in python, requires a header row
cat file.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > file.json

cat file.json |jq
@bretton
bretton / import-letsencrypt-java.sh
Created February 17, 2023 17:02 — forked from galan/import-letsencrypt-java.sh
Imports the letsencrypt certificates into the java keystore
#!/bin/bash -e
# JAVA_HOME can be passed as argument if not set
if [ ! -d $JAVA_HOME ]; then
JAVA_HOME=${1}
fi
KEYSTORE=$JAVA_HOME/jre/lib/security/cacerts
if [ ! -f "$KEYSTORE" ]; then
echo "Keystore not found in '$KEYSTORE'"
exit 1
@bretton
bretton / self-determination-routing-node.md
Last active January 3, 2023 07:28
Self-Determination and Routing Capacity

Self-Determination and Routing Capacity

This has been observed in the wild. I'm not the originator, just documenting what I've seen.

Fund a node

You need a bitcoin and lightning network node.

You need to fund it with Bitcoin.

Open genesis channel