<?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>Hampson.ca</title>
	<atom:link href="http://www.hampson.ca/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hampson.ca</link>
	<description></description>
	<lastBuildDate>Fri, 09 Jul 2010 13:02:50 +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>Port Forward via Tunnel in PuTTY</title>
		<link>http://www.hampson.ca/blog/2010/07/08/port-forward-via-tunnel-in-putty/</link>
		<comments>http://www.hampson.ca/blog/2010/07/08/port-forward-via-tunnel-in-putty/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 18:45:46 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
		
		<guid isPermaLink="false">http://www.hampson.ca/?p=41</guid>
		<description><![CDATA[Okay so today were going to take a look at a great feature of PuTTY that maybe some of you may not have been aware of. Port forwarding of a remote machine through a secure SSH tunnel. There are many reasons for doing this the main being it is secure. Everything over SSH is encrypted [...]]]></description>
			<content:encoded><![CDATA[<p>Okay so today were going to take a look at a great feature of PuTTY that maybe some of you may not have been aware of. Port forwarding of a remote machine through a secure SSH tunnel. There are many reasons for doing this the main being it is secure. Everything over SSH is encrypted that is why doing things via SSH takes little bit longer than with lets say an FTP connection, or a Telnet session. Another reason might be is a service your wanting to use on the remote machine is not being forwarded through the router.</p>
<p>With all the this in mind lets begin the tutorial&#8230;</p>
<ol>
<li> Open PuTTY. If your using a connection that is saved highlight it and select &#8216;Load&#8217;. Otherwise fill in the usual connection info. (Host Name, and Port).</li>
<li> Go to the left in the &#8216;Category&#8217; window and click the &#8216;+&#8217; sign next SSH. You should see the sub menu &#8216;Tunnels&#8217; click on it.</li>
<li> Now you should see two empty fields that say &#8216;Source Port&#8217; and &#8216;Destination&#8217;.</li>
<p>In &#8216;Source Port&#8217; your going to enter a random unused port number say &#8217;8806&#8242; (Eventually you are going to enter that port number in the client software connection info).</p>
<p>In &#8216;Destination&#8217; you are going to put &#8217;127.0.0.1:3306&#8242; or &#8216;localhost:3306&#8242; (Sub out 3306 for the actual listening port of the server your trying to connect to in this case I am using MySQL).</p>
<li>Click &#8216;Add&#8217;.</li>
<li>Click &#8216;Open&#8217; at the bottom.</li>
</ol>
<p>If it works PuTTY will connect as normal, make sure you login.</p>
<p>Now to test it out you open the client software I will be using MySQL Administrator in my case. Enter &#8217;8806&#8242; in the port number and in the host information make sure you enter &#8217;127.0.0.1&#8242; or &#8216;localhost&#8217;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hampson.ca/blog/2010/07/08/port-forward-via-tunnel-in-putty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing GD2 on Linux and Windows</title>
		<link>http://www.hampson.ca/blog/2010/03/28/installing-gd2-linux-and-windows/</link>
		<comments>http://www.hampson.ca/blog/2010/03/28/installing-gd2-linux-and-windows/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 03:11:04 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
		
		<guid isPermaLink="false">http://newblog.hampson.ca/?p=20</guid>
		<description><![CDATA[If you have received this error: &#8220;PHP: GD2 Not installed:&#124;&#124; File and or directory is invalid&#8221; Than your at the right place&#8230; You may be wondering what GD2 is… the official explanation is this:“GD is an open source code library for the dynamic creation of images by programmers.” The reason you are getting this error is most likely because have not [...]]]></description>
			<content:encoded><![CDATA[<p>If you have received this error: <span class="caps">&#8220;PHP</span>: <span class="caps">GD2</span> Not installed:|| File and or directory is invalid&#8221;</p>
<p>Than your at the right place&#8230;</p>
<p>You may be wondering what <span class="caps">GD2</span> is… the official explanation is<br />
this:“<span class="caps">GD</span> is an open source code library for the dynamic creation of images by programmers.”</p>
<p>The reason you are getting this error is most likely because have not installed the <span class="caps">GD2</span> extension in <span class="caps">PHP</span> when you first setup your<br />
server. So I will let you know how install it and initialize it in Linux and Windows.</p>
<p><span style="text-decoration: underline">Under Linux::</span><br />
The easiest way is to use your package manager to install it.<br />
For example in Debian… “apt-get install php5-gd”<br />
or Redhat… “—with-libdir=lib64 —with-gd  —with-jpeg-dir —with-png-dir</p>
<p><span style="text-decoration: underline">Under Windows::</span><br />
You will have to download the .zip archive version of PHP because the binary install doesn&#8217;t include most extensions.</p>
<p>Download it here: <a href="http://windows.php.net/download/">http://windows.php.net/download/</a> (Make sure if your using Apache to download the VC6 version).</p>
<p><a href="http://windows.php.net/download/"></a>Copy all the extensions from the &#8220;ext&#8221; directory from the download into your PHP ext directory (eg: “C:\<span class="caps">PHP</span>\ext”) .</p>
<p>You should notice a file called “php_gd2.dll”.</p>
<p>Now to initialize it (like any extension) you have to open your “php.ini” file search for “Dynamic Extensions” and just under that place this exact phrase “extension=php_gd2.dll”.</p>
<p>(Note: make sure that your php.ini file is configured to look in the “C:\<span class="caps">PHP</span>\ext” folder for the extensions. Search in the file for “extension_dir”.)</p>
<p>Restart Apache.</p>
<p>And there you have it you now have full <span class="caps">GD2</span> support for <span class="caps">PHP</span>. You can now resize, scale and flip images on the fly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hampson.ca/blog/2010/03/28/installing-gd2-linux-and-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python on AIX 6.1</title>
		<link>http://www.hampson.ca/blog/2009/11/05/python-aix-61/</link>
		<comments>http://www.hampson.ca/blog/2009/11/05/python-aix-61/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 07:08:19 +0000</pubDate>
		<dc:creator>lukeh</dc:creator>
		
		<guid isPermaLink="false">http://newblog.hampson.ca/?p=18</guid>
		<description><![CDATA[To start, I&#8217;m not an AIX expert. I&#8217;m just a hobbiest that wanted to get a python/django/apache/mysql (db2 down the road) environment work in AIX. Installing python: Download and compile the latest python source. # cd ~/ # wget http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tgz # gunzip Python-2.6.4.tgz # tar -xvf Python-2.6.4.tgz # cd Python-2.6.4 # export PATH=/usr/bin:/usr/vacpp/bin for 32bit: [...]]]></description>
			<content:encoded><![CDATA[<p>To start, I&#8217;m not an <span class="caps">AIX</span> expert. I&#8217;m just a hobbiest that wanted to get a python/django/apache/mysql (db2 down the road) environment  work in <span class="caps">AIX</span>.<br />
Installing python:</p>
<p>Download and compile the latest python source.</p>
<p># cd ~/</p>
<p># wget http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tgz</p>
<p># gunzip Python-2.6.4.tgz</p>
<p># tar -xvf Python-2.6.4.tgz</p>
<p># cd Python-2.6.4</p>
<p># export <span class="caps">PATH</span>=/usr/bin:/usr/vacpp/bin</p>
<p>for 32bit:</p>
<p># ./configure<br />
for 64bit:</p>
<p># ./configure —with-gcc=”xlc_r -q64” —with-cxx=”xlC_r -q64”  —disable-ipv6 <span class="caps">AR</span>=”ar -X64”<br />
# make</p>
<p># su</p>
<p># make install<br />
If no problems crept up, the python executable should be available here:</p>
<p>/usr/local/bin/python<br />
The apache installation to next to come!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hampson.ca/blog/2009/11/05/python-aix-61/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML to PDF in Django</title>
		<link>http://www.hampson.ca/blog/2009/09/30/html-pdf-django/</link>
		<comments>http://www.hampson.ca/blog/2009/09/30/html-pdf-django/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 07:04:56 +0000</pubDate>
		<dc:creator>lukeh</dc:creator>
		
		<guid isPermaLink="false">http://newblog.hampson.ca/?p=16</guid>
		<description><![CDATA[I&#8217;ve been involved in a number of project where I need to create pdf reports from a set of data using the Django framework. The easiest way for me to do this is generate the pdf directly from&#160;html. I will provide a list of software required, and how to program a django view to generate [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been involved in a number of project where I need to create pdf reports from a set of data using the Django framework. The easiest way for me to do this is generate the pdf directly from&nbsp;html.</p>
<p>I will provide a list of software required, and how to program a django view to generate the&nbsp;pdf.</p>
<p>Here&#8217;s the software you&#8217;ll&nbsp;need:</p>
<p>pisa:&nbsp;http://pypi.python.org/pypi/pisa/</p>
<p>ReportLab:&nbsp;http://www.reportlab.org/downloads.html</p>
<p>html5lib:&nbsp;http://code.google.com/p/html5lib/downloads/list</p>
<p>Here&#8217;s a simple view to generate the&nbsp;pdf.</p>
<pre><code>#view.py

import cStringIO as StringIO
import ho.pisa as pisa
from django.http import HttpResponse
from django.template.loader import render_to_string

def my_view(request, *args, **kwargs):

   html = render_to_string('some_template.html', RequestContext(request, {
       'title': 'This is a test PDF document'
   }))
   result = StringIO.StringIO()
   pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("ISO-8859-1")), result)
   response = HttpResponse(result.getvalue(), mimetype='application/pdf')
   response['Content-Disposition'] = 'attachment; filename=document.pdf'
   return response
</code></pre>
<p>Enjoy</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hampson.ca/blog/2009/09/30/html-pdf-django/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup git on Centos 5.3, Centos 5.4 and make public over ssh</title>
		<link>http://www.hampson.ca/blog/2009/09/08/setup-git-centos-53-and-make-public-over-ssh/</link>
		<comments>http://www.hampson.ca/blog/2009/09/08/setup-git-centos-53-and-make-public-over-ssh/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 03:00:12 +0000</pubDate>
		<dc:creator>lukeh</dc:creator>
		
		<guid isPermaLink="false">http://newblog.hampson.ca/?p=14</guid>
		<description><![CDATA[update oct 22. 2009: This method also works in Centos 5.4. I’ll post the epel think below once they’re available I setup git on a Centos 5.3 server the other day, accessible over ssh. Here are the steps I followed to get things up and running. Centos’s yum repository does not have git in it, so setup [...]]]></description>
			<content:encoded><![CDATA[<p>update oct 22. 2009:<br />
This method also works in Centos 5.4. I’ll post the epel think below once they’re available</p>
<p>I setup git on a Centos 5.3 server the other day, accessible over ssh. Here are the steps I followed to get things up and running.</p>
<p>Centos’s yum repository does not have git in it, so setup fedoras epel (Extra Packages for Enterprise Linux) repo.</p>
<p>i386:</p>
<pre><code>rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
</code></pre>
<p>x86_64:</p>
<pre><code>rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm
</code></pre>
<p>As root run this command:</p>
<pre><code>yum install git
</code></pre>
<p>Next I’m going to setup a new repository and make it accessible over ssh:</p>
<pre><code>mdkir /home/username/repo #create directory for new repository
cd /home/username/repo
git init
</code></pre>
<p>We’ll create a dummy file to get started. If you trying to clone (checkout) an empty git repository, you’ll just get errors:</p>
<pre><code>touch firstfile
</code></pre>
<p>Add all files in this directory to your git repository:</p>
<pre><code>git add .
</code></pre>
<p>Commit the changes you’ve made to the repo:</p>
<pre><code>git commit
</code></pre>
<p>Next we’ll create a clone of the repo and configure it to be public:</p>
<pre><code>cd /home/username
git clone --bare ./repo repo.git
touch  repo.git/git-daemon-export-ok
</code></pre>
<p>you can copy your repo.git directory to where you want to make the repo public</p>
<p>Now we want to checkout a copy of the new repository from a different server.</p>
<pre><code>git clone ssh://yourserveraddress/home/username/repo.git
</code></pre>
<p>You should now have a new directory labeled repo which contains the file ‘firstfile’</p>
<p>To add a new file to the repo:</p>
<pre><code>cd repo
touch secondfile
git add .
git commit
</code></pre>
<p>Now we want to submit the changes back to the git server:</p>
<pre><code>git push
</code></pre>
<p>You’ll be prompted for your password.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hampson.ca/blog/2009/09/08/setup-git-centos-53-and-make-public-over-ssh/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Add confirm dialog to a link with jQuery</title>
		<link>http://www.hampson.ca/blog/2009/06/15/add-confirm-dialog-link-jquery/</link>
		<comments>http://www.hampson.ca/blog/2009/06/15/add-confirm-dialog-link-jquery/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 02:54:32 +0000</pubDate>
		<dc:creator>lukeh</dc:creator>
		
		<guid isPermaLink="false">http://newblog.hampson.ca/?p=12</guid>
		<description><![CDATA[Here&#8217;s another simple jQuery snippet I like to add to my projects. This will allow you to present a javascript confirm dialog when a user clicks on a link or a submit button with a confirm attribute it. The value of the confirm attribute will be the text displayed in the confirm dialog box. I [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s another simple jQuery snippet I like to add to my projects. This will allow you to present a javascript confirm dialog when a user clicks on a link or a submit button with a confirm attribute it. The value of the confirm attribute will be the text displayed in the confirm dialog box. I often use this for delete button so the user has a chance to back&nbsp;out.</p>
<pre><code>$(function() {
   $("a[confirm], input[type=submit][confirm]").click(function() {
       conf = confirm($(this).attr("confirm"));
       if(!conf)
           return false;
   });
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hampson.ca/blog/2009/06/15/add-confirm-dialog-link-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turn table rows and buttons into clickable links with jQuery</title>
		<link>http://www.hampson.ca/blog/2009/06/06/turn-table-rows-and-buttons-clickable-links-jquery/</link>
		<comments>http://www.hampson.ca/blog/2009/06/06/turn-table-rows-and-buttons-clickable-links-jquery/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 02:46:48 +0000</pubDate>
		<dc:creator>lukeh</dc:creator>
		
		<guid isPermaLink="false">http://newblog.hampson.ca/?p=9</guid>
		<description><![CDATA[This simple little script often comes in quite handy when I’m working on a web app. It allow you to add an href attribute to tr, td, or input[type=button] tags to make them clickable links $(function() { $("input[type=button][href], tr[href], td[href]").click(function() { location.href = $(this).attr("href"); }); });]]></description>
			<content:encoded><![CDATA[<p>This simple little script often comes in quite handy when I’m working on a web app. It allow you to add an href attribute to tr, td, or input[type=button] tags to make them clickable links</p>
<pre><code>$(function() {
   $("input[type=button][href], tr[href], td[href]").click(function() {
       location.href = $(this).attr("href");
   });
});
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hampson.ca/blog/2009/06/06/turn-table-rows-and-buttons-clickable-links-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamically change field attributes in a Django ModelForm</title>
		<link>http://www.hampson.ca/blog/2009/06/06/dynamically-change-field-attribute-django-modelform/</link>
		<comments>http://www.hampson.ca/blog/2009/06/06/dynamically-change-field-attribute-django-modelform/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 02:39:57 +0000</pubDate>
		<dc:creator>lukeh</dc:creator>
		
		<guid isPermaLink="false">http://newblog.hampson.ca/?p=6</guid>
		<description><![CDATA[I’ve encountered situations using Django’s ModelForm where I’ve needed the form to validate differently then the default behavior in various instances. Here’s an example of how I changed all the fields from the default of not being required to all being required without much effort: class AddressRequiredForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(AddressForm, self).__init__(*args, **kwargs) for name, [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve encountered situations using Django’s ModelForm where I’ve needed the form to validate differently then the default behavior in various instances.<br />
Here’s an example of how I changed all the fields from the default of not being required to all being required without much effort:</p>
<pre><code>class AddressRequiredForm(forms.ModelForm):

   def __init__(self, *args, **kwargs):
       super(AddressForm, self).__init__(*args, **kwargs)
       for name, field in self.fields.iteritems():
           if name not in ['address2',]:
               field.required = True

   class Meta:
       model = Address
</code></pre>
<p>This is pretty simple, but it saved me a lot of time by not having to re-type each field name with a new set of properties.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hampson.ca/blog/2009/06/06/dynamically-change-field-attribute-django-modelform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
