Skip to content

Instantly share code, notes, and snippets.

$IPT --policy INPUT DROP
# Drop invalid
dvasilen / ipint.go
Created Sep 12, 2021 — forked from ammario/ipint.go
Golang ip <-> int conversion
View ipint.go
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 / dynamic_crds.go
Created Jul 30, 2020 — forked from tallclair/dynamic_crds.go
Example of using CRDs with the dynamic go client
View dynamic_crds.go
package main
import (
apixv1beta1 ""

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
  name: test-secret
dvasilen / gzip.go
Created Jul 3, 2019 — forked from bryfry/gzip.go
Idiomatic golang net/http gzip transparent compression (works with Alice)
View gzip.go
package main
import (
// Gzip Compression
dvasilen / timeout_and_tick.go
Created Nov 15, 2017 — forked from ngauthier/timeout_and_tick.go
Golang timeout and tick loop
View timeout_and_tick.go
// 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 / watchPods.go
Created Nov 11, 2017 — forked from ctaggart/watchPods.go
Kubernetes watch pods
View watchPods.go
// some updates for
// and
import (
dvasilen / aes.go
Created Nov 10, 2017 — forked from willshiao/aes.go
AES 256-CFB in Node.js and Golang
View aes.go
package main
import (
View gist:385eb887d6234fd85b2d876cfee247e3
# first:
lsbom -f -l -s -pf /var/db/receipts/ | 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*
dvasilen / file0.txt
Created Jul 7, 2017 — forked from giwa/file0.txt
Install hive on Mac with Homebrew ref:
View file0.txt
$ brew update
$ brew install hive