Skip to content

Instantly share code, notes, and snippets.

@simonswine
simonswine / copy-k8s-resources-across-namespaces.sh
Created August 2, 2016 13:40
Copying kubernetes resources accross namespaces
kubectl get rs,secrets -o json --namespace old | jq '.items[].metadata.namespace = "new"' | kubectl create-f -
# Flocker go library examples
package main
import (
"encoding/json"
flockerApi "github.com/simonswine/flocker-go"
"log"
)
@simonswine
simonswine / slingshot-flocker.md
Last active July 19, 2016 10:40
Slingshot provisions kubernetes & flocker

Instructions

Create a flocker enabled cluster

slingshot cluster create \
  -f - \
  -I jetstack/slingshot-ip-terraform-aws-coreos:0.1 \
  -C jetstack/slingshot-cp-ansible-k8s-coreos:flocker-0.1 \
 christian-flocker <<EOF
@simonswine
simonswine / hello-world-hpa.yaml
Created April 21, 2016 16:04
Hello world HPA for kubernetes
---
kind: Service
apiVersion: v1
metadata:
name: hello-world-hpa
labels:
app: hello-world
spec:
type: NodePort
ports:
@simonswine
simonswine / .vimrc
Created December 1, 2015 12:37
Vim configuration
" Disable compatability
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Let Vundle manage Vundle
Plugin 'gmarik/vundle'
@simonswine
simonswine / main.go
Last active September 21, 2015 21:56
Go concurrency long and short task
package main
import (
log "github.com/Sirupsen/logrus"
"sync"
"time"
)
// work short is done right away
func workShort(id string) {
@simonswine
simonswine / stringcalc.rb
Last active August 26, 2015 19:57
StringCalc in ruby
class StringCalc
def self.calc(str)
# default regex to split
re_split = %r{[\n,]}
# regex for custom delimiter
m = str.match(%r{^//(.)})
re_split = %r{#{m[1]}} if m
# sum initial val
@simonswine
simonswine / drop all tables
Created November 8, 2014 12:02
Shell oneliner drop all tables from xx
mysql -e "SELECT concat('DROP TABLE IF EXISTS ', table_name, ';') FROM information_schema.tables WHERE table_schema = 'xx';" | tail -n +2 | mysql xx
@simonswine
simonswine / sync_keywords.rb
Last active August 29, 2015 14:06
Sync Keywords from Maildir to IMAP Server by comparing timstamps
require 'date'
require 'net/imap'
dictionary = {
'a' => 'Junk',
'b' => 'NonJunk',
'c' => '$label5',
'd' => '$label2',
'e' => '$label3',
'f' => '$label1',
@simonswine
simonswine / show_gmail_ipv6_pain.sh
Last active August 29, 2015 14:01
Mail.log Debian Postfix Analyzer for Gmail v6 trouble
cat /var/log/mail.info | grep relay=gmail | ruby -ne 'm=/^(\S+\s+\S+\s+\S+).*(relay=[^, ]+).*status=(\S+)(.*)$/.match($_); printf "%s %-8s %-60s %s\n", m[1], m[3], m[2], m[4]'