Archive for the ‘Programming’ Category
Python: Remove Whitespace From a String
>>> print “”.join(” hello world “.split()) helloworld The key to the above is that the String method split() separates the string on any amount of whitespace when no separator is specified.
Categories: Programming
Basic Django WSGI Handler
Creating a basic Django WSGI handler is pretty straightforward. The Django docs version is OK, but it relies on your application being part of the PYTHONPATH. This is what I do instead: import os import sys from django.core.handlers.wsgi import WSGIHandler sys.stdout = sys.stderr sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) os.environ["DJANGO_SETTINGS_MODULE"] = “settings” application = WSGIHandler() This basic handler sets [...]
Categories: Programming
Your Django manage.py ImportError May be a Syntax Problem
Background: While cleaning up my development directory the other day, I renamed one of my Django project directories to the domain name of the site. For the sake of argument, we’ll call it django.slaptijack.com. When I descended into the directory and tried to start the development server, I received the following garbage: $ ./manage.py runserver [...]
Categories: Programming
Listing WordPress Database Queries
If you need to debug what queries your WordPress site is making, try adding the following PHP to your theme: <?php foreach ( $wpdb->queries as $query ) { echo “$query[0]<br />”; } ?> For this code to work, you need to add the following line to wp-config.php: define(‘SAVEQUERIES’, true); After that, you should see a [...]
Categories: Programming
Subversion: Revert to Earlier Version
This is one of those annoying little things I have to do ever so often. There are two different commands to accomplish this task depending on the specific situation. If you’ve made a lot of changes to a file and need to back all of those changes out, you can use the svn revert command. [...]
Categories: Programming

Get Slaptijack updates delivered to your Inbox or RSS Reader for free!