Skip to content

Instantly share code, notes, and snippets.

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@smreed
smreed / nsqadmin-service.json
Last active August 29, 2015 14:10 — forked from bketelsen/nsqadmin-service.json
This gist represents all the manifests you'll need to run a redundant and fault-tolerant NSQ cluster on Kubernetes. NSQ Admin's http interface is available on port 14171 on any node. There's an issue with NSQ Admin if you're running more than one lookupd service, so I recommend running just one lookupd until I figure it out.
{
"id": "nsqadmin-http",
"kind": "Service",
"apiVersion": "v1beta1",
"containerPort": 4171,
"port": 14171,
"protocol": "TCP",
"selector": { "name": "nsqadmin" },
"createExternalLoadBalancer": true
}
@bketelsen
bketelsen / nsqadmin-service.json
Last active March 20, 2024 07:10
This gist represents all the manifests you'll need to run a redundant and fault-tolerant NSQ cluster on Kubernetes. NSQ Admin's http interface is available on port 14171 on any node. There's an issue with NSQ Admin if you're running more than one lookupd service, so I recommend running just one lookupd until I figure it out.
{
"id": "nsqadmin-http",
"kind": "Service",
"apiVersion": "v1beta1",
"port": 14171,
"protocol": "TCP",
"selector": { "name": "nsqadmin" }
}
@dlancea
dlancea / config.fish
Last active December 18, 2015 19:56 — forked from schaary/ssh_agent_start.fish
Setup fish shell to auto-start ssh_agent
# Goes in ~/.config/fish/config.fish
# Start SSH agent
setenv SSH_ENV $HOME/.ssh/environment
start_agent
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active June 28, 2024 10:38
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@athieriot
athieriot / gist:5532748
Last active June 19, 2021 13:32
Hipchat with IRSSI

If you are adventurous, here the process to have Hipchat working in your favourite IRC client:

@solso
solso / autossh.sh
Created July 26, 2012 13:56
Support material for blog post of redis replication
#!/bin/sh
## --- tunnel_to_master_redis
REDIS_MASTER=XYZ
REDIS_SLAVE_PORT=6280
AUTOSSH_POLL=300
AUTOSSH_PORT=20000
AUTOSSH_GATETIME=10
AUTOSSH_LOGFILE=/var/log/autossh/autossh.log
PATH="$HOME/local/bin:/opt/local/bin:/usr/bin:/sbin:/bin"
LD_LIBRARY_PATH="/opt/local/lib:/usr/local/lib:/usr/lib"
for i in $HOME/local/*; do
[ -d $i/bin ] && PATH="${i}/bin:${PATH}"
[ -d $i/sbin ] && PATH="${i}/sbin:${PATH}"
[ -d $i/include ] && CPATH="${i}/include:${CPATH}"
[ -d $i/lib ] && LD_LIBRARY_PATH="${i}/lib:${LD_LIBRARY_PATH}"
[ -d $i/lib/pkgconfig ] && PKG_CONFIG_PATH="${i}/lib/pkgconfig:${PKG_CONFIG_PATH}"
[ -d $i/share/man ] && MANPATH="${i}/share/man:${MANPATH}"
done
IMPORTANT: this is outdated, go to https://github.com/netroy/Lockets
"npm install socket-io" & you are ready to go
From b327a8bf72a96ddeb7d777be9169c56a2cdb3c94 Mon Sep 17 00:00:00 2001
From: Ryan Dahl <ry@tinyclouds.org>
Date: Fri, 25 Feb 2011 18:52:07 -0800
Subject: [PATCH] turn off strictaliasing for v8
---
wscript | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/wscript b/wscript