Container Tools
Helper Commands
Preparation
Create a bin folder
mkdir -p bin
type ValidationInterceptor struct { | |
router http.Handler | |
val routers.Router | |
} | |
func (s *ValidationInterceptor) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
route, pathParams, err := s.val.FindRoute(r) | |
if err != nil { | |
log.Printf("no route: %v", err) | |
w.WriteHeader(http.StatusNotFound) |
package main | |
import ( | |
"bufio" | |
"bytes" | |
"context" | |
"errors" | |
"fmt" | |
"io" | |
"log" |
#!/usr/bin/env bash | |
set -euo pipefail | |
# ./helmdump.sh [target-chart] [output-dir] [namespace] | |
# $1: the target char | |
# $2: the output directory, must be a relative path | |
# $3: optional namespace, if not provided the current namespace is used | |
targetChart="$1" |
#!/usr/bin/env sh | |
set -e | |
# install build tools | |
# | |
apt-get -y update | |
apt-get -y --no-install-recommends install autoconf make | |
# get & compile raft |
Create a bin folder
mkdir -p bin
# check if running in a container in kubernetes or docker | |
is_container = ( | |
path.exists("/var/run/secrets/kubernetes.io/serviceaccount/namespace") | |
or path.exists("/.dockerenv") | |
or ( | |
path.isfile("/proc/self/cgroup") | |
and ( | |
any("kubepods" in line for line in open("/proc/self/cgroup")) | |
or any("docker" in line for line in open("/proc/self/cgroup")) | |
) |
import ( | |
"bufio" | |
"bytes" | |
"fmt" | |
"io" | |
"log" | |
"mime/multipart" | |
"net/http" | |
"net/http/httptest" | |
"net/textproto" |
--- | |
apiVersion: batch/v1 | |
kind: Job | |
metadata: | |
name: myjob | |
spec: | |
ttlSecondsAfterFinished: 10 | |
template: | |
spec: | |
containers: |
// taken from below url, which explains the why this function makes sense | |
// https://blog.stevenlevithan.com/archives/faster-than-innerhtml | |
function replaceHtml(el, html) { | |
var oldEl = typeof el === "string" ? document.getElementById(el) : el; | |
/*@cc_on // Pure innerHTML is slightly faster in IE | |
oldEl.innerHTML = html; | |
return oldEl; | |
@*/ | |
var newEl = oldEl.cloneNode(false); | |
newEl.innerHTML = html; |
export function computeNote( | |
// how far from the base note to go in either direction | |
distance = 0, | |
scale = { | |
// use this frequency as basis | |
// standard A4 is 440hz | |
base: 440.0, | |
// claim that its in the 4 repetition of made up sequence, | |
// on a normal piano it is saying this is A4 | |
position: 4, |