Skip to content

Instantly share code, notes, and snippets.

View apg's full-sized avatar
🐢
Turtle

Andrew Gwozdziewycz apg

🐢
Turtle
View GitHub Profile
;; 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))
@vangberg
vangberg / DWM-ON-OS-X.md
Created February 22, 2010 19:24
dwm on os x [work in progress!]

Installing and configuring dwm on OS X

  1. 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.

  2. Install dwm from Homebrew, brew install dwm. This makes a bunch of necessary tweaks to the DWM configuration.

  3. Add the following script to $PATH, name it dwm-launch and chmod 755:

    cd ~
    

while true

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 = {
@apg
apg / haiku.el
Created September 2, 2010 14:48
;; 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
@apg
apg / mastermind.c
Created December 10, 2010 19:36
A console mastermind game.
/**
* 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
@idris
idris / github.sh
Created January 20, 2011 22:23
command-line utility that opens a browser to the given file/directory in GitHub.
#!/bin/bash
FILE=$1
if [ -d $FILE ]; then
DIR=$FILE
else
DIR=`dirname $FILE`
fi
function parse_git_branch {
@apg
apg / generator-ttd.scm
Created January 29, 2011 16:26
generators (like python yield), in scheme, a language that doesn't normally have them.
;; 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)))
@philikon
philikon / wtf8.py
Created February 8, 2011 08:22
WTF-8 codec for Python
# 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):
@jsocol
jsocol / php-serve.py
Created February 14, 2011 17:32
A local dev server for PHP.
#!/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: