Skip to content

Instantly share code, notes, and snippets.

bradwright / path.el
Created March 15, 2012 20:13
Set Emacs exec-path by shell $PATH
;; This sets the Emacs "PATH" environment variable and the `exec-path`
;; variable to the same value your login shell sees. The reason this
;; is necessary is because of this:
;; Basically apps launched from Finder inherit their environment from
;; a .plist file rather than the shell environment.
(defun set-exec-path-from-shell-PATH ()
bradwright / darwin-keychain.el
Created February 12, 2012 11:39
How to get an OS X KeyChain entry in Emacs (useful for ERC etc.)
(defun chomp (str)
"Chomp leading and tailing whitespace from STR."
(while (string-match "\\`\n+\\|^\\s-+\\|\\s-+$\\|\n+\\'" str)
(setq str (replace-match "" t t str))) str)
(defun get-keychain-password (account-name)
"Gets `account` keychain password from OS X Keychain"
bradwright / websockets-server.js
Created June 11, 2011 23:29
Pure Node.js WebSockets server
* node-ws - pure Javascript WebSockets server
* Copyright Bradley Wright <>
// Use strict compilation rules - we're not animals
'use strict';
var net = require('net'),
crypto = require('crypto');
bradwright /
Created February 20, 2012 17:14
Django date template helpers without relying on Django
# Django licence
Copyright (c) Django Software Foundation and individual contributors.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
bradwright /
Created February 13, 2011 19:56
StackScript to make a more secure Ubuntu server install out of the box
# Setup script designed to get a Ubuntu 10.4 LTS server
# up and running with secure defaults.
# Documentation for StackScripts
# is pretty sparse: see
# User-inputted values for new Linode
# <UDF name="user_hostname" Label="Hostname for new Linode" />
bradwright /
Created May 13, 2012 19:41 — forked from urschrei/
Bootstrap a Flask project
#!/bin/bash -e
# opinionated Flask bootstrap script
# assumes you'll be using MySQL, Fabric, and Blueprints
# creates a virtualenv and an Alembic migrations system
# The script will halt on any error, and remove the project dir if it created one
# accepts a single argument: a new directory name under which to create the project
# check that Python is installed
type python >/dev/null 2>&1 || { echo >&2 "Python doesn't appear to be installed. Aborting."; exit 1; }
bradwright / send-mail-to-omnifocus-and-archive.scpt
Last active August 25, 2016 19:05
Take current message, send its subject and 'message:<>' URL to OmniFocus, and then Archive the email
-- Send currently selected message to OmniFocus 2 quick entry box, then archive it
-- Archive behaviour found at:
tell application "Mail"
set theSelectedMessages to selection
set the selected_message to item 1 ¬
of the theSelectedMessages
set message_id to the message id of the selected_message
set my_subject to the subject of the selected_message
set message_url to "message://%3c" & message_id & "%3e"
Debugger entered--Lisp error: (void-variable G43505)
ad-Advice-magit-status(#[(dir) "\304!\211\204\305\306\307\"!\203\310!\210\304! \205>\311 !\210\312\313 \"\2062\314\315\316\317 !!\320Q!\321\n \"\210\322 \313\323#))\207" [dir topdir buf magit-status-buffer-switch-function magit-get-top-dir y-or-n-p format "There is no Git repository in %S. Create one? " magit-init magit-save-some-buffers magit-find-buffer magit-status-mode generate-new-buffer "*magit: " file-name-nondirectory directory-file-name "*" magit-mode-display-buffer magit-mode-init magit-refresh-status] 6 ("/Users/bradleyw/.emacs.d/.elpa/" . 192294) (list (if current-prefix-arg (magit-read-top-dir (> (prefix-numeric-value current-prefix-arg) 4)) (or (magit-get-top-dir) (magit-read-top-dir nil))))] "/Users/bradleyw/Projects/emacs.d/")
apply(ad-Advice-magit-status #[(dir) "\304!\211\204\305\306\307\"!\203\310!\210\304! \205>\311 !\210\312\313 \"\2062\314\315\316\317 !!\320Q!\321\n \
Vagrantfile: do |config|
config.vm.define :web do |web_config|
web_config.vm.provision :puppet, :options => "--verbose --debug" do |web_puppet|
web_puppet.module_path = "puppet/modules"
web_puppet.manifests_path = "puppet/manifests"
web_puppet.manifest_file = "web.pp"
bradwright /
Created October 24, 2015 21:11
Copy all files from one place to another, recursively, sleeping between runs
  1. Download the above file and save it somewhere (eg ~/Downloads)
  2. Open, and go to where it's saved (eg cd ~/Downloads)
  3. Run the script, with the HDD volume as the first argument, eg: python /Volumes/Thing/Path/to/itunes /Library/Local-path-to-itunes