Skip to content

Instantly share code, notes, and snippets.

View lpenz's full-sized avatar
🐧
🦀 🐊

Leandro Lisboa Penz lpenz

🐧
🦀 🐊
View GitHub Profile
@lpenz
lpenz / .travis.yml
Created April 23, 2015 14:48
.travis.yml: base for go with coveralls
language: go
go:
- tip
before_install:
- go get github.com/axw/gocov/gocov
- go get github.com/mattn/goveralls
- go get github.com/bradfitz/goimports
- go get github.com/golang/lint/golint
- go get golang.org/x/tools/cmd/vet
- if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
@lpenz
lpenz / brewer.tex
Created April 25, 2015 22:02
colorbrewer colors for latex
% Colors from www.ColorBrewer.org by Cynthia A. Brewer, Geography, Pennsylvania State University.
% Apache-Style Software License for ColorBrewer software and ColorBrewer Color Schemes
%
% Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania State University.
%
% Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
% You may obtain a copy of the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
@lpenz
lpenz / docker-create-debian-image.sh
Last active March 1, 2018 06:49
debootstrap a bare debian docker image
#!/bin/bash
DIST=${1?no distribution specified}
ARCH=${2:amd64}
set -e -x
NAME=debian-${DIST}-${ARCH}
debootstrap --no-check-gpg "--arch=$ARCH" "$DIST" "$NAME" http://archive.debian.org/debian
tar -C "$NAME" -c . | docker import - "$USER/$NAME"
@lpenz
lpenz / docker-gc
Last active April 18, 2016 19:48
Docker garbage collector
#!/bin/bash
set -x -e
: gc conteiners
docker ps --filter 'status=exited' -q | xargs -r docker rm
docker ps --filter 'status=created' -q | xargs -r docker rm
: gc images
docker images --filter "dangling=true" -q | xargs -r docker rmi
@lpenz
lpenz / .travis.yml
Created February 21, 2016 12:22
Test .gitignore in travis
script:
- true TESTS RUN HERE
- true Test if we .gitignore test files
- TMP=$(tempfile)
- git ls-files . --exclude-standard --others | tee "$TMP"
- if test -s "$TMP"; then false; else true; fi
- true Test if we .gitignore any tracked files
- git ls-files -i --exclude-standard | tee "$TMP"
- if test -s "$TMP"; then false; else true; fi
@lpenz
lpenz / livedeb
Last active June 25, 2019 14:02
Creates a live debian on the provided (already partitioned) device
#!/bin/bash
DEV=${1?must specify a device}
function finish {
for d in boot dev/pts dev proc sys; do
if test -d "$PWD/usbroot/$d" && mount | grep -q "$PWD/usbroot/$d"; then
umount "$PWD/usbroot/$d"
fi
done
@lpenz
lpenz / Vagrantfile-aws
Last active March 4, 2019 15:26
Vagrantfile for AWS with sshfs
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
config.vm.box = 'dummy'
config.ssh.forward_agent = 'true'
config.vm.synced_folder '.', '/vagrant', type: 'sshfs' # only works with ubuntu
config.vm.provider :aws do |aws, override|
@lpenz
lpenz / dir2img
Last active April 22, 2019 16:24
Script that creates a bootable qcow2 img with a directory's contents - installs mbr and extlinux
#!/bin/bash
DIR=${1?usage: $0 <dir> <img>}
OUT=${2?usage: $0 <dir> <img>}
set -e -x
rm -f "$OUT"
trap 'rm -f $OUT' EXIT INT
virt-make-fs --partition=mbr --type=ext3 --format=raw --size=+300M "$DIR" "$OUT"
@lpenz
lpenz / debootstrap-vagrant
Last active October 4, 2016 22:22
Use debootstrap to create a chroot that can be turned into a vagrant-compatible (virtualbox, wheezy 32) VM
#!/bin/bash
DIR=${1?usage: $0 <dir>}
NAME=${DIR##*/}
set -e -x
rm -rf "$DIR"
trap 'set +e; umount "$DIR/proc"; umount "$DIR/sys"; rm -rf "$DIR"' EXIT INT
@lpenz
lpenz / img2vagrant
Created October 5, 2016 17:12
Create a package.box for vagrant (virtualbox) from the specified raw img file
#!/bin/bash
IMG=${1?usage: $0 <img>}
NAME=wheezy32
set -e -x
rm -f "${IMG}.vmdk" package.box
VBoxManage convertfromraw "$IMG" "${IMG}.vmdk" --format vmdk
VBoxManage unregistervm "$NAME" --delete || :