<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">

    <channel>
        <title>Learn All The Things</title>
        <link>http://simongoudie.com/blog</link>
        <atom:link href="http://simongoudie.com/blog/rss.xml" rel="self" type="application/rss+xml" />
        <description>Simon Goudie's Blog</description>
        <language>en-us</language>
        <pubDate>Mon, 16 Sep 2013 13:49:07 EST</pubDate>
        <lastBuildDate>Mon, 16 Sep 2013 13:49:07 EST</lastBuildDate>

        
        <item>
            <title>My new Mac setup</title>
            <link>http://simongoudie.com/blog/20113/09/16/My-new-Mac-setup.html</link>
            <pubDate>Sat, 16 Sep 20113 00:00:00 EST</pubDate>
            <author>Simon Goudie</author>
            <guid>http://simongoudie.com/blog/20113/09/16/My-new-Mac-setup.html</guid>
            <description>&lt;p&gt;I recently updated my entry-level mid-2011 13&amp;quot; MacBook Pro to a nice new mid-2013 13&amp;quot; MacBook Air. I went with the 256Gb SSD version and bumped the RAM up to 8Gb and, so far, it&amp;#39;s been a great machine. As with all new setups though, this needed a bit of customising as I setttled in and I thought I&amp;#39;d make some notes on what I put on, mainly for my own reference.&lt;/p&gt;

&lt;p&gt;So, these are the details of the second setup of the Air - I say second, as the first thing I did was to try to setup the same triple boot as I had on the Pro (OSX, Windows 7 and Ubuntu). Bootcamp makes installing Windows easy, but there are still huge problems in completing the Ubuntu install on the new Air hardware and I ended up having to to a full disk erase and Mountain Lion recover by the end of the first day! I&amp;#39;ll have to be content with just OSX and Windows for now.&lt;/p&gt;

&lt;p&gt;At any rate, here&amp;#39;s the software that made up the essentials for the new OSX install:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://google.com/chrome&quot;&gt;Chrome&lt;/a&gt;&lt;/strong&gt;: still the best browser for me, although I worry about the RAM usage over time&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://git-scm.com&quot;&gt;Git&lt;/a&gt;&lt;/strong&gt;: makes it easier to download and manage many other things, including...&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://github.com/simongoudie/dotfiles&quot;&gt;Dotfiles&lt;/a&gt;&lt;/strong&gt;: keeping my dotfiles on GitHub makes it easy to move settings between machines. These aren&amp;#39;t kept in the best shape, but there&amp;#39;s enough in there to get me setup and comfortable on a new Mac. PC or Linux box. These files include settings, plugins and themes for zsh, vim and other utilities&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://www.vim.org&quot;&gt;Vim&lt;/a&gt;&lt;/strong&gt;: my editor of choice, so I use MacVim on OSX and plain old Vim on the command line&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://developer.apple.com/xcode&quot;&gt;XCode&lt;/a&gt;&lt;/strong&gt;: command lines tools and homebrew: the basics of the toolkit&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://dropbox.com&quot;&gt;Dropbox&lt;/a&gt;&lt;/strong&gt;: keeps a lot of my files, including projects, photos, settings and so on, in sync between machines&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://shirtpocket.com/superduper&quot;&gt;SuperDuper&lt;/a&gt;&lt;/strong&gt;: for backing up to an external disk that&amp;#39;s also partioned with a Time Machine instance&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://obdev.at/launchbar&quot;&gt;Launchbar&lt;/a&gt;&lt;/strong&gt;: my preferred launcher app, keeping my fingers on the keyboard&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://lightheadsw.com/caffeine&quot;&gt;Caffeine&lt;/a&gt;&lt;/strong&gt;: keeps the screen on, useful when keeping an eye on the progress of all the downloads and installations going on&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://growl.info&quot;&gt;Growl&lt;/a&gt;&lt;/strong&gt;: I don&amp;#39;t really use it to its potential, but it goes on to manage notifications&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://pilotmoon.com/popclip&quot;&gt;PopClip&lt;/a&gt;&lt;/strong&gt;: I&amp;#39;d be lost without this one, I cycle through extensions fairly often, but it&amp;#39;s worth it for the clipboard actions alone&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://agilebits.com/onepassword&quot;&gt;1Password&lt;/a&gt;&lt;/strong&gt;: again, I don&amp;#39;t use it to potential, but it is the way I manage product keys and some passwords&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://sparrowmailapp.com&quot;&gt;Sparrow&lt;/a&gt;&lt;/strong&gt;: I worry for its future, but I still love it for email&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://manytricks.com/moom&quot;&gt;Moom&lt;/a&gt;&lt;/strong&gt;: after switching from Windows a couple of years ago, I still have no idea what the green button does. Now it does what I want&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://videolan.org/vlc&quot;&gt;VLC&lt;/a&gt;&lt;/strong&gt;: the omni-media player&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://microsoft.com/office&quot;&gt;Office&lt;/a&gt;&lt;/strong&gt;: unfortunately still necessary these days&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some nice tweaks that follow soon after:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://macbartender.com&quot;&gt;Bartender&lt;/a&gt;&lt;/strong&gt;: tidy up an unruly menubar&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://justgetflux.com&quot;&gt;F.lux&lt;/a&gt;&lt;/strong&gt;: make it all much easier on the eyes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://totalfinder.binaryage.com&quot;&gt;TotalFinder&lt;/a&gt;&lt;/strong&gt;: I quite like what this adds to Finder, although it will be interesting to see what get duplicated in Mavericks&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://totalterminal.binaryage.com&quot;&gt;TotalTerminal&lt;/a&gt;&lt;/strong&gt;: I&amp;#39;ve tried using other termainal emulators, but I still like using TotalTerminal&amp;#39;s visor mode, mapped to Control-~&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://apple.com/itunes&quot;&gt;iTunes&lt;/a&gt;&lt;/strong&gt;: logging in and setting up iTunes match, although Rdio gets most of my music listening currently&lt;/li&gt;
&lt;li&gt;Plus a &lt;a href=&quot;http://fstoppers.com/pictures-unbelievable-macro-shots-taken-inside-instruments&quot;&gt;nice background&lt;/a&gt; and at least two Spaces - one on the left for Sparrow/Twitter and one on the right for working. The dock gets sent to the bottom left of screen and autohides for maximum screen real estate&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And then the rest of the apps that I use every so often:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://evernote.com&quot;&gt;Evernote&lt;/a&gt;&lt;/strong&gt;: still trying to work out where Evernote fits in my workflow, but I&amp;#39;ve ended up with a couple of years of Premium on my account all the same&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://transmissionbt.com&quot;&gt;Transmission&lt;/a&gt;&lt;/strong&gt;: for downloading those big... distros&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://steampowered.com&quot;&gt;Steam&lt;/a&gt;&lt;/strong&gt;: mainly for Civilization V and FTL&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://anvilformac.com&quot;&gt;Anvil&lt;/a&gt;&lt;/strong&gt;: nice for local web experiments&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://virtualbox.org&quot;&gt;VirtualBox&lt;/a&gt;&lt;/strong&gt;: usually for messing around with creating Linux servers&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://freemacsoft.net/appcleaner&quot;&gt;App Cleaner&lt;/a&gt;&lt;/strong&gt;: I think this is better for removing apps from OSX, but still not sure what best practice is&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://kapeli.com&quot;&gt;Dash&lt;/a&gt;&lt;/strong&gt;: a great way to check up on documentation&lt;/li&gt;
&lt;li&gt;Plus: &lt;strong&gt;&lt;a href=&quot;http://skype.com&quot;&gt;Skype&lt;/a&gt;, &lt;a href=&quot;http://dayoneapp.com&quot;&gt;Day One&lt;/a&gt;, &lt;a href=&quot;http://apple.com/iphoto&quot;&gt;iPhoto&lt;/a&gt;, &lt;a href=&quot;http://mediaatelier.com/CheatSheet&quot;&gt;Cheatsheet&lt;/a&gt;, &lt;a href=&quot;http://bywordapp.com&quot;&gt;Byword&lt;/a&gt;, &lt;a href=&quot;http://panic.com/coda&quot;&gt;Coda 2&lt;/a&gt;, &lt;a href=&quot;http://markedapp.com&quot;&gt;Marked&lt;/a&gt;, &lt;a href=&quot;http://apple.com/iwork&quot;&gt;Pages&lt;/a&gt;, &lt;a href=&quot;http://reederapp.com&quot;&gt;Reeder&lt;/a&gt;, &lt;a href=&quot;http://twitter.com&quot;&gt;Twitter&lt;/a&gt;, &lt;a href=&quot;http://amazon.com/kindle&quot;&gt;Kindle&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That&amp;#39;s actually a pretty long list, it really doesn&amp;#39;t feel like that when everything is set up and running! Dropbox and hosting some dotfiles on Github really make transferring settings a breeze and it doesn&amp;#39;t take long from a fresh install to feel comfortable again.&lt;/p&gt;
</description>
        </item>
        
        <item>
            <title>Monitoring a Raspberry Pi on Status Board</title>
            <link>http://simongoudie.com/blog/2013/04/12/Monitoring-a-Raspberry-Pi-on-Status-Board.html</link>
            <pubDate>Fri, 12 Apr 2013 00:00:00 EST</pubDate>
            <author>Simon Goudie</author>
            <guid>http://simongoudie.com/blog/2013/04/12/Monitoring-a-Raspberry-Pi-on-Status-Board.html</guid>
            <description>&lt;p&gt;&lt;a href=&quot;http://panic.com&quot;&gt;Panic&amp;#39;s&lt;/a&gt; latest iPad app, &lt;a href=&quot;http://panic.com/statusboard&quot;&gt;Status Board&lt;/a&gt;, offers a really attractive dashboard to monitor key statistics, email, social media and other goings on. I really don&amp;#39;t have that much use for it, but I downloaded it to play with anyway.&lt;/p&gt;

&lt;p&gt;One thing that I thought I could monitor was the CPU load on my &lt;a href=&quot;http://raspberrypi.org&quot;&gt;Raspberry Pi&lt;/a&gt; server that I keep running from home. It&amp;#39;s not a production server, just a sandbox to play in, but I thought it would be the kind of thing that Status Board should be used for. Seeing that Status Board works well with &lt;a href=&quot;http://stathat.com&quot;&gt;StatHat&lt;/a&gt;, and that StatHat offer a feature-reduced free tier, I thought I would see if I could tie all of these together to get something happening.&lt;/p&gt;

&lt;p&gt;Here&amp;#39;s what I got to work. I&amp;#39;m sure there are better ways to do this and I&amp;#39;m sure something like &lt;a href=&quot;http://nagios.org&quot;&gt;Nagios&lt;/a&gt; would be a much better alternative, but this was what I chose to play with.&lt;/p&gt;

&lt;h3&gt;Getting stats from the Raspberry Pi&lt;/h3&gt;

&lt;p&gt;My Pi runs &lt;a href=&quot;http://archlinux.org&quot;&gt;Arch&lt;/a&gt; and is a very barebones setup. It&amp;#39;s easy to get the current CPU load average via the &lt;code&gt;/proc/loadavg&lt;/code&gt; file. This file gives the load average for the last one, five and 15 minute window, as well as some process info. I wanted to log the one-minute average, so only needed the first four characters of this file to be dumped out. Starting a short script, the line&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;loadavg=`head -c 4 /proc/loadavg`
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;was enough to grab the current one-minute average and place it in a variable called &amp;#39;loadavg&amp;#39;.&lt;/p&gt;

&lt;h3&gt;Sending the stats to StatHat&lt;/h3&gt;

&lt;p&gt;StatHat make it really easy to send them data to log. There are a whole stack of ways to do this programatically, but I opted to use the &lt;a href=&quot;http://curl.haxx.se&quot;&gt;cURL&lt;/a&gt; method so I could add it to the same script. Once you have a StatHat account ready, sending the data is as easy as adding a single line to finish the script:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;curl -d &amp;quot;stat=Pi Load&amp;amp;email=YOUR@EMAIL.COM&amp;amp;value=$loadavg&amp;quot; http://api.stathat.com/ez
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This takes the figure that we pulled from &lt;code&gt;/proc/loadavg&lt;/code&gt; and send it to StatHat to add to the &amp;#39;Pi Load&amp;#39; log.&lt;/p&gt;

&lt;h3&gt;Doing this more than once&lt;/h3&gt;

&lt;p&gt;Having the commands to pull the data and send it are great and putting them in a script makes it even easier, but it&amp;#39;s no good unless this is being done regularly and automatically. A cron job to do this every five minutes takes care of this task. I&amp;#39;m certainly not a cron expert, but here&amp;#39;s what works for me. Running &lt;code&gt;crontab -e&lt;/code&gt; will open your editor to enter the cron tasks. The syntax to do this is better explained at &lt;a href=&quot;http://www.thegeekstuff.com/2011/07/cron-every-5-minutes/&quot;&gt;this site&lt;/a&gt; than what I could do, but, effectively, this line will run your script every five minutes and scrap any output (otherwise cron may email it to you, a great way to fill your inbox):&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;*/5 * * * * ~/path/to/your/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The script I run is literally just the two lines that I mentioned above, here&amp;#39;s the whole thing:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;#! /bin/zsh
loadavg=`head -c 4 /proc/loadavg`
curl -d &amp;quot;stat=Pi Load&amp;amp;email=YOUR@EMAIL.COM&amp;amp;value=$loadavg&amp;quot; http://api.stathat.com/ez
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Displaying the log on Status Board&lt;/h3&gt;

&lt;p&gt;StatHat is one of the two services that are already integrating with Status Board. This makes it super easy to drop the log into Status Board and have it come out as a nice graph. Just visit the log on the StatHat site, choose the timeframe you want to plot and look for the &amp;#39;Status Board Graph URL&amp;#39; button at the bottom of the page. This can email the URL to your iPad. Once there, copy the URL, open Status Board and add a new graph, pasting in the URL you received.&lt;/p&gt;

&lt;h3&gt;That&amp;#39;s about it&lt;/h3&gt;

&lt;p&gt;With the graph added, you&amp;#39;re all done - the cron job will pull the load data every five minutes and send it to StatHat, where it will be pulled from Status Board to display. It may look something like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://simongoudie.com/blog/img/piload.jpg&quot; alt=&quot;Pi Load on Status Board&quot; title=&quot;Pi Load on Status Board&quot;&gt;&lt;/p&gt;

&lt;p&gt;I quite like StatHat - they offer a really good site and adding data is dead easy. Unfortunately, their &lt;a href=&quot;http://www.stathat.com/pricing&quot;&gt;one price point of US$99/month&lt;/a&gt; means that it won&amp;#39;t be worth me signing up to unlock all the features of the site and will remain on their free plan, limited to ten stats (probably enough) with no automatic alerts or small-interval tracking (a bit disappointing). Hopefully, more services will be integrating with Status Board soon and the options will open up a bit.&lt;/p&gt;
</description>
        </item>
        
        <item>
            <title>Publishing with Jekyll</title>
            <link>http://simongoudie.com/blog/2012/12/08/Publishing-with-Jekyll.html</link>
            <pubDate>Sat, 08 Dec 2012 00:00:00 EST</pubDate>
            <author>Simon Goudie</author>
            <guid>http://simongoudie.com/blog/2012/12/08/Publishing-with-Jekyll.html</guid>
            <description>&lt;p&gt;After using &lt;a href=&quot;http://wordpress.com&quot;&gt;WordPress&lt;/a&gt; for years for both blogs and content sites, I was looking for a new way to host my own blog, as well as an opportunity to experiment a bit more with CSS and hosting options. A number of Ruby tutorials use writing a CMS as their end product, but I wasn&amp;#39;t too keen on doing that and instead came across &lt;a href=&quot;https://github.com/mojombo/jekyll&quot;&gt;Jekyll&lt;/a&gt; as a way to create a static site from a set of markdown files and layout templates. So after spending a while learning how the different pieces of the site come together, how the Liquid tags work and the best way to deploy the site from the various local and remote systems I&amp;#39;ve set up, I&amp;#39;ve finally switched this site over from a standard WordPress install to a deployed Jekyll static site.&lt;/p&gt;

&lt;p&gt;There&amp;#39;s still a fair bit left to implement - a lot of the styling needs to be done, RSS needs to be fixed up, more pages need to be added and there&amp;#39;s probably a lot of stuff that should/shouldn&amp;#39;t be in the &amp;#39;head&amp;#39; tag. However, the basic site seems to work fine and the deploy scripts seem to work from each place I might want to write from. The full site, with the exception of a drafts folder, is &lt;a href=&quot;http://github.com/simongoudie/blog&quot;&gt;kept on GitHub&lt;/a&gt;. I&amp;#39;m not using GitHub Pages to host it at this stage, but I have set up a page that I might use in future. Instead, the site uses &lt;a href=&quot;https://github.com/dmathieu/glynn&quot;&gt;Glynn&lt;/a&gt; to push it to the shared host that it lives on, or rsync to push to a test server on a VPS.&lt;/p&gt;

&lt;p&gt;I&amp;#39;ve found Jekyll to be a great way to experiment with putting together a site, with a good balance between control over layout/configuration and automated &amp;#39;magic&amp;#39; to make the site all come together and be ready to upload. I look forward to doing more work with it and will look at using it for other projects in future, too.&lt;/p&gt;
</description>
        </item>
        
        <item>
            <title>Rails: Trusting the magic</title>
            <link>http://simongoudie.com/blog/2012/08/23/rails-trusting-the-magic.html</link>
            <pubDate>Thu, 23 Aug 2012 00:00:00 EST</pubDate>
            <author>Simon Goudie</author>
            <guid>http://simongoudie.com/blog/2012/08/23/rails-trusting-the-magic.html</guid>
            <description>&lt;p&gt;I&amp;#39;m working my way through a couple of Ruby on Rails tutorials at the moment, looking at why this framework has gotten so much interest. In particular, &lt;a href=&quot;http://ruby.railstutorial.org/&quot; title=&quot;Ruby On Rails Tutorial&quot;&gt;Michael Hartl&amp;#39;s tutorial&lt;/a&gt; has been excellent. So far, things are going well and I have a nice little app coming together. However, the thing that gets me with such frameworks and helpers is the level of abstraction from what you are writing at any given time.&lt;/p&gt;

&lt;p&gt;I don&amp;#39;t know if it&amp;#39;s just the way I work or not, but I&amp;#39;m most of the way through the tutorial series and I&amp;#39;m still struggling with the amount of &amp;#39;magic&amp;#39; that Rails is doing on my behalf. While I can see the advantage of simply installing a few dozen gems and not writing a full framework from scratch, I can&amp;#39;t help but be a little puzzled when the notion of database access or password hashing is hand-waved away by the framework. Writing tests, while a great way to develop, is likewise confusing and I&amp;#39;m still finding that the attempt to use a native-sounding syntax is more confusing than helpful. Differentiation between bracketing types {([||])} is another puzzling aspect that I&amp;#39;m having trouble finding consistency with, something that I&amp;#39;m sure is to do with the way that the lower-level Ruby code is abstracted away.&lt;/p&gt;

&lt;p&gt;So yes, I can see the benefits in using such a framework and I can see the time saved in bootstrapping an app, but there&amp;#39;s only so much opacity that I feel comfortable with in a framework and, at this very early stage, Rails seems to be way over the limit. Hopefully, continued practice will make me feel more at home and I will be able to relax into it a bit more, trusting the magic to hold up in the end.&lt;/p&gt;
</description>
        </item>
        
        <item>
            <title>Adding email data export to iOS apps</title>
            <link>http://simongoudie.com/blog/2012/07/29/adding-email-data-export-to-ios-apps.html</link>
            <pubDate>Sun, 29 Jul 2012 00:00:00 EST</pubDate>
            <author>Simon Goudie</author>
            <guid>http://simongoudie.com/blog/2012/07/29/adding-email-data-export-to-ios-apps.html</guid>
            <description>&lt;p&gt;Very happy with how easy it is to add email capabilities to an iOS app. Following &lt;a href=&quot;http://mobile.tutsplus.com/tutorials/iphone/mfmailcomposeviewcontroller/&quot; title=&quot;iOS SDK: Send E-mail In-App&quot;&gt;the example given&lt;/a&gt; at &lt;a href=&quot;http://mobile.tutsplus.com/&quot; title=&quot;Mobile Tuts+&quot;&gt;Mobile Tuts+&lt;/a&gt;, it was pretty simple to add an export function to my test app that now means users can have a csv file of their data emailed to them from within the app itself quickly and easily.&lt;/p&gt;

&lt;p&gt;The process to prepare the csv file is still a bit of a mess and the whole process needs a bit of a tidy, but overall, it was a painless process.&lt;/p&gt;

&lt;p&gt;If you&amp;#39;re interested in following along, the &lt;a href=&quot;https://github.com/simongoudie/Tracking&quot; title=&quot;Tracking&quot;&gt;Tracking app&lt;/a&gt; is being maintained on my &lt;a href=&quot;https://github.com/simongoudie&quot; title=&quot;Simon Goudie on GitHub&quot;&gt;GitHub page&lt;/a&gt;.&lt;/p&gt;
</description>
        </item>
        
        <item>
            <title>WWDC videos</title>
            <link>http://simongoudie.com/blog/2012/07/03/wwdc-videos.html</link>
            <pubDate>Tue, 03 Jul 2012 00:00:00 EST</pubDate>
            <author>Simon Goudie</author>
            <guid>http://simongoudie.com/blog/2012/07/03/wwdc-videos.html</guid>
            <description>&lt;p&gt;Nothing much to post for now, as I haven&amp;#39;t had much time to keep working on my projects. However, what I will say is that the WWDC session videos are great watching and are packed full of great information and explanations. If you have a developer account, it would be well worth the time to check out a few that relate to the systems you use. They can be found at &lt;a href=&quot;http://developer.apple.com/videos/wwdc/2012/&quot; title=&quot;WWDC 2012 videos&quot;&gt;http://developer.apple.com/ videos/wwdc/2012/&lt;/a&gt; and are also available through iTunes U.&lt;/p&gt;
</description>
        </item>
        
        <item>
            <title>Sharing port 443 between SSL and SSH using SSLH</title>
            <link>http://simongoudie.com/blog/2012/06/03/sharing-port-443-between-ssl-and-ssh-using-sslh.html</link>
            <pubDate>Sun, 03 Jun 2012 00:00:00 EST</pubDate>
            <author>Simon Goudie</author>
            <guid>http://simongoudie.com/blog/2012/06/03/sharing-port-443-between-ssl-and-ssh-using-sslh.html</guid>
            <description>&lt;p&gt;The port that SSH runs on, port 22, is firewalled on a lot of networks. Conversely, ports 80 and 443 are almost always open for HTTP and HTTPS traffic, respectively. This presents an opportunity to SSH via port 443 rather than 22. However, only one service can listen on a port at once, so you would usually have to choose to run one or the other. There is another service though, &lt;a href=&quot;http://www.rutschle.net/tech/sslh.shtml&quot; title=&quot;SSLH&quot;&gt;SSLH&lt;/a&gt;, that can run as a multiplexer and listen on 443 instead of SSL or SSH. When SSLH receives traffic, it can decide if it should go to SSL or SSH and redirect accordingly, effectively meaning that both SSL and SSH can run on the same port.&lt;/p&gt;

&lt;p&gt;Setting up SSLH was more of a learning experience than I expected, so I&amp;#39;m making some notes here that might help someone else, and myself in future.&lt;/p&gt;

&lt;p&gt;Installing on my &lt;a href=&quot;http://simongoudie.com/blog/vps-an-education-in-servers/&quot; title=&quot;VPS - an education in servers&quot;&gt;CentOS VPS&lt;/a&gt; (&lt;a href=&quot;http://www.comforthost.net/billing/aff.php?aff=155&quot; title=&quot;SpotVPS&quot;&gt;affiliate link!&lt;/a&gt;) was simple enough. Yum found it and installed it using a simple:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;yum install sslh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Looking at the readme file gives a quick copy instruction for CentOS to set up the config file:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;cp scripts/etc.rc.d.init.d.sslh /etc/rc.d/init.d/sslh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That&amp;#39;s the easy bit - SSLH is now ready to run, but there&amp;#39;s a bit of configuration to do first. The goal is to reach the following situation:
&lt;ul&gt;
&lt;li&gt;Connection is made to port 443&lt;/li&gt;
&lt;li&gt;SSLH receives it and recognises traffic type&lt;/li&gt;
&lt;li&gt;If SSH, the traffic is passed to localhost:22, where SSH is listening on all port 22 connections&lt;/li&gt;
&lt;li&gt;If SSL, the traffic is passed to localhost:443, where Apache is listening only on localhost:443 for secure connections&lt;/li&gt;
&lt;/ul&gt;&lt;/p&gt;

&lt;p&gt;The SSLH configuration file (at /etc/init.d/sslh) looks pretty straightforward, with only one line to change:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;OPTIONS=&amp;quot;--user nobody --pidfile $PIDFILE -p 0.0.0.0:443 --ssl localhost:443 --ssh localhost:22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Looking at this line, the intention is to set the user running the process as &amp;#39;nobody&amp;#39;; allocate a process id; listen at 0.0.0.0:443, which is port 443 on all IP addresses; redirect SSL traffic to localhost:443; and redirect SSH traffic to localhost:22 (Note that this is NOT the configuration that worked for me, keep reading).&lt;/p&gt;

&lt;p&gt;It&amp;#39;s worth noting that there are other SSLH configuration files, such as /etc/sysconfig/sslh. I&amp;#39;m sure that these are there to make the settings easier, and indeed the readme references the one at /etc/default/sslh, but I just ended up getting confused and setting conflicting options. In the end, I just deleted the additional settings files and just used the main file at /etc/init.d/sslh.&lt;/p&gt;

&lt;p&gt;SSH doesn&amp;#39;t need to be changed, as by default it listens to port 22 on all IPs, including localhost. As a side note, localhost should be equivalent to 127.0.0.1 and to the machine name.&lt;/p&gt;

&lt;p&gt;SSL does need to be changed, as by default, it will be listening to port 443 on all IPs. This will clash with SSLH, which needs sole access to port 443. Instead, according to our goals above, we need SSL to listen only on localhost:443. This is where I ran into trouble. Apache has one main config file at /etc/httpd/conf/httpd.conf where the main LISTEN directives are listed, however, neither Listen 443 nor Listen localhost:443 should go there. The secure site is handled as a virtual host, which has a spot at the bottom of the httpd.conf file. The virtual host section contains all the information about the SSL certificates (another post altogether) as well as the port to listen on. However, another gotcha is that the httpd.conf file includes other files, in the same way that source files use &amp;#39;require&amp;#39; and &amp;#39;include&amp;#39; or web files can pull in css or javascript files. In this case, the httpd.conf pulls in the file at /etc/httpd/conf.d/ssl.conf. It is in this file that the virtualhost settings should be listed. Getting these mixed up means that you&amp;#39;re very like to get overlaps on ports when you restart Apache.&lt;/p&gt;

&lt;p&gt;Making things more complex was that, no matter what I did, I couldn&amp;#39;t resolve the clash caused by SSLH listening to port 443 on all IPs and SSL listening on localhost:443, which is obviously included in all IPs. I never worked this out, and instead changed SSL to listen on port 442 with the virtualhost section starting with:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;&amp;lt;VirtualHost localhost:442&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This meant that the SSLH config file also needed to be updated to point SSL traffic to localhost:442 instead of localhost:443. Clash resolved, with the SSLH options line now reading:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;OPTIONS=&amp;quot;--user nobody --pidfile $PIDFILE -p 0.0.0.0:443 --ssl localhost:442 --ssh localhost:22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Restarting the HTTPD service, then the SSLH service and then using a web browser to check the https:// site, it looked like all was in order for the SSL setup. Unfortunately, SSH was still not working on port 443. When trying to connect, the client would initiate the connection, but receive no response from the server. Switching SSLH to the foreground verbose mode with the --v switch, it showed that it was intercepting the traffic, but the connection was being refused (suspiciously, the error included the letters ssl). No amount of port configuration changing on either the SSLH side or the SSH side was helping and I was ready to admit defeat. As one last test, I deleted the --ssl section from the SSLH options line to remove SSL from the equation. SSH then connected perfectly. I then added the --ssl section back in, but this time &lt;em&gt;after&lt;/em&gt; the --ssh section. Restarted all services and both SSL and SSH ran beautifully via external connections on port 443! I can only assume that SSL was jumping in first and causing trouble by not passing the traffic to SSH. By reordering the options, SSH must get first shot at the traffic and must be better at deciding to take it or pass it on to SSL.&lt;/p&gt;

&lt;p&gt;The final /etc/init.d/sslh options line used was:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;OPTIONS=&amp;quot;--user nobody --pidfile $PIDFILE -p 0.0.0.0:443 --ssh localhost:22 --ssl localhost:442
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Obviously, this is not a perfect setup and I&amp;#39;m sure I&amp;#39;ve overlooked some basic points, especially about how to leave Apache listening to localhost:443 rather than switching to localhost:442. However, I&amp;#39;m happy to have SSLH working correctly and now have a much better understanding of how Apache is configured, how ports are configured and how Linux services work.&lt;/p&gt;

&lt;p&gt;So, for future reference, my SSLH 1.13 setup checklist for CentOS 6.2 is as follows (assuming correct permissions level and not including TLS/SSL certificate setup):
&lt;ul&gt;
&lt;li&gt;install SSLH:&lt;/li&gt;&amp;#39;yum install sslh&amp;#39;
&lt;li&gt;copy the CentOS config file across:&lt;/li&gt;&amp;#39;cp scripts/etc.rc.d.init.d.sslh /etc/rc.d/init.d/sslh&amp;#39;
&lt;li&gt;set Apache to listen for secure sites on localhost:442, using /etc/httpd/conf.d/ssl.conf:&lt;/li&gt; &amp;#39;&amp;lt;VirtualHost localhost:442&amp;gt;...&amp;#39;
&lt;li&gt;set SSLH options line in /etc/init.d/sslh:&lt;/li&gt; &amp;#39;OPTIONS=&amp;quot;--user nobody --pidfile $PIDFILE -p 0.0.0.0:443 --ssh localhost:22 --ssl localhost:442&amp;#39;
&lt;li&gt;(re)start services, first:&lt;/li&gt; &amp;#39;service httpd restart&amp;#39;
&lt;li&gt; and then:&lt;/li&gt; &amp;#39;service sslh start&amp;#39;
&lt;/ul&gt;&lt;/p&gt;
</description>
        </item>
        
        <item>
            <title>Properties, variables and underscores</title>
            <link>http://simongoudie.com/blog/2012/05/21/properties-variables-and-underscores.html</link>
            <pubDate>Mon, 21 May 2012 00:00:00 EST</pubDate>
            <author>Simon Goudie</author>
            <guid>http://simongoudie.com/blog/2012/05/21/properties-variables-and-underscores.html</guid>
            <description>&lt;p&gt;This was something that confused me for quite a while. No doubt I&amp;#39;m still missing most of the detail involved, but I wanted to jot down here my current understanding of the way instance variables and properties are used in Objective-C code.&lt;/p&gt;

&lt;p&gt;The puzzle starts with the header code that is in many tutorials and examples (please bear with my mockup):&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;@interface TheClassName : NSObject &amp;lt;NSCoding&amp;gt; {
    NSMutableArray * _foo;
    NSInteger _bar;
}

@property NSMutableArray * foo;
@property NSInteger bar;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;and then continues at the start of the matching .m file:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;#import &amp;quot;TheClassName.h&amp;quot;

@implementation TheClassName

@synthesize foo = _foo;
@synthesize bar = _bar;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In isolation, I understood the idea of declaring variables, as well as the idea of synthesizing properties. However, looking at the above combination, why declare variables, then created them as properties, synthesize them, and then complicate things by using names with underscores? Seems like trebling the work and then obfuscating it!&lt;/p&gt;

&lt;p&gt;Thankfully, we have &lt;a href=&quot;http://stackoverflow.com&quot; title=&quot;Stack Overflow&quot;&gt;StackOverflow&lt;/a&gt;, which has addressed this matter a number of times. The question that helped me the most, though, was this one: &amp;#39;&lt;a href=&quot;http://stackoverflow.com/questions/2371489/why-do-you-use-an-underscore-for-an-instance-variable-but-not-its-corresponding&quot; title=&quot;Stack Overflow ivars and underscores&quot;&gt;Why do you use an underscore for an instance variable, but not its corresponding property?&lt;/a&gt;&amp;#39;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://twitter.com/#!/hotdogsladies/statuses/72390171408089088&quot; title=&quot;Turns Out&quot;&gt;Turns out&lt;/a&gt;, the underscore works to differentiate the raw instance variable (_foo), which should only be referenced from inside the instance (and even then it&amp;#39;s apparently not a good idea, for reasons to do with reference counting I think), with the property (foo) and its associated methods (foo and setFoo), which can be safely used and called from elsewhere. Therefore, when setting foo, you have the option of the unsafe &lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;_foo = x;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;or the safer&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;[self setFoo:x];
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;or, from outside the class, the safe&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;[TheClassName setFoo:x];
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It&amp;#39;s an added layer of abstraction from working directly with the variable, but if it makes it safer to rely on Xcode&amp;#39;s memory management, then I&amp;#39;m ok with that. Looking back over the code I&amp;#39;ve been writing, I realised that I had a fantastic combination of property usage and variable usage, with no logic behind any of it. A short time later, all of that was much more consistent and made full use of the properties, with no remaining references to the raw variables. Everything compiled and ran fine, so I feel much more confident about the way I&amp;#39;m creating and using these properties.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/simongoudie/Tracking&quot; title=&quot;GitHub: Simon Goudie&quot;&gt;The code is still on GitHub&lt;/a&gt; and any comments would be appreciated. Likewise, I&amp;#39;m sure the above story is wildly inaccurate in parts, so let me know!&lt;/p&gt;
</description>
        </item>
        
        <item>
            <title>VPS - an education in servers</title>
            <link>http://simongoudie.com/blog/2012/04/24/vps-an-education-in-servers.html</link>
            <pubDate>Tue, 24 Apr 2012 00:00:00 EST</pubDate>
            <author>Simon Goudie</author>
            <guid>http://simongoudie.com/blog/2012/04/24/vps-an-education-in-servers.html</guid>
            <description>&lt;p&gt;You can get Virtual Private Servers for $15/year. A YEAR! Sure, they&amp;#39;ve got less RAM than my couch, but $15 is a pretty small price to pay for a new playground. I signed up for &lt;a href=&quot;http://spotvps.com&quot; title=&quot;SpotVPS&quot;&gt;SpotVPS&amp;#39; offering&lt;/a&gt; (&lt;a href=&quot;http://www.comforthost.net/billing/aff.php?aff=155&quot; title=&quot;Comfort Host&quot;&gt;affiliate link!&lt;/a&gt;), which is a VPS with 128MB RAM (256MB burstable), 10GB storage and 500GB of bandwidth.&lt;/p&gt;

&lt;p&gt;It&amp;#39;s dead easy to set up, you just specify which OS you want loaded on your virtual server, then away you go. There&amp;#39;s next to nothing by way of support, so it is a bit daunting to be left with the barebones of a server and not much else. I initially SSHed in and had a look around, realising that I should get a better feel for the OS. I initially opted for an Ubuntu install, as I had had a bit of practice on the desktop; however, this seemed to use too much memory, so I switched for &lt;a href=&quot;http://www.centos.org/&quot; title=&quot;CentOS&quot;&gt;CentOS&lt;/a&gt;. I don&amp;#39;t know a whole lot about CentOS, but it turns out to be an offshoot of Red Hat Enterprise that is very stable, but not necessarily on the latest versions. The book &lt;a href=&quot;http://www.amazon.com/Definitive-Guide-CentOS-Professionals-ebook/dp/B004VH7L0K/ref=tmm_kin_title_0?ie=UTF8&amp;amp;m=AG56TWVU5XWC2&quot; title=&quot;The Definitive Guide to CentOS&quot;&gt;&amp;#39;The Definitive Guide to CentOS&amp;#39;&lt;/a&gt; is a pretty easy read and was really helpful in getting a handle on what was going on and before too long I had user accounts set up and some idea about using Yum to install packages.&lt;/p&gt;

&lt;p&gt;After this orientation, I was able to install and setup:
&lt;ul&gt;&lt;li&gt;Webmin, to make server management much easier&lt;/li&gt;
&lt;li&gt;PHP, mySQL and configure the existing Apache install&lt;/li&gt;
&lt;li&gt;proFTP&lt;/li&gt;
&lt;li&gt;update DNS settings to route a spare domain name &lt;a href=&quot;http://simon4.com&quot;&gt;(Simon4)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;and, finally, WordPress.&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;

&lt;p&gt;Having WordPress up and running was the first achievement I was aiming for, as a way to prove that I could setup and configure a server with the necessary requirements. With WordPress running, a lot of other common web hosting tasks would be possible, so I&amp;#39;m pretty happy with hitting this target.&lt;/p&gt;

&lt;p&gt;So, lessons learned from a bargain-basement VPS setup?
&lt;ul&gt;
&lt;li&gt;Firstly, 128MB of RAM is nothing! Even now, the server typically idles at around 180MB being used after a reset, frequently maxing out and throwing strange errors in the SSH session. Moving up to 512MB (1024MB burstable) is only $50/year, and I&amp;#39;ll probably make this change if I continue to use the server.&lt;/li&gt;
&lt;li&gt;Second, a VPS is a great test environment. If things go horribly wrong, then it is just a button press to restore the SOE or change to a new OS.&lt;/li&gt;
&lt;li&gt;Third, Linux should not be feared. I don&amp;#39;t have a great deal of experience with Linux systems, but there is plenty of documentation and Googling for answers is a a great way to get a feel for the system and the esoteric corners that you need to explore. If something isn&amp;#39;t working, you just start at the bottom and work backwards to find what&amp;#39;s broken!&lt;/li&gt;
&lt;li&gt;Fourth, setting up a server is a great way to see just how transparent the structure of the web really is. You get to see every cog and play with every setting. You quickly realise, just like learning HTML, that the every web site is based on the same common technical elements.&lt;/li&gt;
&lt;li&gt;Lastly, the command line is woefully underrated. Being able to administer whole servers from a CLI shows the real power of the interface. SSH out is blocked at work, but I had the exact same abilities with a &lt;a href=&quot;http://www.panic.com/blog/2011/04/introducing-prompt-ssh-for-ios/&quot;&gt;Prompt&lt;/a&gt; session running on my iPhone over 3G. I really look forward to developing some more bash and scripting skills to exploit the command line.&lt;/li&gt;
&lt;/ul&gt;&lt;/p&gt;

&lt;p&gt;All in all, I was pretty happy with what I was able to put together for $15 and half a weekend&amp;#39;s worth of effort and research. I&amp;#39;ve now got my own platform to experiment with, break and repair with full control (as opposed to having to fill out tickets for a hosting company to action when changing MX records - also a project that was accomplished on the weekend).&lt;/p&gt;
</description>
        </item>
        
        <item>
            <title>Editing in Vim</title>
            <link>http://simongoudie.com/blog/2012/03/25/editing-in-vim.html</link>
            <pubDate>Sun, 25 Mar 2012 00:00:00 EST</pubDate>
            <author>Simon Goudie</author>
            <guid>http://simongoudie.com/blog/2012/03/25/editing-in-vim.html</guid>
            <description>&lt;p&gt;On the path to becoming a real geek, the command line is pretty key. I&amp;#39;ve never been scared of the DOS prompt in Windows, but haven&amp;#39;t had much exposure to the terminal in OSX or Linus until recently. As part of coming to terms with working from the keyboard, I decided to tackle one of the seminal text editors - either emacs or vi.&lt;/p&gt;

&lt;p&gt;I ended up choosing Vim as it seemed to fit my style of working a bit better, purely personal preference. Perhaps a lot of the decision had to do with already being used to the idea of using j/k to move p and down in other programs, like Reeder and the Google apps. So I picked Vim and got to work. I had the typical initial shock of modal editing, that is, one mode for entering text and another mode for everything else, but soon began to see the logic and the power in it. I worked through the built-in tutorial, then found a few more resources to work through online (I think that &lt;a href=&quot;http://stevelosh.com/blog/2010/09/coming-home-to-vim&quot; title=&quot;Coming Home To Vim&quot;&gt;this article by Steve Losh&lt;/a&gt; made a lot of things click in to place).&lt;/p&gt;

&lt;p&gt;Before long, I was somewhat competent. At least, I was no longer deleting paragraphs and not knowing why, and I also learned to work out where I was saving the files I was working on - although I did spray test files throughout the file system in learning this. I found a nice theme, &lt;a href=&quot;http://ethanschoonover.com/solarized&quot; title=&quot;Solarized&quot;&gt;Solarized&lt;/a&gt;, and worked out how to make Vim behave on the different operating systems. Importantly, I also discovered the power of the .vimrc file and set about putting together a set of options that further enhanced Vim, but without going overboard and copy/pasting dozens of other people&amp;#39;s settings into one ugly file.&lt;/p&gt;

&lt;p&gt;While I still don&amp;#39;t need to use Vim for much coding (most of it is in Xcode), I try to use Vim for all my text notes and replaced Notepad with Vim as the default editor on my Windows machine. Vim&amp;#39;s ubiquity means that I can run it on my MacBook, my Windows machines and also on the Ubuntu instances that I&amp;#39;m playing around with. I even put it on my iPhone and iPad, although the utility of this is still questionable! To keep everything in sync, I store my master .vimrc file in a Dropbox folder and then use the &amp;#39;source&amp;#39; command from each machine&amp;#39;s local .vimrc to import these settings. This means that there&amp;#39;s only one .vimrc file to change and all the settings are kept up to date on all machines. Any OS-specific settings also get put in the local file, but there aren&amp;#39;t very many of these. In case anyone is interested, I have added my settings files, including the master .vimrc, to my GitHub profile - these can be found at: &lt;a href=&quot;https://github.com/simongoudie/dotfiles&quot; title=&quot;dotfiles&quot;&gt;https://github.com/simongoudie/dotfiles&lt;/a&gt;.&lt;/p&gt;
</description>
        </item>
        
        <item>
            <title>Table view</title>
            <link>http://simongoudie.com/blog/2012/03/21/table-view.html</link>
            <pubDate>Wed, 21 Mar 2012 00:00:00 EST</pubDate>
            <author>Simon Goudie</author>
            <guid>http://simongoudie.com/blog/2012/03/21/table-view.html</guid>
            <description>&lt;p&gt;So table views are a bit more trouble than I thought they&amp;#39;d be. As the second view in the tab bar, I want to display a table view with each item in a row. Tapping on a row should go to an item screen with more details and some actions. Currently, the items are added to a mutable array (probably to move to a database when I get around to learning how to implement one). The items are &amp;#39;food&amp;#39; objects with a number of properties, the key one being the name which is in the property &amp;#39;food&amp;#39;.&lt;/p&gt;

&lt;p&gt;I initially thought that I could create an instance of a table object, pass it the array and tell the table how to arrange the array in rows and columns, as well as what to do when clicked. Not quite so easy. Turns out there&amp;#39;s a whole heap of pieces that need to be implemented to get this working, not many of which are intuitive. First up is making sure the file knows that it&amp;#39;s working on a table, so the .h file needs to include&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;@interface TrackingTableViewController : UITableViewController
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After this, there&amp;#39;s a set of functions that need to be implemented. I found these out through much Googling and trawling Apple documentation, but mostly ended up keeping the bare bones structure of the functions. The fuctions that were basically copypasta included:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;- (id)initWithStyle:(UITableViewStyle)style
- (void)viewDidLoad
- (void)viewDidUnload
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The prototype functions I left commented out, most of which I believe are editing functions, included:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The trickiest part (for now) was to work out how to get the data from the array to the cells. I eventually caught on to how the &lt;code&gt;tableView:cellForRowAtIndexPath:&lt;/code&gt; was meant to work, in addition to the concept of recycling table cells. I&amp;#39;m still not completely au fait with this concept, but on the face of it, it looks like once a cell is scrolled off screen, it is then reused for the cell coming up on to the screen (rather than generating cells for every row, onscreen or off). With that in mind, the function turned out to look like:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView 
                             dequeueReusableCellWithIdentifier:@&amp;quot;ReuseCell&amp;quot;];
    TrackingFood *food = [self.tableViewArray objectAtIndex:indexPath.row];
    cell.textLabel.text = food.food;
    cell.detailTextLabel.text = food.reminder;
    return cell;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Not to forget setting the number of rows required:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.tableViewArray count];
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And there was a table! This was a long time coming in itself, but a problem quickly became apparent - once the table was generated and displayed once, adding new items to the array didn&amp;#39;t show up in the table. Turns out that the table needed to be reloaded. How? Well, it seemed to be linked to the &lt;code&gt;tableView reloadData&lt;/code&gt; function, but how to call it? On viewDidLoad was the first thought, but again, this only works on the first time the page is created, so no go there. So if viewDidLoad happens on the first visit, what happens when you move to that view after the first time? viewWillAppear, apparently. This seemed to do the trick:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;- (void)viewWillAppear:(BOOL)animated
{
    //    [tableView reloadData];
    [self loadArray];
    [self.tableView reloadData];
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So finally:
- I had a table
- It filled with the array data
- It reloaded that data and updated the display each time it was shown&lt;/p&gt;

&lt;p&gt;The next challenge? Creating a new view to display item details for an item selected in the table. More on that soon, but the main problem was how to pass the correct item and its data from the table view to the new item view, particularly when I have no idea what the table is called or how to address it!&lt;/p&gt;
</description>
        </item>
        
        <item>
            <title>The next project</title>
            <link>http://simongoudie.com/blog/2012/02/28/the-next-project.html</link>
            <pubDate>Tue, 28 Feb 2012 00:00:00 EST</pubDate>
            <author>Simon Goudie</author>
            <guid>http://simongoudie.com/blog/2012/02/28/the-next-project.html</guid>
            <description>&lt;p&gt;So the general idea of rebooting this blog is to track things that I&amp;#39;m learning and to keep myself honest by posting updates, questions, answers and interesting things that I find along the way. Given that the first entry was some Objective-C code, it should be no surprise that learning to program something functional is on the list of things to learn.&lt;/p&gt;

&lt;p&gt;I guess that the best way to learn is to do, so the pet project to practise on at the moment will be a tracking app to keep track of things over time, the first use case will be to track what food the user eats and then how they feel later on. This is mainly because I often feel crap after eating and would like to find out what I shouldn&amp;#39;t eat.&lt;/p&gt;

&lt;p&gt;Continuing with the theme of learning transparently, I&amp;#39;ve put the starting files up as a new github repository and should be updating this on a regular basis as I work on it and learn new things. You can find the project at: &lt;a href=&quot;https://github.com/simongoudie/Tracking/&quot; title=&quot;Tracking&quot;&gt;https://github.com/simongoudie/Tracking/&lt;/a&gt;.&lt;/p&gt;
</description>
        </item>
        
        <item>
            <title>Three ways to save data in iOS apps</title>
            <link>http://simongoudie.com/blog/2012/02/26/three-ways-to-save-data-in-ios-apps.html</link>
            <pubDate>Sun, 26 Feb 2012 00:00:00 EST</pubDate>
            <author>Simon Goudie</author>
            <guid>http://simongoudie.com/blog/2012/02/26/three-ways-to-save-data-in-ios-apps.html</guid>
            <description>&lt;p&gt;Today I tested three different ways to implement data saving in a test iOS app. Here&amp;#39;s what I got to work:&lt;/p&gt;

&lt;p&gt;The save and load snippets here fit into the app by storing the data when a &amp;#39;save&amp;#39; button is pressed, and recalling it when the &amp;#39;load&amp;#39; button is pressed. In each case, the function is called with the text to be saved passed to it as the NSString object &amp;#39;textToWrite&amp;#39;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Using a file, text.txt:&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;+ (void) writeToFile:(NSString *) textToWrite {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@&amp;quot;Text.txt&amp;quot;];
    NSError *error;
    NSLog(@&amp;quot;filePath = %@ and textToLoad = %@&amp;quot;, filePath, textToWrite);
    [textToWrite writeToFile:filePath atomically:YES encoding:NSUnicodeStringEncoding error: &amp;amp;error];
};

+ (NSString *) loadFromFile {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@&amp;quot;Text.txt&amp;quot;];
        NSError *error;
        NSString *textToLoad = [NSString stringWithContentsOfFile:filePath encoding:NSUnicodeStringEncoding error: &amp;amp;error];
        NSLog(@&amp;quot;filePath = %@ and textToLoad = %@&amp;quot;, filePath, textToLoad);
        if (textToLoad) {  
            return textToLoad;  
        } else
            return nil;
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;Using user defaults:&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;+ (void) writeToFile:(NSString *) textToWrite {
    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
    [prefs setObject:textToWrite forKey:@&amp;quot;savedText&amp;quot;];
    [prefs synchronize];
};

`+ (NSString *) loadFromFile {
    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
    NSString *textToLoad = [NSString stringWithFormat:@&amp;quot;&amp;quot;];
    textToLoad = [prefs stringForKey:@&amp;quot;savedText&amp;quot;];
    NSLog(@&amp;quot;Using defaults, textToLoad = %@&amp;quot;, textToLoad);
    if (textToLoad) {  
        return textToLoad;  
    } else
        return nil;
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;Using property lists (some of this is copy/paste, but I think I get most of what&amp;#39;s going on):&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;text language-text&quot; data-lang=&quot;text&quot;&gt;+ (void) writeToFile:(NSString *) textToWrite {
    NSString *error = @&amp;quot;Save failed&amp;quot;;
    NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSString *plistPath = [rootPath stringByAppendingPathComponent:@&amp;quot;savefile.plist&amp;quot;];
    NSDictionary *plistDict = [NSDictionary dictionaryWithObject:textToWrite forKey:@&amp;quot;savedText&amp;quot;];
    NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:plistDict
                                                                   format:NSPropertyListXMLFormat_v1_0
                                                         errorDescription:&amp;amp;error];
    if(plistData) {
        [plistData writeToFile:plistPath atomically:YES];
    }
    else {
        NSLog(@&amp;quot;Something happened. Error message is: %@&amp;quot;,error);
    }   
};

+ (NSString *) loadFromFile {
    NSString *errorDesc = nil;
    NSPropertyListFormat format;
    NSString *plistPath;
    NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    plistPath = [rootPath stringByAppendingPathComponent:@&amp;quot;savefile.plist&amp;quot;];
    if (![[NSFileManager defaultManager] fileExistsAtPath:plistPath]) {
        plistPath = [[NSBundle mainBundle] pathForResource:@&amp;quot;savefile&amp;quot; ofType:@&amp;quot;plist&amp;quot;];
    }
    NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
    NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization propertyListFromData:plistXML
                                                    mutabilityOption:NSPropertyListMutableContainersAndLeaves 
                                                              format:&amp;amp;format errorDescription:&amp;amp;errorDesc];
    if (!temp) {
        NSLog(@&amp;quot;Error reading plist: %@, format: %d&amp;quot;, errorDesc, format);
    }
    NSLog(@&amp;quot;Using plist at %@, textToLoad = %@&amp;quot;, plistPath, [temp valueForKey:@&amp;quot;savedText&amp;quot;]);
    return [temp valueForKey:@&amp;quot;savedText&amp;quot;];
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;User defaults is obviously the easiest of the options, although it&amp;#39;s probably also the least correct option to use in most cases. For this app, which is a simple text editor that can save and reload files, the file-based method is probably the most appropriate.&lt;/p&gt;
</description>
        </item>
        

    </channel>
</rss>

