Skip to content

Instantly share code, notes, and snippets.

View mitchellh's full-sized avatar
👻
Building.

Mitchell Hashimoto mitchellh

👻
Building.
View GitHub Profile
#!/bin/sh
set -e
IMAGE="image.bin"
DISK="coreos.vdi"
VM_NAME="CoreOS"
# Delete any existing VDI
rm -f $DISK
Vagrant.configure("2") do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "coreos"
config.ssh.username = "core"
config.vm.synced_folder ".", "/vagrant", disabled: true
end
@mitchellh
mitchellh / gist:5436471
Last active December 16, 2015 12:39
Reading forwarded ports in VMware Workstation on Windows
results = {}
results[:tcp] = {}
results[:udp] = {}
Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\VMware, Inc.\VMnetLib\VMnetConfig') do |reg|
# Get each of the vmnets
reg.each_key do |vmnet|
reg.open(vmnet) do |vmnet_reg|
# If this network doesn't include the NAT key, we
# don't really care about it.
@mitchellh
mitchellh / new.go
Created April 5, 2013 06:29
Sudo wrapper that ships with Fusion provider for Vagrant, rewritten in Go.
// This is a dead simple wrapper that can have setuid set on it so that
// the sudo helper is run as root. It is expected to run in the same CWD
// as the actual Ruby sudo helper. Any arguments to this script are forwarded
// to the Ruby sudo helper script.
package main
import (
"fmt"
"os"
"path/filepath"
# This is just a sample of what the new networking syntax in
# Vagrant 1.1 can look like.
Vagrant.configure("2") do |config|
# ...
# High-level configurations that are portable across providers.
# Providers do a "best effort" to satisfy these. If they can't,
# they should warn and still try to come up.
config.vm.network :forwarded_port, 80, 8080
#!/bin/bash
#
# This is the script responsible for updating our Puppet master data,
# which includes modules, manifests, hiera data, etc. All of this data is
# managed in a git repository and upon "deploy" it is synced into the Puppet
# master.
#
# This script mirrors the remote git repository, looking for branches that
# match "env-*" (such as "env-production" or "env-test"). Each of these branches
# is setup as an environment into the Puppet master's data files. The
require "fiber"
module Middleware
# This is a basic runner for middleware stacks based on Ruby fibers.
# By using fibers rather than recursion, the stack is not deepened, and
# therefore cannot stack overflow. This allows middleware sequences of
# thousands to be used without crashing Ruby.
#
# This runner is much more complicated than the normal runner because it
# has to do a lot of work to _simulate_ a call stack. For example, one of
@mitchellh
mitchellh / gist:3707876
Created September 12, 2012 16:25
init file for pg clusters on Ubuntu
#!/bin/sh
set -e
### BEGIN INIT INFO
# Provides: postgresql-cluster-<%= @cluster_name %>
# Required-Start: $local_fs $remote_fs $network $time
# Required-Stop: $local_fs $remote_fs $network $time
# Should-Start: $syslog
# Should-Stop: $syslog
# Default-Start: 2 3 4 5
module Mixin
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def foo
puts "HELLO!"
end
end
CONSTANT = "in <global>"
class Foo
CONSTANT = "in foo"
end
class Foo::Bar
puts CONSTANT # => "in <global>"
end