Skip to content

Instantly share code, notes, and snippets.

View alex-leonhardt's full-sized avatar
❄️

Alex Leonhardt alex-leonhardt

❄️
View GitHub Profile
@alex-leonhardt
alex-leonhardt / bitshifty.go
Last active April 9, 2020 12:07
bit shifty things
package main
import (
"fmt"
"math"
)
func main() {
v := 1 << 40
@alex-leonhardt
alex-leonhardt / foldingathome.yaml
Created March 23, 2020 23:30
folding at home deployment
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: folding-at-home
name: folding-at-home
spec:
replicas: 8
selector:
@alex-leonhardt
alex-leonhardt / inventory.py
Created January 12, 2020 15:01
libvirt kvm ansible dynamic inventory script
#! /usr/bin/python
import re
import sys
import subprocess as sub
import json
res = sub.Popen(["virsh", "net-dhcp-leases", "default"], stdout=sub.PIPE)
output, err = res.communicate()
@alex-leonhardt
alex-leonhardt / main.go
Created December 12, 2019 16:21
timeout with golang using context.WithTimeout()
package main
import (
"context"
"fmt"
"time"
)
func f(ctx context.Context) {
fmt.Println(time.Now().UTC())
@alex-leonhardt
alex-leonhardt / main.go
Last active November 27, 2019 06:43
concurrently run a command using waitGroups and channels
package main
import (
"fmt"
"math/rand"
"os/exec"
"sync"
"time"
)
@alex-leonhardt
alex-leonhardt / main.go
Created July 27, 2019 15:26
basic https web server in go
package main
import (
"fmt"
"html"
"io/ioutil"
"log"
"net/http"
"time"
@alex-leonhardt
alex-leonhardt / ssl.sh
Created July 27, 2019 14:42
Create signed SSL cert with K8S CA
#! /bin/sh
set -o errexit
export APP="${1:-mutateme}"
export NAMESPACE="${2:-default}"
export CSR_NAME="${APP}.${NAMESPACE}.svc"
echo "... creating ${app}.key"
openssl genrsa -out ${APP}.key 2048
@alex-leonhardt
alex-leonhardt / golang_pipe_http_response.go
Created October 20, 2018 13:03 — forked from ifels/golang_pipe_http_response.go
golang pipe the http response
package main
import (
"io"
"net/http"
"os/exec"
)
var (
BUF_LEN = 1024
func renderFile(d *schema.ResourceData) (string, error) {
var err error
tf := template.FuncMap{
"isInt": func(i interface{}) bool {
v := reflect.ValueOf(i)
switch v.Kind() {
case reflect.Int, reflect.Int8, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64:
return true
@alex-leonhardt
alex-leonhardt / main.go
Last active March 9, 2024 04:23
golang text/template with a map[string]interface{} populated from mixed json data
package main
import (
"encoding/json"
"os"
"reflect"
"text/template"
)