Skip to content

Instantly share code, notes, and snippets.

View johananl's full-sized avatar

Johanan Liebermann johananl

View GitHub Profile
@johananl
johananl / README.md
Created February 21, 2024 13:26
Linux CPU monitoring

Linux CPU monitoring

watch -n 0.5 "cat /proc/cpuinfo | grep MHz && echo && sensors"
watch cat /sys/devices/system/cpu/cpu{0..7}/cpufreq/cpuinfo_max_freq
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
watch -n 0.5 sudo tlp-stat -p
@johananl
johananl / script.sh
Created February 17, 2023 10:14
Build Flatcar CAPI images (OVA) for vSphere
# Generate a Packer var file
cat <<EOF > packer-ova.json
{
"vcenter_server":"vcenter.example.com",
"username":"me",
"password":"mypass",
"datacenter": "DC",
"datastore":"Datastore",
"folder": "foo",
"cluster": "10.1.2.3",
@johananl
johananl / fix-dns.sh
Created June 27, 2022 07:43
Set WSL DNS to Windows host
#!/bin/bash
set -x
set -eou pipefail
gw=$(ip route | grep default | awk {'print $3'})
echo Fixing DNS
chattr -i /etc/resolv.conf
@johananl
johananl / alacritty.yml
Created May 4, 2022 15:37
Solarized Dark color scheme for Alacritty
# Colors (Solarized Dark)
colors:
# Default colors
primary:
background: '#002b36' # base03
foreground: '#839496' # base0
# Cursor colors
cursor:
text: '#002b36' # base03
@johananl
johananl / main.go
Created March 28, 2022 19:09
A good retry loop in Go
const maxAttempts = 10
const retryIntervalSeconds = 5
var sshConnected bool
log.Printf("Connecting to VM using SSH")
for i := 0; i < maxAttempts; i++ {
if i > 0 {
time.Sleep(time.Second * retryIntervalSeconds)
@johananl
johananl / launch.json
Last active December 6, 2021 15:32
Debugging Go unit tests with Delve in VS Code
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch test function",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${workspaceFolder}/bootstrap/kubeadm/internal/controllers",
"args": [
@johananl
johananl / README.md
Last active November 17, 2021 12:03
Manipulating Google Calendar events using Python
@johananl
johananl / README.md
Last active September 9, 2021 15:47
Get kubeconfig access to CAPI e2e kind cluster
export container_name=$(docker ps --format '{{.Names}}' | grep test-.\*-control-plane)
export host_port=$(docker inspect $container_name -f '{{(index (index .NetworkSettings.Ports "6443/tcp") 0).HostPort}}')
docker exec $container_name cat /etc/kubernetes/admin.conf | sed "s/server: https:\/\/${container_name}:6443/server: https:\/\/localhost:${host_port}/" > /tmp/kubeconfig
export KUBECONFIG=/tmp/kubeconfig
kubectl get pods -A
@johananl
johananl / README.md
Last active May 4, 2021 10:02
A dummy HTTPS server which generates a self-signed TLS certificate for itself

A simple Go HTTPS server

I often need a local HTTPS server which simply responds with a self-signed certificate. This server does just that in pure Go, without additional dependencies and without having to worry about generating the certificate (no more googling openssl commands...).

Usage

go run main.go
@johananl
johananl / kuard.yaml
Last active January 5, 2021 14:38
kuard sample k8s app
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: kuard
labels:
app: kuard
spec:
replicas: 1
selector: