Skip to content

Instantly share code, notes, and snippets.

View ptone's full-sized avatar

Preston Holmes ptone

View GitHub Profile
@ptone
ptone / gist:877899
Created March 19, 2011 23:21
versioning strategies
from distutils.version import StrictVersion, LooseVersion
def compare_versions(version1, version2):
try:
return cmp(StrictVersion(version1), StrictVersion(version2))
# in case of abnormal version number, fall back to LooseVersion
except ValueError:
return cmp(LooseVersion(version1), LooseVersion(version2))
@ptone
ptone / convore-api-notes.rst
Created March 23, 2011 20:55
Some minimal documentation and examples of the Convore Live API data

Covore live API: message kinds

  • message
  • message-delete
  • topic
  • topic-delete
  • topic-rename
  • login
  • logout
-----BEGIN WEBFACTION INSTALL SCRIPT-----
#!/bin/env python2.4
"""
Nginx 0.7.65 Installer New
"autostart": not applicable
"extra info": Enter domain name for the nginx app
"""

Python 2.6 + Virtualenv + Django 1.1 + Postgres on WebFaction

  1. mkdir -p ~/bin ~/lib/python2.6/site-packages

  2. Configure the environment by putting something like this in your .bashrc and sourcing it:

    export CFLAGS=-I/usr/local/pgsql/include
    export LDFLAGS=-L/usr/local/pgsql/lib
    
@ptone
ptone / _webfaction_setup.rst
Created April 4, 2011 23:56
setting up a stack on webfaction

Setting up Webfaction for modern Django deployment

last updated: 4/5/2011

note that this stuff is always a moving target, much of this has been cribbed and combined from various blog posts. Much of the information was out of date from those, and if it is more than a couple months after the last updated date above, consider some of this likely to now be out of date.

@ptone
ptone / pypi_refactor_notes.rst
Created April 6, 2011 14:05
packaginator pypi refactor notes

Notes on PyPI Packaginator refactor

The goals:

  • decouple PyPI specific code from core Packaginator
  • allow enhanced PyPI related features for pythonpackages instance of Packaginator
@ptone
ptone / choices.vim
Created July 28, 2011 23:08
getting and replacing selection in vim
if !has('python')
echo "Error: Required vim compiled with +python"
finish
endif
" Vim comments start with a double quote.
" Function definition is VimL. We can mix VimL and Python in
" function definition.
" function! MakeChoices()
@ptone
ptone / gist:1246480
Created September 27, 2011 22:47
potential layout

ArchiveIndexView

Properties (with optional accessor):

allow_empty = True (django.views.generic.list.MultipleObjectMixin)

@ptone
ptone / webdiff.py
Created October 12, 2011 17:24
display diff output in webpage
#!/usr/bin/env python
# encoding: utf-8
"""
Usage: git diff | webdiff
Created by Preston Holmes on 2009-11-20.
Copyright (c) 2009 __MyCompanyName__. All rights reserved.
"""
@ptone
ptone / patch_coverage.py
Created October 21, 2011 00:17
Annotate coverage report with lines modified by patch
#!/usr/bin/env python
import os
from collections import defaultdict
import patch
import re
import coverage
import django
from optparse import OptionParser
import webbrowser