Skip to content

Instantly share code, notes, and snippets.

tanelmae / k3ctx
Last active Nov 1, 2019
BASH function for managing k3d cluster contexts
View k3ctx
k3ctx() {
local CLUSTER_NAME=${1}
# Show the current context/namespace
local CTX=$(kubectl config current-context)
local NS=$(kubectl config view -o jsonpath="{.contexts[?('$CTX')].context.namespace}")
if [[ -z $NS ]]; then
echo "Current ctx/ns: $CTX/$NS"
superseb /
Last active Oct 20, 2020
Generate Rancher 2 cluster/node agent definitions

Generate Rancher 2 cluster/node agents definitions

This is not official documentation/tooling, use with caution

This generate the Kubernetes definitions of the cattle-cluster-agent Deployment and cattle-node-agent DaemonSet, in case it's accidentally removed/server-url was changed/certficates were changed. It is supposed to run on every cluster Rancher manages. If you have custom clusters created in Rancher, see Kubeconfig for Custom clusters created in Rancher how to obtain the kubeconfig to directly talk to the Kubernetes API (as usually it doesn't work via Rancher anymore). For other clusters, use the tools provided by the provider to get the kubeconfig.

IMPORTANT: You get the cluster/node agents definitions from Rancher, and you apply them to the cluster that is created/managed so you need to switch kubeconfig to point to that cluster before applying them.

Running it

jgreat /
Last active Oct 10, 2020
Rancher 2.0 Terraform AWS example.

Set up a 3 node HA rancher cluster.

This will create and prep nodes for RKE. This uses the default vpc and subnets.

We create:

  • SSH Key Pair
  • Security Groups
  • 3 Instances
  • ELB for 80/443 points to the 3 instances.
superseb /
Last active Oct 23, 2020
Cleanup host added as custom to Rancher 2.0
docker rm -f $(docker ps -qa)
docker volume rm $(docker volume ls -q)
cleanupdirs="/var/lib/etcd /etc/kubernetes /etc/cni /opt/cni /var/lib/cni /var/run/calico /opt/rke"
for dir in $cleanupdirs; do
echo "Removing $dir"
rm -rf $dir
shivakar / tls-server-in-memory-cert.go
Created Dec 12, 2015
TLS server with in-memory self-signed certificate
View tls-server-in-memory-cert.go
package main
import (
lolzballs /
Created Mar 22, 2015
Hello World Enterprise Edition
public class HelloWorld{
private static HelloWorld instance;
public static void main(String[] args){
carlo / google-img-resize.mdown
Last active Oct 14, 2020
Google’s authentication-less on-the-fly image resizing service
View google-img-resize.mdown

Google's authentication-less on-the-fly image resizing service

I found it while poking around the Google+ HTML. Jotting down some notes felt like a good idea, so here goes. If you know more about this API, let me know, please!

(Word of warning: I spent ~30 minutes on both my experimentation and this here write-up, so it might not be the most thought-provoking, brilliant thing you read today.)

orenitamar / country_codes.json
Created Jul 30, 2012
Two letter country code mapping, grouped by continent/region
View country_codes.json
"europe": {
"va": "vatican city",
"ch": "switzerland",
"ad": "andorra",
"ee": "estonia",
"is": "iceland",
"am": "armenia",
"al": "albania",
"cz": "czech republic",
esperlu /
Created Apr 27, 2011
MySQL to Sqlite converter
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
You can’t perform that action at this time.