Skip to content

Instantly share code, notes, and snippets.

@miekg
miekg / gitconfig
Created December 4, 2023 16:09
git config
# Fetch a mr/pr number from the hub and check it out in either mr-<num> or pr-<num> branch
pr = "!f() { \
case $(git hubtype) in \
github) git githubpr;; \
gitlab) git gitlabpr;; \
esac; \
}; f"
gitlabpr = "!f() { pr=$(basename $1); git fetch origin pull/$pr/head:pr-$pr && git checkout pr-$pr; }; f"
githubpr = "!f() { mr=$(basename $1); git fetch origin merge-requests/$mr/head:mr-$mr && git checkout mr-$mr; }; f"
hubtype = "!f() { case $(git remote get-url origin) in *github*) echo github;; *gitlab*) echo gitlab;; esac; }; f"
@miekg
miekg / replace2.go
Created November 14, 2023 16:39
replace BBCode [color=#xxxxx] with terminal equivalent
package main
import (
"bytes"
"flag"
"fmt"
"log"
"os"
"os/exec"
"strconv"
@miekg
miekg / gallery.html
Created September 6, 2023 18:48
hugo shortcode to have a gallery
# check current service
% ./gitopperctl list service @localhost grafana-server
SERVICE HASH STATE INFO SINCE
grafana-server 606eb576c1b91248e4c1c4cd0d720f27ac0deb70 OK 0001-01-01 00:00:00 +0000 UTC
# oh no, we need to rollback
% ./gitopperctl state rollback @localhost grafana-server 8df1b3db679253ba501d594de285cc3e9ed308ed
# check
package dns
import (
"fmt"
"net"
"testing"
)
// Test function to test how the API feels.
func TestDNS(t *testing.T) {
package main
import (
"fmt"
"log"
"os"
"github.com/miekg/dns"
)
@miekg
miekg / coredns.md
Created March 25, 2021 09:50
coredns overlay plugin

Corefile is:

example.com {
    file db.example.com
    debug
    lboverlay example.com
    forward . 8.8.8.8
}

Simplify Grafana

Goal: a minimal grafana that is 100% provisioned via files. There is no U/I to add dashoards on the fly.

  • A (go?) package, contains structs that define the dasbhoards, either see what grafana has or cleanup: https://github.com/grafana-tools/sdk
  • Dashboard are put in folders and may have tags
  • Dashboards are defined in (minimal) YAML
  • Everything is defined on a per-dashboard basis - consistency is put in the generate dashboard layer.
@miekg
miekg / gist:993dcbde700dc3a9844e7e783f189059
Created August 3, 2019 09:05
Force resigning with CoreDNS
# Force resigning
$ rm /var/lib/coredns/db.miek.nl.signed
[ERROR] plugin/file: Failed to open zone "miek.nl." in "/var/lib/coredns/db.miek.nl.signed": open /var/lib/coredns/db.miek.nl.signed: no such file or directory
$ kill -SIGUSR1 $(pidof coredns)
[INFO] SIGUSR1: Reloading
[INFO] Reloading
@miekg
miekg / 7511.xml
Created November 24, 2018 08:14
RFC 7511 in XML format
<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.nl" -->
<rfc version="3" ipr="trust200902" submissionType="IETF" category="info" xml:lang="en" consensus="true" xmlns:xi="http://www.w3.org/2001/XInclude" number="7511">
<front>
<title abbrev="Scenic Routing for IPv6">Scenic Routing for IPv6</title><seriesInfo value="7511" stream="IETF" status="informational" name="RFC"></seriesInfo>
<author initials="M." surname="Wilhelm" fullname="Maximilian Wilhelm"><organization></organization><address><postal><street></street>
<city>Paderborn, NRW</city>
<country>Germany</country>
</postal><phone>+49 176 62 05 94 27</phone>