Skip to content

Instantly share code, notes, and snippets.

@bradwright
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:
;;
;; http://developer.apple.com/library/mac/#qa/qa1067/_index.html
;;
;; 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
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"
(chomp
(shell-command-to-string
(concatenate
@bradwright
bradwright / websockets-server.js
Created June 11, 2011 23:29
Pure Node.js WebSockets server
/*
* node-ws - pure Javascript WebSockets server
* Copyright Bradley Wright <brad@intranation.com>
*/
// Use strict compilation rules - we're not animals
'use strict';
var net = require('net'),
crypto = require('crypto');
@bradwright
bradwright / date_helper.py
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
bradwright / linode-secure-ubuntu-stackscript.sh
Created February 13, 2011 19:56
StackScript to make a more secure Ubuntu server install out of the box
#!/bin/bash
# Setup script designed to get a Ubuntu 10.4 LTS server
# up and running with secure defaults.
# Documentation for StackScripts
# is pretty sparse: see http://www.linode.com/stackscripts/
# User-inputted values for new Linode
# <UDF name="user_hostname" Label="Hostname for new Linode" />
@bradwright
bradwright / mkflask.sh
Created May 13, 2012 19:41 — forked from urschrei/mkflask.sh
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
bradwright / send-mail-to-omnifocus-and-archive.scpt
Last active August 25, 2016 19:05
Take current Mail.app message, send its subject and 'message:<>' URL to OmniFocus, and then Archive the email
-- Send currently selected Mail.app message to OmniFocus 2 quick entry box, then archive it
-- Archive behaviour found at: http://vemedio.com/blog/posts/my-archive-email-apple-script
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/24.3.50.1/magit-20131126.621/magit.elc" . 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:
Vagrant::Config.run 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"
end
@bradwright
bradwright / Instructions.md
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 Terminal.app, and go to where it's saved (eg cd ~/Downloads)
  3. Run the script, with the HDD volume as the first argument, eg: python sleep-and-copy.py /Volumes/Thing/Path/to/itunes /Library/Local-path-to-itunes