<?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>It&#039;s Forty Two! &#187; Coding</title>
	<atom:link href="http://blog.itsfortytwo.net/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.itsfortytwo.net</link>
	<description>The Answer to Life, the Universe and Everything ...</description>
	<lastBuildDate>Fri, 11 Nov 2011 10:50:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Harddrive failure and monitoring</title>
		<link>http://blog.itsfortytwo.net/2011/10/harddrive-failure-and-monitoring/</link>
		<comments>http://blog.itsfortytwo.net/2011/10/harddrive-failure-and-monitoring/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 17:13:11 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Stuff]]></category>
		<category><![CDATA[Harddrive Failure]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[RAID]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.itsfortytwo.net/?p=1025</guid>
		<description><![CDATA[<a href="http://blog.itsfortytwo.net/2011/10/harddrive-failure-and-monitoring/" title="Harddrive failure and monitoring"></a>I have two Ubuntu servers running at home which both have large RAID volumes on them, set up via mdadm. This summer I had a total disk failure in one of my RAID5s which luckily didn&#8217;t result in data loss. &#8230;<p class="read-more"><a href="http://blog.itsfortytwo.net/2011/10/harddrive-failure-and-monitoring/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.itsfortytwo.net/2011/10/harddrive-failure-and-monitoring/" title="Harddrive failure and monitoring"></a><p style="text-align: justify;"><a href="http://blog.itsfortytwo.net/2011/10/harddrive-failure-and-monitoring/broken-hard-disk/" rel="attachment wp-att-1040"><img class="alignright size-medium wp-image-1040" style="margin: 0px 0px 4px 8px;" title="Broken harddisk" src="http://blog.itsfortytwo.net/wp-content/uploads/2011/10/broken-hard-disk-250x167.jpg" alt="Broken harddisk" width="188" height="130" /></a>I have two Ubuntu servers running at home which both have large RAID volumes on them, set up via <a title="Ubuntu mdadm: “Device or resource busy” error" href="http://blog.itsfortytwo.net/2010/08/ubuntu-mdadm-device-or-resource-busy-error/">mdadm</a>. This summer I had a total disk failure in one of my RAID5s which luckily didn&#8217;t result in data loss. Thanks you RAID5!</p>
<p style="text-align: justify;">In any case, it caused me to write a script that logs <a href="http://en.wikipedia.org/wiki/S.M.A.R.T." target="_blank">SMART</a>-data to a MySQL database. I also wrote an admin webpage that displays this data for me in an easy to follow way. The monitoring script itself is written in php5 and so are the admin pages. I used php5 because it is easy to communicate with MySQL from it, and it has the needed string manipulation commands. It could probably be done as easily in Python though. The script is called as a cron job every 2 hours on the servers and every hour on the desktops when they&#8217;re running. Examples of the code I&#8217;m using is attached below and includes the cron-ed script and the code generating the log output and plot.</p>
<p><strong>What to look for?</strong></p>
<p style="text-align: justify;">Well, that is the big question. How do you know if a drive is about to fail? Google Labs has looked into this topic back in 2007 in this paper: «<a href="http://research.google.com/pubs/pub32774.html" target="_blank">Failure Trends in a Large Disk Drive Population</a>». An interesting read if you are at all concerned about harddrive failure in servers. The results for how temperature affects the lifetime and failure rate in harddrives are especially interesting. It turns out, at least in their data, that low temperature isn&#8217;t such a good thing for the drives contrary to what many people seem to assume. I have up until now been concerned that my drives get too hot, but in fact they seem to be almost overcooled the way I have things set up now.</p>
<p style="text-align: justify;">When I wrote these scripts this summer I decided to log temperature and reallocated sector count primarily, which is what is emphasized in the log display scripts. Seems now I also should be including scan errors as well after reading that paper. The colour coding I use in the temperature plot below is loosely based on Figure 4 in the paper and reflects what seems to be the optimal operating temperature for harddrives.</p>
<p style="text-align: justify;"><strong>Screenshots</strong><br />
<a href="http://blog.itsfortytwo.net/wp-content/uploads/2011/10/screenshot1.png"><img class="size-thumbnail wp-image-1027 alignnone" title="HD-Mon Screenshot 1" src="http://blog.itsfortytwo.net/wp-content/uploads/2011/10/screenshot1-150x150.png" alt="HD-Mon Screenshot 1" width="150" height="150" /></a><a href="http://blog.itsfortytwo.net/wp-content/uploads/2011/10/screenshot2.png"><img class="size-thumbnail wp-image-1028 alignnone" title="HD-Mon Screenshot 2" src="http://blog.itsfortytwo.net/wp-content/uploads/2011/10/screenshot2-150x150.png" alt="HD-Mon Screenshot 2" width="150" height="150" /></a><a href="http://blog.itsfortytwo.net/wp-content/uploads/2011/10/screenshot3.png"><img class="size-thumbnail wp-image-1029 alignnone" title="HD-Mon Screenshot 3" src="http://blog.itsfortytwo.net/wp-content/uploads/2011/10/screenshot3-150x150.png" alt="HD-Mon Screenshot 3" width="150" height="150" /></a><br />
<em>Screenshot 1</em>: The overview page.<br />
<em>Screenshot 2</em>: Details of one of the RAID-drives.<br />
<em>Screenshot 3</em>: Details of one of the drives with reallocated sectors.</p>
<p style="text-align: justify;"><strong>Code</strong></p>
<p style="text-align: justify;">The php source code I wrote is available in this file: <a href="http://folk.uio.no/frankol/download/hd-mon.tar.gz">hd-mon.tar.gz</a></p>
<p style="text-align: justify;">It is specifically designed to work with my setup and hardware and probably isn&#8217;t universal, but it gives an idea of how I set it up. There are probably better ways of doing this though. I just call shell commands from php and parse the returned text-string and do simple search on it and input the data into a MySQL database.</p>
<p style="text-align: justify;">I also included php-snippets showing how the admin page is generated. These are not standalone php files, they need to be wrapped in a template. However they reproduce what is seen in the screenshots above.</p>
<p>Packages needed for these scripts to run:</p>
<ul>
<li><strong>php5-cli</strong> for the php5 command line.</li>
<li><strong>mysql-client</strong>, <strong>php5-mysql</strong> for the database connection.</li>
<li><strong>smartctl</strong> to access the SMART-data.</li>
<li><strong>mdadm</strong> to access RAID-data (assuming you use mdadm for RAIDs in the first place)</li>
</ul>
<p>All are available in the Ubuntu repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.itsfortytwo.net/2011/10/harddrive-failure-and-monitoring/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Converting Charset in MySQL</title>
		<link>http://blog.itsfortytwo.net/2011/08/converting-charset-in-mysql/</link>
		<comments>http://blog.itsfortytwo.net/2011/08/converting-charset-in-mysql/#comments</comments>
		<pubDate>Sat, 06 Aug 2011 20:44:55 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Stuff]]></category>
		<category><![CDATA[Charset]]></category>
		<category><![CDATA[Encoding]]></category>
		<category><![CDATA[Latin1]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[UTF8]]></category>

		<guid isPermaLink="false">http://blog.itsfortytwo.net/?p=899</guid>
		<description><![CDATA[<a href="http://blog.itsfortytwo.net/2011/08/converting-charset-in-mysql/" title="Converting Charset in MySQL"></a>Just a quick MySQL tip &#8230; I have a RSS reader that I coded myself a while back with php/MySQL. The news table was set to latin1 character encoding and I wanted to change that into utf8, but couldn&#8217;t quite &#8230;<p class="read-more"><a href="http://blog.itsfortytwo.net/2011/08/converting-charset-in-mysql/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.itsfortytwo.net/2011/08/converting-charset-in-mysql/" title="Converting Charset in MySQL"></a><p style="text-align: justify;"><a href="http://blog.itsfortytwo.net/2011/08/converting-charset-in-mysql/logo-mysql-110x57/" rel="attachment wp-att-901"><img class="alignright size-full wp-image-901" style="margin: 0px 0px 4px 8px;" title="Logo MySQL" src="http://blog.itsfortytwo.net/wp-content/uploads/2011/08/logo-mysql-110x57.png" alt="Logo MySQL" width="110" height="57" /></a>Just a quick MySQL tip &#8230;</p>
<p style="text-align: justify;">I have a RSS reader that I coded myself a while back with php/MySQL. The news table was set to latin1 character encoding and I wanted to change that into utf8, but couldn&#8217;t quite figure out how. Eventually I stumbled upon this solution:</p>
<p style="text-align: justify;"><a href="http://dev.mysql.com/doc/refman/4.1/en/charset-conversion.html" target="_blank">9.1.11.2. Converting 4.0 Character Columns to 4.1 Format</a></p>
<p style="text-align: justify;">Basically what I needed to do to convert the field &#8220;Title&#8221; in the table &#8220;news&#8221; was running the following SQLs:</p>
<pre>ALTER TABLE news MODIFY Title BLOB;
ALTER TABLE news MODIFY Title VARCHAR(250) CHARACTER SET utf8;</pre>
<p style="text-align: justify;">Easy peasy &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.itsfortytwo.net/2011/08/converting-charset-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MOBI-Books</title>
		<link>http://blog.itsfortytwo.net/2011/06/mobi-books/</link>
		<comments>http://blog.itsfortytwo.net/2011/06/mobi-books/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 20:49:09 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Stuff]]></category>
		<category><![CDATA[Calibre]]></category>
		<category><![CDATA[eBooks]]></category>
		<category><![CDATA[Kindle]]></category>
		<category><![CDATA[MOBI Files]]></category>

		<guid isPermaLink="false">http://blog.itsfortytwo.net/?p=850</guid>
		<description><![CDATA[<a href="http://blog.itsfortytwo.net/2011/06/mobi-books/" title="MOBI-Books"></a>As I posted a while back, I have bought myself an Amazon Kindle. I am very happy with that little piece of technology. I have already made a template for generating pdf-files that fits well on my Kindle. Last weekend &#8230;<p class="read-more"><a href="http://blog.itsfortytwo.net/2011/06/mobi-books/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.itsfortytwo.net/2011/06/mobi-books/" title="MOBI-Books"></a><p style="text-align: justify;">As I posted a while back, I have bought myself an Amazon Kindle. I am very happy with that little piece of technology. I have already made <a href="http://blog.itsfortytwo.net/2011/01/kindle-latex-template/" target="_blank">a template for generating pdf-files</a> that fits well on my Kindle.</p>
<p style="text-align: justify;">Last weekend I decided to try to compile my own mobi files. It is actually fairly simple (although preparing the text itself can be very time-consuming). First you need the text you&#8217;d want to convert into a book. I had read <a href="http://pandasthumb.org/archives/2011/06/science-and-rel.html" target="_blank">this post on pandasthumb.org</a> and downloaded Matt Young&#8217;s book «<em>No Sense of Obligation: Science and Religion in an Impersonal Universe</em>». Since the pdf was not very well suited for my Kindle, I decided to try and convert it to mobi-format.</p>
<p style="text-align: justify;">Firstly you need a decent tool. Amazon has provided a tool that prepares books for the Kindle, it can be found on their <em>Kindle Publishing Programs</em> page <a href="http://www.amazon.com/gp/feature.html?ie=UTF8&amp;docId=1000234621" target="_blank">here</a>. However the conversion tool isn&#8217;t all that practical. It&#8217;s command-line which is no problem for me, but it also have very few options. A much better program is <a href="http://calibre-ebook.com/" target="_blank">Calibre</a>, which is multi-platform and is a full eBook management tool that connects and sync with the Kindle and other eBook readers. It can import many formats and also export/convert to many formats.</p>
<p style="text-align: justify;">I found that the easiest way to format an eBook is by making a html-document of it first and the convert the html to mobi. As an example I have made a short eBook out of the essay about Homeopathy I posted about earlier. I will provide all the source files in a bit.</p>
<p style="text-align: justify;">The html file needs to start with a header. Something like:</p>
<pre>&lt;?xml Version='1.0' Encoding='utf-8'?&gt;
&lt;html Xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
    &lt;title&gt;Homeopathy and Its Kindred Delusions&lt;/title&gt;
    &lt;meta Http-Equiv="Content-Type" Content="text/html; charset=utf8"&gt;
    &lt;link Rel="Stylesheet" Type="text/css" Href="Style.css"&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p style="text-align: justify;">The text of the book goes inside the body-tag.</p>
<p style="text-align: justify;">Calibre generates a pagebreak for each &lt;h1&gt; and &lt;h2&gt; heading by default, so I use the &lt;h2&gt; tag for chapter headings. You&#8217;d also want to put in an anchor tag before each chapter and make a table of contents at the beginning of the book. It is the usual syntax:</p>
<pre>&lt;a Name="Chapter1"&gt;&lt;/a&gt;</pre>
<p style="text-align: justify;">for the chapter tag, and</p>
<pre>&lt;a Href="#Chapter1"&gt;Chapter 1&lt;/a&gt;</pre>
<p style="text-align: justify;">for the TOC link.</p>
<p style="text-align: justify;">Otherwise the text formatting is straight forward with &lt;i&gt; and &lt;b&gt; tags for italics and bold as usual. One point worth mentioning is paragraph formatting. I myself prefer the indented paragraph as opposed to the extra linebreak style for books. To achieve this I used &lt;div&gt; tags instead of &lt;p&gt; tags in the text, and use the CSS style &#8220;Text-Indent: 1.5em&#8221; to indent the text at the start of each paragraph. The example files should demonstrate this well enough.</p>
<p style="text-align: justify;">When the html version looks fine (you can preview it in your web-browser), Then you import it to calibre via &#8220;Add Book&#8221;. Then you do a conversion to &#8220;MOBI&#8221; (in the right-click dropdown menu). You may play around with the settings, but there were no need to change anything when I converted this book, except I disabled the option to let calibre generate your TOC. Sync with the Kindle, and read away!</p>
<p style="text-align: justify;"><strong>Example files:</strong><br />
<em>Oliver Wendell Holmes &#8211; Homeopathy and Its Kindred Delusions (1842)</em></p>
<ul style="text-align: justify;">
<li><a href="http://www.itsfortytwo.net/stuff/2011/06/holmes.tar.gz">HTML source files</a></li>
<li><a href="http://www.itsfortytwo.net/stuff/2011/06/holmes_mobi.tar.gz">Final MOBI file</a></li>
</ul>
<p style="text-align: justify;">(The files are gzipped.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.itsfortytwo.net/2011/06/mobi-books/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Torrent Name from File in php</title>
		<link>http://blog.itsfortytwo.net/2011/01/getting-torrent-name-from-file-in-php/</link>
		<comments>http://blog.itsfortytwo.net/2011/01/getting-torrent-name-from-file-in-php/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 13:59:10 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Parsing Torrent]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.itsfortytwo.net/?p=432</guid>
		<description><![CDATA[<a href="http://blog.itsfortytwo.net/2011/01/getting-torrent-name-from-file-in-php/" title="Getting Torrent Name from File in php"></a>Wrote a script today that parses a torrent file and retrieve the name of the torrent. The reason I made this is that I have a small web page running at home that parses an RSS feed and upload selected &#8230;<p class="read-more"><a href="http://blog.itsfortytwo.net/2011/01/getting-torrent-name-from-file-in-php/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.itsfortytwo.net/2011/01/getting-torrent-name-from-file-in-php/" title="Getting Torrent Name from File in php"></a><p style="text-align: justify;">Wrote a script today that parses a torrent file and retrieve the name of the torrent. The reason I made this is that I have a small web page running at home that parses an RSS feed and upload selected torrents to another computer. Since the name of the torrent on disk (the data folder) doesn&#8217;t always match the name of the actual .torrent file, I need to get the name from the file itself. It is quite simple really, and it falls back to the .torrent file name if it fails.</p>
<pre>// Find torrent name
$sTorrent     = "torrent_file_name.torrent";
$sTName       = trim(substr($sTorrent, 0, strrpos($sTorrent, ".")));
$sTorrentData = file_get_contents("path/to/torrent/file/".$sTorrent);
preg_match("(:name[0-9]+:)",$sTorrentData,$aTemp,PREG_OFFSET_CAPTURE);
if(count($aTemp) == 1) {
  $sTemp = str_replace(":","",$aTemp[0][0]);
  $sTemp = str_replace("name","",$sTemp);
  if(is_numeric($sTemp)) {
    $sTName = substr($sTorrentData,$aTemp[0][1]+strlen($aTemp[0][0]),(int)$sTemp);
    $sMessage = "&lt;div&gt;Torrent successfully parsed.&lt;br&gt;";
    $sMessage = "Name: ".$sTName."&lt;/div&gt;";
  } else {
    $sError = "&lt;div&gt;Parseing failed.&lt;br&gt;Using name: ".$sTName."&lt;/div&gt;";
  }
} else {
  $sError = "&lt;div&gt;Parseing failed.&lt;br&gt;Using name: ".$sTName."&lt;/div&gt;";
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.itsfortytwo.net/2011/01/getting-torrent-name-from-file-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auto UnRar Script</title>
		<link>http://blog.itsfortytwo.net/2011/01/auto-unrar-script/</link>
		<comments>http://blog.itsfortytwo.net/2011/01/auto-unrar-script/#comments</comments>
		<pubDate>Sun, 16 Jan 2011 15:23:18 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Stuff]]></category>
		<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Recursive]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Unrar]]></category>

		<guid isPermaLink="false">http://blog.itsfortytwo.net/?p=426</guid>
		<description><![CDATA[<a href="http://blog.itsfortytwo.net/2011/01/auto-unrar-script/" title="Auto UnRar Script"></a>Ever needed a script that automatically extracts all rar archives in a directory and subdirectories, unrar them into their respective directories and then delete the archive files, but only if the extraction was successful? Well in that case, I wrote &#8230;<p class="read-more"><a href="http://blog.itsfortytwo.net/2011/01/auto-unrar-script/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.itsfortytwo.net/2011/01/auto-unrar-script/" title="Auto UnRar Script"></a><p style="text-align: justify;">Ever needed a script that automatically extracts all rar archives in a directory and subdirectories, unrar them into their respective directories and then delete the archive files, but only if the extraction was successful? Well in that case, I wrote this little bash script today:</p>
<pre>#!/bin/bash
if [ -n "$1" ]
then
    echo "Unraring from $1"
    find $1 -type f -name '*.part01.rar' -execdir rar x -y -o- {} \;
    find $1 -type f -name '*.part001.rar' -execdir rar x -y -o- {} \;
    find $1 -type f -name '*.rar' -execdir rar x -y -o- {} \;
fi</pre>
<p>It takes the path of the folder you want to scan as argument: <span style="color: #008000;">unrarscript.sh /path/to/folder</span></p>
<p style="text-align: justify;">Edit Jan 31 2011: It seems the if statements checking if the extraction failed or not only checks if last extraction was successful. For it to work correctly the unlink should be nested inside the finds. I have not yet made any corrections to the script, but be aware of this weakness.</p>
<p style="text-align: justify;">Edit Nov 11 2011: Just removed the unlink part as it wasn&#8217;t working properly anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.itsfortytwo.net/2011/01/auto-unrar-script/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>C++ Progress Counter</title>
		<link>http://blog.itsfortytwo.net/2010/11/c-progress-counter/</link>
		<comments>http://blog.itsfortytwo.net/2010/11/c-progress-counter/#comments</comments>
		<pubDate>Sun, 14 Nov 2010 20:33:57 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Progress]]></category>

		<guid isPermaLink="false">http://blog.itsfortytwo.net/?p=376</guid>
		<description><![CDATA[<a href="http://blog.itsfortytwo.net/2010/11/c-progress-counter/" title="C++ Progress Counter"></a>Much of the code I write these days is for numerical methods used in physics. What I often need is some output that tells me how long a program has come in for instance a Monte Carlo integration. I had &#8230;<p class="read-more"><a href="http://blog.itsfortytwo.net/2010/11/c-progress-counter/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.itsfortytwo.net/2010/11/c-progress-counter/" title="C++ Progress Counter"></a><p style="text-align: justify;">Much of the code I write these days is for numerical methods used in physics. What I often need is some output that tells me how long a program has come in for instance a Monte Carlo integration. I had to look a bit around on the net as a regular cout command doesn&#8217;t seem to work within a loop, and I want the progress counter to overwrite the same line as it progresses. Here is the solution:</p>
<pre>j=0;
cout &lt;&lt; "Progress: 0%";
for(i=0; i&lt;iMax; i++) {
  //Algorithm here..

  if(i%(iMax/100)==0) {
    j++;
    cout &lt;&lt; "\rProgress: " &lt;&lt; j &lt;&lt; "%";
    fflush(stdout);
  }
}
cout &lt;&lt; endl;
</pre>
<p style="text-align: justify;">Key elements here are the &#8220;\r&#8221; to return the cursor to the beginning of the line (for the overwrite) and &#8220;fflush(stdout)&#8221; to flush the buffer, something which isn&#8217;t done automatically if you do not have an endl.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.itsfortytwo.net/2010/11/c-progress-counter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to stop the damn commentspam!</title>
		<link>http://blog.itsfortytwo.net/2009/11/how-to-stop-the-damn-commentspam/</link>
		<comments>http://blog.itsfortytwo.net/2009/11/how-to-stop-the-damn-commentspam/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 10:29:47 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.itsfortytwo.net/wp/index.php/2009/11/how-to-stop-the-damn-commentspam</guid>
		<description><![CDATA[<a href="http://blog.itsfortytwo.net/2009/11/how-to-stop-the-damn-commentspam/" title="How to stop the damn commentspam!"></a>I got fed up with the comment spam I get on my blog. I googled a bit and found a few solutions, but ended up with a plugin that adds CAPTCHA to the comment form.This little gem can be downloaded &#8230;<p class="read-more"><a href="http://blog.itsfortytwo.net/2009/11/how-to-stop-the-damn-commentspam/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.itsfortytwo.net/2009/11/how-to-stop-the-damn-commentspam/" title="How to stop the damn commentspam!"></a><p style="text-align: justify;"><a rel="attachment wp-att-138" href="http://blog.itsfortytwo.net/2009/11/how-to-stop-the-damn-commentspam/captcha/"><img class="alignright size-full wp-image-138" style="margin: 0 0 8px 8px;" title="captcha" src="http://blog.itsfortytwo.net/wp-content/uploads/2009/11/captcha.jpg" alt="captcha" width="175" height="45" /></a>I got fed up with the comment spam I get on my blog. I googled a bit and found a few solutions, but ended up with a plugin that adds CAPTCHA to the comment form.This little gem can be downloaded from <a href="http://www.642weather.com/weather/scripts-wordpress-captcha.php" target="_blank">here</a>.</p>
<p style="text-align: justify;">It is fun to observe the spammer-scripts bang their virtual heads against this simple little tool. I can observe all the spam attempts in my website log. <img src='http://blog.itsfortytwo.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.itsfortytwo.net/2009/11/how-to-stop-the-damn-commentspam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LaTeX Margins</title>
		<link>http://blog.itsfortytwo.net/2009/05/latex-margins/</link>
		<comments>http://blog.itsfortytwo.net/2009/05/latex-margins/#comments</comments>
		<pubDate>Tue, 19 May 2009 19:20:42 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[LaTeX]]></category>

		<guid isPermaLink="false">http://www.itsfortytwo.net/wp/?p=47</guid>
		<description><![CDATA[<a href="http://blog.itsfortytwo.net/2009/05/latex-margins/" title="LaTeX Margins"></a>Was writing a formula sheet for my quantum mechanics exam today, and needed to maximize usage of my available space on a piece of A4 paper. So I googled some solutions to get LaTeX to do just that. In addition &#8230;<p class="read-more"><a href="http://blog.itsfortytwo.net/2009/05/latex-margins/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.itsfortytwo.net/2009/05/latex-margins/" title="LaTeX Margins"></a><p>Was writing a formula sheet for my quantum mechanics exam today, and needed to maximize usage of my available space on a piece of A4 paper. So I googled some solutions to get LaTeX to do just that. In addition to using the /tiny command to make small text of course.</p>
<p>Firstly I needed to minimize the margins, so I added this in the header:</p>
<pre>\setlength\topmargin{-3cm}
\setlength\textheight{27cm}
\setlength\textwidth{19cm}
\setlength\oddsidemargin{-1.5cm}
\setlength\evensidemargin{-1.5cm}</pre>
<p>Then I needed to split the page into 3 columns so I wouldn&#8217;t waste too much space at each lineshift:</p>
<pre>\usepackage{multicol}

\begin{document}
\tiny
\begin{multicols}{3}
...text...
\end{multicols}</pre>
<p>And last but not least, get rid of that annoying huge indent that the align environment has.</p>
<pre>\documentclass[fleqn]{article}

\usepackage{amsmath}

\makeatletter
\setlength\@mathmargin{0.2cm}
\makeatother</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.itsfortytwo.net/2009/05/latex-margins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Meh, WordPress will do&#8230;</title>
		<link>http://blog.itsfortytwo.net/2009/05/meh-wordpress-will-do/</link>
		<comments>http://blog.itsfortytwo.net/2009/05/meh-wordpress-will-do/#comments</comments>
		<pubDate>Sun, 17 May 2009 19:00:45 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.itsfortytwo.net/wp/?p=40</guid>
		<description><![CDATA[<a href="http://blog.itsfortytwo.net/2009/05/meh-wordpress-will-do/" title="Meh, Wordpress will do..."></a>After spending most the afternoon coding php scripts for a new website, I decided to just stick with WordPress afterall. There are many things I don&#8217;t like about it, but I managed to find plugins for the stuff I was &#8230;<p class="read-more"><a href="http://blog.itsfortytwo.net/2009/05/meh-wordpress-will-do/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.itsfortytwo.net/2009/05/meh-wordpress-will-do/" title="Meh, Wordpress will do..."></a><p style="text-align: justify;">After spending most the afternoon coding php scripts for a new website, I decided to just stick with WordPress afterall. There are many things I don&#8217;t like about it, but I managed to find plugins for the stuff I was missing. Not to mention the animated Tag Cloud I saw the other day. Looks fancy, just need more, uhm, tags&#8230; <img src='http://blog.itsfortytwo.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: justify;">The current theme is fine too, spent a lot of time yesterday cleaning it up. It had several bugs. I also modified a lot of the code. I may just replace the banner (have a few made) and change the colors too, at which point there won&#8217;t be much left of the original theme. I have kept the link to it on the footer tho, but removed the ads.</p>
<p style="text-align: justify;">Tweaking is half the fun of a website!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.itsfortytwo.net/2009/05/meh-wordpress-will-do/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

