This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Add php-serve.py to your PATH, then, from whatever directory is the root | |
of your PHP application, just run: | |
$ php-serve.py | |
You can optionally specify a port number as an argument. By default, | |
port 8000 is used: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# wtf8.py | |
import codecs | |
def encode(input, errors='strict'): | |
return input.encode('utf-8', errors).decode('latin-1', errors).encode('utf-8', errors), len(input) | |
def decode(input, errors='strict'): | |
return input.decode('utf-8', errors).encode('latin-1', errors).decode('utf-8', errors), len(input) | |
class StreamWriter(codecs.StreamWriter): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Deriving something like generators, but I didn't really feel like | |
;; doing exactly that. | |
;; It doesn't, for instance, support sending back into the generator | |
;; This applys a function across a range from 0 to x. | |
(define (apply-to-range f i x) | |
(when (< i x) | |
(f i) | |
(apply-to-range f (+ 1 i) x))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILE=$1 | |
if [ -d $FILE ]; then | |
DIR=$FILE | |
else | |
DIR=`dirname $FILE` | |
fi | |
function parse_git_branch { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* guessit | |
* Itty-bitty mastermind type game. | |
* | |
* OBJECT: | |
* | |
* The object of the game is to guess what the computer has choosen. | |
* | |
* The computer starts out by randomly selecting a number of symbols. Your job | |
* is to figure out what the symbols are. You have a limited number of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Lingua::EN::Syllable::syllable() estimates the number of syllables in | |
;; the word passed to it. | |
;; Note that it isn't entirely accurate... it fails (by one syllable) for | |
;; about 10-15% of my /usr/dict/words. The only way to get a 100% accurate | |
;; count is to do a dictionary lookup, so this is a small and fast alternative | |
;; where more-or-less accurate results will suffice, such as estimating the | |
;; reading level of a document. | |
;; I welcome pointers to more accurate algorithms, since this one is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Module, request, redirect, url_for, render_template, abort | |
from formalchemy import FieldSet | |
from example import db | |
from example import Service, User, Forum, Category, Topic, Post | |
mod = Module(__name__) | |
models = { |
-
Install XQuartz (http://xquartz.macosforge.org) which is the development version of the X11.app that ships with OS X, which means it is way more up to date. I have had some weird issues with X11.app v. 2.3-something. XQuartz 2.5.0 fixed that.
-
Install
dwm
from Homebrew,brew install dwm
. This makes a bunch of necessary tweaks to the DWM configuration. -
Add the following script to $PATH, name it
dwm-launch
andchmod 755
:cd ~
while true
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; emacsd-tile.el -- tiling windows for emacs | |
(defun swap-with (dir) | |
(interactive) | |
(let ((other-window (windmove-find-other-window dir))) | |
(when other-window | |
(let* ((this-window (selected-window)) | |
(this-buffer (window-buffer this-window)) | |
(other-buffer (window-buffer other-window)) | |
(this-start (window-start this-window)) |