<?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/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/"
>

<channel>
	<title>ITauthor &#187; Programming</title>
	<atom:link href="http://www.itauthor.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.itauthor.com</link>
	<description>Stuff about technical writing and software</description>
	<lastBuildDate>Sat, 07 Jan 2012 12:34:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<!-- podcast_generator="Blubrry PowerPress/2.0.4" -->
	<itunes:summary>Talking about technical writing, software and technology in general. The ITauthor Podcast is an advert-free, irregularly published show by technical writers for technical writers or anyone interested in software documentation or IT generally.</itunes:summary>
	<itunes:author>Alistair Christie - ITauthor.com</itunes:author>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://www.itauthor.com/images/ITauthor-PhotoLogo-300px.jpg" />
	<itunes:owner>
		<itunes:name>Alistair Christie - ITauthor.com</itunes:name>
		<itunes:email>comments@itauthor.com</itunes:email>
	</itunes:owner>
	<managingEditor>comments@itauthor.com (Alistair Christie - ITauthor.com)</managingEditor>
	<copyright>2006-2009</copyright>
	<itunes:subtitle>Talking about technical writing, software and technology in general.</itunes:subtitle>
	<itunes:keywords>itauthor, alistair christie, technology, writing, documentation</itunes:keywords>
	<image>
		<title>ITauthor &#187; Programming</title>
		<url>http://www.itauthor.com/images/ITauthor-PhotoLogo-144px.jpg</url>
		<link>http://www.itauthor.com/category/programming/</link>
	</image>
	<itunes:category text="Technology">
		<itunes:category text="Software How-To" />
		<itunes:category text="Tech News" />
		<itunes:category text="Podcasting" />
	</itunes:category>
		<item>
		<title>Rails Chronicles &#8211; Part 2</title>
		<link>http://www.itauthor.com/2011/07/09/rails-chronicles-part-2/</link>
		<comments>http://www.itauthor.com/2011/07/09/rails-chronicles-part-2/#comments</comments>
		<pubDate>Sat, 09 Jul 2011 20:29:17 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/2011/07/09/rails-chronicles-part-2/</guid>
		<description><![CDATA[Before you read any further: This is the second in a series of posts intended to capture how I went about learning how to create Web apps using Rails. I thought it might be interesting to look back in a few months and see all the things I got wrong and didn’t understand about Ruby [...]]]></description>
			<content:encoded><![CDATA[<p><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 0px 1em; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" border="0" src="http://www.itauthor.com/wp-content/uploads/2011/06/150px-Ruby_on_Rails.svg_thumb.png" width="150" height="194" /><font color="#3f8287"><em><strong>Before you read any further</strong>:</em> This is the second in a series of posts intended to capture how I went about learning how to create Web apps using Rails. I thought it might be interesting to look back in a few months and see all the things I got wrong and didn’t understand about Ruby and Rails when I started out. So, if you’re looking for enlightenment about Rails, you’re in the wrong place. I’d recommend you head over to Michael Hartl’s </font><a href="http://ruby.railstutorial.org"><font color="#3f8287">Ruby on Rails Tutorial</font></a><font color="#3f8287">: that’s the site that really got me started.</font></p>
<h2 style="clear: left">Test first</h2>
<p>Chapter 3 of Michael Hartl’s Rails Tutorial introduces you to testing within Rails development. I’ve known about test-driven development (TDD) for a long time, but I’ve never actually done it. So I was looking forward to finding out how you write tests for something you’ve not built yet. </p>
<p>To be honest, not only have I never written tests before writing the code, I’ve never written tests full stop. In all my years of writing software programs (I wrote my first program, in BASIC, in 1989, then worked my way through C, Visual Basic for Applications, JavaScript, Perl and PHP) I’ve never actually <em>written</em> a test in software to test software I’ve written. So, this feels like a step up from my hacky habits towards a modicum of semi-professional rigour.</p>
<h2>RSpec</h2>
<p>RSpec (the R is for Ruby, Spec for Specification) is a Ruby package that lets you use a simple grammar to create specifications for software you intend to build. You can then test the software against the specification. The process goes something like this:</p>
<div class="quote">
<ul>
<li style="margin: 0px">You write a test. This test describes the behavior of a small element of your system. </li>
<li style="margin: 0px">You run the test. The test fails because you have not yet built the code for that part of your system. This important step tests your test case, verifying that your test case fails when it should. </li>
<li style="margin: 0px">You write enough code to make the test pass. </li>
<li style="margin: 0px">You run the tests and verify that they pass. </li>
</ul></div>
<p>The above is from <a href="http://www.ibm.com/developerworks/web/library/wa-rspec/"><em>Behavior-driven testing with RSpec</em></a> by <a href="http://www.ibm.com/developerworks/web/library/wa-rspec/#author1">Bruce Tate</a>, which is a good tutorial on RSpec if you want to stray from Michael Hartl’s tutorial for a while.</p>
<h3>Fixing the ANSICON warning</h3>
<p>When I ran the RSpec tests for the first time (<a href="http://ruby.railstutorial.org/chapters/static-pages#sec:TDD">section 3.2.2 of the Rails Tutorial</a>):</p>
<p><code style="margin: 0px">$ bundle exec rspec spec/ </code></p>
<p>it worked but the output text included the message:</p>
<pre style="margin: 0px 0px 1.8em"> *** WARNING: You must use ANSICON 1.31 or higher (<a href="http://adoxa.110mb.com/ansicon">http://adoxa.110mb.com/ansicon</a>) to get coloured
 output on Windows</pre>
<p>This sounds serious but it only means your console (in my case MINGW32 running bash – which came when I installed git from GitHub) isn’t displaying the colours it could be displaying.</p>
<p>If you want to fix this: </p>
<ol>
<li>Go to <a title="http://adoxa.110mb.com/ansicon/" href="http://adoxa.110mb.com/ansicon/">http://adoxa.110mb.com/ansicon/</a> and download ANSICON 1.40. </li>
<li>Unzip the downloaded zip file. </li>
<li>Open a command console as Administrator (i.e. type cmd into the start menu, right-click <strong>cmd.exe</strong> and choose <strong>Run as Administrator</strong>). </li>
<li>cd to the location of the unzipped files </li>
<li>You’ll find subdirectories called <strong>x86</strong> and <strong>x64</strong>. On a 32-bit machine go into the x86 directory. On a 64-bit machine go into the x64 directory. </li>
<li>
<p>If you want to see command syntax enter:</p>
<p><code>ansicon.exe -h</code></p>
</li>
<li>
<p>To install ANSICON, enter:</p>
<p><code>ansicon.exe -i</code></p>
</li>
</ol>
<h2>Autotest and Growl</h2>
<p>The tutorial describes using Autotest and Growl to run tests and notify you when your test completes by displaying a summary of the test results. The good thing about using Growl is that, you can kick off a suite of tests and then go away and do other things in Windows while the tests run. When they finish, a message is displayed on top of all other windows.</p>
<p>I’m still pretty hazy about exactly what Autotest does and doesn’t do. As its name suggests it obviously runs tests automatically, but I’ve yet to figure out why tests get triggered when you save changes to some files but not others. However, it’s very handy for something to be sitting waiting for you to change certain files and, when you do, checking the file to make sure you haven’t contravened any of the definitions in your specification. You do this by opening a dedicated console window, entering: </p>
<p><code>$ autotest </code></p>
<p>and then just leaving the window open in the background so that the autotest process keeps running and will run your tests as you work on your Rails project.</p>
<p>I set up Growl by following Michael Hartl’s instructions (plus the instructions he cross-refers to for Windows users):</p>
<p><code>$ gem install autotest -v 4.4.6 $ gem install autotest-rails-pure -v 4.1.2 $ gem install autotest-standalone $ gem install autotest-growl </code></p>
<p>Download and install Growl for Windows from:</p>
<p><a title="http://www.growlforwindows.com/gfw/" href="http://www.growlforwindows.com/gfw/">http://www.growlforwindows.com/gfw/</a>&#160;</p>
<p>Create a <strong>.autotest</strong> file as follows:</p>
<p><code>$ gvim ~/.autotest</code></p>
<p>Containing the single line of text:</p>
<p><code>require 'autotest/growl'</code></p>
<p>Of course if you want to use Growl to notify you the results of tests you’ve got to start it first. In Windows 7 just enter <span style="font-family: consolas,courier,&#39;Courier New&#39;">growl</span> in the Start menu search box and then press Enter when Windows finds the Growl program. I suppose if you were working on Ruby all the time and regularly running tests you could set up Growl to start automatically when Windows starts.</p>
<p>When you start Growl it displays a message telling you it’s running, but that’s all it does. It’s just waiting for a notification to display. Growl lives in the system tray. You can click it and change the setup options:</p>
<p class="img-holder"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="growl1" border="0" alt="growl1" src="http://www.itauthor.com/wp-content/uploads/2011/07/growl11.png" width="701" height="438" /></p>
<p class="img-holder"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="growl2" border="0" alt="growl2" src="http://www.itauthor.com/wp-content/uploads/2011/07/growl21.png" width="698" height="440" /></p>
<p>I’m not entirely sure what added Autotest to the list of applications. It wasn’t there at first but one of the command-line commands must have added it.</p>
<p>After setting up Growl when you start Autotest: </p>
<p><code>$ autotest </code></p>
<p>and your tests complete you get a sound and a visual notification telling you whether your tests passes or failed. I chose the notification style called Visor which slides down from the top of the screen:</p>
<p class="img-holder"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="growl-autotest-notification" border="0" alt="growl-autotest-notification" src="http://www.itauthor.com/wp-content/uploads/2011/07/growl-autotest-notification1.png" width="773" height="225" /></p>
<h2>No DRb server is running</h2>
<p>If, when you run autotest (or when you just run <strong>bin/rspec spec</strong>), you get:</p>
<pre style="margin: 0px 0px 1.8em">No DRb server is running. Running in local process instead ...</pre>
<p>it means Spork isn’t running.</p>
<p>Spork is a gem that you put into the Gemfile for your project. It contains a Distributed Ruby (DRb) server that enables Ruby programs to work with other Ruby programs by sending/receiving messages via the DRb server. So one Ruby program can use a method that’s defined in another Ruby program running on the same computer, or on a computer somewhere else on the network.</p>
<p>More about Distrubuted Ruby here: <a title="http://ruby.about.com/od/advancedruby/a/drb.htm" href="http://ruby.about.com/od/advancedruby/a/drb.htm">http://ruby.about.com/od/advancedruby/a/drb.htm</a></p>
<p>You need to associate your Ruby program with Spork. The setup instructions for Spork are described in the tutorial here: <a title="http://ruby.railstutorial.org/chapters/static-pages#sec:spork" href="http://ruby.railstutorial.org/chapters/static-pages#sec:spork">http://ruby.railstutorial.org/chapters/static-pages#sec:spork</a></p>
<p>To start Spork, open a new console window for the purpose, navigate to your project directory and enter:</p>
<p><code>$ bundle exec spork </code></p>
<p>You can then go back to your other console window and run autotest and it should complete the tests in less time, because it’s not having to load so much stuff (Spork has preloaded that stuff and is sitting waiting for connections).</p>
<h2>Switching Web server from WEBrick to thin</h2>
<p>Rails comes with the lightweight WEBrick Web server that you can use for testing pages – as described in the Rails Tutorial. However, I had a few odd little niggles with it, and it seemed very slow, so I switched to using an alternative called “thin”. To do this you need to install the <strong>eventmachine</strong> and <strong>thin</strong> gems. </p>
<p><em><strong>Note</strong>:</em> You need a particular version of eventmachine for thin on Windows. </p>
<ol>
<li>At the command line, change directories to your project directory. </li>
<li>
<p>Edit the <strong>Gemfile</strong> file within the project directory to:</p>
<p><code>group :development do&#160;&#160; …&#160;&#160; gem 'eventmachine', '1.0.0.beta.2'&#160;&#160; gem 'thin' end</code></p>
</li>
<li>
<p>Then run:</p>
<p><code>$ bundle install</code></p>
</li>
<li>
<p>You can then start the server like this:</p>
<p><code>$ rails s thin</code></p>
<p>Or, to redirect it’s output to a file and detach the process from the bash shell: </p>
<p><code>$ rails s thin &gt;&gt; thin_output_log.txt &amp;</code></p>
</li>
</ol>
<h2>Solving the ssh.exe problem</h2>
<p>After initially using GitHub without any problems, when I tried to update GitHub a few days later I discovered that this was no longer working. </p>
<p>Whenever I tried to do anything involving a connection to GitHub – even just<font face="Consolas"> ssh git@github.com</font> – I got a message saying: <strong>ssh.exe has stopped working</strong>.</p>
<p class="img-holder"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="ssh-stopped-working" border="0" alt="ssh-stopped-working" src="http://www.itauthor.com/wp-content/uploads/2011/07/ssh-stopped-working1.png" width="537" height="271" /></p>
<p>After much fruitless Googling, uninstalling and reinstalling Git for Windows, disabling anti-virus, etc. I finally discovered the fix, which is to set the file properties of <strong>ssh.exe</strong> and <strong>ssh-keygen.exe</strong> (in the <strong>Git/bin</strong> directory) so that they run in either Windows XP or Vista compatibility mode (either will do). </p>
<p class="img-holder"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="compatibility-mode" border="0" alt="compatibility-mode" src="http://www.itauthor.com/wp-content/uploads/2011/07/compatibility-mode1.png" width="772" height="699" /></p>
<p>I presume this is because I’m running 64-bit Windows 7. But I’ve no idea why it worked fine when I installed it initially.</p>
<p>Bizarrely, after restarting Windows I seem to have to go through this process again, even though the settings indicate that it should run in compatibility mode. It appears to be necessary to go to this tab in the Properties dialog box for these files and click OK to force this mode to be used.
  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2011/07/09/rails-chronicles-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My first (useful) Ruby program</title>
		<link>http://www.itauthor.com/2011/06/25/my-first-useful-ruby-program/</link>
		<comments>http://www.itauthor.com/2011/06/25/my-first-useful-ruby-program/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 22:44:40 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/2011/06/25/my-first-useful-ruby-program/</guid>
		<description><![CDATA[Summary: Batch convert files with names like 25_06_2011 21_30.wav to names like 2011-06-25_2130_Saturday.wav. I have a load of files with date/time-based file names in the format dd_mm_yyyy hh_mm.wav. I’d prefer these files to have a format that allowed them to be sorted in a directory in a meaningful way by the file name (i.e. yyyy-dd-mm). [...]]]></description>
			<content:encoded><![CDATA[<div style="padding-bottom: 13px; background-color: #eee; padding-left: 10px; padding-right: 10px; margin-bottom: 18px; padding-top: 12px"><strong>Summary</strong>: Batch convert files with names like <strong>25_06_2011 21_30.wav</strong> to names like <strong>2011-06-25_2130_Saturday.wav</strong>. </div>
<p>I have a load of files with date/time-based file names in the format <strong><em>dd_mm_yyyy hh_mm</em>.wav</strong>. I’d prefer these files to have a format that allowed them to be sorted in a directory in a meaningful way by the file name (i.e. <em>yyyy-dd-mm</em>). I also have a pet hate of file names containing spaces. It would also be useful to show the day of the week in the file name. So what I’d really like is a file name in the format <strong><em>yyyy-dd-mm_hhmm_&lt;dayname&gt;</em>.wav</strong>. </p>
<p>In the past I’d have written a Perl script to rename a batch of files, but since I’ve been looking at Ruby recently it made sense to have a bash at doing this in Ruby. </p>
<p>Here’s the program I came up with: </p>
<div><a style="text-decoration: none" href="/wp-content/uploads/2011/06/RenameWavFiles.rb">
<div style="background-color: #1b1d1e; font-family: consolas,monospace,monospace; color: #ffffff; font-size: 11pt"><span style="background-color: #232526"><font color="#bcbcbc">1 </font></span><font color="#a6e22e">#!/c/ruby/bin/ruby</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">2 </font></span><font color="#80a0ff"># Created by Alistair Christie</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">3 </font></span><font color="#80a0ff"># Date: 25 June 2011</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">4 </font></span><font color="#80a0ff"># This is my first functional Ruby program.</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">5 </font></span><font color="#80a0ff"># It's purpose is to take files in the current directory (if no arg supplied) -</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">6 </font></span><font color="#80a0ff"># or files in the specified directory (argument on command line) -</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">7 </font></span><font color="#80a0ff"># that match the pattern nn_nn_nnnn nn_nn.wav</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">8 </font></span><font color="#80a0ff"># (i.e. iPod voice memos saved as WAV files: dd_mm_yyyy hh_mm.wav)</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">9 </font></span><font color="#80a0ff"># copy them to an archive subdirectory</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">10 </font></span><font color="#80a0ff"># and rename the originals yyyy-mm-dd_hhmm_&lt;dayname&gt;.wav</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">11 </font></span>        <br /><span style="background-color: #232526"><font color="#bcbcbc">12 </font></span><font color="#a6e22e">require</font>&#160;<font color="#8f8f8f">'</font><font color="#e6db74">date</font><font color="#8f8f8f">'</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">13 </font></span><font color="#a6e22e">require</font>&#160;<font color="#8f8f8f">'</font><font color="#e6db74">fileutils</font><font color="#8f8f8f">'</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">14 </font></span>        <br /><span style="background-color: #232526"><font color="#bcbcbc">15 </font></span><font color="#f92672"><b>if</b></font>&#160;<font color="#fd971f">ARGV</font>.length &gt; <font color="#ae81ff">0</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">16 </font></span>&#160;&#160;&#160; <font color="#fd971f">$input_directory</font> = <font color="#fd971f">ARGV</font>[<font color="#ae81ff">0</font>]         <br /><span style="background-color: #232526"><font color="#bcbcbc">17 </font></span><font color="#f92672"><b>else</b></font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">18 </font></span>&#160;&#160;&#160; <font color="#fd971f">$input_directory</font> = <font color="#8f8f8f">'</font><font color="#e6db74">.</font><font color="#8f8f8f">'</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">19 </font></span><font color="#f92672"><b>end</b></font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">20 </font></span>        <br /><span style="background-color: #232526"><font color="#bcbcbc">21 </font></span><font color="#66d9ef">Dir</font>.chdir(<font color="#fd971f">$input_directory</font>)         <br /><span style="background-color: #232526"><font color="#bcbcbc">22 </font></span>        <br /><span style="background-color: #232526"><font color="#bcbcbc">23 </font></span><font color="#fd971f">$archivedir</font> = <font color="#8f8f8f">&quot;</font><font color="#e6db74">originalFiles_nowRenamed</font><font color="#8f8f8f">&quot;</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">24 </font></span><font color="#fd971f">$count</font> = <font color="#ae81ff">0</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">25 </font></span>        <br /><span style="background-color: #232526"><font color="#bcbcbc">26 </font></span>puts <font color="#8f8f8f">&quot;</font><font color="#e6db74">Processing ...</font><font color="#8f8f8f">&quot;</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">27 </font></span>        <br /><span style="background-color: #232526"><font color="#bcbcbc">28 </font></span><font color="#66d9ef">def</font>&#160;<font color="#a6e22e">file_match</font>(pattern=<font color="#8f8f8f">/</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\d\d</i></font></span><font color="#e6db74">_</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\d\d</i></font></span><font color="#e6db74">_</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\d\d\d\d</i></font></span><font color="#e6db74">&#160;</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\d\d</i></font></span><font color="#e6db74">_</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\d\d</i></font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\.</i></font></span><font color="#e6db74">wav</font><font color="#8f8f8f">/</font>, path=<font color="#8f8f8f">'</font><font color="#e6db74">.</font><font color="#8f8f8f">'</font>)         <br /><span style="background-color: #232526"><font color="#bcbcbc">29 </font></span>&#160; <font color="#66d9ef">Dir</font>[<font color="#66d9ef">File</font>.join(path,<font color="#8f8f8f">'</font><font color="#e6db74">*</font><font color="#8f8f8f">'</font>)].each <font color="#f92672"><b>do</b></font> |<font color="#fd971f">file</font>|         <br /><span style="background-color: #232526"><font color="#bcbcbc">30 </font></span>&#160;&#160;&#160; <font color="#f92672"><b>if</b></font> file =~ pattern         <br /><span style="background-color: #232526"><font color="#bcbcbc">31 </font></span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="#fd971f">$count</font> += <font color="#ae81ff">1</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">32 </font></span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="#f92672"><b>if</b></font>&#160;<font color="#fd971f">$count</font>==<font color="#ae81ff">1</font>&#160;<font color="#f92672"><b>then</b></font>&#160;<font color="#66d9ef">Dir</font>.mkdir(<font color="#fd971f">$archivedir</font>) <font color="#f92672"><b>unless</b></font>&#160;<font color="#66d9ef">File</font>.exists?(<font color="#fd971f">$archivedir</font>)         <br /><span style="background-color: #232526"><font color="#bcbcbc">33 </font></span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="#f92672"><b>end</b></font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">34 </font></span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; file =~ <font color="#8f8f8f">/</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>^</i></font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>[^\d]</i></font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>*</i></font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>(</i></font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\d\d</i></font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>)</i></font></span><font color="#e6db74">_</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>(</i></font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\d\d</i></font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>)</i></font></span><font color="#e6db74">_</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>(</i></font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\d\d\d\d</i></font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>)</i></font></span><font color="#e6db74">&#160;</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>(</i></font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\d\d</i></font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>)</i></font></span><font color="#e6db74">_</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>(</i></font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\d\d</i></font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>)</i></font></span><font color="#8f8f8f">/</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">35 </font></span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="#80a0ff">#puts &quot;Matched file: #{file}&quot; </font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">36 </font></span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; dt = <font color="#66d9ef">Date</font>.new(<font color="#fd971f">$3</font>.to_i, <font color="#fd971f">$2</font>.to_i, <font color="#fd971f">$1</font>.to_i);         <br /><span style="background-color: #232526"><font color="#bcbcbc">37 </font></span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; dy = <font color="#66d9ef">Date</font>::<font color="#66d9ef">DAYNAMES</font>[dt.wday]         <br /><span style="background-color: #232526"><font color="#bcbcbc">38 </font></span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; newfilename = <font color="#8f8f8f">&quot;</font><font color="#8f8f8f">#</font><font color="#fd971f">$3</font><font color="#e6db74">-</font><font color="#8f8f8f">#</font><font color="#fd971f">$2</font><font color="#e6db74">-</font><font color="#8f8f8f">#</font><font color="#fd971f">$1</font>_<font color="#8f8f8f">#</font><font color="#fd971f">$4</font><font color="#8f8f8f">#</font><font color="#fd971f">$5</font>_<font color="#8f8f8f">&quot;</font> + dy + <font color="#8f8f8f">&quot;</font><font color="#e6db74">.wav</font><font color="#8f8f8f">&quot;</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">39 </font></span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="#66d9ef">FileUtils</font>.cp(file, <font color="#fd971f">$archivedir</font> + <font color="#8f8f8f">&quot;</font><font color="#e6db74">/</font><font color="#8f8f8f">&quot;</font> + file)         <br /><span style="background-color: #232526"><font color="#bcbcbc">40 </font></span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="#66d9ef">FileUtils</font>.mv(file, newfilename)         <br /><span style="background-color: #232526"><font color="#bcbcbc">41 </font></span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; puts file + <font color="#8f8f8f">&quot;</font><font color="#e6db74"> renamed </font><font color="#8f8f8f">&quot;</font> + newfilename         <br /><span style="background-color: #232526"><font color="#bcbcbc">42 </font></span>&#160;&#160;&#160; <font color="#f92672"><b>end</b></font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">43 </font></span>&#160; <font color="#f92672"><b>end</b></font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">44 </font></span><font color="#66d9ef">end</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">45 </font></span>        <br /><span style="background-color: #232526"><font color="#bcbcbc">46 </font></span>file_match         <br /><span style="background-color: #232526"><font color="#bcbcbc">47 </font></span>        <br /><span style="background-color: #232526"><font color="#bcbcbc">48 </font></span><font color="#f92672"><b>if</b></font>&#160;<font color="#fd971f">$count</font>&gt;<font color="#ae81ff">0</font>&#160;<font color="#f92672"><b>then</b></font> puts <font color="#fd971f">$count</font>.to_s + <font color="#8f8f8f">&quot;</font><font color="#e6db74"> files were renamed.</font><font color="#8f8f8f">&quot;</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">49 </font></span><font color="#f92672"><b>else</b></font> puts <font color="#8f8f8f">&quot;</font><font color="#e6db74">No files were renamed.</font><font color="#8f8f8f">&quot;</font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">50 </font></span><font color="#f92672"><b>end</b></font>        <br /><span style="background-color: #232526"><font color="#bcbcbc">51 </font></span>        </div>
<p>   </a></div>
<p style="margin-top: 25px">Anyone looking at this who knows how to code in Ruby will, doubtless, immediately see all sorts of issues with it. But I’m quite happy with it because it didn’t take long to write and it does the job. </p>
<p>I’ve saved this file as <strong>RenameWavFiles.rb</strong> in the iTunes directory where all these files get created and I have a shortcut to that directory so that all I need to do is click the shortcut icon to open the directory in Windows Explorer, then double-click the Ruby file to rename any new files. The files are copied to a subdirectory with their original names just in case there’s a problem. Job done! </p>
<p>I wrote the code in Vim 7.2 and one nice thing about the GVim incarnation of Vim is that, in the Syntax menu, there’s a <strong>Convert to HTML</strong> option that creates the output you can see above. </p>
<p style="margin-top: -10px"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="gvim-convert-to-HTML" border="0" alt="gvim-convert-to-HTML" src="/wp-content/uploads/2011/06/gvim-convert-to-HTML_thumb2.png" width="751" height="297" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2011/06/25/my-first-useful-ruby-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Chronicles &#8211; Part 1</title>
		<link>http://www.itauthor.com/2011/06/19/rails-chronicles-part-1/</link>
		<comments>http://www.itauthor.com/2011/06/19/rails-chronicles-part-1/#comments</comments>
		<pubDate>Sun, 19 Jun 2011 13:05:22 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/2011/06/19/rails-chronicles-part-1/</guid>
		<description><![CDATA[Before you read any further: The purpose of this post is to capture how I went about learning how to create Web apps using Rails. I thought it might be interesting to look back in a few months and see all the things I got wrong and didn’t understand about Ruby and Rails when I [...]]]></description>
			<content:encoded><![CDATA[<p><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 10px 20px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="150px-Ruby_on_Rails.svg" border="0" alt="150px-Ruby_on_Rails.svg" src="http://www.itauthor.com/wp-content/uploads/2011/06/150px-Ruby_on_Rails.svg_thumb.png" width="150" height="194" /><font color="#3f8287"><em><strong>Before you read any further</strong>:</em> The purpose of this post is to capture how I went about learning how to create Web apps using Rails. I thought it might be interesting to look back in a few months and see all the things I got wrong and didn’t understand about Ruby and Rails when I started out. So, if you’re looking for enlightenment about Rails, you’re in the wrong place. I’d recommend you head over to Michael Harl’s </font><a href="http://ruby.railstutorial.org"><font color="#3f8287">Ruby on Rails Tutorial</font></a><font color="#3f8287">: that’s the site that really got me started.</font></p>
<h2 style="clear: left">Introduction</h2>
<p>I have a stinking cold this weekend and, apart from dragging myself out to walk the dog, I’ve been fit for nothing else but sitting on the sofa (or lying in bed) with my laptop. But I thought I’d try to use the time profitably by <em>finally</em> getting around to learning how to use Rails. I’ve been meaning to do this for over five years now – i.e. since the days when all the tech podcasts I listened to hyped it up as the great new thing on the Web.</p>
<p>Back in 2006 I even bought my daughter a copy of the original edition of Chris Pine’s <em><a href="http://www.amazon.com/Learn-Program-Second-Facets-Ruby/dp/1934356360/ref=dp_ob_title_bk">Learn to Program</a></em> book – which uses Ruby to teach programming – on the off-chance that she might get interested in coding. We sat and went through some of it together but she really wasn’t interested so the book then lay unread for years, until a couple of months back when I packed it into one of several big cardboard boxes with all my other computer books and it went off to the Oxfam bookshop.</p>
<p>The trouble has been (apart from inertia, laziness and wariness about potentially wasting lots of time on yet one more thing I really don’t need to know about) that I’ve been doing most of the dynamic Web page goodness I need to do quite fine all these years using PHP (well, a combination of PHP, MySQL, Javascript, CSS and plain old HTML to be precise). So I haven’t had a <em>need</em> to learn about Rails. But PHP seems antiquated these days and I really feel like I need to move on. I also wanted to get a better understanding what Model-View-Controller (MVC) is all about. I understand the principals of MVC, but it’s not until you actually use a programming concept that you really understand it. </p>
<p>Before PHP I was a committed Perl devotee and it took me a while to switch to PHP because I really liked Perl and I was doing some fairly complex stuff with it. I got into Perl because I’d started writing Web pages in HTML, discovered you couldn’t do much with HMTL alone, started writing Javascript, discovered that that had its limitations (as well as being the source of a great deal of pain back then) and so I ended up, like many people who followed the same route, writing Perl CGI scripts. That was before PHP had really got going and, for hobbyist Web site creators like myself, Perl CGI scripts on Apache servers was about the only way to go. And I really enjoyed writing Perl. The only thing that did for Perl was the whole issue with modules: figuring out which modules you needed, which versions were installed, installing multiple versions of modules so as not to break someone else’s scripts, and so on. Modules were a bit of a nightmare. PHP just seemed to have everything built in and you could just crack on and do the coding.</p>
<p>So I switched from Perl to PHP and never looked back. But I do remember being horrified at first by the mix of HTML and code within PHP files. The recipe seemed to be: chuck all your ingredients (design, content, functionality) into one bowl and give it a good old mix. It struck me as having massive potential for confusion and maintenance issues. With my Perl scripts I’d used separate HTML templates. The Perl script requested by the browser called up other scripts as required, did the processing, worked with the database, gathered together all the dynamic content and then selected from a choice of templates and built the final HTML by replacing placeholders with the dynamic content. I really liked the idea of keeping the page design and static content as separate as possible from the code – it just seemed a lot cleaner that way. So that’s one thing I’m expecting Rails to have got right and I’m looking forward to getting back to that kind of way of doing things. We’ll see.</p>
<h2>Starting point</h2>
<p>I can’t code in Ruby. I’ve read up about it at various points during the past few years and I’ve written a few little Ruby programs in the course of dipping my toes in the subject. Specifically, I’ve spent some time with these resources:</p>
<ul>
<li>Chris Pine’s book, mentioned above (I recently downloaded the 2nd edition to my iPad) </li>
<li><em><a href="http://www.amazon.com/Beginning-Ruby-Novice-Professional-Experts/dp/1590597664/ref=pd_sim_b_93">Beginning Ruby: From Novice to Professional</a></em> by Peter Cooper </li>
<li><a title="http://tryruby.org/" href="http://tryruby.org/">http://tryruby.org/</a> – a great, try-it-online-as-you-go, getting started tutorial </li>
<li><a href="http://why's (poignant) Guide to Ruby">why's (poignant) Guide to Ruby</a> – better experienced than described; the story behind this is as intriguing as the book itself </li>
</ul>
<p>But, as of today, I have to say I really can’t code in Ruby. Should I have concentrated on this for a bit before jumping into Rails? I’ve read conflicting advice answering this question <em>definitely yes</em>, and <em>no, it’s not necessary</em>. It’ll be interesting to see how much this lack of knowledge holds me back or trips me up.</p>
<p>As far as Rails goes, before this weekend I’d watched pretty much every video I could find about Rails at one time or another – including all the ones where someone zips through and creates a (seemingly) fully functioning social media Web site in about ten minutes. For non-macho programmers like myself that kind of thing (where someone is talking super fast and typing commands even faster, and things are zapping past you on the screen: zap, there goes validation, blink and you miss it, there goes authentication …), that just puts me off, because what it says to me is: only ubergeeks will <em>really</em> find this as easy as this guy seems to – the rest of us would doubtlessly only get mired in bizarre error messages before we ever got anywhere near creating a working Web page.</p>
<p>Anyway, I’d heard a podcast a while back where Michael Hartl was being interviewed about the Rails tutorial he’d written and the screencasts he’d created, and how he makes a really good living from people buying the screencasts and the PDF of the tutorial, even though the same content that’s in the PDF is available for free as Web pages. So this weekend I finally went and looked up <a title="http://ruby.railstutorial.org/ruby-on-rails-tutorial-book" href="http://ruby.railstutorial.org/ruby-on-rails-tutorial-book">http://ruby.railstutorial.org/ruby-on-rails-tutorial-book</a> and started reading the first chapter of the tutorial book. And so far so good. I’ve done the first two chapters now and I like it. It’s up to date and it works.</p>
<h2>gvim</h2>
<p>The other thing I spent some time on was downloading, setting up and relearning <a href="http://www.vim.org/download.php">vim</a> (actually gvim). This is a lightly updated version of the UNIX vi editor. There’s a Windows version of gvim that lets you relive the experience of using a text editor originally created by a 22-year-old <a href="http://en.wikipedia.org/wiki/Bill_Joy">Bill Joy</a> back in 1976. It might sound crazy to choose to go back to using vim, but I think it might make sense – there are some definite benefits.</p>
<p>I started using vi in 2001 when I got a job as a technical author and discovered, first day on the job, that I wouldn’t be using Word or even Notepad. I had a choice between vi and Emacs, neither of which I’d heard of before. I tried them both and settled on Emacs at the time, but since leaving that job I’ve never used Emacs again but I’ve used vi regularly over the years just because it’s always available on any UNIX/Linux server you ever connect to. </p>
<p>For a long time my text editor of choice was UltraEdit. I then switched to <a href="http://notepad-plus-plus.org/">Notepad++</a> and I’ve stuck with it for the last eight or nine years now. But I thought I’d tie in learning Rails with brushing up my vi expertise (in the shape of gvim on Windows). I should point out that I’m working on Windows 7. So, after some tweaking of colours and window setup, and spending a little time revising the subject and creating a personal cheatsheet on vim (in vim), I’m using it quite happily now. I’ve never really been a mouse lover. I like keyboard shortcuts, and the great thing about vi is being able to keep your hands on the keyboard all the time: it really does allow you to get things done far quicker than you can by pointing, clicking, dragging.</p>
<h2>git</h2>
<p>git is another of those things I’ve been hearing about a lot over the past five years or so and felt I should find out more about. Back when I was learning vi and Emacs I was also learning about CVS, and I found it a steep learning curve. Fast forward a few years and, at my current job, we switched our version control from CVS to SVN and I came to really like SVN. I particularly like TortoiseSVN and its repo browser. But I’ve been thinking about looking at git for a while now – just to find out why people seem to like it better (it seems to be the most-used version control system for software source files now). </p>
<p>So I was pleased to discover that Michael Hartl’s tutorial gets you committing your Rails code to <a href="https://github.com/">github</a> right from the start. The only trouble I’ve had with the tutorial so far has been that I couldn’t push code up to github successfully to begin with and I struggled for a while (and posted a question on stackoverflow about it) before realising that I’d screwed up with one of my initial commands, meaning I had to delete the .git directory and start over. The problem was that I’d tried to push up my code before going to the github Web site and creating an account and a repository. Yes, I know: duh! But the problem seemed to be that having made this error, even though I then went and created the account and repository, something in my .git directory must have been messed up. So that held me up for a few hours, but – after backing up and redoing it – it now works fine.</p>
<p>The git commands are (like much in the world of Ruby on Rails, I suspect) the kind of thing that you just have to learn. It’s not obvious and you can’t just guess and figure it out. You need to know that exact words and syntax or it won’t work.</p>
<p>One of the things I like about having installed git from github is that I now have a bash shell on my Windows 7 machine. I can press the Windows key, type <strong>bash</strong>, press Enter and I get a console window with the bash shell, which allows you to do a lot more, a lot more easily than the standard Windows DOS-type command console.</p>
<h2>Heroku</h2>
<p>Finally, for this inaugural Rails Chronicle post, something else I’d heard about in a podcast but never used: <a href="http://www.heroku.com/">Heroku</a>. I spent a few days up in Glen Esk earlier this year and I remember one day walking the dog across the field to the river and than back up along the side of the Tarf listening to a podcast about Heroku, which is a hosting service for Web applications. Actually it’s more than that. It’s a system for continuous deployment of Web applications that’s intigrated with git to make it easy to push files up to Heroku’s cloud service and build a deployment that you can immediately browse to.</p>
<p>It seems to work incredibly easily and smoothly – but, again, working from the command line, you need to know the right commands; although these seem to amount to:</p>
<pre>$ heroku create
$ git push heroku master
$ heroku rake db:migrate</pre>
<h2 style="margin-top:18px">Conclusion</h2>
<p>So far so good. I’ve only done the first two chapters but they cover a whole lot of ground and I feel like I’ve learned a lot already. What I haven’t learned however, is <em>any</em> Ruby – so far.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2011/06/19/rails-chronicles-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Gotchas with running a Perl script as a cron job</title>
		<link>http://www.itauthor.com/2010/08/03/gotchas-with-running-a-perl-script-as-a-cron-job/</link>
		<comments>http://www.itauthor.com/2010/08/03/gotchas-with-running-a-perl-script-as-a-cron-job/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 20:20:00 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/2010/08/03/gotchas-with-running-a-perl-script-as-a-cron-job/</guid>
		<description><![CDATA[So you've written a Perl script and it runs fine from the command line using a command such as: perl /home/alistair/scripts/myscript.pl Great, so now you set up a cron job so that the script will run automatically. For example, let's say you want to run it every Monday morning at 4.20 am: 20 4 * [...]]]></description>
			<content:encoded><![CDATA[<p>So you've written a Perl script and it runs fine from the command line using a command such as:</p>
<p> <code>perl /home/alistair/scripts/myscript.pl </code>
<p>Great, so now you set up a cron job so that the script will run automatically. For example, let's say you want to run it every Monday morning at 4.20 am:</p>
<p> <code>20 4 * * 1 perl /home/alistair/scripts/myscript.pl </code>
<p>&#160; <br />However, when this runs it generates the following email: </p>
<p> <code>Your &quot;cron&quot; job on myserver    <br />perl /home/alistair/scripts/myscript.pl     </p>
<p>produced the following output:     </p>
<p>Can't locate DBI.pm in @INC (@INC contains: /usr/perl5/5.6.1/lib/sun4-solaris-64int /usr/perl5/5.6.1/lib /usr/perl5/site_perl/5.6.1/sun4-solaris-64int /usr/perl5/site_perl/5.6.1 /usr/perl5/site_perl /usr/perl5/vendor_perl/5.6.1/sun4-solaris-64int /usr/perl5/vendor_perl/5.6.1 /usr/perl5/vendor_perl .) at /home/alistair/scripts/myscript.pl line 15.     <br />BEGIN failed--compilation aborted at /home/alistair/scripts/myscript.pl line 15. </code>
<p>&#160; <br />What this means is that your script uses a Perl module (in this example, DBI.pm) which can't be found. The error message shows all the paths in the @INC list of paths where Perl looks for modules. So, for some reason, Perl found the module when <em>you</em> ran the script, but didn't find the module when cron ran the script as you.</p>
<p>The reason is that cron doesn't run in the same environment that you're using. When you connect to the server, you probably automatically change to your preferred shell (e.g. csh, ksh or bash) and load up a whole set of environment variables. This happens within the startup file – for example, <strong>.bashrc</strong> or <strong>.cshrc</strong>. But cron doesn't load up any of this, and it uses sh by default.</p>
<p>To see what's in @INC within <em>your</em> environment use this command:</p>
<p> <code>perl -le 'print for grep {$_ ne q{.}and -d} @INC' </code>
<p>&#160; <br />And you'll probably notice differences between the output you get and the contents of @INC listed in the error message.</p>
<p>So, to make sure @INC contains the necessary paths in any environment, load it up from within your Perl script. To do this, add something like the following to the top of your Perl script, just after the path to Perl: </p>
<p> <code>BEGIN {    <br />&#160;&#160;&#160;&#160; push @INC,( '/usr/local/lib/perl5/5.8.2/sun4-solaris',     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; '/usr/local/lib/perl5/site_perl/5.8.2/sun4-solaris',     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; '/usr/local/lib/perl5/site_perl/5.8.0/sun4-solaris',     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; '/usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris' );     <br />} </code>
<p>So now Perl will be able to find the missing Perl module. Sorted! Well maybe not.</p>
<p>If you now try running the script from the cron job you may get something like: </p>
<p> <code>Your &quot;cron&quot; job on myserver    <br />perl /home/alistair/scripts/myscript.pl     </p>
<p>produced the following output:     </p>
<p>ld.so.1: perl: fatal: relocation error: file /usr/local/lib/perl5/site_perl/5.8.0/sun4-solaris/auto/DBI/DBI.so: symbol Perl_PerlIO_stderr: referenced symbol not found Killed </code>
<p><em>Now</em> it's complaining about not finding something called <strong>ld.so.1</strong>. The problem here is with your PATH. </p>
<p>On my server, <strong>ld.so.1</strong> lives in <strong>/usr/lib</strong>. You should be able to find out where <strong>ld.so.1</strong> is by running:</p>
<p> <code>whereis ld.so.1</code>
<p><strong>/usr/lib</strong> isn't exactly an obscure place to look, but it's not in the PATH when the cron job runs. So the easy solution is to explicitly set the contents of the PATH environment variable in the cron job:</p>
<p> <code>20 4 * * 1 PATH=/usr/local/bin:/usr/bin:/usr/sbin:/usr/lib; perl /home/alistair/scripts/myscript.pl </code>
<p>Now, just before the Perl script is run, the PATH gets set to three paths: <strong>/usr/local/bin</strong>, <strong>/usr/bin</strong>, <strong>/usr/sbin</strong> and <strong>/usr/lib</strong>. The syntax used here is that required by the sh shell in which cron runs.</p>
<p>At last, job done. The script runs and you'll be emailed any output it generates.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2010/08/03/gotchas-with-running-a-perl-script-as-a-cron-job/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP (or Perl) one line if/then/else statements</title>
		<link>http://www.itauthor.com/2009/08/08/php-or-perl-one-line-ifthenelse-statements/</link>
		<comments>http://www.itauthor.com/2009/08/08/php-or-perl-one-line-ifthenelse-statements/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 06:53:35 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/2009/08/08/php-or-perl-one-line-ifthenelse-statements/</guid>
		<description><![CDATA[If you're toggling something between two states in PHP or Perl it's often handy to use an if/then/else one liner. In pseudocode this goes like this: &#60;if this evaluates to TRUE&#62; then &#60;parse this&#62; else &#60;parse this&#62; All you need to do is replace the &#34;then&#34; with a question mark and the &#34;else&#34; with a [...]]]></description>
			<content:encoded><![CDATA[<p>If you're toggling something between two states in PHP or Perl it's often handy to use an if/then/else one liner.</p>
<p>In pseudocode this goes like this:</p>
<p><em>&lt;<strong>if </strong>this evaluates to TRUE&gt; </em><strong>then </strong><em>&lt;parse this&gt; </em><strong>else </strong><em>&lt;parse this&gt;</em></p>
<p>All you need to do is replace the &quot;then&quot; with a question mark and the &quot;else&quot; with a colon:</p>
<p><em>&lt;<strong>if </strong>this evaluates to TRUE&gt; </em><strong>? </strong><em>&lt;parse this&gt; </em><strong>:</strong><strong> </strong><em>&lt;parse this&gt;</em></p>
<p>For example:</p>
<p><span style="color: #c0c0c0"><em>print</em>&#160; </span>$trueOrFalse ? &quot;you're telling the truth&quot; : &quot;you're lying&quot;;</p>
<p>Ignore the print command, it's not part of the if/then/else statement, it's just here to do something with the outcome of that statement.</p>
<p>The expression immediately to the left of the question mark is evaluated. The expression between the question mark and the colon is parsed if the expression evaluates to TRUE, otherwise the expression immediately to the right of the colon is parsed. So in the above example, either &quot;you're telling the truth&quot; or &quot;you're lying&quot; is printed, depending on whether $trueOrFalse is ... you guessed it ... TRUE or FALSE.</p>
<p>But perhaps a more common situation is toggling the value assigned to a variable. For example, toggling between TRUE and FALSE:</p>
<p><span style="color: #c0c0c0"><em>$trueOrFalse = </em></span>$trueOrFalse ? FALSE : TRUE;</p>
<p>Here's a practical example of the use of if/then/else one liners. There's two in this chunk of PHP. The scroll box list below the code is the kind of thing this PHP produces.</p>
<p>&lt;div style=&quot;overflow:auto; height:100px; width:300px; border:3px groove #DDD; padding:0&quot;&gt;    <br />&lt;?php     <br />&#160;&#160;&#160; $alternateLine = FALSE;     <br />&#160;&#160;&#160; while($presidentsArray) {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; print &quot;&lt;div style=\&quot;background-color:&quot;;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; print $alternateLine ? &quot;#F5F8F9&quot; : &quot;white&quot;;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; print &quot;; padding-bottom: 1px\&quot;&gt; &amp;nbsp; &amp;nbsp; &lt;a href=\&quot;someURL\&quot; title=\&quot;This link goes nowhere\&quot;&gt;&quot; .     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $presidentsArray['name'] . &quot;&lt;/a&gt;&lt;/div&gt;&quot;;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $alternateLine = $alternateLine ? FALSE : TRUE;     <br />&#160;&#160;&#160; }     <br />?&gt;     <br />&lt;/div&gt;</p>
<div style="border-bottom: #dddddd 3px groove; border-left: #dddddd 3px groove; padding-bottom: 0pt; padding-left: 0pt; width: 300px; padding-right: 0pt; height: 100px; overflow: auto; border-top: #dddddd 3px groove; border-right: #dddddd 3px groove; padding-top: 0pt">
<div style="padding-bottom: 1px; background-color: white">&#160;&#160;&#160; <a title="This link goes nowhere" href="someURL">George Washington</a></div>
<div style="padding-bottom: 1px; background-color: #f5f8f9">&#160;&#160;&#160; <a title="This link goes nowhere" href="someURL">John Adams</a></div>
<div style="padding-bottom: 1px; background-color: white">&#160;&#160;&#160; <a title="This link goes nowhere" href="someURL">Thomas Jefferson</a></div>
<div style="padding-bottom: 1px; background-color: #f5f8f9">&#160;&#160;&#160; <a title="This link goes nowhere" href="someURL">James Madison</a></div>
<div style="padding-bottom: 1px; background-color: white">&#160;&#160;&#160; <a title="This link goes nowhere" href="someURL">James Monroe</a></div>
<div style="padding-bottom: 1px; background-color: #f5f8f9">&#160;&#160;&#160; <a title="This link goes nowhere" href="someURL">John Quincy Adams</a></div>
<div style="padding-bottom: 1px; background-color: white">&#160;&#160;&#160; <a title="This link goes nowhere" href="someURL">Andrew Jackson</a></div>
<div style="padding-bottom: 1px; background-color: #f5f8f9">&#160;&#160;&#160; <a title="This link goes nowhere" href="someURL">Martin Van Buren</a></div>
<div style="padding-bottom: 1px; background-color: white">&#160;&#160;&#160; <a title="This link goes nowhere" href="someURL">William Henry Harrison</a></div>
<div style="padding-bottom: 1px; background-color: #f5f8f9">&#160;&#160;&#160; <a title="This link goes nowhere" href="someURL">John Tyler</a></div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2009/08/08/php-or-perl-one-line-ifthenelse-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A handy PHP date() checker</title>
		<link>http://www.itauthor.com/2009/07/30/a-handy-php-date-checker/</link>
		<comments>http://www.itauthor.com/2009/07/30/a-handy-php-date-checker/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 15:54:14 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/2009/07/30/a-handy-php-date-checker/</guid>
		<description><![CDATA[A handy site to remember if you’re writing PHP is http://php-date.com/. It provides everything you need to know about the date() function in PHP and has an interactive form for testing your formatting until you get your dates/times just the way you want them.]]></description>
			<content:encoded><![CDATA[<p>A handy site to remember if you’re writing PHP is <a title="http://php-date.com/" href="http://php-date.com/">http://php-date.com/</a>. It provides everything you need to know about the date() function in PHP and has an interactive form for testing your formatting until you get your dates/times just the way you want them.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="php-date-function" border="0" alt="php-date-function" src="http://www.itauthor.com/wp-content/uploads/2009/07/phpdatefunction.png" width="530" height="216" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2009/07/30/a-handy-php-date-checker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>“Programmers love hierarchy … normal people hate that”</title>
		<link>http://www.itauthor.com/2009/03/15/programmers-love-hierarchy-normal-people-hate-that/</link>
		<comments>http://www.itauthor.com/2009/03/15/programmers-love-hierarchy-normal-people-hate-that/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 20:11:19 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[User interface]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/2009/03/15/programmers-love-hierarchy-normal-people-hate-that/</guid>
		<description><![CDATA[Something I&#8217;ve been preaching for years, to any software developer who&#8217;ll listen, is: don&#8217;t use a tree view control in the user interface if your users are not highly technical and there&#8217;s another way of allowing the user to do the thing they actually want to do (which there usually is if you put some [...]]]></description>
			<content:encoded><![CDATA[<p><img height="318" width="318" border="0" title="treeview" style="border: 0px none ; margin-top: 5px; float: left; margin-right: 10px;" alt="treeview" src="http://www.itauthor.com/wp-content/uploads/2009/03/treeview.gif" />Something I&rsquo;ve been preaching for years, to any software developer who&rsquo;ll listen, is: don&rsquo;t use a tree view control in the user interface if your users are not highly technical and there&rsquo;s another way of allowing the user to do the thing they <em>actually</em> want to do (which there usually is if you put some thought into it).</p>
<p>So I was delighted to hear Jeff Atwood and Joel Spolsky&rsquo;s views on the <a href="http://blog.stackoverflow.com/2009/03/podcast-45/">Stack Overflow Podcast #45</a>:</p>
<p>&nbsp;</p>
<hr />
<blockquote>
<p><b>Atwood:&nbsp;&nbsp; </b>&hellip; programmers <i>love</i> hierarchy, to a degree that they don't even understand how different they are than the public in this regard. Like they love putting everything in this little bucket, that goes in this little bucket, which is this sub-bucket of this and this, and normal people <i>hate</i> that. And threading is <i>totally</i> a manifestation of that and it drives me crazy that a lot of programmers can't see that they're like immediately like: &quot;Oh, threading is good. I <i>love</i> threading. What are you <i>talking</i> about?&quot; You know? They can't see it at all.      </p>
<p><b>Spolsky</b>:&nbsp;&nbsp; Right, right.       </p>
<p><b>Atwood:&nbsp;&nbsp; </b>It's like myopia.      </p>
<p><b>Spolsky</b>:&nbsp;&nbsp; Yeh. I mean it's really a function of the size of the group, and one thing I've learned through years and years of usability testing is that anything that smacks of a hierarchy or a tree is <i>not</i> going to be understandable to the average, non-technical user.      </p>
<p><b>Atwood:&nbsp;&nbsp; </b>Yeh.      </p>
<p><b>Spolsky</b>:&nbsp;&nbsp; You just have to learn that: if it's a tree, or a hierarchy, like eighty per cent of the regular people are going to get confused and not quite get it.</p>
</blockquote>
<hr />
<p>Hierarchies are great at showing nested relationships, and they make sense to programmers, who are used to them &ndash; but most of the time the relationships don&rsquo;t matter to the user. Usually the user just wants to find something and yet the tree view forces them to &ldquo;drill down&rdquo;, clicking down into a hierarchy that becomes increasingly complex as they click.</p>
<p>My request to all programmers placed in the position of having to design a user interface: avoid hierarchies unless you <em>truly</em> believe the end users really <em>need</em> the hierarchical information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2009/03/15/programmers-love-hierarchy-normal-people-hate-that/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Stack Overflow virgin</title>
		<link>http://www.itauthor.com/2009/02/26/stack-overflow-virgin/</link>
		<comments>http://www.itauthor.com/2009/02/26/stack-overflow-virgin/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 21:13:15 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/2009/02/26/stack-overflow-virgin/</guid>
		<description><![CDATA[I posted my first question on Stack Overflow today and already it’s had a couple of replies. I can see how Stack Overflow could become a little addictive because it has elements of a game built into it. For starters, you build up reputation points, which you get from other people by providing answers, but [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://stackoverflow.com/"><img style="float: right; margin: 0px 0px 10px 10px" height="61" alt="stackoverflow-logo-250" src="http://www.itauthor.com/wp-content/uploads/2008/12/stackoverflow-logo-250-thumb.png" width="218" border="0" /></a> I posted <a href="http://stackoverflow.com/questions/591507/is-there-any-way-of-delivering-server-based-help-without-a-web-server">my first question on Stack Overflow</a> today and already it’s had a couple of replies. I can see how Stack Overflow could become a little addictive because it has elements of a game built into it. For starters, you build up reputation points, which you get from other people by providing answers, but you need some reputation points before you can start giving points to others, and you can’t comment on other people’s answers until you’re above a certain rep level. </p>
<p>Have a listen to <a href="http://www.hanselminutes.com/default.aspx?showID=152">Hanselminutes Show 134</a> to hear Jeff Atwood, CEO of Stack Overflow, talking about the concept of the site and what they’ve done to make it an appealing place for software developers to hang out. The bit that really struck a chord with me was when he described Stack Overflow as sort of an antidote to Experts’ Exchange, the latter being a site that really rubs me up the wrong way because of its underhand tactics. There are so many times I’ve searched for something technical on Google and found a hit that looks like it might provide the answer I was looking for but I don’t notice it’s at Experts’ Exchange until I get there and discover the details are obscured because the site is run as a private club, which I refuse to join.</p>
<p>I like Stack Overflow. The only thing I don’t like about it is that I think its search facility is very weak right now. If you want to find stuff it’s best to use Google, like this: </p>
<p><strong>http://www.google.com/search?q=site:stackoverflow.com/questions YOUR QUERY</strong></p>
<p>For example:</p>
<p><a href="http://www.google.com/search?q=site:stackoverflow.com/questions online help">http://www.google.com/search?q=site:stackoverflow.com/questions online help</a></p>
<p>The other aspect of it is that, if you’re not a programmer – or even if you are – it can be an intimidating place for the newcomer. You have to brace yourself and be prepared to be told you’re an idiot and should go away and never darken the doors of Stack Overflow again. But, in some ways, that’s not altogether a bad thing. It’s intended to be a games room for professional programmers – it’s not designed for just anybody to go and find an answer to any old thing. But, unlike Experts’ Exchange, everyone’s allowed to come in and wander around and listen in on the conversations. However, if you try answering a question you’re not qualified to answer, or you start asking questions that should have been asked elsewhere, then you can expect the regulars to give you a hard time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2009/02/26/stack-overflow-virgin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>God damned exception</title>
		<link>http://www.itauthor.com/2009/02/16/god-damned-exception/</link>
		<comments>http://www.itauthor.com/2009/02/16/god-damned-exception/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 21:02:00 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/2009/02/16/god-damned-exception/</guid>
		<description><![CDATA[I was late leaving work this evening and I was rushing to close down my applications so that I could shut down my laptop. I closed a Word document and immediately pulled the cable to my second monitor. The following error message popped up: This isn&#8217;t a Photoshop job, it&#8217;s a real error message, presumably [...]]]></description>
			<content:encoded><![CDATA[<p>I was late leaving work this evening and I was rushing to close down my applications so that I could shut down my laptop. I closed a Word document and immediately pulled the cable to my second monitor. The following error message popped up:</p>
<p><img height="180" width="256" border="0" title="god-damned-exception-Word" style="border: 0px none ; display: inline;" alt="god-damned-exception-Word" src="http://www.itauthor.com/wp-content/uploads/2009/02/goddamnedexceptionword.jpg" /></p>
<p>This isn&rsquo;t a Photoshop job, it&rsquo;s a real error message, presumably tucked away in some remote corner of Microsoft Word.</p>
<hr />
<p><strong>Update</strong>:</p>
<p>Turns out it's nothing to do with Word (more's the pity). It's a &quot;feature&quot; of <a href="http://sourceforge.net/projects/notepad-plus/">Notepad++</a>, which is my text editor of choice right now. I must have been closing down Notepad++ at the same time as Word.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2009/02/16/god-damned-exception/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Switching on the Agile lightbulb</title>
		<link>http://www.itauthor.com/2008/03/21/switching-on-the-agile-lightbulb/</link>
		<comments>http://www.itauthor.com/2008/03/21/switching-on-the-agile-lightbulb/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 22:18:27 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.itauthor.eu/2008/03/21/switching-on-the-agile-lightbulb/</guid>
		<description><![CDATA[I've got to admit I'd always had a jaded opinion of the Agile software development methodology. From what I knew of it - no detailed requirements document, no functional specification, no prototyping, no design thoroughly first then build it - from all of this it seemed to me that Agile was something dreamed up by [...]]]></description>
			<content:encoded><![CDATA[<p>I've got to admit I'd always had a jaded opinion of the Agile software development methodology. From what I knew of it - no detailed requirements document, no functional specification, no prototyping, no design thoroughly first then build it - from all of this it seemed to me that Agile was something dreamed up by a software developer, for software developers, but a potential nightmare for testers, technical authors, marketing, sales and support. To me it seemed like Agile was a kind of a "let's just bash on and make it up as we go along" approach that left developers free to do whatever seemed best (or maybe just easiest), without being tied to anyone else's plan, or maybe any plan at all. And, as a technical author, how do you document something that's evolving from day to day according to the whim of developer?</p>
<p>So that was where I was with Agile until the week before last. Not hostile to Agile, but definitely skeptical.</p>
<p>Then, as part of the restructuring exercise that's underway at my work, I spent a week with <a href="http://www.marketacuity.com/about.html">MarketAcuity</a> CEO and Agile guru Sam Bayer. I'm not entirely sure what Sam's mission was: whether he'd been tasked with introducing Agile product development to the company, or just talking us through the Agile methodology. He has a very laid-back, discursive approach, so it's hard to tell. It never felt like he was trying to teach us particularly, more like he was just talking with us about one way of doing things.</p>
<p>We started with some basics of Agile product development. What's the point? Answer: it's about accelerating value to the customer. The 4 pillars of Agile:</p>
<ul>
<li><strong>Customer</strong><br />
The process is centred around the customer. It's not about producing some new, cool product because it's something we think would be interesting to work on, or because it's this year's big thing. It's about finding out what our customers and potential customers need and value and doing that for them.</li>
<li><strong>Demonstrations</strong><br />
Show your customers the real production software (not a prototype or a smoke and mirrors job) on a regular basis and get their feedback.</li>
<li><strong>Iterative</strong><br />
Build something, demo it, get feedback, build some more, and so on. Demonstrations could be a week or a month apart, but probably not more than a month apart, and always on a regular schedule. Don't go away and work on something for six months or a year only to find at the end of that time that it's not really what the customer wants, because they found it hard to explain, or you weren't listening, or they changed their minds/personnel, or the market or operational environment changed.</li>
<li><strong>Collaborative</strong><br />
This isn't the waterfall approach. There's no leader passing down commands that must be obeyed. Within the company everyone's got a role and a job to do, but these aren't set in stone with high walls. The team have to work together according to their knowledge and abilities to get the job done. And, looking externally, you've got to collaborate with the customer and bring them into the process.</li>
</ul>
<p>Another concept that, first off, I found puzzling was that, as well as accelerating value to the customer, Agile helps you to accelerate <em>failure</em>. Sounds bizarre, but what it means is that if you're producing the wrong thing, or you've made bad decisions, or misunderstood the market, you get to realise this much earlier. You don't work on a project for a year, then have a launch and suddenly get hit with the truth that potential customers don't really rate what you've done, and the stuff they really want is missing from what you produced. If you're really going nowhere with a project then it's much better to find out soon, cut your losses and get on with doing something profitable.</p>
<p>All of this, and more, makes perfect sense to me. But it really wasn't until day 3 of the week that things really clicked with me. A lightbulb went on and suddenly I saw a way of doing this product management thing successfully.</p>
<p>So now I sort of feel like a convert to Agile. It fits with my way of thinking. Don't overcomplicate things. Don't weigh yourself down with a ton of process and procedure rules. Do one thing at a time, bit by bit. Tell the truth. Don't pretend you always have all the answers. Talk to people. Get their opinions. Keep talking. Keep listening. Be prepared to change your mind.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2008/03/21/switching-on-the-agile-lightbulb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fiddler &#8211; the HTTP debugging proxy</title>
		<link>http://www.itauthor.com/2007/11/09/fiddler-the-http-debugging-proxy/</link>
		<comments>http://www.itauthor.com/2007/11/09/fiddler-the-http-debugging-proxy/#comments</comments>
		<pubDate>Fri, 09 Nov 2007 07:40:14 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/2007/11/09/fiddler-the-http-debugging-proxy/</guid>
		<description><![CDATA[If you develop Web pages and you need to see what's actually in the traffic to and from the browser, you'll want to check out Fiddler. Fiddler is a really useful free add-on for Internet Explorer. It's particularly useful if you're developing Web applications that use AJAX, or if you want to investigate what actually [...]]]></description>
			<content:encoded><![CDATA[<p>If you develop Web pages and you need to see what's actually in the traffic to and from the browser, you'll want to check out Fiddler. Fiddler is a really useful free add-on for Internet Explorer. It's particularly useful if you're developing Web applications that use AJAX, or if you want to investigate what actually gets sent to the server when you fill out an online form, or if your PC starts running slowly and you want to check whether there's lots of HTTP traffic going on that you weren't aware of. I found it interesting, and not a little alarming, to see how often passwords I type into a browser are sent up to the server as plain text that anyone along the way could read using a packet sniffer.</p>
<p>Take a look at the Quick Start screencast from <strong>fiddlertool.com</strong>: <br /><a href="http://www.fiddlertool.com/Fiddler/help/video/FiddlerQuickStart.wmv" target=""><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="149" alt="Fiddler-QuickStartVid" src="http://www.itauthor.com/wp-content/uploads/2007/11/fiddler-quickstartvid1.png" width="204" border="0"></a>&nbsp;<br />This video is hosted at: <a title="http://www.fiddlertool.com/Fiddler/firstrun.asp" href="http://www.fiddlertool.com/Fiddler/firstrun.asp">http://www.fiddlertool.com/Fiddler/firstrun.asp</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2007/11/09/fiddler-the-http-debugging-proxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://media.blubrry.com/itauthor/www.fiddlertool.com/Fiddler/help/video/FiddlerQuickStart.wmv" length="9529358" type="video/x-ms-wmv" />
			<itunes:subtitle>If you develop Web pages and you need to see what&#039;s actually in the traffic to and from the browser, you&#039;ll want to check out Fiddler. Fiddler is a really useful free add-on for Internet Explorer. It&#039;s particularly useful if you&#039;re developing Web appli...</itunes:subtitle>
		<itunes:summary>If you develop Web pages and you need to see what&#039;s actually in the traffic to and from the browser, you&#039;ll want to check out Fiddler. Fiddler is a really useful free add-on for Internet Explorer. It&#039;s particularly useful if you&#039;re developing Web applications that use AJAX, or if you want to investigate what actually gets sent to the server when you fill out an online form, or if your PC starts running slowly and you want to check whether there&#039;s lots of HTTP traffic going on that you weren&#039;t aware of. I found it interesting, and not a little alarming, to see how often passwords I type into a browser are sent up to the server as plain text that anyone along the way could read using a packet sniffer. Take a look at the Quick Start screencast from fiddlertool.com:  This video is hosted at: http://www.fiddlertool.com/Fiddler/firstrun.asp</itunes:summary>
		<itunes:author>Alistair Christie - ITauthor.com</itunes:author>
		<itunes:explicit>no</itunes:explicit>
	</item>
		<item>
		<title>SQL find and replace</title>
		<link>http://www.itauthor.com/2007/11/08/sql-find-and-replace/</link>
		<comments>http://www.itauthor.com/2007/11/08/sql-find-and-replace/#comments</comments>
		<pubDate>Thu, 08 Nov 2007 09:42:37 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/2007/11/08/sql-find-and-replace/</guid>
		<description><![CDATA[It's remarkable easy, and quick, to do a search/replace on a MySQL database. PHPmyAdmin makes it even easier. For example, say you have a table containing Web links to a server on your network and the server name gets changed or, more likely, the Web pages get moved. You might have links such as http://oldwebserver/importantstuff/index.html [...]]]></description>
			<content:encoded><![CDATA[<p>It's remarkable easy, and quick, to do a search/replace on a MySQL database. PHPmyAdmin makes it even easier.</p>
<p>For example, say you have a table containing Web links to a server on your network and the server name gets changed or, more likely, the Web pages get moved. You might have links such as <strong>http://oldwebserver/importantstuff/index.html</strong> that should now be <strong>http://newwebserver/importantstuff/index.html</strong>.&nbsp; To correct these with an SQL statement, use:</p>
<pre>UPDATE <em>table_name</em> SET <em>field_name</em> = REPLACE (
<em>field_name</em>,
"<em>old text</em>",
"<em>new text</em>");</pre>
<p>For example:</p>
<pre>UPDATE mytable SET url = REPLACE (
url,
"<strong>http://oldwebserver/importantstuff/</strong>",
"<strong>http://newwebserver/importantstuff/</strong>");<strong></pre>
<p><strong><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="281" alt="PHPmyAdmin-searchreplace" src="http://www.itauthor.com/wp-content/uploads/2007/11/phpmyadmin-searchreplace.png" width="540" border="0"></strong></p>
<p>Note</strong>: The reason I didn't just replace "oldwebserver" with "newwebserver" is as a safeguard against changing things I didn't want changed. You've got to be pretty careful about what you do, and I would strongly advise that you <strong><font color="#ff0000">always back up the database before making any changes like this</font></strong>.</p>
<p>WordPress expert Lorelle has some good advice about doing this kind of thing on your WordPress tables at:</p>
<p><a title="http://lorelle.wordpress.com/2005/12/01/search-and-replace-in-wordpress-mysql-database/" href="http://lorelle.wordpress.com/2005/12/01/search-and-replace-in-wordpress-mysql-database/">http://lorelle.wordpress.com/2005/12/01/search-and-replace-in-wordpress-mysql-database/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2007/11/08/sql-find-and-replace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP files return a blank page</title>
		<link>http://www.itauthor.com/2007/11/07/php-files-return-a-blank-page/</link>
		<comments>http://www.itauthor.com/2007/11/07/php-files-return-a-blank-page/#comments</comments>
		<pubDate>Wed, 07 Nov 2007 14:27:56 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/2007/11/07/php-files-return-a-blank-page/</guid>
		<description><![CDATA[If, when you browse to a PHP page, you just see the text of the PHP script, it means the server knows nothing about PHP. To it the PHP script is just a text file, so it sends you that, like it would a .txt file. If, however, you get a blank page, it suggests [...]]]></description>
			<content:encoded><![CDATA[<p>If, when you browse to a PHP page, you just see the text of the PHP script, it means the server knows nothing about PHP. To it the PHP script is just a text file, so it sends you that, like it would a <strong>.txt</strong> file.</p>
<p>If, however, you get a blank page, it suggests the Web server knows that <strong>.php</strong> files should be served up like Web pages, but the PHP isn't being handled properly.</p>
<p>On Apache, the most likely cause - or at least the first thing you should check out - is that the <strong>httpd.conf</strong> file hasn't been updated properly to point to the PHP module. Make sure this file contains <font face="Courier New">LoadModule</font>, <font face="Courier New">AddType</font> and <font face="Courier New">PHPIniDir</font> statements such as the following (these are for an XAMPP installation of Apache/PHP on Windows):</p>
<p><font face="Courier New">LoadModule php5_module "c:/xampp/php/php5apache2_2.dll"<br />AddType application/x-httpd-php .php<br />PHPIniDir "c:/xampp/php"</font></p>
<p>If these lines are in the <strong>httpd.conf</strong> file, the problem may just be that the file hasn't been read since the change was made. Restart Apache and the changes in the file will be applied.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2007/11/07/php-files-return-a-blank-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Memory Builder version 1.0 released</title>
		<link>http://www.itauthor.com/2007/10/07/memory-builder-version-10-released/</link>
		<comments>http://www.itauthor.com/2007/10/07/memory-builder-version-10-released/#comments</comments>
		<pubDate>Sun, 07 Oct 2007 22:43:25 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[View all]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/2007/10/07/memory-builder-version-10-released/</guid>
		<description><![CDATA[I've just released onto the world my first publicly available desktop application. I call it Memory Builder. It was designed to help my kids build up their French vocabulary, but you could use it to test yourself on almost any subject where small questions and answers work. The idea is that you add in a [...]]]></description>
			<content:encoded><![CDATA[<p>I've just released onto the world my first publicly available desktop application. I call it Memory Builder. It was designed to help my kids build up their French vocabulary, but you could use it to test yourself on almost any subject where small questions and answers work.</p>
<p>The idea is that you add in a selection of questions/answers (e.g. words/phrases in German and their English meanings, or questions about car engine parts and the answers to those questions), then you just test yourself by going through a few questions every now and again and checking the answers if you need to. I have the program set as a scheduled task so that it pops up every couple of hours and I can do a few questions, or just click <strong>Quit</strong>. The questions are randomly selected, so you get different ones coming up each time.</p>
<p>The installer I've put up for download comes with a default French/English data file. This presents French words/phrases. You've got to remember the English meanings. Click <strong>Next </strong>to page through from one French word/phrase to the next: <br style="" /><br />
<a href="http://www.itauthor.com/wp-content/uploads/2007/10/memorybuilder1-0-french.png" atomicselection="true"> <img height="210" width="350" border="0" style="border: 0px none ;" alt="MemoryBuilder1-0-French" src="http://www.itauthor.com/wp-content/uploads/2007/10/memorybuilder1-0-french-thumb.png" /></a><br style="" /><br />
You can click <strong>English</strong> if you can't remember the word/phrase. <br style="" /><br />
<a href="http://www.itauthor.com/wp-content/uploads/2007/10/memorybuilder1-0-english.png" atomicselection="true"><img height="214" width="350" border="0" style="border: 0px none ;" alt="MemoryBuilder1-0-English" src="http://www.itauthor.com/wp-content/uploads/2007/10/memorybuilder1-0-english-thumb.png" /></a>  <br style="" /><br />
To add or remove&nbsp;&nbsp;entries to/from the data file, click <strong>Feed</strong>. <br style="" /><br />
<a href="http://www.itauthor.com/wp-content/uploads/2007/10/memorybuilder1-0-questionanswer.png" atomicselection="true"><img height="552" width="350" border="0" style="border: 0px none ;" alt="MemoryBuilder1-0-QuestionAnswer" src="http://www.itauthor.com/wp-content/uploads/2007/10/memorybuilder1-0-questionanswer-thumb.png" /></a>&nbsp; <br style="" /><br />
Scroll to the bottom and add more French words and their English meanings, or click in the left, grey column to highlight a row and press Delete on the keyboard to remove it. To get rid of everything and add your own data, highlight the lot and press Delete.  The Properties tab allows you to change the button text from French/English to something that suits your questions/answers.  </p>
<p><a href="http://www.itauthor.com/downloads">See the Downloads page for a link to the Memory Builder installer.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2007/10/07/memory-builder-version-10-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Number ranges for common data types</title>
		<link>http://www.itauthor.com/2005/06/23/number-ranges-for-common-data-types/</link>
		<comments>http://www.itauthor.com/2005/06/23/number-ranges-for-common-data-types/#comments</comments>
		<pubDate>Thu, 23 Jun 2005 14:48:58 +0000</pubDate>
		<dc:creator>alistair at work</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/?p=152</guid>
		<description><![CDATA[I spent a while today rooting around trying to find out what range of numbers could be stored in a particular data type. Here&#8217;s a list for future reference: C data type Description Number range Storage required char character (or string) &#8211;128 to 127 1 byte int integer &#8211;32768 to 32,767 2 bytes short (or [...]]]></description>
			<content:encoded><![CDATA[<p>I spent a while today rooting around trying to find out what range of numbers<br />
  could be stored in a particular data type. Here&#8217;s a list for future reference:
</p>
<table cellpadding="7">
<tr>
<td valign="top">
<p><b><i>C<br />
        data type </i></b></p>
</td>
<td valign="top">
<p><b><i>Description</i></b></p>
</td>
<td valign="top">
<p><b><i>Number range</i></b></p>
</td>
<td valign="top">
<p><b><i>Storage required</i></b></p>
</td>
</tr>
<tr>
<td valign="top">
<p>char</p>
</td>
<td valign="top">
<p>character (or string)</p>
</td>
<td valign="top">
<p>&#8211;128 to 127</p>
</td>
<td valign="top">
<p>1 byte</p>
</td>
</tr>
<tr>
<td valign="top">
<p>int</p>
</td>
<td valign="top">
<p>integer</p>
</td>
<td valign="top">
<p>&#8211;32768 to 32,767</p>
</td>
<td valign="top">
<p>2 bytes</p>
</td>
</tr>
<tr>
<td valign="top">
<p>short (<i>or</i> short int)</p>
</td>
<td valign="top">
<p>short integer</p>
</td>
<td valign="top">
<p>&#8211;32768 to 32,767</p>
</td>
<td valign="top">
<p>2 bytes</p>
</td>
</tr>
<tr>
<td valign="top">
<p>long</p>
</td>
<td valign="top">
<p>long integer</p>
</td>
<td valign="top">
<p>&#8211;2,147,483,648 to 2,147,483,647</p>
</td>
<td valign="top">
<p>4 bytes</p>
</td>
</tr>
<tr>
<td valign="top">
<p>unsigned char</p>
</td>
<td valign="top">
<p>unsigned character</p>
</td>
<td valign="top">
<p>0 to 255</p>
</td>
<td valign="top">
<p>1 byte</p>
</td>
</tr>
<tr>
<td valign="top">
<p>unsigned int</p>
</td>
<td valign="top">
<p>unsigned integer</p>
</td>
<td valign="top">
<p>0 to 65,535</p>
</td>
<td valign="top">
<p>2 bytes</p>
</td>
</tr>
<tr>
<td valign="top">
<p>unsigned short </p>
</td>
<td valign="top">
<p>unsigned short integer</p>
</td>
<td valign="top">
<p>0 to 65,535</p>
</td>
<td valign="top">
<p>2 bytes</p>
</td>
</tr>
<tr>
<td valign="top">
<p>unsigned long</p>
</td>
<td valign="top">
<p>unsigned long integer</p>
</td>
<td valign="top">
<p>0 to 4,294,967,295</p>
</td>
<td valign="top">
<p>4 bytes</p>
</td>
</tr>
<tr>
<td valign="top">
<p>float</p>
</td>
<td valign="top">
<p>single-precision floating point (accurate to 7 digits)</p>
</td>
<td valign="top">
<p>+ or -3.4 x 10<SUP>38</SUP> to + or -3.4 x10<SUP>-38</SUP></p>
</td>
<td valign="top">
<p>4 bytes</p>
</td>
</tr>
<tr>
<td valign="top">
<p>double</p>
</td>
<td valign="top">
<p>double-precision floating point (accurate to 15 digits)</p>
</td>
<td valign="top">
<p>+ or -1.7 x 10<SUP>-308</SUP> to + or -1.7 x10<SUP>308</SUP></p>
</td>
<td valign="top">
<p>8 bytes</p>
</td>
</tr>
</table>
<p>Adapted from a Dummies article: <a href="http://www.dummies.com/WileyCDA/DummiesArticle/id-1064.html">Determining<br />
  Types of Numbers in C</a> </p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2005/06/23/number-ranges-for-common-data-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

