Skip to content

Instantly share code, notes, and snippets.

View dserodio's full-sized avatar
🐕

Daniel Serodio dserodio

🐕
View GitHub Profile
@dserodio
dserodio / root.sh
Last active November 29, 2018 15:23
Ensure that a script is executed as root
#!/bin/bash
if [[ "$(id -u)" -ne 0 ]]; then
sudo "$0" "$@"
exit $?
fi
@dserodio
dserodio / cleanup.sh
Created April 24, 2017 20:20
Cleanup temp files on Bash scripts
#!/bin/bash
function cleanup() {
# Your cleanup code here
}
trap cleanup EXIT
# See http://redsymbol.net/articles/bash-exit-traps/
cmd: python hello.py
@dserodio
dserodio / git-timestamp.sh
Created January 5, 2017 20:35 — forked from davidwindell/git-timestamp.sh
Set a files last modified time to match it's git commit timestamp
#!/bin/bash -e
####
# based on http://www.clock.co.uk/blog/a-guide-on-how-to-cache-npm-install-with-docker
#
# Set's the last modified timestamp of a file to it's repositories commit timestamp.
#
# Particularly useful with docker when building after a new git checkout has been made,
# can improve docker build times for composer, bower, npm, etc
#
# @see https://github.com/docker/docker/issues/3556
@dserodio
dserodio / gist:48635d457e01de3d4134f0dcabc9390b
Created January 5, 2017 20:20 — forked from jdoconnor/gist:32ef0314cecb80157c4e
Update mtimes based off commit time
#!/bin/bash -e
####
# based on https://gist.github.com/jeffery/1115504
# Helper script to update the Last modified timestamp of files in a Git SCM
# Projects working Copy
#
# When you clone a Git repository, it sets the timestamp of all the files to the
# time when you cloned the repository.
#
# This becomes a problem when you want the cloned repository, which is part of a
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: dserodio-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Mi
@dserodio
dserodio / docker-machine-screen.sh
Created December 8, 2016 13:36
Attach to Moby Dock VM in Docker for Mac
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
@dserodio
dserodio / minikube-on-xhyve.sh
Created November 29, 2016 16:20
Get native (no VM) Docker support for Kubernetes on OS X
# get native (no VM) docker support (see also Docker for Mac, but this is to support minikube)
brew install docker-machine-driver-xhyve
sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
minikube start --vm-driver=xhyve
# or do this first
minikube config set vm-driver xhyve
minikube start
@dserodio
dserodio / git-tips.md
Last active December 17, 2018 12:50
Some git tips

Don't blame people for changing whitespaces or moving code

git blame will show the author of the last commit that modified the particular line. If whitespaces were removed or that piece of code was moved around, blame will show that commit and you might blame the wrong person.

git blame -w -M

-w will ignore whitespaces and -M will detect moved or copied lines.

Source: https://coderwall.com/p/x8xbnq/git-don-t-blame-people-for-changing-whitespaces-or-moving-code

# Set the default terminal mode to 256color mode
set -g default-terminal "screen-256color"
# Enable utf-8
set -g status-utf8 on
## Keybindings
# use PREFIX | to split window horizontally and PREFIX - to split vertically
bind | split-window -h