Skip to content

Instantly share code, notes, and snippets.

@niels-s
niels-s / update_kubeconfig.sh
Last active January 21, 2021 16:53
Script to parse the Lokomotive cluster kubeconfig from in the assets directory and add it to your local global kubeconfig file
#!/bin/bash
# update_kubeconfig.sh takes the admin credentials of a Lokomotive cluster assets directory and adds it to your local
# kubeconfig file
set -e
if ! command -v yaml2json >/dev/null; then
echo >&2 "Run 'go get -u github.com/bronze1man/yaml2json' to install yaml2json"
exit 1
@niels-s
niels-s / Cloudflare.dashboard.jsonnet
Created June 28, 2020 15:42
Example Grafonnet dashboard for Cloudflare Exporter metrics by https://github.com/wehkamp/docker-prometheus-cloudflare-exporter
local basic = import 'basic.libsonnet';
local grafana = import 'grafonnet/grafana.libsonnet';
local template = grafana.template;
local pieChartPanel = grafana.pieChartPanel;
local layout = import 'layout.libsonnet';
local promQuery = import 'prom_query.libsonnet';
basic.dashboard(
'Cloudflare PoP statistics',
'A9497F55-AE98-4EC5-819D-D41243D8C9E3',
@niels-s
niels-s / example.dashboard.jsonnet
Last active September 14, 2022 15:13
An example Grafana dashboard defined in Grafonnet with alerts
local grafana = import 'grafonnet/grafana.libsonnet';
local influxdb = grafana.influxdb;
local graphPanel = grafana.graphPanel;
local alertCondition = grafana.alertCondition;
local dashboard = grafana.dashboard;
local warning_threshold = 644245094400;
local db_instances = [
'db-1',
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: redis
spec:
serviceName: "redis"
replicas: 1
template:
metadata:
@niels-s
niels-s / queue.go
Last active December 1, 2016 10:28
Example of partitioning message over internal channels in golang
package main
import (
"fmt"
"hash/fnv"
"strconv"
"sync"
"time"
)
package main
import (
"log"
"os"
"time"
"github.com/Shopify/sarama"
)
@niels-s
niels-s / main.go
Created September 15, 2016 12:07
Demonstrate use of defer in golang with kill sig
package main
import (
"log"
"os"
"os/signal"
"sync"
"time"
)
@niels-s
niels-s / main.go
Created March 8, 2016 09:59
Time thing in golang
package main
import (
"fmt"
"time"
)
var utc *time.Location
func main() {
require "net/http"
require "socket"
sock = Net::BufferedIO.new(UNIXSocket.new("path_to_socket/tmp/unicorn.sock"))
request = Net::HTTP::Get.new("/time")
request.exec(sock, "1.1", "/time")
begin
response = Net::HTTPResponse.read_new(sock)
end while response.kind_of?(Net::HTTPContinue)

Keybase proof

I hereby claim:

  • I am niels-s on github.
  • I am stvnsn (https://keybase.io/stvnsn) on keybase.
  • I have a public key whose fingerprint is 6C43 9A21 9658 27DF D0DE 216A 3C6F 2764 B5D6 998B

To claim this, I am signing this object: