<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>damontimm.com</title>
	<atom:link href="http://blog.damontimm.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.damontimm.com</link>
	<description>Where I go to remember what I did</description>
	<lastBuildDate>Sat, 16 Feb 2013 13:48:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>How To: Unlock, Root, and Install a Custom ROM on a Galaxy Nexus (Verizon) Using a Mac</title>
		<link>http://blog.damontimm.com/how-to-unlock-root-and-install-a-custom-rom-on-a-galaxy-nexus-verizon-using-a-mac-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-unlock-root-and-install-a-custom-rom-on-a-galaxy-nexus-verizon-using-a-mac-2</link>
		<comments>http://blog.damontimm.com/how-to-unlock-root-and-install-a-custom-rom-on-a-galaxy-nexus-verizon-using-a-mac-2/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 13:39:18 +0000</pubDate>
		<dc:creator>Damon</dc:creator>
				<category><![CDATA[how to]]></category>

		<guid isPermaLink="false">http://blog.damontimm.com/?p=304</guid>
		<description><![CDATA[Purpose: unlock and root the Galazy Nexus (Verizon) using nothing but a Mac and Google&#8217;s Android SDK. We&#8217;re a Mac household (with some Linux underpinnings) and I had a hard time finding what I would call a definitive guide to approaching the task with my Galaxy Nexus (Verizon).  I had started with Droid Life’s Complete [...]]]></description>
				<content:encoded><![CDATA[<p><strong>Purpose:</strong> unlock and root the Galazy Nexus (Verizon) using nothing but a Mac and Google&#8217;s Android SDK.  We&#8217;re a Mac household (with some Linux underpinnings) and I had a hard time finding what I would call a definitive guide to approaching the task with my Galaxy Nexus (Verizon).  I had started with <a href="http://www.droid-life.com/2011/12/15/galaxy-nexus-roundup-ice-cream-sandwich-tips-bootloaders-extended-batteries-day-one-thoughts-and-more/">Droid Life’s Complete Nexus Guide</a> but it was primarily for Windows users and I couldn’t get VMWare Fusion to play nice with the Samsung driver. So: here’s how I unlocked my Galaxy Nexus (Verizon) on my Mac.  It only took Google Search and a couple hours in front of the computer and was actually really, really easy in the end.  Much easier than on the PC and much easier than any Mac guide I coud find (which all required me to download a mythical <code>fastboot</code> if I could find it. I ended up just using the “fastboot” that came from Google in the SDK.  Wee!</p>
<p><span id="more-304"></span></p>
<h3>Install the Android SDK</h3>
<p>Go to Andoird SDK and download the SDK for the Mac: <a href="http://developer.android.com/sdk/index.html">http://developer.android.com/sdk/index.html</a>.<br />
Unzip  it and move the entire folder to the Desktop. In the Mac Finder, browse to the: <code>~/Desktop/android-sdk-macosx/tools</code> folder and double click the “android” unix file (which loads the Android SDK Manager). I  checked the 4.0.3 (API15) box and followed the steps to install it.</p>
<p>Here’s what it looked like after I was done:</p>
<p><img class="aligncenter size-medium wp-image-314" title="Screen shot 2012-01-29 at 8.21.53 PM" src="http://blog.damontimm.com/wp-content/uploads/2012/01/Screen-shot-2012-01-29-at-8.21.53-PM1-650x464.png" alt="" width="650" height="464" /></p>
<h3>Enable USB Debugging and Reboot into the Bootloader</h3>
<p>You need to enable <em>USB Debugging</em> on your Galaxy Nexus.  Head over to <code>Settings&gt;Developer options&gt;USB debugging</code> and shut off phone (and said goodbye to everything on it).</p>
<h3>Unlock Using Fastboot</h3>
<p>In Terminal.app on your Mac, head into your  I went to my platform-tools folder and ran fastboot like so:</p>
<ul class="terminal">
<li><code>cd ~/Desktop/android-sdk-macosx/platform-tools</code></li>
<li><code>./adb reboot bootloader</code></li>
<li><code>./fastboot oem unlock</code></li>
</ul>
<p>Immediately after this, you should see a <code>&lt; waiting for device &gt;</code> warning.  Go ahead and plug in the phone via USB and, like magic, it should ask you if really want to unlock it.  Which you do.  Badly. </p>
<p>Using the volume keys to toggle my answer and the power button to select I updated the lock state.  (Terminal.app threw a usb_read error but it turned out to be nothing.)</p>
<p>Lastly, toggle the bootloader screen into a “start” button and reboot.  Personally, I had to wait a good period of time (did two restarts) before I was in!</p>
<h3>install custom recovery and superuser access</h3>
<p>Download the latest custom recovery file from <a href="http://www.clockworkmod.com/rommanager">clockworkmod.com</a> and a <code>su.zip</code> file (not sure where I got that actually).  With the phone running and your usb cable plugged in run:</p>
<ul class="terminal">
<li><code>./adb push su.zip /sdcard/</code></li>
<li><code>./adb reboot bootloader</code></li>
<li><code>./fastboot flash recovery recovery-clockwork-touch-6.0.2.3-toro.img</code></li>
</ul>
<p>Then boot into the recovery and install the su.zip file.  Reboot.</p>
<h3>Backup Tips and Next Steps</h3>
<p>I ended up doing this part of the process twice because the first time the mistake (as I like to call it) I made was to latch my Google account to the phone and do auto-backup and restore of settings/apps immediately after it restarted.  Not so bad if I was getting ready to use the phone &#8230; however, the next step in my journey was to make a <em>nandroid</em> backup of the stock ROM.  And I didn&#8217;t want a bloated backup.  So &#8211; if you are also planning to make your stock backup at this point, I wouldn&#8217;t let Google restore everything just yet.</p>
<p>The rest of the instructions for flashing a recovery, actually making the <em>nandroid</em> backup, and all else Galaxy Nexus can be found at <a href="http://www.droid-life.com/2011/12/15/how-to-root-the-galaxy-nexus-4g-lte-and-flash-custom-recovery-verizon/">Droid-Life</a>.  I followed these instructions exactly (except where they say copy files to the SDK&#8217;s <code>/tools</code> folder I copied them to <code>/platform-tools</code>).</p>
<p>Enjoy!  I would recommend <a href="http://forum.aokp.co/page/releases">AOKP</a> for your custom ROM.  It&#8217;s what I&#8217;m using and has been swell.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damontimm.com/how-to-unlock-root-and-install-a-custom-rom-on-a-galaxy-nexus-verizon-using-a-mac-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Install Vim 7.x Locally on Site5</title>
		<link>http://blog.damontimm.com/how-to-install-vim-7-x-locally-on-site5/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-install-vim-7-x-locally-on-site5</link>
		<comments>http://blog.damontimm.com/how-to-install-vim-7-x-locally-on-site5/#comments</comments>
		<pubDate>Sat, 30 Oct 2010 17:36:41 +0000</pubDate>
		<dc:creator>Damon</dc:creator>
				<category><![CDATA[how to]]></category>
		<category><![CDATA[site5]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://blog.damontimm.com/?p=283</guid>
		<description><![CDATA[Purpose: upgrade your Vim distribution to 7.x on your Site5 account with minimal hassle. I had tried to follow this guide initially but kept running into problems with my $VIMRUNTIME files &#8230; anyway, this method works very easily utilizing a bash script and eliminating the problems I had. a couple easy steps: Log into your [...]]]></description>
				<content:encoded><![CDATA[<p><strong>Purpose:</strong> upgrade your Vim distribution to 7.x on your <a href="http://site5.com">Site5</a> account with minimal hassle.  I had tried to follow <a href="http://forums.site5.com/showthread.php?t=16914">this guide</a> initially but kept running into problems with my <code>$VIMRUNTIME</code> files &#8230; anyway, this method works very easily utilizing <a href="http://www.vim.org/scripts/script.php?script_id=1473">a bash script</a> and eliminating the problems I had.</p>
<p><span id="more-283"></span></p>
<h2>a couple easy steps:</h2>
<p>Log into your Site5 account via ssh and follow these steps (note, the version of the script doesn&#8217;t exist anymore, try getting it <a href="http://www.vim.org/scripts/script.php?script_id=1473">here</a>):</p>
<ul class="terminal">
<li><code><del datetime="2012-03-06T02:03:56+00:00">wget http://ilerner.3b1.org/vim/vim7-install.sh</del></code></li>
<li><code>chmod +x vim7-install.sh</code></li>
<li><code>./vim7-install.sh -cache tmp/ -home</code></li>
</ul>
<p>This will install the Vim executable at <code>~/bin/vim</code>.  </p>
<p>In order for it to run in lieu of the default Vim app, make an alias at the bottom of your <code>~/.bashrc</code> file that points to it:</p>
<pre class="brush: bash;">alias vim=~/bin/vim</pre>
<p>That should be all you have to do.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damontimm.com/how-to-install-vim-7-x-locally-on-site5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How To: Store iMovie &#8217;09 Events and Projects on a Network Volume (NAS)</title>
		<link>http://blog.damontimm.com/how-to-store-imovie-09-events-and-projects-on-a-network-volume-nas/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-store-imovie-09-events-and-projects-on-a-network-volume-nas</link>
		<comments>http://blog.damontimm.com/how-to-store-imovie-09-events-and-projects-on-a-network-volume-nas/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 15:33:32 +0000</pubDate>
		<dc:creator>Damon</dc:creator>
				<category><![CDATA[how to]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[iMovie]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[nas]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.damontimm.com/?p=248</guid>
		<description><![CDATA[Purpose: while iMovie &#8217;09 allows you to store your events and projects on physically attached hard drives (external or internal) it doesn&#8217;t offer an out-of-the-box way to store them on a network attached storage (NAS) device. I have a file serve and I want to use it. how to set it up The only way [...]]]></description>
				<content:encoded><![CDATA[<p><strong>Purpose</strong>: while iMovie &#8217;09 allows you to store your events and projects on physically attached hard drives (external or internal) it doesn&#8217;t offer an out-of-the-box way to store them on a network attached storage (NAS) device.  I have a file serve and I want to use it.</p>
<p><span id="more-248"></span></p>
<h2>how to set it up</h2>
<p>The only way I have found to circumvent this annoyance is to play a little trick on iMovie.  And that trick is to move the original <code>~/Movies</code> folder under a different name and put a symlink in its place (to the network folder of your choice).</p>
<p>Here are the steps I took from the Terminal to do this (you will need to have Administrator privileges and you will need to know where your network folder is attached):</p>
<ul class="terminal">
<li><code>sudo mv ~/Movies/ ~/Movies-original</code></li>
<li><code>ln -s /Volumes/my-network-volume/Movies/ ~/Movies</code></li>
</ul>
<p>Now, when I load up iMovie it will use the networked volume.  If you don&#8217;t like this, you can always move your <code>~/Movies-original</code> folder back where it was.</p>
<h2>remaining issues</h2>
<p>Unfortunately, this isn&#8217;t a perfect fix.  There are two caveats or issues I have found.  </p>
<p>One, is that now my hard drive (called Papa Bear) is listed twice in the <em>Project Library</em>:</p>
<p><img src="http://blog.damontimm.com/wp-content/uploads/2010/04/imovie-duplicate-project-libraries.png" alt="" title="imovie-duplicate-project-libraries" width="415" height="96" class="aligncenter size-full wp-image-249" /></p>
<p>And two, is that when you delete an event or project from within iMovie, it moves the project into a temporary folder rather than actually deleting it.  The next time you open iMovie, it will show up again.  I&#8217;m sure this is because it <em>thinks</em> it is working with a bona fide Trash system but its not (because it is network storage.  See this example:</p>
<p><img src="http://blog.damontimm.com/wp-content/uploads/2010/04/imovie-temporary-folders.png" alt="" title="imovie-temporary-folders" width="423" height="93" class="aligncenter size-full wp-image-250" /></p>
<p>In order to get around this annoyance, I created a Python script which removes the temporary files for me and created a cron job to run the script from time to time (cleaning up the mess iMovie leaves behind).</p>
<pre class="brush: python; gutter: true;">#!/usr/bin/env python
'''
Simple script to remove all directories that match the name:
    /iMovie Temporary Items */  [note the star!]

'''
import os
import fnmatch
import shutil

# tuple of directories to search through (you can add more than one)
DIRS = ('/Volumes/leaker-damon/tps/Videos/',)

for directory in DIRS:
    for root, dirnames, filenames in os.walk(directory):
        for directory in dirnames:
            if fnmatch.fnmatch(directory,'iMovie Temporary Items *'):
                shutil.rmtree(os.path.join(root,directory))</pre>
<h2>make this more better</h2>
<p>Am interested to hear how other people have been handling this &#8212; this approach certainly isn&#8217;t perfect, but it seems to work (for now).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damontimm.com/how-to-store-imovie-09-events-and-projects-on-a-network-volume-nas/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Script: clean_bzip &#8211; a command line program for clean directory compression</title>
		<link>http://blog.damontimm.com/python-script-clean-bzip/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=python-script-clean-bzip</link>
		<comments>http://blog.damontimm.com/python-script-clean-bzip/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 14:01:05 +0000</pubDate>
		<dc:creator>Damon</dc:creator>
				<category><![CDATA[scripts]]></category>
		<category><![CDATA[bzip2]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://blog.damontimm.com/?p=237</guid>
		<description><![CDATA[A simple command-line python utility that compresses a directory (or directories) and excludes certain unwanted files. As a self-taught Python user I am still looking for insight on the most pythonic and programmatically-friendly way of accomplishing a given task. In this case, I have written a script that will perform a &#8220;clean bzip2&#8243; of a [...]]]></description>
				<content:encoded><![CDATA[<p>A simple command-line python utility that compresses a directory (or directories) and excludes certain unwanted files.</p>
<p><span id="more-237"></span></p>
<p>As a self-taught Python user I am still looking for insight on the most pythonic and programmatically-friendly way of accomplishing a given task.  In this case, I have written a script that will perform a &#8220;clean bzip2&#8243; of a directory (or directories).  Mac OS X (via AFP and netatalk, in my case) tends leaves a bunch of ugly files/directories hanging around and I would rather not include them in my compressed tar file.</p>
<p>In writing the script, though, I ran into some questions and I am not sure what the recommended approach would be. The script works, as it is, but I feel its a little hacked together and also a little limited in its application.   There is something to be said for programs that &#8220;just work&#8221; (this does) but I want to take it a little further as an educational endeavor and would like it to appear robust, future-thinking, and pythonic.</p>
<p>My initial questions are:</p>
<ol>
<li><del datetime="2010-04-02T10:58:26+00:00">Is there a better way to implement a <code>--quiet</code> flag?</del> [using <code>logging</code>]</li>
<li>I am not very clear on the use of Exceptions (or even if I am using it in a good way here) &#8212; is what I have done the right approach? </li>
<li>Finally, in general: any feedback on how to improve this?  (I am thinking, just now, that the script is only suitable for a command line usage, and couldn&#8217;t be imported by another script, for example.)</li>
</ol>
<p>Any feedback is greatly appreciated.  Writing a script like this is a good learning tool (for me, at least).</p>
<pre class="brush: python;">#! /usr/bin/env python

'''Script to perform a "clean" bzip2 on a directory (or directories).  Removes
extraneous files that are created by Apple/AFP/netatalk before compressing.
'''

import os
import tarfile
import logging
from optparse import OptionParser

# Default files and directories to exclude from the bzip tar
IGNORE_DIRS = ('.AppleDouble',)
IGNORE_FILES = ('.DS_Store',)

class DestinationTarFileExists(Exception):
    '''If the destination tar.bz2 file already exists.'''

def ignore_walk(directory, ignore_dirs=None, ignore_files=None):
    '''Ignore defined files and directories when doing the walk.'''

    # TODO: this does not currently take wild cards into account.  For example,
    # if you wanted to exclude *.pyc files ... should fix that.  Perhaps
    # consider moving this entirely into the below function (or making it more
    # reusable for other apps).
    for dirpath, dirnames, filenames in os.walk(directory):
        if ignore_dirs:
            dirnames[:] = [dn for dn in dirnames if dn not in ignore_dirs]
        if ignore_files:
            filenames[:] = [fn for fn in filenames if fn not in ignore_files]
        yield dirpath, dirnames, filenames

def tar_bzip2_directory(directory, ignore_dirs=IGNORE_DIRS,
                                   ignore_files=IGNORE_FILES ):
    '''Takes a directory and creates a tar.bz2 file (based on the directory
    name).  You can exclude files and sub-directories as desired.'''

    file_name = '-'.join(directory.split(' '))
    tar_name = file_name.replace('/','').lower() + ".tar.bz2"
    
    if os.path.exists(tar_name):
        msg = ("The file %s already exists. " + 
                "Please move or rename it and try again.") % tar_name
        raise DestinationTarFileExists(msg)
    
    tar = tarfile.open(tar_name, 'w:bz2')

    for dirpath, dirnames, filenames in ignore_walk(directory, ignore_dirs,
            ignore_files):
        for file in filenames:
            logging.info(os.path.join(dirpath, file))
            tar.add(os.path.join(dirpath, file))

    tar.close()

def main(args=None, callback=None):
    directories = []

    for arg in args:
        if os.path.isdir(arg):
            directories.append(arg)
        else:
            logging.ERROR("Ingoring: %s (it's not a directory)." % arg)

    for dir in directories:
        try:
            tar_bzip2_directory(dir)
        except DestinationTarFileExists, e:
            print e

if __name__ == "__main__":

    parser = OptionParser(usage="%prog [options: -q ] [dir1] [...dir2]")
    parser.add_option("-q", "--quiet", action="store_true", dest="quiet")
    options, args = parser.parse_args()

    if options.quiet:
        logging.basicConfig(level=logging.ERROR, format='%(message)s')
    else:
        logging.basicConfig(level=logging.INFO, format='%(message)s')

    main(args)</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.damontimm.com/python-script-clean-bzip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>django-hitcount: simple app to count hits/views for an object</title>
		<link>http://blog.damontimm.com/django-hitcount-app-count-hits-views/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=django-hitcount-app-count-hits-views</link>
		<comments>http://blog.damontimm.com/django-hitcount-app-count-hits-views/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 01:10:38 +0000</pubDate>
		<dc:creator>Damon</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.damontimm.com/?p=201</guid>
		<description><![CDATA[django-hitcount: a simply django application that allows you to count hits/views on a per object basis. This app came about as an answer to my own question at stackoverflow.com. Am hoping that others will find it useful. March 2011 Update: I haven&#8217;t done much with this in the past few months and there are some [...]]]></description>
				<content:encoded><![CDATA[<p><strong>django-hitcount</strong>: a simply django application that allows you to count hits/views on a per object basis.  This app came about as an answer to <a href="http://stackoverflow.com/questions/1603340/track-the-number-of-page-views-or-hits-of-an-object">my own question</a> at stackoverflow.com.  Am hoping that others will find it useful.</p>
<p><span id="more-201"></span></p>
<p><em>March 2011 Update:</em> I haven&#8217;t done much with this in the past few months and there are some good changes/forks out there that need to be merged.  Sorry for the delays.  I intend to update it in April when I finally have some free time to work on it again.  Thanks for all your input and ideas and changes. -Damon</p>
<p>This isn&#8217;t meant to be a full-fledged tracking application (see django-tracking) or a real analytic tool (try Google Analytics); rather, it&#8217;s meant to simply count the number of hits/view on an object-per-object basis.  </p>
<h2>How to install:</h2>
<p>I find that the easiest way to work with django apps is to symbolically link them to my <code>site-packages</code> directory.  It&#8217;s easier to update the apps with svn, git, or hg than it is to manually download the files and install by hand.</p>
<p>For me, this is what it looks like (you can cut and paste to make it easy):</p>
<ul class="terminal">
<li><code>cd ~/src</code></li>
<li><code>git clone git://github.com/thornomad/django-hitcount.git</code></li>
<li><code>sudo ln -s `pwd`/django-hitcount/hitcount `python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`/hitcount</code></li>
</ul>
<p>Test it works by loading python and checking the version (should not get an error):</p>
<pre class="brush: python;">
>>> import hitcount
>>> hitcount.__version__
'0.1 alpha'
>>></pre>
<h2>Adding to your django project:</h2>
<p>Add the <code>hitcount</code> app to your <code>INSTALLED_APPS</code> tuple and run <code>syncdb</code>.  </p>
<p>There are three additional settings you can add to your <code>settings.py</code> file:</p>
<pre class="brush: python;">HITCOUNT_KEEP_HIT_ACTIVE = { 'days': 7 }
HITCOUNT_HITS_PER_IP_LIMIT = 0
HITCOUNT_EXCLUDE_USER_GROUP = ( 'Editor', )</pre>
<p><code><strong>HITCOUNT_KEEP_HIT_ACTIVE</strong></code>: is the number of days, weeks, months, hours, etc (timedelta kwargs), that an Hit is kept &#8216;active&#8217;.  If a Hit is &#8216;active&#8217; a repeat viewing will not be counted.  After the active period ends, however, a new Hit will be recorded.  You can decide how long you want this period to last &#8230;</p>
<p><code><strong>HITCOUNT_HITS_PER_IP_LIMIT</strong></code>: limit the number of &#8216;active&#8217; hits from a single IP address.  <code>0</code> means that it is unlimited.  You may want to set this, or not.  </p>
<p><code><strong>HITCOUNT_EXCLUDE_USER_GROUP</strong></code>: don&#8217;t count any hits from certain logged in users.  In the example above, I don&#8217;t want any of my editors inflating the total Hit count.</p>
<h2>Adding to your <code>urls.py</code>:</h2>
<p>You need to add one line to your <code>urls.py</code> file.  </p>
<p>You can have this url, itself, point to anywhere you like, but you need to keep the <code>name='hitcount_update_ajax'</code> constant.  </p>
<pre class="brush: python; gutter: true;">from django.conf.urls.defaults import *
from django.views.generic.list_detail import object_detail
from hitcount.views import update_hit_count_ajax

urlpatterns = patterns('',
    url(r'^ajax/hit/$', # you can change this url if you would like
        update_hit_count_ajax,
        name='hitcount_update_ajax'), # keep this name the same

    # other views, for example my object view is:

    url(r'^/video/(?P&lt;object_id>\d+)$', object_detail,
        {   'queryset': Video.objects.all(),
            'template_name': "video/view.html"},
            name='video_detail_view'),

)</pre>
<h2>Edit your templates</h2>
<p>Add the javascript to your <code>object_detail</code> templates (or any template that handles a single object) so that our hit counter is called after the document loads.  </p>
<p>Here is what my <code>head</code> includes:</p>
<pre class="brush: html;">{% load hitcount_tags %}
&lt;script src="/media/js/jquery-latest.js" type="text/javascript">&lt;/script>
&lt;script type="text/javascript">&lt;!--
    $(document).ready(function() {
        {% get_hit_count_javascript for object %}
    });
-->&lt;/script></pre>
<p>When the template is rendered, it should turn into something like this:</p>
<pre class="brush: js;"> 
$(document).ready(function() {

$.post( '/ajax/hit/',
	{ hitcount_pk : '3' },
	function(data, status) {
		if (data.status == 'error') {
			// do something for error?
		}
	},
	'json');

});</pre>
<h2>Display the hits!</h2>
<p>The most exciting part, is actually displaying your hits.  There are four different ways to do it:</p>
<pre class="brush: text;">    - Return total hits for an object: 
      {% get_hit_count for [object] %}
    
    - Get total hits for an object as a specified variable:
      {% get_hit_count for [object] as [var] %}
    
    - Get total hits for an object over a certain time period:
      {% get_hit_count for [object] within ["days=1,minutes=30"] %}

    - Get total hits for an object over a certain time period as a variable:
      {% get_hit_count for [object] within ["days=1,minutes=30"] as [var] %}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.damontimm.com/django-hitcount-app-count-hits-views/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>Replacing the Capacitors on my Netgear GS108</title>
		<link>http://blog.damontimm.com/replacing-the-capacitors-on-my-netgear-gs108/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=replacing-the-capacitors-on-my-netgear-gs108</link>
		<comments>http://blog.damontimm.com/replacing-the-capacitors-on-my-netgear-gs108/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 22:06:54 +0000</pubDate>
		<dc:creator>Damon</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[diy]]></category>
		<category><![CDATA[gs108]]></category>

		<guid isPermaLink="false">http://blog.damontimm.com/?p=193</guid>
		<description><![CDATA[I got back from vacation recently and found that my Netgear GS108 gigabit switch had died &#8212; or rather, it was flashing green lights at me left and right and &#8212; even worse &#8212; very inconsistenly, at that. Sometimes off, sometimes on &#8230; didn&#8217;t seem to matter what machines were plugged in. Of course, I [...]]]></description>
				<content:encoded><![CDATA[<p>I got back from vacation recently and found that my Netgear GS108 gigabit switch had died &#8212; or rather, it was flashing green lights at me left and right and &#8212; even worse &#8212; very inconsistenly, at that.  Sometimes off, sometimes on &#8230; didn&#8217;t seem to matter what machines were plugged in.</p>
<p><span id="more-193"></span></p>
<p>Of course, I googled it and found this <a href="http://qualapps.blogspot.com/2007/05/netgear-gs108-gige-switch-failure.html">post by Jim Beveridge</a> &#8212; inside the comments were a suggestion to replace the capacitors.  So, I set about doing it.  I needed to replace the green ones (see image) and got everything at RadioShack.  Cost less than $20 (and I had to buy a soldering iron).</p>
<p><img class="aligncenter size-full wp-image-195" title="gs108-before" src="http://blog.damontimm.com/wp-content/uploads/2009/03/gs108-before.png" alt="gs108-before" width="500" height="330" /></p>
<p>So, out went the green ones (which were bulging) and in went the jumbo-sized RadioShack ones (I would recommend buying them online so they actually fit, but hey: I take what I can get).</p>
<p><img class="aligncenter size-full wp-image-194" title="gs108-after" src="http://blog.damontimm.com/wp-content/uploads/2009/03/gs108-after.png" alt="gs108-after" width="500" height="335" /></p>
<p>Case top won&#8217;t fit but a little masking tape did the trick and back to the basement it went &#8212; working like a charm!  Would have cost less than $5 if I had my own soldering iron &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damontimm.com/replacing-the-capacitors-on-my-netgear-gs108/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Server: AMD 4850e with RAID 5</title>
		<link>http://blog.damontimm.com/new-server-amd-4850e-raid-5/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=new-server-amd-4850e-raid-5</link>
		<comments>http://blog.damontimm.com/new-server-amd-4850e-raid-5/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 17:25:44 +0000</pubDate>
		<dc:creator>Damon</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[amd]]></category>

		<guid isPermaLink="false">http://blog.damontimm.com/?p=174</guid>
		<description><![CDATA[Well: the time finally came for me to bite the bullet and buy a new home server. This new machine is replacing my circa 1999 Dell Pentium III 550mhz box that has been running, faithfully I might add, in my basement for the last couple of years as a NAS.  It will also replace the [...]]]></description>
				<content:encoded><![CDATA[<p>Well: the time finally came for me to bite the bullet and buy a new home server. This new machine is replacing my circa 1999 Dell Pentium III 550mhz box that has been running, faithfully I might add, in my basement for the last couple of years as a NAS.  It will also replace the laptop with the broken screen in the basement, which has been serving as my web server.  Since: my file transfer speeds were so appalling (~10MB/s), I am running out of hard drive space, <em>and</em> the box sounds like it is ready to take off at any moment (I don&#8217;t think there are any ball bearings left) I thought it prudent to bit the bullet and get a new server.</p>
<p><span id="more-174"></span></p>
<p>Since this will be used mainly to store my files and do web development, I went with something cheap and, as much as possible, power efficient.  Here&#8217;s what I ended up with:</p>
<ul>
<li>Processor: <a title="View at Amazon.com" href="http://www.amazon.com/exec/obidos/ASIN/B0017K9F44/blog.damontimm.com-20" target="_blank">AMD 4850e</a>  (2.5ghz Dual-Processor, 45Watt)</li>
<li>Motherboard: ECS A780GM-A AM2+ (780G)</li>
<li>Memory: 4gb DDR-800</li>
<li>Hard Drives: 3x Western Digital 1TB &#8220;Green Power&#8221; (<a title="View at Amazon.com" href="http://www.amazon.com/exec/obidos/ASIN/B001IEZX3G/blog.damontimm.com-20" target="_blank">WD10EADS</a>)</li>
<li>Power Supply: Antec 380 Watts Earth Power Supplies (<a title="View at Amazon.com" href="http://www.amazon.com/exec/obidos/ASIN/B000KQ3QQY/blog.damontimm.com-20" target="_blank">EA380</a>)</li>
</ul>
<p>I am still waiting for the new hard drives to arrive (should be here today) &#8212; but so far, so good!  Hope to benchmark some power consumption as well as hard drive performance when I have the chance.  And also, get a virtual machine up and running for the web server so I can get rid of the two computers in my basement and just run one.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damontimm.com/new-server-amd-4850e-raid-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Test Connection Speed Between Two Machines</title>
		<link>http://blog.damontimm.com/how-to-test-connection-speed-between-two-machines/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-test-connection-speed-between-two-machines</link>
		<comments>http://blog.damontimm.com/how-to-test-connection-speed-between-two-machines/#comments</comments>
		<pubDate>Sun, 25 Jan 2009 14:58:26 +0000</pubDate>
		<dc:creator>Damon</dc:creator>
				<category><![CDATA[how to]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[nas]]></category>
		<category><![CDATA[nc]]></category>
		<category><![CDATA[pv]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.damontimm.com/?p=166</guid>
		<description><![CDATA[Purpose: as a quick diagnostic tool, sometimes it&#8217;s nice to know exactly how fast two machines can (theoretically) be connected.  I was having some slow downs on my NAS and using these command line tools, was able to determine that it was my NIC (and not my hard drives) that was causing the slow down.  [...]]]></description>
				<content:encoded><![CDATA[<p>Purpose: as a quick diagnostic tool, sometimes it&#8217;s nice to know exactly how fast two machines can (theoretically) be connected.  I was having some slow downs on my NAS and using these command line tools, was able to determine that it was my NIC (and not my hard drives) that was causing the slow down.  I learned this from a <a href="http://tech.slashdot.org/comments.pl?sid=1064679&amp;cid=26139847" target="_blank">thread at slashdot</a>. </p>
<p><span id="more-166"></span></p>
<h3>install nc and pv</h3>
<p>If you are on a mac, you can use <a href="http://blog.damontimm.com/how-to-install-macports-on-os-x-leopard-105/">MacPorts</a> to install this easily enough:</p>
<ul class="terminal">
<li><code>$ sudo port install netcat pv</code></li>
</ul>
<p>If you are on Ubuntu, you just need to get <code>pv</code> installed (<code>nc</code> is already there):</p>
<ul class="terminal">
<li><code>$ sudo aptitude install pv</code></li>
</ul>
<p>Once you have <code>nc</code> and <code>pv</code> installed, it&#8217;s really simple.  On one machine, run the following command:</p>
<ul class="terminal">
<li><code>$ nc -ulp 5000 &gt; /dev/null</code></li>
</ul>
<p>On the second machine run the following command (you need the IP address of the first machine):</p>
<ul class="terminal">
<li><code>$ pv &lt; /dev/zero | nc -u ip.addy.of.other.machine 5000</code></li>
</ul>
<p>And you should get some output with a little &lt;=&gt; sign moving across the screen that resembles this (static):</p>
<pre class="brush: text;">1.15GB 0:00:19 [ 218MB/s] [             &lt;=&gt;                  ]</pre>
<p>This will show you the number of MB/s the connection is averaging; if you watch if for a bit, you can get an idea of where things stand.  Here are some of the results I got between my PowerMac, PowerBook, and EEE PC:</p>
<pre class="brush: text;">localhost:                      218MB/s
gigabit Ethernet:               143MB/s
100MB ethernet:                 11.5MB/s
wireless (poor connection):     141kB/s</pre>
<p>If you read the <a href="http://tech.slashdot.org/comments.pl?sid=1064679&amp;cid=26139847">original post on slashdot</a>, it seems you can us pv to measure a lot of other stuff as well &#8212; I haven&#8217;t played with it yet but should, one day.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damontimm.com/how-to-test-connection-speed-between-two-machines/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To: Automated Encrypted Incremental Backups on Amazon S3 with Duplicity (OS X or Ubuntu)</title>
		<link>http://blog.damontimm.com/how-to-automated-secure-encrypted-incremental-backups-amazon-s3-duplicity-os-x-or-ubuntu/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-automated-secure-encrypted-incremental-backups-amazon-s3-duplicity-os-x-or-ubuntu</link>
		<comments>http://blog.damontimm.com/how-to-automated-secure-encrypted-incremental-backups-amazon-s3-duplicity-os-x-or-ubuntu/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 22:26:46 +0000</pubDate>
		<dc:creator>Damon</dc:creator>
				<category><![CDATA[how to]]></category>
		<category><![CDATA[amazon s3]]></category>
		<category><![CDATA[duplicity]]></category>
		<category><![CDATA[gpg]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.damontimm.com/?p=107</guid>
		<description><![CDATA[Purpose: setup an automatic encrypted off-site backup system that utilizes Amazon S3 with incremental backups by duplicity on the Mac (Leopard) or Ubuntu. Currently, I do have my own on-site backup system in place (nightly backups via rsync to external hard drive), but I am wary that some day my house may explode and I&#8217;ll [...]]]></description>
				<content:encoded><![CDATA[<p><strong>Purpose:</strong> setup an automatic encrypted off-site backup system that utilizes Amazon S3 with incremental backups by <a href="http://duplicity.nongnu.org/">duplicity</a> on the Mac (Leopard) or Ubuntu. Currently, I do have my own on-site backup system in place (nightly backups via rsync to external hard drive), but I am wary that some day my house may explode and I&#8217;ll have nothing left. Enter my new friend: the encrypted off-site backup.</p>
<p><span id="more-107"></span></p>
<h2>before you begin</h2>
<p>Before you can start backing things up off-site in a secure fashion, you&#8217;ll need to get a few pieces of the puzzle in place. Namely, you&#8217;ll need software installed (duplicity), a GPG key (for encryption), and an <a href="http://aws.amazon.com/s3/">Amazon S3 </a>account setup (for storage), and then use <a href="http://blog.damontimm.com/bash-script-incremental-encrypted-backups-duplicity-amazon-s3/">a backup script</a> that can be run automatically (for laziness&#8217;s sake!).</p>
<p>Getting an Amazon S3 account is easy to do: head over to <a href="http://aws.amazon.com/s3/">http://aws.amazon.com/s3/</a> and sign up; grab your &#8220;Access Key ID&#8221; and &#8220;Secret Access Key&#8221; and you are ready to go. There is a lot you can do with S3 (and a lot of ways to access it), but for our purposes, this is pretty much all you need.</p>
<p>Lastly, I would recommend spending a little time reading about duplicity (<a href="http://duplicity.nongnu.org/duplicity.1.html">see the man page</a>) as well as GnuPG (<a href="http://gnupg.org/documentation/manuals/gnupg/">man page</a>). There is a lot to consider, and I just picked the options I thought would work best for me.</p>
<h2>Install the Software: Duplicity</h2>
<p>For this to work we need duplicity installed with all the correct dependencies. The easiest way to do this on your Mac is to simply use <a href="http://www.macports.org/">MacPorts</a>, which has an up-to-date version in the repositories (<em>see</em> <a href="http://http://blog.damontimm.com/how-to-install-macports-on-os-x-leopard-105/">Installing MacPorts</a> if you don&#8217;t have it installed already). If you already have MacPorts installed, all you should have to do is run the following from the Terminal:</p>
<ul class="terminal">
<li><code>$ sudo port install duplicity py25-socket-ssl py25-boto</code></li>
</ul>
<p>If you are using Ubuntu, you could simply run <code>sudo aptitude install duplicity</code> to install the program (it is in the repositories); however, if you want to make sure you are using the <a href="http://savannah.nongnu.org/download/duplicity/" target="_blank">latest version</a> (which may not be available there yet), you can try this:</p>
<ul class="terminal">
<li><code>$ sudo apt-get build-dep duplicity</code></li>
<li><code>$ sudo aptitude install python-boto ncftp </code></li>
<li><code>$ wget http://savannah.nongnu.org/download/duplicity/duplicity-0.5.07.tar.gz</code></li>
<li><code>$ tar xvzf duplicity-0.5.07.tar.gz</code></li>
<li><code>$ cd duplicity-0.5.07/</code></li>
<li><code>$ sudo python setup.py install</code></li>
</ul>
<p>If you ever want to upgrade again, just download and untar the latest version and run the last setup line again.  It will install the newest version for you.</p>
<p>If everything has installed correctly, you can do a test run pretty easily on your local machine by backing up a folder to another local folder (first command) and then restoring it to a different folder (second command). If you look inside this <code>/test/backup-location/</code> you&#8217;ll see what duplicity looks like:</p>
<ul class="terminal">
<li><code>$ duplicity --no-encryption /test/folder/ file:///test/backup-location/</code></li>
<li><code>$ duplicity --no-encryption file:///test/backup-location/ /test/restore-location/</code></li>
</ul>
<h2>Setting Up Encryption</h2>
<p>For duplicity to really shine, it needs to have a gpg key to encrypt your files. If you don&#8217;t already have one, you can create it by running the following (read the <a href="http://www.gnupg.org/gph/en/manual.html#AEN26">documentation</a> for more information):</p>
<ul class="terminal">
<li><code>$ gpg --gen-key</code></li>
</ul>
<p>I used all the defaults when setting up my key and chose my own passphrase. Unfortunately, in order to make this work without user input (as an automatic cron job), the passphrase is going to have to be stored somewhere on your computer locally, so, I wouldn&#8217;t use one of your usual passwords (something really long and unique would be better).  Also, if you <em>already</em> have a gpg key (or want to use one for other purposes), I would recommend making a <em>different</em> one for the Amazon S3 backups &#8212; because, in the end, your password has to be stored somewhere on your computer for it to work auto-<em>magically</em>.</p>
<p>Once you have your gpg key created you can check it out by running:</p>
<ul class="terminal">
<li><code>$ gpg --list-keys</code></li>
</ul>
<p>This shows your new key, which probably looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">pub   1024D/CA4ZA320 2008-11-15
uid                  Damon Timm (thornomad) email@example.com
sub   2048g/C1E64A4F 2008-11-15</pre></div></div>

<p>Note the public key identifier &#8220;CA4FA320&#8243; (yours will be different); we will need that to go in our script.</p>
<h2>final step: using a backup script</h2>
<p>So, everything is on your system and, hopefully, working.  Now, to run a backup takes a lot of typing (on the command line) and the easiest way to avoid this chore is to run a backup script.  A script can store your Amazon and GPG key information and make it so you don&#8217;t have to type anything ever again!</p>
<p>Backing things up is a very personal task, and everyone is going to want to do it a little differently.  I created <a href="http://blog.damontimm.com/bash-script-incremental-encrypted-backups-duplicity-amazon-s3/">my own backup script</a> which you are happy to check out &#8212; if you have any neat features you add to suggestions, I would love to hear them and incorporate them.</p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damontimm.com/how-to-automated-secure-encrypted-incremental-backups-amazon-s3-duplicity-os-x-or-ubuntu/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Bash Script: Incremental Encrypted Backups with Duplicity (Amazon S3)</title>
		<link>http://blog.damontimm.com/bash-script-incremental-encrypted-backups-duplicity-amazon-s3/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=bash-script-incremental-encrypted-backups-duplicity-amazon-s3</link>
		<comments>http://blog.damontimm.com/bash-script-incremental-encrypted-backups-duplicity-amazon-s3/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 21:47:18 +0000</pubDate>
		<dc:creator>Damon</dc:creator>
				<category><![CDATA[scripts]]></category>
		<category><![CDATA[amazon s3]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[duplicity]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[s3cmd]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.damontimm.com/?p=131</guid>
		<description><![CDATA[Update (5/6/12): I have not been actively developing this script lately. Zertrin has stepped up to take over the reins and offers a up-to-date and modified version with even more capabilities. Check it out over at github. This bash script was designed to automate and simplify the remote backup process of duplicity on Amazon S3. [...]]]></description>
				<content:encoded><![CDATA[<p>Update (5/6/12): I have not been actively developing this script lately.  <a href="http://blog.damontimm.com/bash-script-incremental-encrypted-backups-duplicity-amazon-s3/comment-page-2/#comment-75061">Zertrin has stepped up</a> to take over the reins and offers a up-to-date and modified version with even more capabilities.  Check it out <a href="https://github.com/zertrin/duplicity-backup">over at github</a>.</p>
<p>This bash script was designed to automate and simplify the remote backup process of duplicity on Amazon S3.  After your script is configured, you can easily backup, restore, verify and clean (either via cron or manually) your data without having to remember lots of different command options and passphrases.</p>
<p>Most importantly, you can easily backup the script and your gpg key in a convenient passphrase-encrypted file.  This comes in in handy if/when your machine ever does go belly up.  <a href="http://github.com/thornomad/dt-s3-backup">Code is hosted at github</a>.</p>
<p><span id="more-131"></span></p>
<h2>how to use</h2>
<p>To get the latest latest code in the script you can <a href="http://github.com/thornomad/dt-s3-backup/zipball/master">download a zip copy of the source</a> or clone the git repository like so:</p>
<ul class="terminal">
<li><code>git clone git://github.com/thornomad/dt-s3-backup.git</code></li>
</ul>
<p>You&#8217;ll also need to have a number of things in place in order to utilize this script, specifically: <a href="http://www.gnupg.org/">gpg</a>, <a href="http://www.nongnu.org/duplicity/">duplicity</a>, an <a href="http://aws.amazon.com/s3/">Amazon S3 account</a>, and (optionally) <a href="http://s3tools.org/s3cmd">s3cmd</a>.  If you need help getting all these in order, I wrote <a title="Check it out" href="http://blog.damontimm.com/how-to-automated-secure-encrypted-incremental-backups-amazon-s3-duplicity-os-x-or-ubuntu/">another post</a> about putting it all together.  It&#8217;s not all that difficult, but does take a few pieces of the puzzle to be in order.</p>
<p>Once you have the script, you will need to fill out the <strong>foobar</strong> variables with your own specific information.  I suggest testing the script on a small directory of files and a local directory for your destination first to make sure it is working.</p>
<h2>Usage</h2>
<p>From the README file:</p>
<pre class="brush: text;">COMMON USAGE EXAMPLES
=====================

* View help:
    $ dt-s3-backup.sh

* Run an incremental backup:
	$ dt-s3-backup.sh --backup

* Force a one-off full backup:
    $ dt-s3-backup.sh --full

* Restore your entire backup:
	$ dt-s3-backup.sh --restore 
    You will be prompted for a restore directory

	$ dt-s3-backup.sh --restore /home/user/restore-folder
    You can also provide a restore folder on the command line.

* Restore a specific file in the backup:
    $ dt-s3-backup.sh --restore-file
    You will be prompted for a file to restore to the current directory

    $ dt-s3-backup.sh --restore-file img/mom.jpg
    Restores the file img/mom.jpg to the current directory

    $ dt-s3-backup.sh --restore-file img/mom.jpg /home/user/i-love-mom.jpg
    Restores the file img/mom.jpg to /home/user/i-love-mom.jpg

* List files in the remote archive
	$ dt-s3-backup.sh --list-current-files

* Verify the backup
    $ dt-s3-backup.sh --verify

* Backup the script and gpg key (for safekeeping)
    $ dt-s3-backup.sh --backup-script</pre>
<h2>Changes</h2>
<p>You can view the changelog at github.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damontimm.com/bash-script-incremental-encrypted-backups-duplicity-amazon-s3/feed/</wfw:commentRss>
		<slash:comments>176</slash:comments>
		</item>
	</channel>
</rss>
