<?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 &#187; blog</title>
	<atom:link href="http://blog.damontimm.com/category/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.damontimm.com</link>
	<description>Where I go to remember what I did</description>
	<lastBuildDate>Fri, 16 Jul 2010 18:51:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<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/</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. This isn&#8217;t meant to be a full-fledged tracking application (see django-tracking) or a real analytic tool (try Google [...]]]></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>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 two 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>13</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/</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/</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>Welcome to the blog</title>
		<link>http://blog.damontimm.com/welcome-to-the-blog/</link>
		<comments>http://blog.damontimm.com/welcome-to-the-blog/#comments</comments>
		<pubDate>Mon, 09 Oct 2006 22:35:34 +0000</pubDate>
		<dc:creator>Damon</dc:creator>
				<category><![CDATA[blog]]></category>

		<guid isPermaLink="false">http://www.damontimm.com/blog/2006/welcome-to-the-blog/</guid>
		<description><![CDATA[Hello and welcome to the blog at damontimm.com. If you have been paying close attention, you will surely have noticed that this is my second blog (in celebration of my two readers). Though much has changed in the year since I first stepped off the boat with damonjustisntfunny.com, one matter has not: I still fear [...]]]></description>
			<content:encoded><![CDATA[<p>Hello and welcome to the blog at <a href="http://www.damontimm.com">damontimm.com</a>.</p>
<p>If you have been paying close attention, you will surely have noticed that this is my second blog (in celebration of my two readers).  Though much has changed in the year since I first stepped off the boat with <a href="http://www.damonjustisntfunny.com">damonjustisntfunny.com</a>, one matter has not: I still <a href="http://www.damonjustisntfunny.com/blog/first-post-fears/">fear for my first post</a> &#8212; such that it is &#8212; and what it all will represent many years from now and how it will, certainly, be a poor attempt at anything.</p>
<p>What to say?  How to say it?  How to explain in so few words what fewer people will ever read?</p>
<p>This blog serves a distinct purpose (unlike the witticisms and clever prose from my first one): a place for me to document all the little things I learn in front of the computer and then immediately forget and have to re-learn again.  Posting my wanderings here, I hope, will shorten the re-learning process.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damontimm.com/welcome-to-the-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
