Skip to content

Instantly share code, notes, and snippets.

@simonhorlick
simonhorlick / list-serial-numbers.sh
Created December 9, 2024 02:39
List serial numbers for each sata device
#!/bin/bash
# run as root
for d in /sys/block/sd*
do
s=$(basename $d)
h=$(ls -l $d | egrep -o "host[0-9]+")
t=$(ls -l $d | egrep -o "target[0-9:]*")
a2=$(echo $t | egrep -o "[0-9]:[0-9]$" | sed 's/://')
@simonhorlick
simonhorlick / zfs-setup.sh
Created September 18, 2024 04:09
zfs setup
sudo zpool create -m /mnt/pool pool draid2 /dev/disk/by-path/pci-0000\:0b\:00.1-ata-3 /dev/disk/by-path/pci-0000\:ca\:00.0-ata-3 /dev/disk/by-path/pci-0000\:0b\:00.1-ata-7 /dev/disk/by-path/pci-0000\:ca\:00.1-ata-3 /dev/disk/by-path/pci-0000\:ca\:00.0-ata-7 /dev/disk/by-path/pci-0000\:ca\:00.1-ata-7
sudo zfs set atime=off pool
sudo zpool status
@simonhorlick
simonhorlick / BUILDING.md
Created July 19, 2024 09:36
Building the flutter engine on macOS

Build the engine shared library

Make sure engine is on the same commit as the flutter tool. My flutter sdk is downloaded from the internet and placed in ~/src/github.com/flutter/sdk. The engine source is under ~/src/engine.

# Go into the engine/src/flutter directory
cd ~/src/engine/src/flutter
git checkout `cat ~/src/github.com/flutter/sdk/flutter/bin/internal/engine.version`
sudo apt update
sudo apt install -y pulseaudio pulseaudio-module-bluetooth
sudo usermod -a -G bluetooth simon
sudo vim /etc/bluetooth/main.conf
Class = 0x41C
DiscoverableTimeout = 0
@simonhorlick
simonhorlick / script.sh
Last active July 3, 2023 03:23
Enable notifications on zfs failures
# Configure zed to send emails
sudo sed -i 's/ZED_EMAIL_ADDR="root"/ZED_EMAIL_ADDR="simonhorlick@gmail.com"/g' /etc/zfs/zed.d/zed.rc
sudo sed -i 's/#ZED_EMAIL_PROG="mail"/ZED_EMAIL_PROG="msmtp"/g' /etc/zfs/zed.d/zed.rc
sudo sed -i "s/#ZED_EMAIL_OPTS=\"-s '@SUBJECT@' @ADDRESS@\"/ZED_EMAIL_OPTS=\"@ADDRESS@\"/g" /etc/zfs/zed.d/zed.rc
sudo sed -i 's/#ZED_NOTIFY_VERBOSE=0/ZED_NOTIFY_VERBOSE=1/g' /etc/zfs/zed.d/zed.rc
# Generate an app password for Mail and write it down
open https://myaccount.google.com/apppasswords
# Configure msmtp to send email via gmail smtp.
@simonhorlick
simonhorlick / script.sh
Last active June 20, 2024 15:45
Replacing failed drives
# get the guid of the unavailable disk
sudo zpool status
# mark the unavailable disk as offline
sudo zpool offline default-pool 14714788819670456418
# replace with the new disk
sudo zpool replace default-pool 14714788819670456418 /dev/disk/by-id/usb-WD_My_Book_25ED_4437483757384B4E-0\:0
# Using tailscale as a VPN replacement
Create an AWS instance, for example m5.xlarge using ubuntu and ssh into it.
```bash
curl -fsSL https://tailscale.com/install.sh | sh
echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.conf
# Don't use this if you need stateless autoconfiguration
echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p /etc/sysctl.conf
@simonhorlick
simonhorlick / Palindromes.fm
Created July 14, 2020 11:32
A minimal, but non-trivial Formality example.
// isPalindrome returns whether the given string is a palindrome. A palindrome
// is a word that reads the same forwards as it does backwards.
Palindromes.isPalindrome(x: String): Bool
String.eql(x, String.reverse(x))
Palindromes.filterPalindromes(xs: List(String)): List(String)
List.filter<>(Palindromes.isPalindrome, xs)
// main is a demo app that prints the palindromes in the words list.
Palindromes.main: IO(Unit)
package main
import (
"log"
"net/http"
"github.com/gorilla/mux"
)
func main() {
#!/bin/bash
# Kill tsc when this script exits.
trap 'kill $(jobs -p)' EXIT
./node_modules/.bin/tsc --watch &
go run server.go