Skip to content

Instantly share code, notes, and snippets.

@mjhennig
mjhennig / vagrant-cheat-sheet.md
Last active September 26, 2018 06:47 — forked from wpscholar/vagrant-cheat-sheet.md
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
@mjhennig
mjhennig / .rubocop.yml
Last active June 27, 2018 12:29
RuboCop configuration example
# This is a configuration file for RuboCop, a static code analyzer for the
# Ruby programming language, adjusting its behavior to reflect the syle guide
# of some eyeo Ruby projects. Refer to https://github.com/bbatsov/rubocop and
# https://github.com/bbatsov/rubocop/blob/master/manual/configuration.md for
# more information on the RuboCop software and configuration.
---
# Metics/BlockLength has been disabled due to nested RSpec describe blocks
# easily exceeding any limit one may consider reasonable in "regular" code.
# Note that authors are encouraged to keep block length short nonetheless.
@mjhennig
mjhennig / debimage.sh
Last active December 25, 2022 23:36
Yet another wrapper for the debootstrap(8) command
#!/bin/sh
# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 textwidth=80:
# Mathias J. Hennig wrote this script and it's manual page. As long as
# you retain this notice you can do whatever you want with this stuff.
# If we meet some day, and you think this stuff is worth it, you can buy
# me a beer in return.
# Ensure the script to abort on error
set -e
@mjhennig
mjhennig / hetzner.py
Last active December 4, 2018 14:34
Ansible Hetzner inventory
#!/usr/bin/env python
# coding: utf-8
# Copyright (c) 2016-2017 eyeo GmbH
#
# This is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@mjhennig
mjhennig / lock.sh
Last active October 19, 2017 08:24
Lock a shell terminal's location
# source or include with .${SHELL}rc
lockon ()
{
pushd ${1:-$PWD} > /dev/null;
$SHELL -c "while [ \$? -eq 0 ]; do $SHELL; done";
popd > /dev/null
}
lockoff ()
@mjhennig
mjhennig / puppet-setup.sh
Last active June 14, 2017 10:52
Configure Puppet with Puppet
#!/bin/sh
# vi: set fenc=utf-8 ft=sh ts=8 sw=2 sts=2 et:
# coding: utf-8
# http://www.in-ulm.de/~mascheck/various/set-e/
set -e
# https://docs.puppet.com/puppet/latest/install_linux.html
if ! which puppet >/dev/null; then
apt-get -y update
@mjhennig
mjhennig / scm.sh
Created June 8, 2017 13:11
Combining Git and Mercurial using a custom login shell
#!/bin/sh
# This script is part of the Uplink project. It is used as login-shell for
# SSH users git@ and hg@ in development, allowing for integration of both Git
# and Mercurial workflows, and for the user to push into any repository that
# is identified by a valid name, irregardless whether it exists already.
basename="`basename \"$0\"`"
# Login shells are meant to be executed with option -c followed by a command
if [ $# -ne 2 -o "x-c" != "x$1" ]; then
echo "$basename: Invalid or malformed login shell command: $@" >&2
@mjhennig
mjhennig / metaclass.py
Created October 6, 2015 08:36
Metaclasses in Python 2 and 3
def with_metaclass(metaclass, *bases):
"""
Resembles functions six.with_metaclass() and flask.with_metaclass().
"""
constructor = lambda c, name, b, dct: metaclass(name, bases, dct)
intermediate = type('__metaclass__', (type,), {'__new__': constructor})
return type.__new__(intermediate, '__class__', (object,), {})