Skip to content

Instantly share code, notes, and snippets.

View dln's full-sized avatar
🚀

Daniel Lundin dln

🚀
View GitHub Profile
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:
@dln
dln / _ssh_config
Created March 12, 2024 16:43
_config_systemd_user_opener@.service
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 <dln@arity.se>
#
# 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
@dln
dln / test-csv-with-header.py
Last active August 25, 2022 10:07
csv processing with duckdb and arrow
#!/usr/bin/env python
import duckdb
import pyarrow as pa
import pyarrow.csv as csv
# curl -L https://www.stats.govt.nz/assets/Uploads/Annual-enterprise-survey/Annual-enterprise-survey-2021-financial-year-provisional/Download-data/annual-enterprise-survey-2021-financial-year-provisional-csv.csv | gzip > /tmp/test-header.csv.gz
data = csv.read_csv('/tmp/test-header.csv.gz')
con = duckdb.connect()