Skip to content

Instantly share code, notes, and snippets.

View dln's full-sized avatar
🚀

Daniel Lundin dln

🚀
View GitHub Profile
@dln
dln / configuration.nix
Created June 16, 2024 19:20
dev container for systemd-nspawn
{ pkgs, modulesPath, ... }:
{
imports = [
(modulesPath + "/profiles/minimal.nix")
./nspawn-image.nix
];
boot.isContainer = true;
networking.hostName = "nixos";
curl https://github.com/cert-manager/cert-manager/releases/download/v1.14.5/cert-manager.yaml |
  cue import - -p kube -l '"_cert-manager"' -l 'strings.ToCamel(kind)' -l metadata.name -f
@dln
dln / .envrc
Last active April 30, 2024 18:21
Minimal example of using nix flake as "devshell" with direnv for a portable environment of various handy tools
if has nix; then
use flake
fi
@dln
dln / opentelemetry-collector.yaml
Created March 26, 2024 13:45
otel collector with prometheus remote write example
extensions:
zpages:
endpoint: 0.0.0.0:8080
receivers:
hostmetrics:
collection_interval: 3s
scrapers:
cpu:
load:
Host dln-dev
RemoteForward ${XDG_RUNTIME_DIR}/opener.sock ${XDG_RUNTIME_DIR}/opener.dln-dev.sock
@dln
dln / uuid.go
Last active February 18, 2023 14:30
UUID with extra encodings
package uuid
import (
"bytes"
"encoding/base64"
"strings"
"github.com/gofrs/uuid/v5"
)
// Proquints: Identifiers that are Readable, Spellable, and Pronounceable
// https://arxiv.org/html/0901.4016
package main
import (
"bytes"
"fmt"
"regexp"
"strings"
@dln
dln / _fail.sh
Last active February 7, 2023 13:32
% buf generate
google/protobuf/timestamp.proto:136:9:symbol "google.protobuf.Timestamp" already defined at timestamp.proto:136:9
google/protobuf/timestamp.proto:140:9:symbol "google.protobuf.Timestamp.seconds" already defined at timestamp.proto:140:9
google/protobuf/timestamp.proto:146:9:symbol "google.protobuf.Timestamp.nanos" already defined at timestamp.proto:146:9
@dln
dln / slog.go
Created November 18, 2022 11:25
structured logging in golang
package main
import (
"errors"
"os"
"golang.org/x/exp/slog"
)
func main() {
@dln
dln / pw
Last active August 31, 2022 08:58
A convenience script for using secrets on the commandline using keyctl as keyring
#!/bin/bash
#
# Author: Daniel Lundin <[email protected]>
#
# Convenience script to hide sensitive variables on the command line.
# Uses keyctl to store secrets in the keyring.
#
# Example usage: mycommand --user=foo --password=$(pw mypass)
set -eo pipefail