Skip to content

Instantly share code, notes, and snippets.

@dvasilen
dvasilen / setupadmissionwebhook.md
Created October 20, 2023 17:52 — forked from tirumaraiselvan/setupadmissionwebhook.md
Setup admission webhooks in Kubernetes
@dvasilen
dvasilen / basicfw.sh
Created December 21, 2021 14:38 — forked from spuzirev/basicfw.sh
#!/bin/bash
$IPT=/sbin/iptables
#################
# GENERIC INPUT #
#################
$IPT --policy INPUT DROP
# Drop invalid
@dvasilen
dvasilen / ipint.go
Created September 12, 2021 14:09 — forked from ammario/ipint.go
Golang ip <-> int conversion
func ip2int(ip net.IP) uint32 {
if len(ip) == 16 {
return binary.BigEndian.Uint32(ip[12:16])
}
return binary.BigEndian.Uint32(ip)
}
func int2ip(nn uint32) net.IP {
ip := make(net.IP, 4)
binary.BigEndian.PutUint32(ip, nn)
@dvasilen
dvasilen / dynamic_crds.go
Created July 30, 2020 18:51 — forked from tallclair/dynamic_crds.go
Example of using CRDs with the dynamic go client
package main
import (
"fmt"
"log"
"os/user"
"path/filepath"
"strings"
apixv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
@dvasilen
dvasilen / k8s-update-secret.md
Created July 7, 2020 20:25 — forked from dleske/k8s-update-secret.md
k8s: Updating a Secret

Hopefully helped another k8s newbie with the following. The question was, how do you update a single key in a secret in k8s? I don't know anything about secrets but I will probably want to know this in the future, so here we go.

First, to create a dummy secret:

apiVersion: v1
kind: Secret
metadata:
  name: test-secret
data:
@dvasilen
dvasilen / gzip.go
Created July 3, 2019 19:06 — forked from bryfry/gzip.go
Idiomatic golang net/http gzip transparent compression (works with Alice)
package main
import (
"compress/gzip"
"io"
"net/http"
"strings"
)
// Gzip Compression
@dvasilen
dvasilen / timeout_and_tick.go
Created November 15, 2017 13:39 — forked from ngauthier/timeout_and_tick.go
Golang timeout and tick loop
// keepDoingSomething will keep trying to doSomething() until either
// we get a result from doSomething() or the timeout expires
func keepDoingSomething() (bool, error) {
timeout := time.After(5 * time.Second)
tick := time.Tick(500 * time.Millisecond)
// Keep trying until we're timed out or got a result or got an error
for {
select {
// Got a timeout! fail with a timeout error
case <-timeout:
@dvasilen
dvasilen / watchPods.go
Created November 11, 2017 20:06 — forked from ctaggart/watchPods.go
Kubernetes watch pods
// some updates for https://rsmitty.github.io/Kubernetes-Events/
// and http://blog.ctaggart.com/2016/09/accessing-kubernetes-api-on-google.html
import (
"encoding/base64"
"fmt"
"log"
"net/http"
"time"
@dvasilen
dvasilen / aes.go
Created November 10, 2017 00:43 — forked from willshiao/aes.go
AES 256-CFB in Node.js and Golang
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"fmt"
"io"
@dvasilen
dvasilen / gist:385eb887d6234fd85b2d876cfee247e3
Created July 13, 2017 17:17 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*