Skip to content

Instantly share code, notes, and snippets.

Avatar

Sebastian Nyberg sebnyberg

View GitHub Profile
View archive_1.sh
#!/usr/bin/env bash
#
# Make a backup and remove files
#
# Usage:
#
# ./archive $path $backup_path
#
@sebnyberg
sebnyberg / .bashrc
Last active Oct 19, 2020
Basic .bashrc
View .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
## Bash settings
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
View Dockerfile
FROM golang:1.15 as protobuilder
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get -y install --no-install-recommends \
curl \
unzip \
gcc \
g++ \
@sebnyberg
sebnyberg / ingress.yaml
Created Sep 15, 2020
Example ingress protected with AD
View ingress.yaml
# Source: airflow/templates/webserver/webserver-ingress.yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: someapp
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/auth-signin: "https://$host/oauth2/start?rd=$escaped_request_uri"
nginx.ingress.kubernetes.io/auth-url: "https://$host/oauth2/auth"
@sebnyberg
sebnyberg / ingress.yaml
Last active Sep 15, 2020
Example ingress protected with AD
View ingress.yaml
# Source: airflow/templates/webserver/webserver-ingress.yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: someapp
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/auth-signin: "https://$host/oauth2/start?rd=$escaped_request_uri"
nginx.ingress.kubernetes.io/auth-url: "https://$host/oauth2/auth"
@sebnyberg
sebnyberg / release.sh
Created Sep 14, 2020
Fluxctl release script
View release.sh
#!/bin/bash
#
# release.sh: wait for an image to become available before issuing a flux release
#
set -o errexit
set -o xtrace
# complain to STDERR and exit with error
die() { echo "$*" >&2; exit 2; }
@sebnyberg
sebnyberg / .bashrc
Last active Sep 13, 2020
BashRC snippet for printing kubectl config info
View .bashrc
color_red="\033[0;31m"
color_yellow="\033[0;33m"
color_green="\033[0;32m"
color_ochre="\033[38;5;95m"
color_blue="\033[0;34m"
color_white="\033[0;37m"
color_reset="\033[0m"
kube_info() {
local current_context=$(kubectl config current-context)
View placeholders.go
package placeholders
import (
"fmt"
"strings"
)
func Original(columns []string) string {
questionMarks := []string{}
for _, _ = range columns {
@sebnyberg
sebnyberg / helmfile.yaml
Last active Jun 1, 2020
oauth2-proxy example
View helmfile.yaml
repositories:
- name: stable
url: https://kubernetes-charts.storage.googleapis.com
releases:
- name: {{ requiredEnv "SERVICE_NAME" }}-oauth2-proxy
namespace: {{ requiredEnv "NAMESPACE" }}
cleanupOnFail: true
chart: stable/oauth2-proxy
# kubeContext: somecontext
@sebnyberg
sebnyberg / go_cpu_memory_profiling_benchmarks.sh
Last active May 27, 2020 — forked from arsham/go_cpu_memory_profiling_benchmarks.sh
Go cpu and memory profiling benchmarks. #golang #benchmark
View go_cpu_memory_profiling_benchmarks.sh
FILENAME=$(basename $(pwd))
go test -run=. -bench=. -cpuprofile=cpu.out -benchmem -memprofile=mem.out -trace trace.out
go tool pprof -pdf $FILENAME.test cpu.out > cpu.pdf && open cpu.pdf
go tool pprof -pdf --alloc_space $FILENAME.test mem.out > alloc_space.pdf && open alloc_space.pdf
go tool pprof -pdf --alloc_objects $FILENAME.test mem.out > alloc_objects.pdf && open alloc_objects.pdf
go tool pprof -pdf --inuse_space $FILENAME.test mem.out > inuse_space.pdf && open inuse_space.pdf
go tool pprof -pdf --inuse_objects $FILENAME.test mem.out > inuse_objects.pdf && open inuse_objects.pdf
go tool trace trace.out
go-torch $FILENAME.test cpu.out -f ${FILENAME}_cpu.svg && open ${FILENAME}_cpu.svg