Skip to content

Instantly share code, notes, and snippets.

@rhcarvalho
rhcarvalho / .gitconfig
Created November 6, 2016 09:36
Git config for large repositories
# This file represents part of the .git/config file for a given repository.
# The settings below allow git-pack-objects to work on large repositories (e.g., Kubernetes, OpenShift Origin, ...).
[core]
packedGitLimit = 4g
[pack]
windowMemory = 256m
# packSizeLimit = ...
@rhcarvalho
rhcarvalho / old.sh
Created November 5, 2016 19:29
List old files in a Git repository by last modification date
git ls-tree -r --name-only HEAD | while read filename; do
echo "$(git log -1 --format="%ad" --date=short -- $filename) $filename";
done | sort | head -20
@rhcarvalho
rhcarvalho / tgz.go
Created July 25, 2016 13:47
Experiment writing to a tar.gz in Go
//+build ignore
package main
import (
"archive/tar"
"bytes"
"compress/gzip"
"io"
"os"
@rhcarvalho
rhcarvalho / init.coffee
Last active June 17, 2016 16:08
Automatic integration with Godep using Atom's Init Script
# Add the lines below to your init.coffee file to automatically update the
# GOPATH used by tools like those from the go-plus plugin.
fs = require("fs")
path = require("path")
for p in atom.project.getPaths()
workspace = path.join(p, "Godeps", "_workspace")
if fs.existsSync(workspace)
process.env.GOPATH = workspace + ":" + process.env.GOPATH
@rhcarvalho
rhcarvalho / console
Created April 5, 2016 12:29
Programs cannot catch SIGKILL
$ go build sigkill.go
$ ./sigkill &
[1] 13969
$ kill %1
[1]+ Exit 2 ./sigkill
@rhcarvalho
rhcarvalho / console
Last active April 1, 2016 19:53
Insistent cleanup of terminating Go program
$ go run panic.go
2016/04/01 21:51:12 start
2016/04/01 21:51:12 creating container "680b98d36ce2e667"...
^C2016/04/01 21:51:15 removing container "680b98d36ce2e667"...
2016/04/01 21:51:16 removed "680b98d36ce2e667"
2016/04/01 21:51:16 done
2016/04/01 21:51:16 run time panic: early termination
$ go run panic.go
2016/04/01 21:51:18 start
2016/04/01 21:51:18 creating container "7265daca397afe17"...
@rhcarvalho
rhcarvalho / console
Created March 31, 2016 08:57
Go executes deferred calls on panic
$ go run signal.go
1/3 = 0
1/2 = 0
1/1 = 1
hello from deferred call!
panic: runtime error: integer divide by zero
[signal 0x8 code=0x1 addr=0x400d3d pc=0x400d3d]
goroutine 1 [running]:
main.main()
@rhcarvalho
rhcarvalho / console
Created March 29, 2016 19:57
data race example
$ go run -race racy.go
==================
WARNING: DATA RACE
Write by goroutine 5:
main.func·001()
/tmp/racy.go:12 +0x158
Previous read by main goroutine:
main.main()
/tmp/racy.go:15 +0xdb
@rhcarvalho
rhcarvalho / commands
Created March 29, 2016 19:49
data race in openshift/origin PR 8268
git fetch upstream pull/8268/merge:pr8268
git checkout pr8268
godep go build -race ./cmd/oc
./oc rsync docs/ frontend-1-208zy:/ --watch > stdout.log 2> stderr.log
+ set -o errexit
+ rm -rf /tmp/gopath
+ mkdir -p /tmp/gopath/src/github.com/openshift /tmp/gopath/src/k8s.io
+ export GOPATH=/tmp/gopath
+ GOPATH=/tmp/gopath
+ cd /tmp/gopath/src/github.com/openshift
+ git clone https://github.com/openshift/origin
Cloning into 'origin'...
+ cd /tmp/gopath/src/k8s.io
+ git clone https://github.com/kubernetes/kubernetes