<?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>Alex Harvey</title>
	<atom:link href="http://alexharvey.eu/feed/" rel="self" type="application/rss+xml" />
	<link>http://alexharvey.eu</link>
	<description>Python Programming, Linux Systems Administration and the technology behind Online Affiliate Marketing</description>
	<lastBuildDate>Fri, 30 Mar 2012 23:08:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Resizing /dev/sda1 on Amazon EC2</title>
		<link>http://alexharvey.eu/etc/amazon-cloud/resizing-devsda1-on-amazon-ec2/</link>
		<comments>http://alexharvey.eu/etc/amazon-cloud/resizing-devsda1-on-amazon-ec2/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 20:55:54 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Amazon Cloud]]></category>
		<category><![CDATA[amazon ebs]]></category>
		<category><![CDATA[amazon ec2]]></category>
		<category><![CDATA[amazon elastic ip]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[df]]></category>
		<category><![CDATA[ebs snapshot]]></category>
		<category><![CDATA[resize2fs]]></category>
		<category><![CDATA[root partition]]></category>
		<category><![CDATA[xvda1]]></category>

		<guid isPermaLink="false">http://alexharvey.eu/?p=687</guid>
		<description><![CDATA[When working on a medium size EC2 instance, running Debian 6, I ran out of free space. The root partition had fully grown into its 1GB EBS volume. 1GB was a default setting and I should have changed this before I started working. You can use “df -h” to check how much free disk space [...]]]></description>
			<content:encoded><![CDATA[<p>When working on a <em>medium</em> size <a title="Elastic Cloud Compute" href="http://aws.amazon.com/ec2/">EC2</a> instance, running <a title="A mature Linux distribution, famous for its stability." href="http://www.debian.org/">Debian</a> 6, I ran out of free space. The root partition had fully grown into its 1GB <a title="Elastic Block Store" href="http://aws.amazon.com/ebs/">EBS</a> volume. 1GB was a default setting and I should have changed this before I started working.</p>
<p>You can use “df -h” to check how much free disk space you have remaining (<a title="df man page" href="http://linux.die.net/man/1/df">man page</a>).</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-688" title="diskfree on my netbook" src="http://alexharvey.eu/wp-content/uploads/2012/03/diskfree.png" alt="df shows how much free space is remaining" width="450" height="185" /></p>
<h3>No disk space!</h3>
<p>So I cant just mount another disk because all my work is in <a title="Debian documentation on partitions" href="http://www.debian.org/releases/woody/i386/ch-partitioning.en.html">/dev/sda1 (root)</a>.</p>
<p>By work I mean a <a title="PostgreSQL works great on Debian" href="http://www.postgresql.org/">PostgreSQL</a> database, my <a title="An immense scripting language" href="http://www.python.org/">Python</a> app and <a title="A brilliant FTP server" href="http://www.proftpd.org/">ProFTPD</a>. Normally I could just admit defeat and start a new EC2 instance but then I wouldn&#8217;t have a blog post. There could be times when you wouldn&#8217;t want to do that anyway.</p>
<p>So.. I&#8217;m not at the magical level where I can unmount and re-mount the disk the OS resides on while it is running.</p>
<p>The solution is to <a title="Amazon documentation on creating EBS volumes" href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/ebs-creating-volume.html">create a new EBS volume</a>, copy the file system using the <a title="Official documentation for EBS snapshot feature" href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/ebs-creating-snapshot.html">EBS &#8216;Snapshot&#8217; feature</a> and then attach it to your server instance.</p>
<h3>How to fix</h3>
<p>It&#8217;s an easy job and the downtime is only a few minutes.</p>
<ul>
<li>Stop the EC2 instance<br />
<a href="http://alexharvey.eu/wp-content/uploads/2012/03/stopinstance.png"><img class="size-full wp-image-695 aligncenter" title="stopinstance" src="http://alexharvey.eu/wp-content/uploads/2012/03/stopinstance.png" alt="Turn off the server" width="120" height="118" /></a></li>
<li>Take a &#8216;Snapshot&#8217; of the EC2 instance (in the EBS section)<a href="http://alexharvey.eu/wp-content/uploads/2012/03/createsnapshot.png"><img class="aligncenter size-full wp-image-696" title="createsnapshot" src="http://alexharvey.eu/wp-content/uploads/2012/03/createsnapshot.png" alt="create a copy of your servers hard drive" width="128" height="55" /></a></li>
</ul>
<div></div>
<ul>
<li>Create a new larger EBS volume and load the &#8216;Snapshot&#8217;<br />
<a href="http://alexharvey.eu/wp-content/uploads/2012/03/assignsnapshot.png"><img class="aligncenter size-full wp-image-697" title="assignsnapshot" src="http://alexharvey.eu/wp-content/uploads/2012/03/assignsnapshot.png" alt="assign a snapshot of an ec2 instance to the new ebs volume" width="450" height="294" /></a><a href="http://alexharvey.eu/wp-content/uploads/2012/03/createsnapshot.png"><br />
</a></li>
<li><a title="official docs on detaching ebs volumes" href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/ebs-detaching-volume.html#detaching-ebs-console">Detach</a> the EBS volume currently being used by the EC2 instance</li>
<li><a title="official docs on attaching ebs volumes" href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/ebs-attaching-volume.html#attaching-ebs-console">Attach</a> the larger EBS volume, containing the snapshot</li>
<li>Start the EC2 instance</li>
<li>Assign any <a title="throw away ip addresses" href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/using-instance-addressing.html">Elastic Ip&#8217;s</a> you need</li>
<li>Log in via SSH</li>
<li>Reclaim the new space (The OS won&#8217;t do this on its own), see below</li>
</ul>
<h3>Claim the new free space</h3>
<p>The command to claim unused space on your hard drive is <a title="resize2fs manual" href="http://linux.die.net/man/8/resize2fs">resize2fs</a>. Read about it first because you can specify some things like which disk to use. Run time may be a few minutes and there<strong> wont be any output to stdout</strong> until its complete. Allow it to finish or <a title="how to run commands in background" href="http://hacktux.com/bash/ampersand">append the command with an &amp;</a>.</p>
<p>As root just execute:</p>
<pre>resize2fd /dev/sda1</pre>
<p>If that doesn&#8217;t work then try:</p>
<pre>resize2fs /dev/xvda1</pre>
<p><em>quick note: &#8220;xvda&#8221; &#8211; this is a <a title="xen is an open source hypervisor" href="http://www.xen.org/">Xen</a> Virtual Disk, <a title="explanation of xvda" href="http://superuser.com/questions/356533/whats-the-difference-between-dev-sda1-and-dev-xvda1">explained</a></em></p>
<p>Finally, execute <a title="df man page" href="http://linux.die.net/man/1/df">df</a> to check it worked. Output should be like the top picture with a small % under <em>use</em>.</p>
<h3>In future</h3>
<p>In my haste I used the wizard to set up a <a title="Debian on Amazon" href="http://wiki.debian.org/Cloud/AmazonEC2Image">Debian &#8216;Squeeze&#8217;</a> instance. The <a title="Machine images explained" href="http://bitnami.org/tutorials/amazon_machine_images">Amazon Machine Image (AMI)</a> came with a 1GB hard drive (EBS). It&#8217;s at that point you could attach a larger EBS just for the job you are working on. That would also be cool as you could detach (unmount) it and attach (mount) on another EC2 instance without having to take servers offline.</p>
<h4>More info</h4>
<p>This article saved me:<br />
<a href="http://alestic.com/2010/02/ec2-resize-running-ebs-root">http://alestic.com/2010/02/ec2-resize-running-ebs-root</a></p>
<p>This issue seams pretty common:<br />
<a href="http://stackoverflow.com/questions/6151695/ec2-instace-on-amazon-and-i-am-greeted-with-no-space-left-on-the-disk">http://stackoverflow.com/questions/6151695/ec2-instace-on-amazon-and-i-am-greeted-with-no-space-left-on-the-disk</a></p>
<p>Amazon official documentation:<br />
<a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/using.html">http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/using.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexharvey.eu/etc/amazon-cloud/resizing-devsda1-on-amazon-ec2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove terrible newspapers from news.google.com</title>
		<link>http://alexharvey.eu/etc/insight-and-opinion/remove-terrible-newspapers-from-news-google-com/</link>
		<comments>http://alexharvey.eu/etc/insight-and-opinion/remove-terrible-newspapers-from-news-google-com/#comments</comments>
		<pubDate>Sun, 11 Mar 2012 08:48:28 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Insight and Opinion]]></category>
		<category><![CDATA[bad news]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://alexharvey.eu/?p=666</guid>
		<description><![CDATA[I use news.google.com to quickly check the headlines. Some news corps get in the way with their lies and pseudo-facts. Follow these steps for minimal waft: Click the pencil at the top right (Personalize your news) Scroll down to &#8216;Adjust Sources&#8217; and move the slider(s)]]></description>
			<content:encoded><![CDATA[<p>I use news.google.com to quickly check the headlines. Some news corps get in the way with their lies and pseudo-facts. Follow these steps for minimal waft:</p>
<ol>
<li>Click the pencil at the top right (Personalize your news)</li>
<li>Scroll down to &#8216;Adjust Sources&#8217; and move the slider(s)</li>
</ol>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-668" style="border: 1px #ddd solid;" title="removedm" src="http://alexharvey.eu/wp-content/uploads/2012/03/removedm.png" alt="" width="311" height="147" /></p>
]]></content:encoded>
			<wfw:commentRss>http://alexharvey.eu/etc/insight-and-opinion/remove-terrible-newspapers-from-news-google-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using urllib2 to POST JSON</title>
		<link>http://alexharvey.eu/code/python/using-urllib2-to-post-json/</link>
		<comments>http://alexharvey.eu/code/python/using-urllib2-to-post-json/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 08:56:04 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[REST webservice]]></category>
		<category><![CDATA[urllib2]]></category>

		<guid isPermaLink="false">http://alexharvey.eu/?p=635</guid>
		<description><![CDATA[import json import urllib2 data = {'name':'Alex','colour':'Green','number':42,'foo':'bar'} data = json.dumps(data) url = "http://somewebsite.zzz/webservice" req = urllib2.Request(url, data, {'Content-Type': 'application/json'}) f = urllib2.urlopen(req) response = f.read() f.close() Excellent guide to Python and REST webservices: http://developer.yahoo.com/python/python-rest.html]]></description>
			<content:encoded><![CDATA[<p><code>import json<br />
import urllib2</code></p>
<p><code>data = {'name':'Alex','colour':'Green','number':42,'foo':'bar'}<br />
data = json.dumps(data)</code></p>
<p><code>url = "http://somewebsite.zzz/webservice"</code><br />
<code><br />
req = urllib2.Request(url, data, {'Content-Type': 'application/json'})</code></p>
<p><code>f = urllib2.urlopen(req)<br />
response = f.read()<br />
f.close()</code></p>
<p>Excellent guide to Python and REST webservices: <a title="Yahoo is a treasure trove for developers" href="http://developer.yahoo.com/python/python-rest.html">http://developer.yahoo.com/python/python-rest.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexharvey.eu/code/python/using-urllib2-to-post-json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Amazon EC2 for everything except Email</title>
		<link>http://alexharvey.eu/networking/dns/using-amazon-ec2-for-everything-except-email/</link>
		<comments>http://alexharvey.eu/networking/dns/using-amazon-ec2-for-everything-except-email/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 06:00:40 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[DNS]]></category>
		<category><![CDATA[amazon ec2]]></category>
		<category><![CDATA[mx record]]></category>

		<guid isPermaLink="false">http://alexharvey.eu/?p=630</guid>
		<description><![CDATA[Amazon Elastic Cloud Compute is great if you want to get a server live very quickly. You can go live (including IP address) or shut everything down in only a few minutes. However for hosting email, I&#8217;d like something more permanent. Amazon could potentially be wide open to spammers (make a server, send spam, shutdown) [...]]]></description>
			<content:encoded><![CDATA[<p>Amazon Elastic Cloud Compute is great if you want to get a server live very quickly. You can go live (<a title="Borrow an IPV4 address only when you need to" href="http://aws.amazon.com/articles/1346">including IP address</a>) or shut everything down in only a few minutes.</p>
<p><a href="http://alexharvey.eu/wp-content/uploads/2012/02/ec2terminate.png"><img class="alignleft size-full wp-image-640" title="ec2terminate" src="http://alexharvey.eu/wp-content/uploads/2012/02/ec2terminate.png" alt="" width="264" height="176" /></a>However for hosting email, I&#8217;d like something more permanent. Amazon could potentially be wide open to spammers (make a server, send spam, shutdown) so you first have to get <a title="Amazon Webservice FAQ" href="http://aws.amazon.com/ec2/faqs/#Are_there_any_limitations_in_sending_email_from_EC2_instances">permission</a>.</p>
<p>Instead of EC2 I host my email on a managed hosting plan. I use DNS so that an  EC2 instance is my web server and my managed hosting (not Amazon) is my email server.</p>
<p>&nbsp;</p>
<p>Sending email to another server is really simple to set up:</p>
<pre>@ 	MX 	10 	mail.your-website.com.
mail 	A 		111.222.333.444</pre>
<p>The MX record says &#8220;send email to mail.your-website.com&#8221;. Then the A record says &#8220;send traffic to mail.your-website.com to 111.222.333.444&#8243;.</p>
<p>This is a great guide explaining each of the DNS record types: <a title="Great guide to DNS records" href="https://www.hover.com/help/edit-dns-records-cname-mx-txt-and-srv">https://www.hover.com/help/edit-dns-records-cname-mx-txt-and-srv</a></p>
<p>So in total I have:</p>
<pre>@	A		444.333.222.111
www	A		444.333.222.111
@ 	MX 	10 	mail.your-website.com.
mail 	A 		111.222.333.444</pre>
<p>444.333.222.111 is the web server.<br />
111.222.333.444 is the email server.</p>
<p>Everthing works perfectly but this is a very simple set up. You could have multiple email servers and machines for different applications. Learn <a title="DNS" href="http://en.wikipedia.org/wiki/Domain_Name_System">DNS</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://alexharvey.eu/networking/dns/using-amazon-ec2-for-everything-except-email/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amazon makes Infrastructure as a Service easy</title>
		<link>http://alexharvey.eu/etc/insight-and-opinion/amazon-makes-infrastructure-as-a-service-easy/</link>
		<comments>http://alexharvey.eu/etc/insight-and-opinion/amazon-makes-infrastructure-as-a-service-easy/#comments</comments>
		<pubDate>Sat, 25 Feb 2012 15:38:49 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Insight and Opinion]]></category>
		<category><![CDATA[amazon ec2]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[web hosting]]></category>

		<guid isPermaLink="false">http://alexharvey.eu/?p=605</guid>
		<description><![CDATA[The term &#8220;Cloud Computing&#8221; was invented by a marketing executive. I think its the most over-hyped trend in computing ever. Vineet Nayar called it BS. First where is &#8220;the cloud&#8221;? Thats not like asking &#8220;where is the internet?&#8221;. The cloud is the network of data centers owned by companies like Google, Amazon and IBM. Like [...]]]></description>
			<content:encoded><![CDATA[<p>The term &#8220;Cloud Computing&#8221; was invented by a marketing executive. I think its the most over-hyped trend in computing ever. <a title="this guy is awesome" href="http://www.vineetnayar.com/">Vineet Nayar</a> called it BS.</p>
<p><a title="Dilbert.com" href="http://dilbert.com/strips/comic/2011-01-07/"><img src="http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/100000/00000/9000/700/109703/109703.strip.gif" alt="Dilbert.com" border="0" /></a></p>
<p>First where is &#8220;the cloud&#8221;? Thats not like asking &#8220;where is the internet?&#8221;. The cloud is the network of data centers owned by companies like <a title="gmail, plus, docs - Software as a Service" href="http://www.google.com/apps/intl/en/business/cloud.html">Google</a>, <a title="Amazon Elastic Compute Cloud (Amazon EC2)" href="http://aws.amazon.com/ec2/">Amazon</a> and <a title="IBM SmartCloud Enterprise" href="http://www-935.ibm.com/services/us/en/cloud-enterprise/">IBM</a>. Like always they have <a title="good articles on recovering from disaster" href="http://searchdatacenter.techtarget.com/resources/Data-center-disaster-recovery">emergency fail safe systems</a> and <a title="automatically distribute incoming application traffic across multiple Amazon EC2 instances" href="http://aws.amazon.com/elasticloadbalancing/">load balancing</a> but are all vulnerable to <a title="why launch a missile when you can execute code" href="http://en.wikipedia.org/wiki/Cyberterrorism">attack</a>, <a title="knowledge is useless if you cant communicate" href="http://www.guardian.co.uk/commentisfree/video/2011/oct/20/esc-ctrl-arab-spring-video">tyranny</a>, <a title="aka The Great Firewall of China" href="http://mashable.com/2011/02/15/open-internet-infographic/">censorship</a>, <a title="earthquake, solar flare, tornado, blizzard... take your pic" href="http://www.datacenterknowledge.com/archives/2007/07/17/earthquake-proofing-the-data-center/">natural disaster</a> and <a title="service providers are failing to meet increasing traffic from smart phones" href="http://www.datacenterknowledge.com/archives/2011/10/11/communication-fail-blackberry-down-again/">blackspots</a>. We&#8217;ve had data centers since the 1950&#8242;s! This is just the rebranding of main frame computing.</p>
<p>However what is new and great is the services that are now easily and cheaply available to the masses.</p>
<h3>Cloud computing is just webhosting++</h3>
<p>At my current job I manage three Linux servers. The first is next to my desk and runs the BI software we created to manage the company.  The second is from before my time, its on a dedicated hosting plan, runs CentOS and it costs us<strong> £60 per month</strong>. The third is an Ubuntu box hosted on Amazon EC2. For the first year its <strong>free</strong> and there after its predicted to be under <strong>£30 per month</strong>.</p>
<p>Getting a Linux box (any distro/version) live on Amazon is ridiculously easy.</p>
<ol>
<li>Go to aws.amazon.com and sign up</li>
<li>Go to the aws management console, select <acronym title="Elastic Cloud Compute">EC2</acronym> and which data center you want to use (geographic location)</li>
<li>Go to instances, create new, choose the distro + version</li>
<li>Grab the .pem file and ssh into your new server</li>
</ol>
<p>You can have a server live with root access running your choice of distro, for nothing, in less than 15 minutes. This is called &#8220;Infrastructure as a Service&#8221;.</p>
<p>The £60/month server I talked about is now totally obsolete. Thats all cloud computing means to me.</p>
<h4> More info</h4>
<p><a title="...just repackaging of a commercial solution..." href="http://www.enterpriseirregulars.com/30118/%E2%80%9Ccloud-is-bullsht%E2%80%9D-%E2%80%93-hcl%E2%80%99s-ceo-vineet-nayar-explains-why-he-said-just-that/">Vineet Nayar talks absolute sense! &#8211; “Cloud is bullsh*t”</a></p>
<p><a title="New Scientist article on cloud and botnets" href="http://www.newscientist.com/article/mg21028175.500-botclouds-a-cyberattackers-dream.html">Botclouds: a cyberattacker&#8217;s dream </a></p>
<p><a title="EC2StartersGuide" href="https://help.ubuntu.com/community/EC2StartersGuide"> Ubuntu docs for getting live on Amazon EC2</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://alexharvey.eu/etc/insight-and-opinion/amazon-makes-infrastructure-as-a-service-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get a files &#8216;last modified&#8217; datetime using Python</title>
		<link>http://alexharvey.eu/code/python/get-a-files-last-modified-datetime-using-python/</link>
		<comments>http://alexharvey.eu/code/python/get-a-files-last-modified-datetime-using-python/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 19:30:40 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[ftplib]]></category>
		<category><![CDATA[getmtime]]></category>
		<category><![CDATA[modified time]]></category>
		<category><![CDATA[os.path]]></category>

		<guid isPermaLink="false">http://alexharvey.eu/?p=577</guid>
		<description><![CDATA[Recently I wrote a script which checks an FTP server every morning for a new file. When it finds the remote file it must decide whether or not it is newer than the same file it downloaded at an earlier date. This is how the code compares the &#8216;last modified&#8217; date of two files. The [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I wrote a script which checks an FTP server every morning for a new file. When it finds the remote file it must decide whether or not it is newer than the same file it downloaded at an earlier date. This is how the code compares the &#8216;last modified&#8217; date of two files.</p>
<p>The &#8216;newest&#8217; of two files will have the highest &#8216;last modified&#8217; time.<br />
&nbsp;</p>
<h3>Using os.path to find a file modified time</h3>
<p><code><br />
import os</p>
<p>pathToFirstFile = "/path/to/file1"<br />
pathToSecondFile = "/path/to/file2"</p>
<p>firstFile = os.path.getmtime(pathToFirstFile)<br />
secondFile = os.path.getmtime(pathToSecondFile)</p>
<p>if firstFile &gt; secondFile:<br />
&nbsp; print "firstFile is the most recently modified."<br />
else:<br />
&nbsp; print "firstFile is not the most recently modified."</p>
<p></code><br />
&nbsp;<br />
<a title="os.path.getmtime" href="http://docs.python.org/library/os.path.html#os.path.getmtime">os.path.getmtime()</a> returns a time stamp. To turn it into a readable date you can use <a title="datetime.datetime.fromtimestamp" href="http://docs.python.org/library/datetime.html?highlight=datetime.datetime#datetime.datetime.fromtimestamp">datetime.datetime.fromtimestamp()</a>.</p>
<p><code><br />
import os<br />
from datetime import datetime</p>
<p>filePath = "/path/to/file"<br />
modifiedTime = os.path.getmtime(filePath)</p>
<p>print datetime.fromtimestamp(modifiedTime).strftime("%d%b%Y %H:%M:%S")</p>
<p></code><br />
&nbsp;</p>
<h3>Get the &#8216;last modified&#8217; time of a file on an FTP server</h3>
<p>I&#8217;ve always used <a href="http://docs.python.org/library/ftplib.html?highlight=ftplib#ftplib" title="Python ftllib documentation">ftplib</a> for handling FTP in my scripts. Over FTP, the command for getting a files modified time is <a href="http://www.nsftools.com/tips/RawFTP.htm#MDTM" title="FTP file modified time">MDTM</a>. We can send this in Python using the code below.</p>
<p><code><br />
import ftplib</p>
<p>fileName = "nameOfFile.txt"</p>
<p>ftpCredentials = {'host' : 'myftpserver.zzz',<br />
                  'user' : 'alex',<br />
                  'passwd' : 'secret'}</p>
<p>connection = ftplib.FTP(**ftpCredentials)</p>
<p>modifiedTime = connection.sendcmd('MDTM ' + fileName)<br />
# successful response: '213 20120222090254'</p>
<p>connection.quit()<br />
</code></p>
<p>The <em>modifiedTime</em> comes back with &#8220;213 &#8221; at the start, this means the command was successful. The rest of the data is year + month + day + hour + minute + seconds or &#8220;%Y%m%d%H%M%S&#8221;. Using datetime we can make MDTM more readable.</p>
<p><code><br />
from datetime import datetime</p>
<p>print datetime.strptime(modifiedTime[4:], "%Y%m%d%H%M%S").strftime("%d %B %Y %H:%M:%S")</p>
<p># prints like 01 January 1970 09:30:01<br />
</code></p>
<p>&nbsp;</p>
<p>ftplib.FTP and os.path are both great. Python wins!</p>
]]></content:encoded>
			<wfw:commentRss>http://alexharvey.eu/code/python/get-a-files-last-modified-datetime-using-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Richard St. John answers &#8220;What leads to success?&#8221;</title>
		<link>http://alexharvey.eu/etc/cool-stuff/what-leads-to-succes/</link>
		<comments>http://alexharvey.eu/etc/cool-stuff/what-leads-to-succes/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 09:59:41 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[success]]></category>
		<category><![CDATA[Ted.com]]></category>

		<guid isPermaLink="false">http://alexharvey.eu/?p=571</guid>
		<description><![CDATA[I found this on TED.com. Richard John has interviewed 500 successful people (like Bill Gates and Rupert Murdoch) and asked them &#8220;What leads to success?&#8221;. He explains in 3.5 minutes that to be successful you need these 8 points: Passion, do it for love not money. Work, work really hard. Good, you have to be [...]]]></description>
			<content:encoded><![CDATA[<p><object width="398" height="374"><param name="movie" value="http://video.ted.com/assets/player/swf/EmbedPlayer.swf"></param><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always"/><param name="wmode" value="transparent"></param><param name="bgColor" value="#ffffff"></param><param name="flashvars" value="vu=http://video.ted.com/talk/stream/2005/Blank/RichardStJohn_2005-320k.mp4&#038;su=http://images.ted.com/images/ted/tedindex/embed-posters/RichardSt.John-2005.embed_thumbnail.jpg&#038;vw=384&#038;vh=288&#038;ap=0&#038;ti=70&#038;lang=&#038;introDuration=15330&#038;adDuration=4000&#038;postAdDuration=830&#038;adKeys=talk=richard_st_john_s_8_secrets_of_success;year=2005;theme=how_we_learn;theme=presentation_innovation;theme=not_business_as_usual;event=TED2005;tag=Business;tag=Culture;tag=Entertainment;tag=education;tag=happiness;tag=psychology;tag=short+talk;tag=work;&#038;preAdTag=tconf.ted/embed;tile=1;sz=512x288;" /><embed src="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" pluginspace="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" bgColor="#ffffff" width="398" height="374" allowFullScreen="true" allowScriptAccess="always" flashvars="vu=http://video.ted.com/talk/stream/2005/Blank/RichardStJohn_2005-320k.mp4&#038;su=http://images.ted.com/images/ted/tedindex/embed-posters/RichardSt.John-2005.embed_thumbnail.jpg&#038;vw=384&#038;vh=288&#038;ap=0&#038;ti=70&#038;lang=&#038;introDuration=15330&#038;adDuration=4000&#038;postAdDuration=830&#038;adKeys=talk=richard_st_john_s_8_secrets_of_success;year=2005;theme=how_we_learn;theme=presentation_innovation;theme=not_business_as_usual;event=TED2005;tag=Business;tag=Culture;tag=Entertainment;tag=education;tag=happiness;tag=psychology;tag=short+talk;tag=work;&#038;preAdTag=tconf.ted/embed;tile=1;sz=512x288;"></embed></object></p>
<p>I found this on <a title="TED talks" href="http://www.ted.com/talks">TED.com</a>. Richard John has interviewed 500 successful people (like Bill Gates and Rupert Murdoch) and asked them &#8220;What leads to success?&#8221;.</p>
<p>He explains in 3.5 minutes that to be successful you need these 8 points:</p>
<ol>
<li>Passion, do it for love not money.</li>
<li>Work, work really hard.</li>
<li>Good, you have to be damn good at what you do.</li>
<li>Focus, focus on one thing.</li>
<li>Push, you must be pushed physically and mentally.</li>
<li>Serve, serve others something of value.</li>
<li>Ideas, follow a good one.</li>
<li>Persist, even through failure.</li>
</ol>
<p>More info on &#8216;Success Analyst&#8217; Richard St. John:<br />
<a title="richard john bio" href="http://www.ted.com/speakers/richard_st_john.html">http://www.ted.com/speakers/richard_st_john.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexharvey.eu/etc/cool-stuff/what-leads-to-succes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Seth Godin: This is broken</title>
		<link>http://alexharvey.eu/etc/cool-stuff/seth-godin-this-is-broken/</link>
		<comments>http://alexharvey.eu/etc/cool-stuff/seth-godin-this-is-broken/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 12:37:08 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Seth Godin]]></category>
		<category><![CDATA[Ted.com]]></category>
		<category><![CDATA[This is broken]]></category>

		<guid isPermaLink="false">http://alexharvey.eu/?p=566</guid>
		<description><![CDATA[Excellent talk I found on TED.com on why things are broken by Seth Godin ~ http://www.sethgodin.com Seven reasons why things suck Not my job Selfish jerks The world changed I didn&#8217;t know I&#8217;m not a fish Contradictions Broken on purpose More info: http://www.ted.com/speakers/seth_godin.html This Is Broken website (new version): http://goodexperience.com]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://player.vimeo.com/video/4246943?title=0&amp;byline=0&amp;portrait=0&amp;color=ececec&amp;autoplay=0" frameborder="0" width="560" height="420"></iframe></p>
<p>Excellent talk I found on <a title="great site for lectures" href="http://ted.com">TED.com</a> on why things are broken by Seth Godin ~ <a title="Seth Godins home page" href="http://www.sethgodin.com">http://www.sethgodin.com</a></p>
<h2>Seven reasons why things suck</h2>
<ol>
<li>Not my job</li>
<li>Selfish jerks</li>
<li>The world changed</li>
<li>I didn&#8217;t know</li>
<li>I&#8217;m not a fish</li>
<li>Contradictions</li>
<li>Broken on purpose</li>
</ol>
<p><strong>More info:</strong></p>
<p><a title="Seth Godin on ted.com" href="http://www.ted.com/speakers/seth_godin.html">http://www.ted.com/speakers/seth_godin.html</a></p>
<p>This Is Broken website (new version): <a title="customer and human experience is important" href="http://goodexperience.com/">http://goodexperience.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexharvey.eu/etc/cool-stuff/seth-godin-this-is-broken/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Surprise you need a Client Access License!</title>
		<link>http://alexharvey.eu/etc/insight-and-opinion/surprise-you-need-a-client-access-license/</link>
		<comments>http://alexharvey.eu/etc/insight-and-opinion/surprise-you-need-a-client-access-license/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 11:00:47 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Insight and Opinion]]></category>
		<category><![CDATA[alternative operating systems]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[paradigm shift]]></category>
		<category><![CDATA[proprietary madness]]></category>
		<category><![CDATA[ubuntu linux]]></category>

		<guid isPermaLink="false">http://alexharvey.eu/?p=528</guid>
		<description><![CDATA[There is a safe in the office where I work. Inside it, among valuables like petty cash and sensitive documents, are our CAL&#8217;s from Microsoft. We had to buy them when we upgraded the Windows Small Business 2008 Server. What is a Client Access License? &#8220;A CAL is not a software product; rather, it is [...]]]></description>
			<content:encoded><![CDATA[<p>There is a safe in the office where I work. Inside it, among valuables like petty cash and sensitive documents, are our CAL&#8217;s from Microsoft. We had to buy them when we upgraded the Windows Small Business 2008 Server.</p>
<h2>What is a Client Access License?</h2>
<p><em>&#8220;A CAL is not a software product; rather, it is a license that gives a user the right to access the services of the server.&#8221; &#8211; Definition from Microsoft</em></p>
<p>A CAL is a piece of paper you are legally required to have purchased for each individual user which will be connected to your Windows Domain at one time. They came in brown envelopes and are size A4.</p>
<p>When we upgraded in early 2011 they <strong>cost us £60 each</strong>. 5 came &#8220;free&#8221; with <acronym title="Small Business Server">SBS</acronym> and the rest we bought from a Microsoft reseller. <a title="dont buy this!" href="http://amzn.to/syuyOl">Currently $168 for a pack of 5 on Amazon</a>.</p>
<p>There is a second kind of license, Device Client Access License. This is so that if you have more computers than people then you <em>save</em> by getting CAL&#8217;s otherwise if there are more people than computers <em>its cheaper</em> to use DCAL&#8217;s.</p>
<h2>Paradigm shift</h2>
<p>Our most recent upgrade was the first time we were required to purchase licenses in this way. It marks a paradigm shift; the software, even though it has a financial cost, has no value. The value (for Microsoft) is in licensing on a per user or device basis. Whats messed up is that both Small Business Server and the Licenses cost money despite one being totally worthless.</p>
<p>This came as a surprise. For the previous version this was not required and there were no extra costs. But thats tough luck for anyone dependent on propitiatory tech.</p>
<p>Even better the latest version of SBS comes with a <a title="a stupid idea" href="http://www.microsoft.com/oem/en/products/servers/Pages/windows_sbs_2011_essentials_overview.aspx">&#8220;Vista Home Premium&#8221; style <em>Essentials</em> edition</a> which only supports 25 clients but doesn&#8217;t require CAL&#8217;s. Thats pretty dumb because as soon as you&#8217;re business grows above 25 then you need an upgrade and at least 20 CAL&#8217;S to go with it.</p>
<h2>Proprietary Madness</h2>
<p>By purchasing SBS 2008 we got Windows Server, Exchange (office file sharing and email) and 5 CAL&#8217;s. We purchased more packs of CALS so now 30 computers can join the domain. Legally that is, technically nothing stops you.</p>
<p>The majority of companies are dependent on Microsoft products. So are all our schools (in the UK) and <a title="Cabinet minister Francis Maude says his new ICT strategy will save the government millions" href="http://www.eweekeurope.co.uk/news/government-cost-cutting-strategy-embraces-open-source-25311" target="_blank">government</a>.. but why?! The most common reason I&#8217;ve heard when debating/arguing a switch is that &#8220;its the industry standard&#8221; or you get technical support with Windows and any employee we hire will know how to use it.</p>
<h2>Alternative Operating Systems</h2>
<p>Windows is not the only OS and it is not the most fit for purpose. Seriously, if you are willing to buy software and licenses for each user/device every 4-5 years, just so your company can share files and use email, then good luck to you.</p>
<p>&nbsp;</p>
<h3 style="text-align: center;">I recommend the <a title="Software is like sex, its best when its free." href="http://www.ubuntu.com/">Ubuntu</a> distribution of Linux.</h3>
<p>&nbsp;</p>
<p><strong>More info:</strong></p>
<p><a title="CALS What The F*ck" href="http://www.neowin.net/forum/topic/633184-cals-wtf/">http://www.neowin.net/forum/topic/633184-cals-wtf/</a></p>
<p><a title="official Microsoft page on client access license" href="http://www.microsoft.com/licensing/about-licensing/client-access-license.aspx">http://www.microsoft.com/licensing/about-licensing/client-access-license.aspx</a></p>
<p><a title="cal vs dal in one sentence" href="http://blog.montopolis.com/2008/03/05/microsoft-windows-server-user-cal-versus-device-cal/">http://blog.montopolis.com/2008/03/05/microsoft-windows-server-user-cal-versus-device-cal/</a></p>
<p><a title="10 points on upgrading to SBS 2011" href="http://www.techrepublic.com/blog/10things/10-things-you-should-know-about-microsoft-small-business-server-2011/2339">http://www.techrepublic.com/blog/10things/10-things-you-should-know-about-microsoft-small-business-server-2011/2339</a></p>
<p><a title="Cabinet minister Francis Maude says his new ICT strategy will save the government millions" href="http://www.eweekeurope.co.uk/news/government-cost-cutting-strategy-embraces-open-source-25311">http://www.eweekeurope.co.uk/news/government-cost-cutting-strategy-embraces-open-source-25311</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://alexharvey.eu/etc/insight-and-opinion/surprise-you-need-a-client-access-license/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lectures on Computer Programming from Stanford University</title>
		<link>http://alexharvey.eu/etc/education/lectures-on-computer-programming-from-stanford-university/</link>
		<comments>http://alexharvey.eu/etc/education/lectures-on-computer-programming-from-stanford-university/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 21:12:13 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[lectures]]></category>
		<category><![CDATA[stanford university]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://alexharvey.eu/?p=515</guid>
		<description><![CDATA[Stanford University is brilliant. Hundreds of their lectures, entire computer science modules, have been uploaded to Youtube! Programming Paradigms (CS 107) 27 Lectures Languages: C, C++, assembly, Python, Scheme. http://www.youtube.com/playlist?list=PL9D558D49CA734A02 Programming Abstractions (CS 106B) 27 Lectures Languages: C++ http://www.youtube.com/playlist?list=PLFE6E58F856038C69 Programming Methodology (CS 106A) 28 Lectures Languages: Java http://www.youtube.com/playlist?list=PL84A56BC7F4A1F852 &#160; Also of interest: Introduction to Robotics [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Stanford University channel on youtube" href="http://www.youtube.com/user/StanfordUniversity">Stanford University</a> is brilliant.</p>
<p>Hundreds of their lectures, entire computer science modules, have been uploaded to Youtube!</p>
<p><strong>Programming Paradigms</strong> (CS 107)<br />
27 Lectures<br />
Languages: C, C++, assembly, Python, Scheme.<br />
<a title="programming paradigms playlist on youtube" href="http://www.youtube.com/playlist?list=PL9D558D49CA734A02">http://www.youtube.com/playlist?list=PL9D558D49CA734A02</a></p>
<p><strong>Programming Abstractions</strong> (CS 106B)<br />
27 Lectures<br />
Languages: C++<br />
<a title="programming abstractions playlist on youtube" href="http://www.youtube.com/playlist?list=PLFE6E58F856038C69">http://www.youtube.com/playlist?list=PLFE6E58F856038C69</a></p>
<p><strong>Programming Methodology</strong> (CS 106A)<br />
28 Lectures<br />
Languages: Java<br />
<a title="programming methodology playlist on youtube" href="http://www.youtube.com/playlist?list=PL84A56BC7F4A1F852">http://www.youtube.com/playlist?list=PL84A56BC7F4A1F852</a></p>
<p>&nbsp;</p>
<p><em>Also of interest:</em></p>
<p><strong>Introduction to Robotics</strong> (CS 223A)<br />
16 Lectures<br />
<a title="introduction to robotics playlist on youtube" href="http://www.youtube.com/playlist?list=PL65CC0384A1798ADF">http://www.youtube.com/playlist?list=PL65CC0384A1798ADF</a></p>
<p><strong>Machine Learning</strong> (CS 229)<br />
20 Lectures<br />
<a title="machine learning playlist on youtube" href="http://www.youtube.com/playlist?list=PLA89DCFA6ADACE599">http://www.youtube.com/playlist?list=PLA89DCFA6ADACE599</a></p>
<p>&nbsp;</p>
<p>Above are just the play lists related to writing software, theres a few more subjects but also talks and debates. One good talk is <a title="Stan 2011, future of Robotics and AI" href="http://youtu.be/AY4ajbu_G3k">The Future of Robotics and Artificial Intelligence</a>.</p>
<p>Stanford University Youtube channel: <a title="Stanford University channel on youtube" href="http://www.youtube.com/user/StanfordUniversity">http://www.youtube.com/user/StanfordUniversity</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexharvey.eu/etc/education/lectures-on-computer-programming-from-stanford-university/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

