Skip to content

Instantly share code, notes, and snippets.

View grantstephens's full-sized avatar
🍍

Grant Stephens grantstephens

🍍
View GitHub Profile
@grantstephens
grantstephens / mastodon.nix
Created March 16, 2024 08:36
Self Hosted Mastodon using Minio and NixOS
{ pkgs, modulesPath, ... }:
{
security.acme = {
acceptTerms = true;
defaults.email = "~your-email-here~";
};
networking = {
hostName = "mastodon";
hostId = "3e55fdff";
firewall = {
@grantstephens
grantstephens / c4.lst
Last active October 2, 2023 20:29
Channel 4 Blocklist
ds.channel4.com
cdn.http.anno.channel4.com
cdn.ss.anno.channel4.com
channel4.com.112.2o7.net
channel4.com.sc.omtrdc.net
channel4.com.ssl.sc.omtrdc.net
ic.channel4.com
monitor.channel4.com
sexperienceuk.channel4.com
webstat.channel4.com
@grantstephens
grantstephens / main.go
Created September 26, 2023 18:15
Clickhouse IPv6 Address Bug
package main
import (
"context"
"net"
"github.com/ClickHouse/clickhouse-go/v2"
)
func main() {
@grantstephens
grantstephens / main.go
Created August 31, 2023 15:08
Golang Greatest Common Denomenator
package main
import (
"fmt"
)
func greatestCommonDenomenator(x []int) int {
gcd := func(a, b int) int {
for b != 0 {
t := b
@grantstephens
grantstephens / Readme.md
Created February 9, 2023 06:00
How to restore home assistant on k8s
  1. Deploy new home asssiant
  2. Edit deployment and add custom command: `command: ["sleep", "infinity"]
  3. Exec onto sleeping pod and delete everything in config dir. eg: k exec -n homeassistant home-assistant-xxx -it /bin/sh`
  4. Use kubectl cp to copy unzipped backup into place: k cp -n homeassistant . home-assistant-xxx:/config You may have to hurry as the pod will be restarted as it will be failing its liveliness tests.
  5. Edit the deployment again to remove the sleep command
  6. Breathe
@grantstephens
grantstephens / ashp.yaml
Created February 3, 2023 17:40
Monitoring of Grant Aerona ASHP using ESPHome and Serial Port to RS485 UART Converter
esphome:
name: ashp
esp32:
board: nodemcu-32s
wifi: !include wifi.yaml
api:
logger:
@grantstephens
grantstephens / starlight.h
Created October 31, 2021 18:59
Starlight esphome code
#include "esphome.h"
#include "Wire.h"
#include "Adafruit_GFX.h"
#include "Adafruit_IS31FL3731.h"
Adafruit_IS31FL3731 ledmatrix = Adafruit_IS31FL3731();
@grantstephens
grantstephens / main.go
Created September 8, 2021 06:38
Go Script for converting gpx and fit files from strava archive to GeoJson
package main
import (
"archive/zip"
"compress/gzip"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"math"
@grantstephens
grantstephens / ipv4.go
Last active March 20, 2020 16:03
Golang Function to determine if a host is a valid IPv4 Address
func IsIPv4Net(host string) bool {
valid := net.ParseIP(host) != nil
if valid {
return !strings.ContainsRule(host, ':')
}
return false
}
@grantstephens
grantstephens / main.go
Created January 22, 2020 21:51
Example of wasm freezing
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"gioui.org/app"
"gioui.org/io/system"