Skip to content

Instantly share code, notes, and snippets.

View mitchellh's full-sized avatar
👻
Building.

Mitchell Hashimoto mitchellh

👻
Building.
View GitHub Profile
671ff0e7b1f416c3b04ab80e0a9d14d07b28fc598d29ac7926ef73672477780d
b7b9867e7de60dbc0b8dd2151ec5bca82297d38c094a2e56c61a8d34bb859972
foo → ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
foo → time vagrant -h
Tasks:
vagrant box # Commands to manage system boxes
vagrant destroy # Destroy the environment, deleting the created virtual machines
vagrant halt # Halt the running VMs in the environment
vagrant help [TASK] # Describe available tasks or one specific task
vagrant init [box_name] [box_url] # Initializes the current folder for Vagrant usage
vagrant package # Package a Vagrant environment for distribution
@mitchellh
mitchellh / mri.txt
Created January 11, 2012 01:15
Ruby vs. Rubinius Startup on Mac OS X 10.7
Last login: Tue Jan 10 17:14:06 on ttys004
foo → ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
foo → time ruby test.rb
HELLO!
real 0m0.022s
user 0m0.017s
sys 0m0.005s
foo → time ruby test.rb
@mitchellh
mitchellh / gist:1556811
Created January 3, 2012 20:37
Vagrant 0.9 Forwarded Ports
# Forwarded port configurations were changed so that they no longer
# require a unique name:
# Before
config.vm.forward_port "http", 80, 8080
# After
config.vm.forward_port 80, 8080
# After (if you still want to name it you can, optionally)
;; Fullscreen is a bit different on OS X
(defun toggle-fullscreen (&optional f)
(interactive)
(let ((current-value (frame-parameter nil 'fullscreen)))
(set-frame-parameter nil 'fullscreen
(if (equal 'fullboth current-value)
(if (boundp 'old-fullscreen) old-fullscreen nil)
(progn (setq old-fullscreen current-value)
'fullboth)))))
@mitchellh
mitchellh / gist:1317151
Created October 26, 2011 17:55
Chef file lock to enforce only one chef run
# Putting this at the top of your "base" recipe or some common recipe that
# is loaded very early on will force Chef to only run one process at a time.
# This is enforced using a file lock. The file lock is automatically released
# when the process exits, so there is no need to explicitly do so.
#----------------------------------------------------------------------
# Obtain File Lock
#----------------------------------------------------------------------
$_chef_lock_file = File.open(File.join(Chef::Config[:file_cache_path], "chef_lock"), "w+")
if $_chef_lock_file.flock(File::LOCK_EX | File::LOCK_NB) === false
@mitchellh
mitchellh / gist:1277049
Created October 11, 2011 01:30
Configure Vagrant VM to use Host DNS for VPN
Vagrant::Config.run do |config|
# ...
config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
@mitchellh
mitchellh / gist:1241519
Created September 26, 2011 02:57
reCaptcha field for WTForms
"""
Contains reCaptcha fields for WTForms which can be used
for various forms. This library depends on `recaptcha-client` ~> 1.0.6.
Example usage is below.
Defining a form with a ``RecaptchaField``:
from wtforms import Form
from recaptcha_field import RecaptchaField
sudo sed -i -r -e 's/http:\/\/(.+)\.ec2/http:\/\/us/' /etc/apt/sources.list