Skip to content

Instantly share code, notes, and snippets.

@tyzbit
tyzbit / ginjson.go
Last active May 3, 2022 23:58
Gin JSON Formatter
func GinJSONFormatter(param gin.LogFormatterParams) string {
jsonFormat := `{"time":"%s","clientip":"%s","method":"%s","uri":"%s","status":%3d,"latency":"%v","message":"%s","host":"%s","useragent":"%s","proto":"%s","error_msg":"%s","size":%d}` + "\n"
return fmt.Sprintf(jsonFormat,
param.TimeStamp.Format(TimeFormatter),
param.ClientIP,
param.Method,
param.Request.RequestURI,
param.StatusCode,
param.Latency,
fmt.Sprintf("%s %s %s", param.Method, param.Request.URL, param.Request.Proto),
@tyzbit
tyzbit / tylertios_hot_sauces.md
Last active April 17, 2022 16:49
Tylertio's Hot Sauce Reviews

Tylertio's Hot Sauce Reviews


Hot sauces I like and would buy again


Iris Lune | Eclipse Hot Sauce ⭐️⭐️⭐️⭐️⭐️

Brooklyn alt-pop band Iris Lune (featuring HEATONIST's own Aaron Liao) teamed up with the Ontario hot sauce gurus at Dawson’s Hot Sauce for this peachy concoction. The heavier consistency and perfect blend of sweetness and mild heat make Eclipse great with salads, eggs, fried chicken, and even cheesecake. Enjoy while grooving out to Iris Lune’s equally spicy and flavorful music here: www.irislune.com

Ingredients: Peach, yellow pepper, vinegar, extra virgin, olive oil, garlic, sugar, Vietnamese red chili, salt.

@tyzbit
tyzbit / output
Created February 25, 2022 20:50
fio output
$ sudo fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=fiotest --filename=testfio --bs=4k --iodepth=64 --size=8G --readwrite=randrw --rwmixread=75
fiotest: (g=0): rw=randrw, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=64
fio-3.16
Starting 1 process
fiotest: Laying out IO file (1 file / 8192MiB)
Jobs: 1 (f=1): [m(1)][100.0%][r=511MiB/s,w=170MiB/s][r=131k,w=43.4k IOPS][eta 00m:00s]
fiotest: (groupid=0, jobs=1): err= 0: pid=2634098: Fri Feb 25 20:47:34 2022
read: IOPS=130k, BW=510MiB/s (534MB/s)(6141MiB/12049msec)
bw ( KiB/s): min=465664, max=565208, per=99.99%, avg=521844.38, stdev=27636.21, samples=24
iops : min=116416, max=141302, avg=130461.08, stdev=6909.07, samples=24
@tyzbit
tyzbit / helmrelease.yml
Created February 15, 2022 20:29
Longhorn RecurringJobs HelmRelease
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: longhorn-recurring-jobs
namespace: flux-system
spec:
targetNamespace: longhorn-system
releaseName: longhorn-recurring-jobs
chart:
spec:
@tyzbit
tyzbit / recurringjobs.yml
Last active August 11, 2023 13:20
Longhorn RecurringJobs
## The purpose of snapshots and backups are to be able to restore data to the last known good state
## either due to full data loss or corruption/unwanted data change
## Data properties:
## - Can change slowly or quickly.
## If the data changes quickly, we must snapshot/backup more frequently. We must also retain more.
## If the data changes slowly, we can snapshot less frequently
## - Is low priority or high priority.
## Low priority means we don't need offsite backups
## Medium priority means we need an offsite backup
## High priority means we need multiple historical offsite backups
@tyzbit
tyzbit / .zshrc
Created November 10, 2021 18:02
Kubernetes TCP proxy
function kubeproxy() {
setopt local_traps
pod_name="socat-$(whoami)"
if [[ "${2}x" == "x" ]]; then
echo "Usage: kubeproxy [Hostname] [Port]"
return 0
fi
if kubectl run --restart=Never --image=alpine/socat $pod_name -- -d -d tcp-listen:$2,fork,reuseaddr tcp-connect:$1:$2; then
while [[ $(kubectl get pod $pod_name -o json | jq -r '.status.phase') != "Running" ]]; do
sleep 0.1
@tyzbit
tyzbit / query.md
Last active October 21, 2021 13:52
New Relic Days until k8s Volume is full (reaches 99%)
FROM K8sVolumeSample 
SELECT min(fsAvailableBytes / 1024 / 1024 / 1024) as 'GiB Free',
       clamp_min(
         (100 - 1 - stddev(fsUsedPercent) - max(fsUsedPercent))
           /
         clamp_min(
           deriv(fsUsedPercent, 1 days)
         ,0.00000313)
 ,0) as 'Days until full'
192.168.206.67 - - [28/Sep/2021:06:50:10 +0000] "GET /v1 HTTP/1.1" 200 3871 "" "Go-http-client/1.1"
192.168.206.67 - - [28/Sep/2021:06:50:10 +0000] "GET /v1 HTTP/1.1" 200 3871 "" "Go-http-client/1.1"
192.168.206.67 - - [28/Sep/2021:06:50:10 +0000] "GET /v1 HTTP/1.1" 200 3871 "" "Go-http-client/1.1"
192.168.206.67 - - [28/Sep/2021:06:50:10 +0000] "GET /v1 HTTP/1.1" 200 3871 "" "Go-http-client/1.1"
192.168.206.67 - - [28/Sep/2021:06:50:10 +0000] "GET /v1 HTTP/1.1" 200 3871 "" "Go-http-client/1.1"
fatal error: concurrent map writes
/usr/local/go/src/runtime/panic.go:1114 +0x72 fp=0xc001edd760 sp=0xc001edd730 pc=0x4348e2
runtime.throw(0x1b8963e, 0x15)
goroutine 1151041 [running]:
@tyzbit
tyzbit / configuration.yaml
Created August 2, 2021 20:23
Home Assistant KP115 config
tplink:
discovery: false
switch:
- host: 192.168.1.10
- host: 192.168.1.11
- host: 192.168.1.12
- host: 192.168.1.13
sensor:
- platform: template

|Timestamp |Container Name |Host |Pod Name |Message