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 fabric.api import * | |
""" | |
Base configuration | |
""" | |
env.project_name = '$(project)' | |
env.database_password = '$(db_password)' | |
env.site_media_prefix = "site_media" | |
env.admin_media_prefix = "admin_media" | |
env.newsapps_media_prefix = "na_media" |
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
import sys | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.sqlite3', | |
'NAME': 'dev.sqlite', | |
'USER': '', | |
'PASSWORD': '', | |
'HOST': 'localhost', | |
'PORT': '', |
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
def install_libxml(tag='v2.8.0'): | |
run('git clone git://git.gnome.org/libxml2') | |
with('cd libxml'): | |
run('git reset %s' % tag) | |
run('./autogen.sh') | |
run('make') | |
sudo('make install') | |
run('rm -rf libxml') | |
def install_libxslt(tag='v1.1.26'): |
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
# Import these into your fabfile.py as to not clutter it up. | |
import re | |
import textwrap | |
from fabric.api import * | |
from fabric.operations import prompt, require | |
from fabric.context_managers import settings, prefix | |
from fabric.contrib.console import confirm | |
from fabric.contrib.files import upload_template, exists, append | |
from fabric.utils import warn |
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
Date.prototype.toDjangoString = function() { | |
// YYYY-MM-DD HH:MM:SS | |
return this.getFullYear() + '-' + | |
(this.getMonth() + 1) + "-" + | |
this.getDate() + " " + | |
this.getHours() + ":" + | |
this.getMinutes() + ":" + | |
this.getSeconds(); | |
}; |
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
google.maps.LatLng.prototype.toPointWKT = function() { | |
return "POINT("+ this.Za + " " + this.Ya + ")"; | |
}; |
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
import datetime | |
from django.db import models | |
from django.db.models.query import QuerySet | |
class PostQuerySet(QuerySet): | |
def live(self): | |
"""Filter out posts that aren't ready to be published""" | |
now = datetime.datetime.now() | |
return self.filter(date_published__lte=now, status="published") |
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 | |
# add repositories | |
# get latest mercurial | |
sudo apt-add-repository ppa:mercurial-ppa/releases | |
# Virtualbox | |
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add - |
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
# Get password from ~/.my.cnf if it exists | |
my_cnf_path = os.path.expanduser('~/.my.cnf') | |
if os.path.exists(my_cnf_path): | |
from ConfigParser import SafeConfigParser | |
config = SafeConfigParser() | |
with open(my_cnf_path) as my_cnf: | |
config.readfp(my_cnf) | |
try: | |
DATABASES['default']['PASSWORD'] = config.get('client', 'password') | |
except ConfigParser.NoOptionError: |
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
# Custom prompt | |
function parse_git_dirty { | |
git branch > /dev/null 2>&1 | |
if [[ $(echo $?) == "0" ]] | |
then [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "⚡" | |
fi | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/on \1/" | |
} |
OlderNewer