Skip to content

Instantly share code, notes, and snippets.

View purcell's full-sized avatar

Steve Purcell purcell

View GitHub Profile
@purcell
purcell / color-utils.el
Created October 17, 2011 12:59
A few hacky color-related functions
(defun format-color (rgb)
"Convert a triplet of floating point (0.0-1.0) RGB values into
a hex triplet"
(apply 'format "#%02x%02x%02x"
(mapcar (lambda (x) (* 255 x)) rgb)))
(defconst colour-triplet-regex
"\\([0-9A-Fa-f]\\{2\\}\\)\\([0-9A-Fa-f]\\{2\\}\\)\\([0-9A-Fa-f]\\{2\\}\\)")
(defn follow-chain [base-url number]
(let [result (slurp (str base-url number))]
(if-let [next-number
(if (re-find #"^Yes" result)
(/ (Integer/parseInt number) 2)
(let [idx (.indexOf result "and the next")]
(when (>= idx 0)
(last (string/split (subs result idx) #" ")))))]
(do
(println result)
@purcell
purcell / oxtail-stew.markdown
Created November 16, 2011 12:13
Oxtail Stew Recipe

Oxtail stew recipe

By Steve Purcell

Serves 2-3. Prep time: 20 mins. Cooking time: around 4 1/2 hrs.

This stew is rich and satisfying, not to mention deceptively healthy, easy to make, and dirt cheap.

@purcell
purcell / completion.js
Created November 28, 2011 16:54
Cached autocompletion of wikipedia page titles with jquery ui autocomplete plugin
function cached_completer(completer) {
var cache = {};
return function(request, response) {
if (request.term in cache) {
response(cache[request.term]);
} else {
completer(request, function(resp) {
cache[request.term] = resp;
response(resp);
});
//////////////////////////////////////////////////////////////////////
// Wikipedia
//////////////////////////////////////////////////////////////////////
(function(w) {
var call_wikipedia_api = function(data, callback) {
$.ajax({
url: "http://en.wikipedia.org/w/api.php",
data: $.extend({ format: "json" }, data),
dataType: "jsonp",
Challenge ID: 4d28aef94bcd032f1c0000dc
http://vimgolf.com/challenges/4d28aef94bcd032f1c0000dc.yaml
Keystrokes (28):
M-f M-4 M-d <down> M-f M-f M-3 M-d <down> M-f M-f M-6 M-d C-y M-y M-y <up> M-b M-b <left> C-y M-y <up> M-5 M-b <left> C-y M-y
Full command log:
M-f forward-word
(defvar package-filter-function nil
"Optional predicate function used to internally filter packages used by package.el.
The function is called with the arguments PACKAGE VERSION ARCHIVE, where
PACKAGE is a symbol, VERSION is a vector as produced by `version-to-list', and
ARCHIVE is the string name of the package archive.")
(defadvice package--add-to-archive-contents
(around filter-packages (package archive) activate)
"Add filtering of available packages using `package-filter-function', if non-nil."
(defadvice package-download-transaction
(around disable-keepalives (&optional args) activate)
"Disable HTTP keep-alives to work around network issues with Melpa host."
(let ((url-http-attempt-keepalives nil))
ad-do-it))
==> Downloading http://www.complang.tuwien.ac.at/schani/metapixel/files/metapixel-1.0.2.tar.gz
Already downloaded: /Users/steve/Library/Caches/Homebrew/metapixel-1.0.2.tar.gz
/usr/bin/tar xf /Users/steve/Library/Caches/Homebrew/metapixel-1.0.2.tar.gz
==> make CC=/usr/bin/llvm-gcc MACOS_LDOPTS=-L/usr/local/lib MACOS_CCOPTS=-Os -w -pipe -march=core2 -msse4.1 -I/usr/local/include
make CC=/usr/bin/llvm-gcc MACOS_LDOPTS=-L/usr/local/lib MACOS_CCOPTS=-Os -w -pipe -march=core2 -msse4.1 -I/usr/local/include
/usr/bin/llvm-gcc -Os -w -pipe -march=core2 -msse4.1 -I/usr/local/include -I/usr/X11R6/include -I/usr/X11R6/include/X11 -I. -Irwimg -Wall -O2 -DMETAPIXEL_VERSION=\"1.0.2\" -DRWIMG_JPEG -DRWIMG_PNG -DRWIMG_GIF -c metapixel.c
/usr/bin/llvm-gcc -Os -w -pipe -march=core2 -msse4.1 -I/usr/local/include -I/usr/X11R6/include -I/usr/X11R6/include/X11 -I. -Irwimg -Wall -O2 -DMETAPIXEL_VERSION=\"1.0.2\" -DRWIMG_JPEG -DRWIMG_PNG -DRWIMG_GIF -c vector.c
/usr/bin/llvm-gcc -Os -w -pipe -march=core2 -msse4.1 -I/usr/local/incl
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/Users/steve/bin/proxy-config