Skip to content

Instantly share code, notes, and snippets.

View mitchellh's full-sized avatar
👻
Building.

Mitchell Hashimoto mitchellh

👻
Building.
View GitHub Profile
@mitchellh
mitchellh / interpreter.hs
Created July 13, 2011 06:04
"The Essence of Functional Programming" Basic Interpreter
type Name = String
data Term = Var Name
| Con Int
| Add Term Term
| Lam Name Term
| App Term Term
data Value = Wrong
| Num Int
$ brew install emacs --cocoa --srgb
==> Downloading http://ftp.gnu.org/pub/gnu/emacs/emacs-23.3.tar.bz2
File already downloaded in /Users/mitchellh/Library/Caches/Homebrew
==> Downloading patches
######################################################################## 100.0%
######################################################################## 100.0%
==> Patching
patching file src/ChangeLog
patching file src/unexmacosx.c
patching file lisp/term/ns-win.el
@mitchellh
mitchellh / Questions
Created August 8, 2011 21:36
Frozen Rails Give-away
Day job: Operations Engineer
Your Rails contributions (if any): None
What's your Ruby/Rail experience?: Was a Rails consultant for 3.5 years, switched to Python and now do Ops work.
How do you use GitHub?: Open source projects, issues, wiki, site hosting, as well as corporate git hosting.
@mitchellh
mitchellh / gist:1171261
Created August 25, 2011 17:43
They see me wiresharkin'... They hatin'...
#!/usr/bin/env python
"""
This Python scripts listens for all HTTP requests to the
Turntable CDNs and downloads the file requested into the
current directory.
Disclaimer: This is a proof of concept. The author of this
script is not responsible for how this is used.
"""
@mitchellh
mitchellh / gist:1171262
Created August 25, 2011 17:44
They see me wiresharkin'... they hatin'...
#!/usr/bin/env python
"""
This Python scripts listens for all HTTP requests to the
Turntable CDNs and downloads the file requested into the
current directory.
Disclaimer: This is a proof of concept. The author of this
script is not responsible for how this is used.
"""
sudo sed -i -r -e 's/http:\/\/(.+)\.ec2/http:\/\/us/' /etc/apt/sources.list
@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
@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: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
;; 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)))))