Django Decorator to Print SQL Queries
Django's ORM is great for fast development, but it is sometimes all too easy to write inefficient queries in the language. There are a few options to help find rogue queries sucking all that process time. My favorite is of course Django Debug Toolbar. However, sometimes this is not a viable option, such as when writing AJAX processors, or for some reason DDTB is not available to you.
This simple decorator may help you alleviate some pain. It also becomes a useful tool to copy and paste the queries into an external query browser. My favorite for Linux is CrunchyFrog.
Fun with Simple Encryption
Every programmer loves thinking they can come up with some crafty way to encrypt a string. Having no background in encryption, of course I think the same thing. The hard part is coming up with something that is also easily decryptable, but clever enough that the average joe can't figure it out. Here is my attempt.
Setup Dynamic DNS using Linode
Being a fan and veteran of both DNS services dyndns.org and no-ip.org I was always very slightly annoyed that I could not do this with my personal domain name. The annoyance went up a little more when DynDNS started forcing me to log in every 3 months just to let them know I am still alive.
Since moving to Linode this weekend, I setup my own short DNS updating script. Update the variables APIKEY, DOMAIN, and RECORD to your desired settings and let her rip. Here are my settings for reference. This way when I hit home.pushingkarma.com, it routes to my home network.
Kickstarting a Linode Server
First, I would like to thank Brett Hoerner for providing the initial details for this setup on my old Slicehost server. Without his previous post I would be a little duck in the middle of the ocean. This walk through will cover the following setup:
- Create a New User and Disable Root Login
- Update and Install Common Packages
- Setup Postfix for Email Forwarding
- Install Basic Apache2 Configuration
- Install Basic PHP5 Libraries
- Install Basic Python Libraries
- Install & Setup Postgresql
- Create a better SSH Motd
Install psycopg2 in Virtualenv on Ubuntu
It seems every time I setup a new machine I hit the same snag installing psycopg2 into a virtualenv via pip. It's not well documented online. After a bunch of failed searching with my Google foo I found a solution. In short, you can get around the issues using build-dep. Thanks Eliot!
Michael Shepanski
I've been creating websites for over 12 years, using Python since 2004 & Django since early 2009. Web development used to be a hobby to me. As web applications started becoming more complex and the demand so high, it turned into a full-time job. My passion is finding simple and elegant ways to display complex information.