View Django Project Settings

Start a Python shell and import settings to view your Django project settings python manage.py shell >>> import settings >>> settings.ROOT_URLCONF ‘myproject.urls’

Posted in <code> | Leave a comment

Short Django Tutorial Notes

Some condensed notes on the Django tutorial (Django 1.3) This is just a short self-reference (or maybe a 2-minute overview), not an actual tutorial. Database Create / update database python manage.py syncdb Models Models define how data is stored. Create a model by inheriting from django.db.models.Model from django.db import models   class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes … Continue reading

Posted in <code> | Tagged , , , | 1 Comment

Installing Mezzanine (Django based CMS) on Dreamhost via virtualenv

Here’s some notes for installing Mezzanine on Dreamhost using virtualenv. This can be useful for installing on any server where you don’t have permissions to install python packages normally. There’s also notes here for how to set up Passenger to serve your site via Apache. In Dreamhost panel, setup site for use with Passenger & ssh Ssh into your Dreamhost … Continue reading

Posted in <code> | Tagged , , , , , , , , , , , | 3 Comments

Notes on installing Gitorious on Ubuntu 10.10

A few notes from my experience installing Gitorious on Ubuntu Maverick 10.10. I used soundmaster’s fork of the gitorious-ubuntu-sprinkle script. I used ruby 1.8 and rubygems from the Ubuntu repository. Edit Config Files The sprinkle readme doesn’t mention it, but you need to edit the config files before running. Add your mysql password to config/database.yml and change your hostname and … Continue reading

Posted in <linux> | Leave a comment

Gps Navigators

I wish there was an Android Garmin Nuvi. C’mon Google!

Posted in <uncategorized> | Leave a comment

Bedtools-python install in Windows

Compiling applications from source may be the MO in Linux, but it is really tedious in Windows. This is not for the faint of heart.

Posted in <code> | Leave a comment

Simple python printing

Simplify python string formatting using locals() or vars(). In python 2 style print keyword usage. Use print( string ) for python 3k. name = ‘moose’ adjective = ‘squishy’   print ‘{name} is {adjective}’.format(**locals()) # moose is squishy   # vars() with no args is same as locals() print ‘{name} is {adjective}’.format(**vars()) # moose is squishy Using vars to access object … Continue reading

Posted in <code> | Leave a comment

explicit is not better than implicit

I’m sick of all the python fangeeks always using the argument that “explicit is better than implicit” to justify python behaviors. I think it’s a good design principle to consider, but it is not a overarching commandment that good code should always be explicit. Convenience and readability is sometimes better than explicit. Use your brain, don’t be a eibti zombie.

Posted in <code> | Leave a comment

Python call easy_install within a Python session

Thanks stack overflow from setuptools.command import easy_install easy_install.main( ["-U","py2app"] )

Posted in <code> | Tagged , | Leave a comment

Redmine on Ubuntu Maverick

Redmine is a project management software. There’s existing documentation on the web about installing Redmine on Ubuntu, but much of it is out of date and confusing. Redmine is in the Ubuntu repos now so the installation is really quite simple. sudo tasksel install lamp-server sudo apt-get install redmine Select sqlite for the database (redmine-sqlite is installed as a dependency … Continue reading

Posted in <linux> | Tagged , , , , | 1 Comment

Python Getters and Setters

A quick note on defining getters and setters using decorators for Python 2.6+ #Must inherit from object #class C: won’t work. class C(object): # Define getter for x #@x.getter doesn’t work because self.x is not defined yet :( @property def x(self): return self._x   # Define setter for x @x.setter def x(self, value): self._x = value   # Define deleter … Continue reading

Posted in <code> | Tagged , , , | Leave a comment

How to setup a SparkleShare Private Server on Ubuntu

*Feb 3, 2011: This is a work in progress… *Todo: nautilus integration not working – missing dependencies? (no ubuntu python-nautilus-dev package?) *Todo: compile a release build instead of a debug build? *Todo: build a ubuntu/debian package? SparkleShare is dropbox-like software that can sync to your own private server. The SparkleShare documentation recommends syncing to GitHub or Gitorius, but all you … Continue reading

Posted in <code>, <linux> | Tagged , , , , , , , | 9 Comments

Python woes

It’s cool that there are so many Python modules available, but it’s kinda a pain to install them all. It’s too bad easy_install doesn’t do better dependency checking. It just errors out when there’s something missing. I couldn’t get numpy to work with the 64 bit version of Python 2.7 for Windows, so I uninstalled the 64 bit version and … Continue reading

Posted in <code> | Leave a comment

Vim: Save and Run Shortcut

Make Vim more IDE-like by assigning F5 to save and run your current script. Just add this to your ~/.vimrc map <F5> <Esc>:w<CR>:!%:p<CR> This maps the F5 key to run two things: :w, which saves your file, and :!%:p, which will run your current script (! runs a shell command and %:p expands to the path of your current file). … Continue reading

Posted in <customization>, <linux> | Tagged , , , , , | 2 Comments

Python: Create directory

Simple Python snippet which creates a directory if it doesn’t exist. #! /usr/bin/env python import os   # create directory "mydir" if it doesn’t exist already os.path.exists("mydir") or os.mkdir("mydir")

Posted in <code> | Tagged , , , , , | Leave a comment
<RSS Feed>