Skip to content

Instantly share code, notes, and snippets.

@russelldavies
russelldavies / Caddyfile
Created October 8, 2024 18:33
Invoice Ninja docker
{
frankenphp
}
{$APP_URL} {
root /srv/public
encode zstd br gzip
php_server
}
@russelldavies
russelldavies / Caddyfile
Created October 7, 2024 16:36
Invoice Ninja flake
:80 {
root invoiceninja/public
encode gzip
php_fastcgi unix/fpm.sock
file_server
}
@russelldavies
russelldavies / daemon.json
Created February 6, 2024 15:46
Docker IPv6
{
"ipv6": true,
"fixed-cidr-v6": "2001:db8::/64",
"experimental": true,
"ip6tables": true,
"default-address-pools":[
{"base": "172.17.0.0/16", "size": 24 },
{"base": "2001:db8:1::/64", "size": 80 }
],
"dns": [
@russelldavies
russelldavies / permutations.rs
Created November 8, 2023 20:38
Permutations
fn main() {
let mut items: Vec<&str> = vec!["a", "b", "c"];
let mut c = vec![0; items.len()];
println!("{:?}", items);
let mut i = 0;
while i < items.len() {
if c[i] < i {
if i % 2 == 0 {
@russelldavies
russelldavies / satshunter.py
Created October 19, 2023 19:37
Sats Hunter
import argparse
import multiprocessing
import itertools
from bip_utils import Bip39SeedGenerator, Bip44Changes, Bip84, Bip84Coins
from bip_utils.utils.mnemonic import MnemonicChecksumError
def validate_mnemonic(perm):
mnemonic = " ".join(perm)
return False
@russelldavies
russelldavies / init.sh
Last active June 2, 2024 18:11
IPv6 bootstrap EC2 instance
#!/bin/sh
# nat64.net NAT64 DNS resolvers
# This can be removed once AWS adds IPv6 DNS records for various services, e.g. SSM
echo 'DNS=2a00:1098:2c::1 2a01:4f9:c010:3f02::1 2a01:4f8:c2c:123f::1\nDomains=~.' >> /etc/systemd/resolved.conf
systemctl restart systemd-resolved.service
# AWS Ubuntu repo doesn't support IPv6 so use default
sed -E -i 's/[a-z]{2}-[a-z]+-[0-9]\.ec2\.//g' /etc/apt/sources.list
@russelldavies
russelldavies / intercept.js
Created August 5, 2023 11:26
Intercept unauthorized requests for Elm
XMLHttpRequest = class extends XMLHttpRequest {
send() {
const onreadystatechange = this.onreadystatechange;
this.onreadystatechange = () => {
console.log(this.readyState);
if (typeof onreadystatechange === 'function') {
this._onreadystatechange();
}
};
super.send();
#!/bin/sh
snap switch --channel=candidate amazon-ssm-agent
snap refresh amazon-ssm-agent
@russelldavies
russelldavies / mount.sh
Created June 4, 2023 14:51
Mount disk image in MacOS
#!/bin/sh
hdiutil attach -readonly -imagekey diskimage-class=CRawDiskImage disk.img
@russelldavies
russelldavies / git.md
Created November 2, 2022 23:15
Git message imperatives

Git message imperatives:

  • Add = Create a capability e.g. feature, test, dependency.
  • Cut = Remove a capability e.g. feature, test, dependency.
  • Fix = Fix an issue e.g. bug, typo, accident, misstatement.
  • Bump = Increase the version of something e.g. dependency.
  • Make = Change the build process, or tooling, or infra.
  • Start = Begin doing something; e.g. create a feature flag.
  • Stop = End doing something; e.g. remove a feature flag.
  • Refactor = A code change that MUST be just a refactoring.
  • Reformat = Refactor of formatting, e.g. omit whitespace.