<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>nickcharlton.net</title>
    <link href="http://nickcharlton.net/atom.xml" rel="self" />
    <link href="http://nickcharlton.net" />
    <id>http://nickcharlton.net/atom.xml</id>
    <author>
        <name>Nick Charlton</name>
        <email>hello@nickcharlton.net</email>
    </author>
    <updated>2013-05-21T20:11:00Z</updated>
    <entry>
    <title>George Zarkadakis: Love and artificial intelligence</title>
    <link href="http://nickcharlton.net/links/love-and-artificial-intelligence.html" />
    <id>http://nickcharlton.net/links/love-and-artificial-intelligence.html</id>
    <published>2013-05-21T20:11:00Z</published>
    <updated>2013-05-21T20:11:00Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://www.aeonmagazine.com/being-human/george-zarkadakis-love-artificial-intelligence/">The essayist George Zarkadakis writes about love and AI</a>.</p>]]></summary>
</entry>
<entry>
    <title>The downsides of live music</title>
    <link href="http://nickcharlton.net/links/downsides-of-live-music.html" />
    <id>http://nickcharlton.net/links/downsides-of-live-music.html</id>
    <published>2013-05-21T20:04:00Z</published>
    <updated>2013-05-21T20:04:00Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://therealadam.com/2013/05/18/the-downsides-of-live-music/">Adam Keys on Live Music</a>.</p>
<p>All of this, basically. I love the <em>idea</em> of live music, but so often it turns out to not be quite as a good as you imagine it to be. And, much like Keys, I listen to albums in a long-form way. Sometimes a whole artist’s discography in an evening (and for some, over a day). I much prefer it that way.</p>]]></summary>
</entry>
<entry>
    <title>The Default Narative</title>
    <link href="http://nickcharlton.net/links/default-narrative.html" />
    <id>http://nickcharlton.net/links/default-narrative.html</id>
    <published>2013-05-21T19:58:00Z</published>
    <updated>2013-05-21T19:58:00Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://tracks.ranea.org/post/47791661856/the-default-narrative">Watts Martin talks about the “default narrative” which pervades journalism</a>.</p>
<p>Basically this. I don’t read most technology news any more because it’s almost always scraping the bottom of the barrel crap. And bar one or two writers, this default way of thinking is all over Apple “journalism”, too.</p>
<p>It stinks.</p>]]></summary>
</entry>
<entry>
    <title>Wired writes something sensible about the Internet of Things</title>
    <link href="http://nickcharlton.net/links/wired-io.html" />
    <id>http://nickcharlton.net/links/wired-io.html</id>
    <published>2013-05-21T19:51:00Z</published>
    <updated>2013-05-21T19:51:00Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://www.wired.com/gadgetlab/2013/05/internet-of-things/all/">Bill Wasik writes something about IoT over on Wired.</a>.</p>
<p>This is probably the first post I’ve seen at a more mainstream publication which talks about IoT well and doesn’t get it all wrong.</p>
<p>I also quite like that they use the term, “Sensor Revolution”. We’re mostly talking about adding a layer of sensors to objects, not giving a fridge a web browser.</p>
<p>And, the location stuff reminds me of <a href="http://www.meridianapps.com/">Meridian</a>, and some of the research I’m interested in (but my stuff is attached to robots).</p>]]></summary>
</entry>
<entry>
    <title>You should write about yourself more</title>
    <link href="http://nickcharlton.net/links/personal-brands.html" />
    <id>http://nickcharlton.net/links/personal-brands.html</id>
    <published>2013-05-21T19:45:00Z</published>
    <updated>2013-05-21T19:45:00Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://tommorris.org/posts/8268">Tom Morris talks about writing about yourself on your blog</a>.</p>
<blockquote>
<p>“As for one’s “personal brand”? Puh-lease. The concept of such a thing is so toxic to human honesty as to make me want to kick a small child. The reason we’ve only now seen one professional sportsman in the United States come out of the closet as gay is precisely because of “personal brand”. We’re all too horrified about offending some hypothetical future employer with our opinions or even our very own lives that we hide away from telling anyone anything. Sorry, but I’m with the kids on this: YOLO. Lives are short, closets are bad, crippling fear is toxic. If your personal brand demands that you live your life in fear of disclosing important parts of your life or your experience, the answer is to reject the whole sodding concept of personal brands.&quot;</p>
</blockquote>]]></summary>
</entry>
<entry>
    <title>SparkFun: How to Build a Building</title>
    <link href="http://nickcharlton.net/links/how-to-build-a-building.html" />
    <id>http://nickcharlton.net/links/how-to-build-a-building.html</id>
    <published>2013-05-07T16:44:00Z</published>
    <updated>2013-05-07T16:44:00Z</updated>
    <summary type="html"><![CDATA[<p><a href="https://www.sparkfun.com/news/1122">Nate Seidle of SparkFun talks about their upcoming building</a>.</p>
<p>I’ve — suprisingly — seen a few building designs over the years, and they’re always cool to see. When I was on <a href="/posts/finishing-at-rokk-media.html">placement</a>, we moved to a new office building and had to plan out all of the data drops on both floors, and today I saw a bundle of architect’s plans for an interesting project in Plymouth (that, obviously, I can’t talk about.)</p>
<p>But, what’s very cool to see here is SparkFun openly documenting it all. Much of this stuff gets lost in folders of paperwork after the project is completed and all of the contractors move on.</p>]]></summary>
</entry>
<entry>
    <title>Maker Faire 2013</title>
    <link href="http://nickcharlton.net/posts/maker-faire-2013.html" />
    <id>http://nickcharlton.net/posts/maker-faire-2013.html</id>
    <published>2013-05-06T19:00:00Z</published>
    <updated>2013-05-06T19:00:00Z</updated>
    <summary type="html"><![CDATA[<p>Last weekend was <a href="http://makerfaireuk.com/">Maker Faire UK</a>, up in Newcastle. <a href="http://www.stewartstarbuck.co.uk/">Stewart</a>, <a href="http://danbjorn.subvert.org.uk/">Dan</a> and I headed up (aided by Stewart’s Dad’s superb driving skills), part of us from Exeter and Dan from Nottingham.</p>
<p>My journey started on the 6:55 train out of Plymouth to get to Exeter for around 8:00, from there we set off on the drive to Newcastle, via Nottingham. It’s quite the trip; we landed at the <a href="http://www.life.org.uk/">Life Centre</a> by about 18:00 with just about enough time to setup, grab something to eat, find the hotel and then crash in preparation for Day 1 of the Maker Faire.</p>
<p>Our plan for being there was two fold; one was to evangelise 3D printing (as in, the stuff you can do on your desk) and secondly to help sell a few RepRap kits by promoting <a href="http://www.printedworlds.co.uk/">Printed Worlds</a>. To do this we bought along a RepRap and spent the weekend printing off whistles. These make a cool demonstration as just off the printer they essentially work (you just have to poke the ball that’s printed inside of the body). We gave away a few to slobbery children (and, er, adults.) We’ll see how successful it ends up being in the next few weeks<sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup>.</p>
<figure>
  
<img src="/resources/images/maker-faire-danbjorn.jpg" 
       alt="Dan doing some evangelism." width="500px"> <figcaption>Dan doing some evangelism.</figcaption>
</figure>

<p>For the evangelism side, this worked rather well. In the photo above you can see Dan explaining the purpose of a printed part to a group of people (this is likely a hotend assembly, although it’s hard to tell.)</p>
<p>And, as you can see below, we regularly had a rather huge group of people crowded around. The working RepRap (which was printing those whistles) can be blamed for much of it. It was a great crowd puller.</p>
<figure>
  
<img src="/resources/images/maker-faire-crowd.jpg"
       alt="The crowd around the stand on Day 2." width="500px"> <figcaption>The crowd around the stand on Day 2.</figcaption>
</figure>

<p>Overall, we had an interesting mix of people come over to the stand. A small proportion hadn’t heard all that much about 3D printing, had seen the RepRap going and came over to see what was going on. A much larger proportion had heard of 3D printing and were subsequently rather impressed with what we were doing and indeed, impressed with the price of the kit we were promoting. And a few others knew quite a bit (these often had RepRap’s or MakerBots or one of the many others that exist) and were more interested in us personally; that was pretty cool.</p>
<p>Another thing that was nice to see was design and technology teachers talking about what they were either doing, or thinking about doing with a 3D printer. This is already something that Stewart has been doing with local schools and colleges around Exeter; the students can work on their project in the morning (say, learning CAD) and then by the afternoon print it and see it as a real object. As someone who was quite uninspired after making the fifth wooden box at school, I can see this as being quite revolutionary — especially on the motivation front.</p>
<p>At the end of day one, we were fed and then head off in search of a pub. Firstly, we ended up at Newcastle’s Brew Dog Pub (which was rather nice), but then I suggested meeting up with <a href="http://blog.amyl.org.uk">Adam</a>, who was in town, and a few other makers at a Weatherspoon’s closer to the venue. Here we ended up meeting <a href="http://about.me/coldclimate">Oli Wood</a> and a bunch of other people. And had a fine time. Day 2 then followed, with slightly less, but still quite a lot of people. After closing time, we packed up, found something to eat and then turned in. We were leaving at 7, after all.</p>
<figure>
  
<img src="/resources/images/maker-faire-dancing-robots.jpg"
       alt="Pole Dancing Robots. Photo courtesy of Oli Wood." width="500px"> <figcaption>Pole Dancing Robots. Photo courtesy of <a href="https://twitter.com/coldclimate/status/328102769036767233/photo/1">Oli Wood</a>.</figcaption>
</figure>

<p>As a “maker” myself, it was fascinating seeing everyone else’s creations. From <a href="http://pancakebot.com/">Pancake Bot</a> to the Pole Dancing Robots in the photo above, there were lots of things to see. There was also a good showing from the many <a href="http://hackspace.org.uk/view/Main_Page">Hack Spaces</a> around the country; notably <a href="http://nottinghack.org.uk/">Nottingham</a> who had a huge stand.</p>
<p>Exhibiting at Maker Faire, and the faire itself was great fun. I hope to be at the next one. But in the mean time, I’ll likely next be at the <a href="http://www.makerfairebrighton.com">Brighton Mini Maker Faire</a> in September.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn1"><p>And if you’re interested, go and buy a kit. Say I sent you.<a href="#fnref1">↩</a></p></li>
</ol>
</div>]]></summary>
</entry>
<entry>
    <title>Space Apps Challenge 2013</title>
    <link href="http://nickcharlton.net/posts/space-apps-challenge-2013.html" />
    <id>http://nickcharlton.net/posts/space-apps-challenge-2013.html</id>
    <published>2013-05-06T18:00:00Z</published>
    <updated>2013-05-06T18:00:00Z</updated>
    <summary type="html"><![CDATA[<p>A few weekends ago was the second <a href="http://spaceappschallenge.org/">NASA Space Apps Challenge</a>, a hack day centred around building stuff related to space and worldwide collaboration. The <a href="/posts/nasa-space-apps-challenge-predict-the-sky.html">last one was fantastic</a> and this one also did not disappoint. This time around, we set around to continue working on Predict the Sky, but more of that in a bit.</p>
<p>For me, it worked out as a nice breather before the mad rush of <a href="/posts/final-year-project-over.html">finishing off my project</a> (even though I did spend some time reviewing some code and adjusting a few things).</p>
<p>But, more interesting was seeing what other people were coming up with. As an offshoot of <a href="http://www.growers-nation.org/">Growers Nation</a> (er, pun not intended) we had an open hardware soil analyser, entitled “<a href="http://spaceappschallenge.org/project/mudpi">MudPi</a>”, which is able to collect humidity, temperature, dew point &amp; moisture and is designed to be placed in the soil somewhere. They were commended for being quite close to market. I’ll be interested to see what comes next out of it.</p>
<p>Next, was a collection of projects from mostly <a href="http://plymouth.ac.uk/">Plymouth University</a> students entitled <a href="http://spaceappschallenge.org/project/arduhack/">ArduHack</a> that was focused around the <a href="http://www.kickstarter.com/projects/575960623/ardusat-your-arduino-experiment-in-space">ArduSat</a> platform. This is an <a href="http://arduino.cc/">Arduino</a> based <a href="http://www.cubesat.org/">CubeSat</a>, which itself is a project with the aim to reduce the cost of getting satellites into space — to the point where groups of people, researchers (as in, not space ones) can do. Anyway, half of the team was focused upon attaching an earth orientated camera to the ArduSat, so that people would be able to photograph themselves from space; the key bit here was being able to photography themselves — people could essentially operate their own spy satellite for a moment in time.</p>
<p>The other half of the ArduSat project was about bringing some of the sensors “back down to earth”. Using a combination of a <a href="https://www.sparkfun.com/products/10825">Magician Robot Kit</a>, an Arduino, <a href="http://www.raspberrypi.org/">Raspberry Pi</a> and a <a href="http://www.ti.com/tool/cc2541dk-sensor">TI SensorTag Development Kit</a>. The key bit is the last one, it includes an IR temperature sensor, a gyroscope, accelerometer, magnetometer, pressure sensor and a humidity sensor all of which are able to communicate over the <a href="http://en.wikipedia.org/wiki/Bluetooth_low_energy">Bluetooth Low Energy</a> standard. From here, they used the Raspberry Pi to communicate with the SensorTag, to then control the Arduino which would drive the robot around.</p>
<p>Finally, the team behind <a href="http://spaceappschallenge.org/project/webrover1/">WebRover1</a> where looking at expanding what a set of <a href="http://mindstorms.lego.com/">Lego Mindstorms</a> based robots could do for outreach — getting young people interested in robotics and it’s related <a href="http://en.wikipedia.org/wiki/STEM_fields">STEM</a> subjects. They ended up with new control code and an easy to use front end which would work with most browsers (aimed a touch devices). Their project page gives a better explanation of the user interface design process.</p>
<p>There were several other interesting things by other groups there, too. And, the last two, <a href="http://spaceappschallenge.org/project/arduhack/">ArduHack</a> and <a href="http://spaceappschallenge.org/project/webrover1/">WebRover1</a> are up for global judging.</p>
<h2 id="a-continuation-of-predict-the-sky">A Continuation of Predict the Sky</h2>
<p>A few weeks before the event, I’d emailed around asking to see if any of the old team were interested in spending the weeknd continuing on with Predict the Sky. My hope was to catch up with the work which was done at the Met Office’s Weather for Fun event last year (which I’d missed) and for us to work out where we’d take the project. Personally, I wanted a documented API that we could wave around at people and then from there work on the mobile applications and so forth that we had worked on at the first Space Apps Challenge.</p>
<p>And actually; that’s exactly what we did. <a href="https://twitter.com/ehibling">Emma</a> was around all weekend, <a href="http://www.sophiedennis.co.uk/">Sophie</a> was with the <a href="http://spaceappschallenge.org/project/webrover1/">WebRover1</a> team (but we grabbed her on a few bits and pieces) and we were joined by a few more people.</p>
<p>In the end, we ended up assembling <a href="http://predictthesky.org/">predictthesky.org</a>, which will contain a description of what the project is all about, the people involved, the API documentation (there’s some examples at the moment, they need actually implementing) and eventually some cool projects that are using it.</p>
<p>We also looked at the way we were going about calculations and the data sources for certain objects. We’ll be using <a href="http://rhodesmill.org/pyephem/">PyEphem</a> for much of it and relying on <a href="https://www.space-track.org/">Space Track</a> for the object references (a project run under contract to the US Department of Defence). A few other data sources will be used for other objects, too.</p>
<p>The whole API will eventually be implemented using <a href="http://flask.pocoo.org/">Flask</a> and you can find the code (and source for the GitHub Pages based site) under the <a href="https://github.com/PredictTheSky">Predict the Sky Organisation</a>.</p>
<p>My next steps after I finish University (rather soon, now) is to start on the code side, and also build out the documentation — especially for others to contribute who are new to the project.</p>
<p>In the mean time, if you’re interested, <a href="/about">shout at me</a> and I’ll make sure something is done about it.</p>
<p>But overall, another great event, one of hopefully many more to come.</p>]]></summary>
</entry>
<entry>
    <title>Building the Bomber Cam with 3D Printing and Scraps</title>
    <link href="http://nickcharlton.net/links/bomber-cam.html" />
    <id>http://nickcharlton.net/links/bomber-cam.html</id>
    <published>2013-05-06T12:03:00Z</published>
    <updated>2013-05-06T12:03:00Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://www.polygonsandwich.com/blog/2013/5/3/building-the-bomber-cam">A 3D printed lens mounting for a WW2 slightly-radioactive bomber lens</a>.</p>
<p>I find these kind of applications of 3D printing fascinating. Given something cool, what can someone do to make it useful with the application of a 3D printer?</p>]]></summary>
</entry>
<entry>
    <title>The Way of the Megapode</title>
    <link href="http://nickcharlton.net/links/way-of-the-megapode.html" />
    <id>http://nickcharlton.net/links/way-of-the-megapode.html</id>
    <published>2013-05-06T10:57:00Z</published>
    <updated>2013-05-06T10:57:00Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://www.rousette.org.uk/blog/archives/the-way-of-the-megapode/">But She’s a Girl talks about Douglas Adams, endangered species and, er, scripting</a>.</p>]]></summary>
</entry>
<entry>
    <title>Paul Miller on his return to the Internet</title>
    <link href="http://nickcharlton.net/links/paul-miller-returns.html" />
    <id>http://nickcharlton.net/links/paul-miller-returns.html</id>
    <published>2013-05-02T21:21:00Z</published>
    <updated>2013-05-02T21:21:00Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://www.theverge.com/2013/5/1/4279674/im-still-here-back-online-after-a-year-without-the-internet">Paul Miller writes about his return to the internet</a>.</p>
<p>I don’t usually read tech news, but I have been following along Paul Miller’s departure from the internet. It’s interesting, like Miller, I like long form articles — especially writing them — and for a long time I’ve attempted to get through the mountain of books (plus plenty more awaiting purchase in my Amazon basket) that litter every flat surface around me.</p>
<p>But it never happens. I get caught up with everything else. The whole concept of “work-life balance” is alien to me and instead I attempt to balance a stack of plates many times my height. And when they fall (they always do — there’s always a sudden deadline) I succeed in only catching the stuff that’s closer to me — missing the long term bits I want to be working on.</p>
<p>Of course, I suspect I’d come to the same conclusion as Miller if I attempted something as drastic as this. The internet is where the people are, and I’d miss them.</p>]]></summary>
</entry>
<entry>
    <title>Final Year Project is Over</title>
    <link href="http://nickcharlton.net/posts/final-year-project-over.html" />
    <id>http://nickcharlton.net/posts/final-year-project-over.html</id>
    <published>2013-04-30T12:00:00Z</published>
    <updated>2013-04-30T12:00:00Z</updated>
    <summary type="html"><![CDATA[<p>And so, my final year project was handed in. This marks the tail end of my degree — I’ve only got a poster to assemble, a demo to do and three exams left. It’s by far been the hardest thing I’ve ever done, but certainly the most rewarding.</p>
<p>The work I undertook for my final year project was to investigate the use of Kalman filters for <a href="http://en.wikipedia.org/wiki/Simultaneous_localization_and_mapping">robot localisation and mapping</a>. That wasn’t quite my initial plan, though. That was to build a Quadrotor, then write the code for the localisation and mapping, followed by running a series of tests to see how well it worked. Sadly, I ran out of time and got just past having ¾ of a Quadrotor prototype and a simple 2D simulator which just about demonstrates the thing I was attempting to.</p>
<p>But that’s fine as I did end up with doing quite a lot of working and learning a hell of a lot more than I could have expected.</p>
<p>I also have quite a few plans from where I intend to take the project — mostly the hardware and electronics side — and I’ll be slowly revealing the project as it is and then what I intend to do over time.</p>
<p>For the past few months this has been almost completely consuming. I look forward to finally coming up for some air at <a href="http://www.makerfaireuk.com">Maker Faire UK</a> this weekend.</p>]]></summary>
</entry>
<entry>
    <title>Are we approaching a new AI winter?</title>
    <link href="http://nickcharlton.net/links/ai-winter.html" />
    <id>http://nickcharlton.net/links/ai-winter.html</id>
    <published>2013-04-08T16:35:06Z</published>
    <updated>2013-04-08T16:35:06Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://alanwinfield.blogspot.com/2013/03/a-crisis-of-expectations.html">Alan Winfield presents a short paper on the likelihood of a pending AI winter</a>.</p>
<blockquote>
<p>“We need to be truthful about the limitations of robots and robot intelligence, and measured with our predictions. We can show that real robots are both very different and much more surprising than their fictional counterparts”</p>
</blockquote>
<p>Of course, articles such as <a href="http://www.guardian.co.uk/commentisfree/2013/mar/29/domestic-drones-unique-dangers">this by Glenn Greenwald hardly help</a>:</p>
<blockquote>
<p>“the most sophisticated robotics use artificial intelligence that [can] seek out and record certain kinds of suspicious activity”</p>
</blockquote>
<p>(Although, I do agree on the privacy, et. al. risks of using surveillance tools such as ‘drones’ in the name of “the public good”.)</p>]]></summary>
</entry>
<entry>
    <title>Expectations</title>
    <link href="http://nickcharlton.net/links/expectations.html" />
    <id>http://nickcharlton.net/links/expectations.html</id>
    <published>2013-04-05T15:30:00Z</published>
    <updated>2013-04-05T15:30:00Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://canadian-fury.com//2013/04/04/expectations/">Doug Stephen talks about Expectations, and a few other things</a>.</p>
<p>Sounds familiar.</p>]]></summary>
</entry>
<entry>
    <title>Test Environments with Vagrant and Chef</title>
    <link href="http://nickcharlton.net/posts/test-environments-with-vagrant-and-chef.html" />
    <id>http://nickcharlton.net/posts/test-environments-with-vagrant-and-chef.html</id>
    <published>2013-04-04T00:46:00Z</published>
    <updated>2013-04-04T00:46:00Z</updated>
    <summary type="html"><![CDATA[<p>I recently completed a project for an assignment which had a mess of dependencies. It depends upon <a href="http://libgit2.github.com/">libgit2</a> and <a href="http://www.pygit2.org/">pygit2</a>, both of which are a complete pain to get working. After it blew up in my face for the third time, I realised I was being silly and should go back to using <a href="http://www.vagrantup.com/">Vagrant</a>, and along with it, the configuration management tool, <a href="http://www.opscode.com/">Chef</a>.</p>
<p>Why Chef, over it’s main competitor, <a href="https://puppetlabs.com/">Puppet</a>? I like it more. But I can’t really describe why. I’m like that sometimes. I wish it were because one had much nicer, more accessable documentation, but neither seems to be the case. Fortunately, Vagrant has lovely documentation and so I’m not going to replicate it. I am going to go into detail about how to use both together and provide an introduction to Chef, though.</p>
<p>Vagrant allows you to start, stop and destroy virtual machines in a nice abstraction which also provides hooks to automate the provisioning of them. I want to be able to quickly spin up a test environment per project and when it’s started I want everything configured for me, <a href="https://github.com/nickcharlton/dotfiles">dotfiles</a>, libraries, applications, shared folders and so on.</p>
<p>Chef handles the second bit. It’s known as a configuration management tool. It describes what we want the system to look like after it’s run, but we don’t care about how we get there. Chef overuses the cooking analogy a bit, but: A recipe describes the way a specific tool is configured, along with any dependencies. A cookbook contains the recipes we wish to run on a system. I’m mostly going to talk about using “Chef Solo”, that is, Chef without a server as that works best for environments which are quickly created, used and thrown away.</p>
<h3 id="before-you-begin">Before You Begin</h3>
<p>Firstly, you should install:</p>
<ul>
<li><a href="https://www.virtualbox.org/">VirtualBox</a></li>
<li><a href="http://www.vagrantup.com/">Vagrant</a></li>
</ul>
<p>Then you should at least skim read the <a href="http://docs.vagrantup.com/">Vagrant documentation</a>. I’ll only describe it lightly. By the end, I’ll have a “<a href="https://github.com/nickcharlton/test-environment">test-environment</a>” repository which I’ll clone whenever I need a new to spin something up.</p>
<h3 id="virtual-machines-with-vagrant">Virtual Machines with Vagrant</h3>
<p>Vagrant is the glue that holds all of this together and makes interacting with virtual machines as pleasurable as possible. It uses a simple Ruby DSL<sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup> to describe the virtual machines that should be managed. All of this is stored in a <code>Vagrantfile</code>.</p>
<p>Vagrant uses the notion of “boxes” to describe preconfigured base VMs for which we can work from. I’m using Ubuntu here. You should also look at <a href="http://www.morethanseven.net/">Gareth Rushgrove</a>’s <a href="http://vagrantbox.es/">Vagrant Boxes</a> site. A simple Vagrant friendly install with a copy of Chef is all you need.</p>
<p>Firstly, create a Vagrantfile and, if you don’t have one already, grab a box:</p>
<pre class="sh"><code>vagrant init
vagrant box add precise32 \ http://files.vagrantup.com/precise32.box</code></pre>
<p>Then start the Vagrantfile (it already has an example configuration, but I prefer it a little tidier):</p>
<pre class="sourceCode ruby"><code class="sourceCode ruby"><span class="dt">Vagrant</span>.configure(<span class="st">&quot;2&quot;</span>) <span class="kw">do</span> |config|
  config.vm.box = <span class="st">&quot;precise32&quot;</span>
<span class="kw">end</span></code></pre>
<p>Now, you can start the virtual machine and ssh into it:</p>
<pre class="sh"><code>vagrant up
vagrant ssh</code></pre>
<p>And, you can throw the box away by running:</p>
<pre class="sh"><code>vagrant destroy</code></pre>
<p>This might be the bit where you wish you had an SSD, if you don’t already have one. You’ll do that a lot. This base box configures Ruby, Chef and a few other things for us. And notably it’ll share the working directory in which the Vagrantfile is contained. You should now be good to start thinking about provisioning.</p>
<h3 id="provisioning-with-chef">Provisioning with Chef</h3>
<p>There are a few versions of Chef. These can be broadly split into “client”, known as “Solo” and “client-server”, in the case of “Chef Server”, “Chef Hosted” or “Chef Private”. These latter three provide a central area in which to manage nodes, cookbooks, roles and so on.</p>
<p>The node is a server (actually, it’s not necessarily a server, because you could use Chef to manage your workstation too) that is managed by Chef. The routine to complete a task is known as a recipe. This is used to install, configure and start services, from the appropriate package management system, or from source and using the correct dependencies. These recipes are grouped together in a “cookbook”.</p>
<p>A set of cookbooks may be configured together so that a node can have a “role” applied to it. This is something like “web” or “database”, causing Chef to configure the appropriate cookbooks for it.</p>
<p>“Data Bags” are collections of data (which may be encrypted) which are used by Chef to aid the install. The idea here is that the data can be kept seperate from the configuration, like usernames, passwords or keys. Below, I’m using this to put a special set of <code>ssh</code> keys in place so I can push code up to GitHub inside the test environment.</p>
<p>One of the few key points to Chef, and similar configuration management tools is that of “idempotence” — every time Chef is run, the same state will be had at the end. So, for example if you run Chef manually and everything is configured, nothing will happen. If you destroy this virtual machine and create another, once Chef has done it’s thing, it’ll be exactly the same as the old one was.</p>
<p><code>knife</code> is Chef’s main client side tool for interacting with all of this. Whilst it’s designed to be used to interact with the Chef Server, it can also be used locally to assemble cookbooks. Once you hunt around, you’ll also see that <code>knife</code> has plugins available to interact with <a href="http://docs.opscode.com/plugin_knife_ec2.html">EC2</a>, <a href="http://docs.opscode.com/plugin_knife_openstack.html">OpenStack</a> and <a href="http://docs.opscode.com/plugin_knife.html">many others</a>.</p>
<p><em>I’m missing a bunch of stuff out here because I’m only interested in using Chef with Vagrant. Look at the “Further Reading” heading at the bottom.</em></p>
<h4 id="building-cookbooks">Building Cookbooks</h4>
<p>Cookbooks look a little bit like this (with each indent being a subdirectory):</p>
<pre><code>cookbooks
    cookbook-name
        recipes
            default.rb</code></pre>
<p>The root <code>cookbooks</code> represents the default collection of cookbooks that Chef — and especially when used with Vagrant — looks for. Inside here are the cookbooks themselves. A single cookbook can contain multiple recipes, but the one that is called by default is funnily enough, called, <code>default.rb</code>.</p>
<p>A cookbook is then used to describe the tool which needs installing, for example, <code>git</code>. Our cookbook would be called “git” and our <code>default.rb</code> recipe might look like this:</p>
<pre class="sourceCode ruby"><code class="sourceCode ruby">package <span class="st">&quot;git&quot;</span></code></pre>
<p>This will ensure that the package from the local package management system, “git” is installed.</p>
<p>Of course, that doesn’t necessarily exist on every system’s package manager. Chef has a library called “<a href="http://docs.opscode.com/ohai.html">Ohai</a>” that sniffs out the node and reports what it is and what it can do. And to interact with Ohai, Chef’s DSL provides methods like <code>value_for_platform</code>.</p>
<p>You might wish to use Opscode’s ‘<a href="https://github.com/opscode/chef-repo/">chef-repo</a>’, but I’d prefer to build this up myself, at least for now. It is all about learning it, afterall. The same applies for using <code>knife</code>, which I mentioned before. This can be used to create a cookbook’s file structure for you.</p>
<p>Opscode, and the community maintain a collection of cookbooks that you can use. A lot of these include tested support for lots of different OS styles and Linux distributions. So you’ll probably often find you might wish to lean towards these. Opscode have a <a href="http://community.opscode.com/cookbooks">community page for shared Cookbooks</a>. And an organisation on GitHub containing all of the <a href="https://github.com/opscode-cookbooks/">ones which they manage themselves</a>. I’ll use some of these later as submodules.</p>
<h4 id="vagrant-integration">Vagrant Integration</h4>
<p>Vagrant supports configuring Chef from inside the Vagrantfile. Typically, you’d define a <code>node.json</code> file. This would contain the “run list” — the list of recipes that a node should manage. Vagrant handles writing, and copying over the VM this <code>node.json</code> file for you on <code>vagrant up</code> or on <code>vagrant reload</code>. You can also assign roles, add recipes or assign a “data bag” that should be used. The configuration for the <code>git</code> cookbook above should look something like this:</p>
<pre class="sourceCode ruby"><code class="sourceCode ruby"><span class="dt">Vagrant</span>.configure(<span class="st">&quot;2&quot;</span>) <span class="kw">do</span> |config|
  config.vm.box = <span class="st">&quot;precise32&quot;</span>

  config.vm.provision <span class="st">:chef_solo</span> <span class="kw">do</span> |chef|
    chef.add_recipe <span class="st">&quot;git&quot;</span>
  <span class="kw">end</span>
<span class="kw">end</span></code></pre>
<p>This will ensure Chef Solo is invoked when you start up your Vagrant VM, adding “git” to it’s run list.</p>
<h4 id="a-cookbook-for-dotfiles">A Cookbook for <code>dotfiles</code></h4>
<p>That’s all well and good. But, a more complex worked example is more useful. I want to be able to run a <code>git clone</code> on my <a href="https://github.com/nickcharlton/dotfiles">dotfiles</a> and then run the included <code>setup.sh</code> script, but before I do this, I need to also ensure that all of it’s dependencies (and the tools I expect) are installed. On top of this, I want a set of keys copied over so that I can access the likes of GitHub and so forth.</p>
<p>To do this, I’ll create a cookbook called <code>dotfiles</code> which is tasked with installing the client utilities I expect (git, vim, tmux). Followed by configuring the keys. After this, it will pul down a clone of my dotfiles and running it’s <code>setup.sh</code> script.</p>
<p>But before this is installed, I’ll run a few more recipes which install the system libraries and build environment. Then we’ll end up with a Vagrantfile which looks something like this:</p>
<pre class="sourceCode ruby"><code class="sourceCode ruby"><span class="dt">Vagrant</span>.configure(<span class="st">&quot;2&quot;</span>) <span class="kw">do</span> |config|
  config.vm.box = <span class="st">&quot;precise32&quot;</span>

  config.vm.provision <span class="st">:chef_solo</span> <span class="kw">do</span> |chef|
    chef.json = {
      <span class="st">&quot;dotfiles&quot;</span> =&gt; {
        <span class="st">&quot;user&quot;</span> =&gt; <span class="st">&quot;vagrant&quot;</span>,
        <span class="st">&quot;group&quot;</span> =&gt; <span class="st">&quot;vagrant&quot;</span>,
        <span class="st">&quot;public_key&quot;</span> =&gt; <span class="dt">IO</span>.read(<span class="dt">File</span>.expand_path(<span class="st">&quot;~/.ssh/id_rsa.pub&quot;</span>)),
        <span class="st">&quot;private_key&quot;</span> =&gt; <span class="dt">IO</span>.read(<span class="dt">File</span>.expand_path(<span class="st">&quot;~/.ssh/id_rsa&quot;</span>))
      }
    }

    chef.add_recipe <span class="st">&quot;build-essential&quot;</span>
    chef.add_recipe <span class="st">&quot;python&quot;</span>
    chef.add_recipe <span class="st">&quot;dotfiles&quot;</span>
  <span class="kw">end</span>
<span class="kw">end</span></code></pre>
<p>The recipes will be installed in the same order as they are listed here. The <code>chef.json</code> call passes along a data bag. This is used to provide the target user (Chef is run as root, and I probably won’t always want to be using my <code>dotfiles</code> cookbook like this) and to pass along my own public/private key pair<sup><a href="#fn2" class="footnoteRef" id="fnref2">2</a></sup>, by using a quick one-liner to suck up the file and pass it along as a string.</p>
<p>In the <code>dotfiles</code> cookbook, <code>default.rb</code> looks like this:</p>
<pre class="sourceCode ruby"><code class="sourceCode ruby"><span class="co"># tools</span>
<span class="ot">%w(</span><span class="st">git vim vim-scripts tmux</span><span class="ot">)</span>.each <span class="kw">do</span> |pkg|
  package pkg
<span class="kw">end</span>

home_dir = <span class="st">&quot;/home/</span><span class="ot">#{</span>node[<span class="st">&#39;dotfiles&#39;</span>][<span class="st">&#39;user&#39;</span>]<span class="ot">}</span><span class="st">&quot;</span>

<span class="co"># setup ssh keys</span>
file <span class="st">&quot;</span><span class="ot">#{</span>home_dir<span class="ot">}</span><span class="st">/.ssh/id_rsa&quot;</span> <span class="kw">do</span>
  owner node[<span class="st">&#39;dotfiles&#39;</span>][<span class="st">&#39;user&#39;</span>]
  group node[<span class="st">&#39;dotfiles&#39;</span>][<span class="st">&#39;group&#39;</span>]
  mode <span class="st">&quot;0600&quot;</span>
  content node[<span class="st">&#39;dotfiles&#39;</span>][<span class="st">&#39;private_key&#39;</span>]
  action <span class="st">:create</span>
<span class="kw">end</span>

file <span class="st">&quot;</span><span class="ot">#{</span>home_dir<span class="ot">}</span><span class="st">/.ssh/id_rsa.pub&quot;</span> <span class="kw">do</span>
  owner node[<span class="st">&#39;dotfiles&#39;</span>][<span class="st">&#39;user&#39;</span>]
  group node[<span class="st">&#39;dotfiles&#39;</span>][<span class="st">&#39;group&#39;</span>]
  mode <span class="st">&quot;0600&quot;</span>
  content node[<span class="st">&#39;dotfiles&#39;</span>][<span class="st">&#39;public_key&#39;</span>]
  action <span class="st">:create</span>
<span class="kw">end</span>

<span class="co"># sync dotfiles</span>
git <span class="st">&quot;</span><span class="ot">#{</span>home_dir<span class="ot">}</span><span class="st">/dotfiles&quot;</span> <span class="kw">do</span>
  repository <span class="st">&quot;git://github.com/nickcharlton/dotfiles.git&quot;</span>
  reference <span class="st">&quot;master&quot;</span>
  enable_submodules <span class="dv">true</span>
  user node[<span class="st">&#39;dotfiles&#39;</span>][<span class="st">&#39;user&#39;</span>]
  group node[<span class="st">&#39;dotfiles&#39;</span>][<span class="st">&#39;group&#39;</span>]
  action <span class="st">:checkout</span>
<span class="kw">end</span>

<span class="co"># setup dotfiles</span>
bash <span class="st">&quot;setup_dotfiles&quot;</span> <span class="kw">do</span>
  cwd <span class="st">&quot;</span><span class="ot">#{</span>home_dir<span class="ot">}</span><span class="st">/dotfiles&quot;</span>
  user node[<span class="st">&#39;dotfiles&#39;</span>][<span class="st">&#39;user&#39;</span>]
  group node[<span class="st">&#39;dotfiles&#39;</span>][<span class="st">&#39;group&#39;</span>]
  environment <span class="st">&quot;HOME&quot;</span> =&gt; home_dir
  code <span class="st">&quot;./setup.sh&quot;</span>
<span class="kw">end</span></code></pre>
<p>You can use a Ruby whitespace array (the <code>%w()</code> bit) to iterate around a list of packages, and pass that to the <code>package</code> method. This works fine for me, as I’m only going to use Debian/Ubuntu. Then, we create the ssh key files, by using the values from the data bag.</p>
<p>For the last bit, we clone a copy of my <code>dotfiles</code> repo (including it’s multiple submodules) and run the setup script. The environment variable of <code>$HOME</code> specifies where the user’s home directory, so we override this so that the script can handle being run by root.</p>
<p>The process of setting up a new environment is now a matter of cloning the “<a href="https://github.com/nickcharlton/test-environment">test-environment</a>” repository, then running <code>vagrant up</code>. On my 2009 MacBook Pro, on a crappy DSL connection (there’s a few packages to grab) this takes just under 5 minutes, but without grabbing the packages, the Chef run only takes 30 seconds of that. With a good connection (or a local <code>apt-cache</code>) and something a bit faster than this machine you could cut that down quite a bit.</p>
<h3 id="further-reading">Further Reading</h3>
<p>This is just enough Chef to setup a basic Debian/Ubuntu environment for the way I like things, but this should put you in enough of a position to understand the basic concepts. So the next step would be to jump over to the main <a href="http://docs.opscode.com">Chef documentation</a>. It’s quite readable once you understand the basics.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn1"><p>You don’t really need to know all that much Ruby to get working with Vagrant or Chef. But I would recommend at least knowing the basics of the syntax.<a href="#fnref1">↩</a></p></li>
<li id="fn2"><p>I should really be using a seperate key pair here, but that easy enough to change.<a href="#fnref2">↩</a></p></li>
</ol>
</div>]]></summary>
</entry>
<entry>
    <title>On the Long Journey to Production</title>
    <link href="http://nickcharlton.net/links/long-journey-to-production.html" />
    <id>http://nickcharlton.net/links/long-journey-to-production.html</id>
    <published>2013-04-02T19:01:00Z</published>
    <updated>2013-04-02T19:01:00Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://rc3.org/2013/03/31/the-long-journey-toward-production/">Rafe Colburn talks about the extra work that is required to take a simple project and push it into production</a>.</p>
<p>There’s something to be said here as it being the difference between “hacking” and “software engineering”. Software Engineering is all about the other stuff that comes once you have a something working. It’s about elegance, design patterns, testing and the interactions with operations.</p>
<p>I suppose this is partly why I find DevOps so interesting, it’s merging it all together, demonstrating to both sides of the coin the effort that is required to have cost effective, reliable services.</p>]]></summary>
</entry>
<entry>
    <title>On the Future of Humanity</title>
    <link href="http://nickcharlton.net/links/human-extinction.html" />
    <id>http://nickcharlton.net/links/human-extinction.html</id>
    <published>2013-04-02T13:49:00Z</published>
    <updated>2013-04-02T13:49:00Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://www.aeonmagazine.com/world-views/ross-andersen-human-extinction/">Ross Andersen talks about the future of humanity, touching on human extinction</a>.</p>
<blockquote>
<p>&quot;Stuart Armstrong, a research fellow at the Future of Humanity Institute, once illustrated this phenomenon to me with has pithy take on recent primate evolution. ‘The difference in intelligence between humans and chimpanzees is tiny,’ he said. ‘But in that difference lies the contrast between 7 billion inhabitants and a permanent place on the endangered species list. That tells us it’s possible for a relatively small intelligence advantage to quickly compound and become decisive.’</p>
</blockquote>
<p>A slightly fantasised, but interesting look at the future of humanity and AI.</p>]]></summary>
</entry>
<entry>
    <title>Updates of March</title>
    <link href="http://nickcharlton.net/posts/updates-of-march.html" />
    <id>http://nickcharlton.net/posts/updates-of-march.html</id>
    <published>2013-03-31T21:43:00Z</published>
    <updated>2013-03-31T21:43:00Z</updated>
    <summary type="html"><![CDATA[<p>In which I document some changes I made around here…</p>
<p>To start with, I’ve adjusted the leading, measure and font size to make it a little easier to read. This was partly motivated by <a href="https://speakerdeck.com/danbarber/design-eye-for-the-developer-guy">Dan Barber’s talk</a> at <a href="/posts/digpen-vi.html">Digpen VI</a> I also rebalanced the header, but unless you visited in the last few days, you won’t notice.</p>
<p>Secondly, I added a “Link” section. I intend to link to things I come across every so often, sometimes with a bit more than a line of commentry. You’ll see more when I read longer and more indepth things.</p>
<p>It’s in the same Atom feed (and on the homepage) but implemented as a seperate directory. I might do something more with it in future. But you will see it displayed differently on the site itself; it’ll always have a “→” and the post metadata will say “Linked on <code>&lt;date&gt;</code>”, rather than “Posted on <code>&lt;date&gt;</code>”.</p>
<p>This is implemented in the same way as posts, but to provide both (posts and links) to the index page and atom feed, I’m using a regex, like so:</p>
<pre class="sourceCode haskell"><code class="sourceCode haskell">setFieldPageList (<span class="fu">take</span> <span class="dv">3</span> <span class="fu">.</span> myChronological) 
    <span class="st">&quot;templates/post_full.html&quot;</span> <span class="st">&quot;posts&quot;</span> (regex <span class="st">&quot;^(posts|links)/&quot;</span>)</code></pre>
<p>(where take 3 . myChronological is a sorts differently than the default, the template string is where it renders to and “posts” is in the infull.)</p>
<p>I should move to Hakyll 4 and no doubt it’ll be easier than I expect; but I’m waiting until I finish the write up part of my degree. Also known as the next few weeks.</p>
<p>And of course the last two posts make up some of the stuff I’ll start writing up from my project, a retrospect over a month, maybe.</p>]]></summary>
</entry>
<entry>
    <title>Beer Selection</title>
    <link href="http://nickcharlton.net/links/beer-selection.html" />
    <id>http://nickcharlton.net/links/beer-selection.html</id>
    <published>2013-03-30T21:08:06Z</published>
    <updated>2013-03-30T21:08:06Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://www.drbunsen.org/beer-selection/">Seth Brown applies statistics and some Python to beer selection</a>.</p>
<p>It’s a great idea, but also a nice implementation. Something similar applied to Whisky would be interesting.</p>]]></summary>
</entry>
<entry>
    <title>Outputting Matplotlib Plots for the Web</title>
    <link href="http://nickcharlton.net/posts/outputting-matplotlib-plots.html" />
    <id>http://nickcharlton.net/posts/outputting-matplotlib-plots.html</id>
    <published>2013-03-28T20:44:00Z</published>
    <updated>2013-03-28T20:44:00Z</updated>
    <summary type="html"><![CDATA[<p>For the past few days, I’ve been working with Matplotlib and collecting together a bunch of notes on animation. It lead to my previous post, <a href="/posts/drawing-animating-shapes-matplotlib.html">Drawing and Animating Shapes with Matplotlib</a>. In doing so, I realised I’d only embedded plots inside PDFs (when they weren’t part of some sort of application) and so, whilst getting bitmap images out of Matplotlib is quite easy, it’s not so optimal for the web. I’d rather use SVGs.</p>
<p>But, Matplotlib was designed to produce plots for publications, and so it’s centred around printing. And so we have to deal with DPIs, inches and boundary boxes and a bit of configuration.</p>
<p>So, given the <a href="http://scipy-lectures.github.com/intro/matplotlib/matplotlib.html">basic sine wave plot below</a>:</p>
<pre class="sourceCode python"><code class="sourceCode python"><span class="ch">import</span> numpy <span class="ch">as</span> np
<span class="ch">import</span> matplotlib.pyplot <span class="ch">as</span> plt

figure = plt.figure()
plt.subplot(<span class="dv">111</span>)

X = np.linspace(-np.pi, np.pi, <span class="dv">256</span>, endpoint=<span class="ot">True</span>)
C, S = np.cos(X), np.sin(X)

plt.plot(X, C)
plt.plot(X, S)

plt.ylim([-<span class="fl">1.0</span>, <span class="fl">1.0</span>])
plt.xlim([-<span class="dv">3</span>, <span class="dv">3</span>])

figure.savefig(<span class="st">&#39;sine_wave_plot.svg&#39;</span>)</code></pre>
<figure>
    
<img src="/resources/images/sine_wave_plot.svg" width="500px" alt="Figure 1: A Simple Sine Wave"> <figcaption>Figure 1: A Simple Sine Wave</figcaption>
</figure>

<p>The last line handles saving in the simplest of forms. This gives us a standard sized SVG file. A nice way to calculate the resulting size is below. This was helped by <a href="http://stackoverflow.com/questions/332289/how-do-you-change-the-size-of-figures-drawn-with-matplotlib">this Stack Overflow question about page sizes</a>.</p>
<pre class="sourceCode python"><code class="sourceCode python">dpi = figure.get_dpi()
size = figure.get_size_inches()
<span class="kw">print</span> <span class="st">&quot;DPI: </span><span class="ot">%i</span><span class="st">&quot;</span> % dpi
<span class="kw">print</span> <span class="st">&quot;Size in inches: </span><span class="ot">%i</span><span class="st"> x </span><span class="ot">%i</span><span class="st">&quot;</span> % (size[<span class="dv">0</span>], size[<span class="dv">1</span>])
<span class="kw">print</span> <span class="st">&quot;Pixels: </span><span class="ot">%i</span><span class="st"> x </span><span class="ot">%i</span><span class="st">&quot;</span> % (dpi * size[<span class="dv">0</span>], dpi * size[<span class="dv">1</span>])</code></pre>
<p>Typical screen DPI is 72 (with print usually around 300), so that gives us the scaling factor. But, there’s no reason why this cannot be 100 and using this gives more obvious result. We can then use the simple equation of: pixels ÷ DPI to figure out the inches. So, for a 700 x 650 image, you’d want to specify 7 x 6.5 inches:</p>
<pre class="sourceCode python"><code class="sourceCode python">figure.set_dpi(<span class="dv">100</span>)
figure.set_size_inches(<span class="dv">7</span>, <span class="fl">6.5</span>)</code></pre>
<p>The resulting inches measurement will be rounded to the nearest integer, but this will still translate to pixels. So, a 7 x 6.5 inch image will report being 7 x 6, even though in the example above it’ll produce a 700 x 650 image.</p>
<p>To keep the aspect ratio correct, 50 pixels are added in the above example to take into account the y axis. Notably, the plot dispayed with <code>show()</code> won’t respect the same aspect ratio as the saved file.</p>
<p>The next thing to look at is the border around the plot. The simplest thing to configure is that of <code>tight_layout</code>. If turned on, this reduces the white border around the outside of the plot. The same will be applied to each subplot. After enabling this, you get Figure 2.</p>
<pre class="sourceCode python"><code class="sourceCode python">figure.set_tight_layout(<span class="ot">True</span>)</code></pre>
<figure>
    
<img src="/resources/images/sine_wave_plot_tight.svg" width="500px" alt="Figure 2: Sine Wave Plot with Tight Layout"> <figcaption>Figure 2: Sine Wave Plot with Tight Layout</figcaption>
</figure>

<p>And so, with a little bit of extra effort, it’s quite possible to get perfectly sized and positioned plots using <code>savefig</code>. Using SVG means that the file size is relatively small and it can be scaled without losing quality — much nicer on Retina displays — and they can be embedded like any other image.</p>]]></summary>
</entry>
<entry>
    <title>Drawing and Animating Shapes with Matplotlib</title>
    <link href="http://nickcharlton.net/posts/drawing-animating-shapes-matplotlib.html" />
    <id>http://nickcharlton.net/posts/drawing-animating-shapes-matplotlib.html</id>
    <published>2013-03-27T16:55:00Z</published>
    <updated>2013-03-27T16:55:00Z</updated>
    <summary type="html"><![CDATA[<p>As well a being the best Python package for drawing plots, <a href="http://matplotlib.org/">Matplotlib</a> also has impressive primitive drawing capablities. In recent weeks, I’ve been using Matplotlib to provide the visualisations for a set of <a href="http://en.wikipedia.org/wiki/Robotic_mapping">robot localisation</a> projects, where we can use rectangles, circles and lines to demonstrate landmarks, robots and paths. Combined with <a href="http://www.numpy.org/">NumPy</a> and <a href="http://www.scipy.org/">SciPy</a>, this provides a quite capable simulation environment.</p>
<p><em>Note: You should already know how to work with Matplotlib. If you don’t, I suggest either <a href="http://www.amazon.co.uk/gp/product/1847197906/ref=as_li_ss_tl?ie=UTF8&amp;camp=1634&amp;creative=19450&amp;creativeASIN=1847197906&amp;linkCode=as2&amp;tag=nisbl-21">Matplotlib for Python Developers</a> or the <a href="http://scipy-lectures.github.com/">SciPy Lecture Notes</a>.</em></p>
<p>Primative shapes in Matplotlib are known as patches, and are provided by the patches module. Subclasses of patch provide implementations for Rectangles, Arrows, Ellipses (and then Arcs, Circles) and so on. All of this is part of the <a href="http://matplotlib.org/api/artist_api.html">Artist</a> API, which also provides support for text. In fact, everything drawn using Matplotlib is part of the artists module. It’s just a different level of access for drawing shapes compared to plots.</p>
<h3 id="drawing">Drawing</h3>
<p>There are multiple ways to write Matplotlib code<sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup>. Whilst I’m using Pyplot in the demonstrations below, the usage is essentially the same. The differences are in how the figure is initialised.</p>
<p>Drawing is a matter of adding the patch to the current figure’s axes, which using Pyplot looks something like this:</p>
<pre class="sourceCode python"><code class="sourceCode python"><span class="ch">import</span> matplotlib.pyplot <span class="ch">as</span> plt

plt.axes()

circle = plt.Circle((<span class="dv">0</span>, <span class="dv">0</span>), radius=<span class="fl">0.75</span>, fc=<span class="st">&#39;y&#39;</span>)
plt.gca().add_patch(circle)

plt.axis(<span class="st">&#39;scaled&#39;</span>)
plt.show()</code></pre>
<p><code>gca()</code> returns the current Axis instance. Setting the axis to “scaled” ensures that you can see the added shape properly. This should give you something like Figure 2<sup><a href="#fn2" class="footnoteRef" id="fnref2">2</a></sup>.</p>
<figure>
  
<img src="/resources/images/mpl_circles_example.svg" width="500px" alt="Figure 2: Circles"> <figcaption>Figure 2: Circles</figcaption>
</figure>

<h3 id="rectangles">Rectangles</h3>
<pre class="sourceCode python"><code class="sourceCode python">rectangle = plt.Rectangle((<span class="dv">10</span>, <span class="dv">10</span>), <span class="dv">100</span>, <span class="dv">100</span>, fc=<span class="st">&#39;r&#39;</span>)
plt.gca().add_patch(rectangle)</code></pre>
<p><code>rectangle</code> is a <a href="http://matplotlib.org/api/artist_api.html#matplotlib.patches.Rectangle">Rectangle patch</a>. It accepts a tuple of the bottom left hand corner, followed by a width and a height.</p>
<p><code>kwargs</code> of either <code>ec</code> or <code>fc</code> set the edge or face colours respectively. In this case, it gives us a red rectangle without a border. Various others are also supported, as this is just a subclass of <code>Patch</code>.</p>
<h3 id="circles">Circles</h3>
<pre class="sourceCode python"><code class="sourceCode python">circle = plt.Circle((<span class="dv">0</span>, <span class="dv">0</span>), <span class="fl">0.75</span>, fc=<span class="st">&#39;y&#39;</span>)
plt.gca().add_patch(circle)</code></pre>
<p><code>circle</code> is a <a href="http://matplotlib.org/api/artist_api.html#matplotlib.patches.Circle">Circle patch</a>. It accepts a tuple of the centre point, and then the radius.</p>
<p>The argument of <code>fc</code> gives us a yellow circle, without a border.</p>
<h3 id="lines">Lines</h3>
<pre class="sourceCode python"><code class="sourceCode python">line = plt.Line2D((<span class="dv">2</span>, <span class="dv">8</span>), (<span class="dv">6</span>, <span class="dv">6</span>), lw=<span class="fl">2.5</span>)
plt.gca().add_line(line)</code></pre>
<p>A basic line is a <a href="http://matplotlib.org/api/artist_api.html#module-matplotlib.lines">Line2D</a> instance. Note that it’s an Artist itself and so its not added as a patch. The first tuple gives the <code>x</code> positions of the line, the second gives the <code>y</code> positions. <code>lw</code> specifies the line width. Much like lines that are part of plots in Matplotlib, the line has a lot of configurable styles, such as the following:</p>
<pre class="sourceCode python"><code class="sourceCode python">dotted_line = plt.Line2D((<span class="dv">2</span>, <span class="dv">8</span>), (<span class="dv">4</span>, <span class="dv">4</span>), lw=<span class="dv">5</span>., 
                         ls=<span class="st">&#39;-.&#39;</span>, marker=<span class="st">&#39;.&#39;</span>, 
                         markersize=<span class="dv">50</span>, 
                         markerfacecolor=<span class="st">&#39;r&#39;</span>, 
                         markeredgecolor=<span class="st">&#39;r&#39;</span>, 
                         alpha=<span class="fl">0.5</span>)
plt.gca().add_line(dotted_line)</code></pre>
<p>which gives the lower line in Figure 3. <code>ls</code> defines the line style and <code>marker</code> gives the start and end points.</p>
<figure>
  
<img src="/resources/images/mpl_two_lines.svg" width="500px" alt="Figure 3: Two Lines"> <figcaption>Figure 3: Two Lines</figcaption>
</figure>

<p><em>Note: If you can’t see the lines and only the end markers: There’s a <a href="http://code.google.com/p/chromium/issues/detail?id=135321">Bug in WebKit</a> which stops you seeing straight lines. You probably can’t see the plot grid lines, either.</em></p>
<h3 id="polygons">Polygons</h3>
<p><a href="http://matplotlib.org/api/artist_api.html#matplotlib.patches.Polygon">Polygons</a> are just a series of points connected by lines — allowing you to draw complex shapes. The Polygon patch expects an Nx2 array of points.</p>
<pre class="sourceCode python"><code class="sourceCode python">points = [[<span class="dv">2</span>, <span class="dv">1</span>], [<span class="dv">8</span>, <span class="dv">1</span>], [<span class="dv">8</span>, <span class="dv">4</span>]]
polygon = plt.Polygon(points)</code></pre>
<p>Polygons are also a nice way to implement a multi-step line, this can be done by tuning the Polygon constructor somewhat:</p>
<pre class="sourceCode python"><code class="sourceCode python">points = [[<span class="dv">2</span>, <span class="dv">4</span>], [<span class="dv">2</span>, <span class="dv">8</span>], [<span class="dv">4</span>, <span class="dv">6</span>], [<span class="dv">6</span>, <span class="dv">8</span>]]
line = plt.Polygon(points, closed=<span class="ot">None</span>, fill=<span class="ot">None</span>, edgecolor=<span class="st">&#39;r&#39;</span>)</code></pre>
<p>This gives the red line in Figure 4. <code>closed</code> stops Matplotlib drawing a line between the first and last lines. <code>fill</code> is the colour that goes inside the shape, setting this to <code>None</code> removes it and the <code>edgecolor</code> gives the line it’s colour.</p>
<figure>
  
<img src="/resources/images/mpl_polygons.svg" width="500px" alt="Figure 4: Polygons"> <figcaption>Figure 4: Polygons</figcaption>
</figure>

<h3 id="animation">Animation</h3>
<p>The interest here is to move certain shapes around, and in the case of something like a line (which could, for example, represent a path) update its state. Here, I’m going to get a ball to orbit around a central point at a set distance away from it:</p>
<pre class="sourceCode python"><code class="sourceCode python"><span class="ch">import</span> numpy <span class="ch">as</span> np
<span class="ch">from</span> matplotlib <span class="ch">import</span> pyplot <span class="ch">as</span> plt
<span class="ch">from</span> matplotlib <span class="ch">import</span> animation

fig = plt.figure()
fig.set_dpi(<span class="dv">100</span>)
fig.set_size_inches(<span class="dv">7</span>, <span class="fl">6.5</span>)

ax = plt.axes(xlim=(<span class="dv">0</span>, <span class="dv">10</span>), ylim=(<span class="dv">0</span>, <span class="dv">10</span>))
patch = plt.Circle((<span class="dv">5</span>, -<span class="dv">5</span>), <span class="fl">0.75</span>, fc=<span class="st">&#39;y&#39;</span>)

<span class="kw">def</span> init():
    patch.center = (<span class="dv">5</span>, <span class="dv">5</span>)
    ax.add_patch(patch)
    <span class="kw">return</span> patch,

<span class="kw">def</span> animate(i):
    x, y = patch.center
    x = <span class="dv">5</span> + <span class="dv">3</span> * np.sin(np.radians(i))
    y = <span class="dv">5</span> + <span class="dv">3</span> * np.cos(np.radians(i))
    patch.center = (x, y)
    <span class="kw">return</span> patch,

anim = animation.FuncAnimation(fig, animate, 
                               init_func=init, 
                               frames=<span class="dv">360</span>, 
                               interval=<span class="dv">20</span>,
                               blit=<span class="ot">True</span>)

plt.show()</code></pre>
<p>To do this, I’m just using the equation for a point on a circle (but with the sine/ cosine flipped from the typical — this just means it goes around in clockwise), and using the animate function’s <code>i</code> argument to help compute it. This works because I’ve got 360 frames.</p>
<p>The <code>init()</code> function serves to setup the plot for animating, whilst the <code>animate</code> function returns the new position of the object. Setting <code>blit=True</code> ensures that only the portions of the image which have changed are updated. This helps hugely with performance. The purpose of returning <code>patch,</code> from both <code>init()</code> and <code>animate()</code> is to tell the animation function which artists are changing. Both of these except a tuple (as you can be animating multiple different artists.) The <code>Circle</code> is initially created off screen as we need to initialise it before animating. Without initialising off screen, blitting causes a bit of an artifact.</p>
<p>And so, this (with the addition of the section below) produces the video in Figure 5 below:</p>
<figure>
  
<video src="/resources/images/mpl_ball_animation.mp4" 
         type="video/mp4" 
         width="500px"
         poster="/resources/images/mpl_ball_animation_poster.png"
         controls> Dammit. You can’t see this video. It’s MP4 (H.264). But, you can <a href="">download it and see it that way</a>. </video> <figcaption>Figure 5: The Ball Animation as a Video</figcaption>
</figure>

<p><a href="http://jakevdp.github.com/blog/2012/08/18/matplotlib-animation-tutorial/">Jake Vanderplas’ notes on Matplotlib</a> were invaluable in figuring this section out. Notably in blitting<sup><a href="#fn3" class="footnoteRef" id="fnref3">3</a></sup>. But generally, simple Artist animation is a bit thin on the ground. Hopefully this helps with that somewhat.</p>
<h3 id="output">Output</h3>
<p>I initially wanted to be able to export in two formats, one as an H.264 video, like the one above and as an animated gif. My initial assumption was that a gif would most likely have less of an overhead than that of a video and it would avoid browser inconsistencies.</p>
<p>To solve the video export, Matplotlib comes with support for exporting video sequences from an animation using the save method on <code>Animate</code>. It pipes out support for video to <a href="http://www.ffmpeg.org/">ffmpeg</a>, but video formats are somewhat fickle and so you need to add a few more flags to get it to render correctly.</p>
<pre class="sourceCode python"><code class="sourceCode python">anim.save(<span class="st">&#39;animation.mp4&#39;</span>, fps=<span class="dv">30</span>, 
          extra_args=[<span class="st">&#39;-vcodec&#39;</span>, <span class="st">&#39;h264&#39;</span>, 
                      <span class="st">&#39;-pix-fmt&#39;</span>, <span class="st">&#39;yuv420p&#39;</span>])</code></pre>
<p>This saves an H.264 file to ‘animation.mp4’ in a format supported by QuickTime<sup><a href="#fn4" class="footnoteRef" id="fnref4">4</a></sup>. In <a href="http://jakevdp.github.com/blog/2012/08/18/matplotlib-animation-tutorial/">Jake Vanderplas’</a> animation tutorial he doesn’t specify a pixel format and it works fine. I suspect this might be something to do with ffmpeg defaults. You’ll also need to be using Matplotlib version 1.2.0 or greater (I had issues with 1.1.0.)</p>
<p>Sadly, Matplotlib doesn’t support producing gifs on it’s own, but this was only the first of a few issues. We can convert the image we’ve just produced using ffmpeg and stitch it back together as a gif using <a href="http://www.imagemagick.org/script/index.php">ImageMagick</a>:</p>
<pre class="sh"><code>ffmpeg -i animation.mp4 -r 10 output%05d.png

convert output*.png output.gif</code></pre>
<p>Here, ffmpeg converts the video file from before into a series of PNG files, then we use ImageMagick’s <code>convert</code> command to push these back together into a gif. On its own, this ended up with a 4MB file. Even the video was only 83KB and so this isn’t so great. After attempting to compress the final output gif using ImageMagick (they have a huge article on <a href="http://www.imagemagick.org/Usage/anim_opt/">Animation Optimisation</a>), I turned to compressing each input file using <a href="http://imageoptim.com">ImageOptim</a>. This ended up giving me a final image size of 8.0MB (and took a good hour.) Worse than I started with.</p>
<p>With this, I concluded that a gif isn’t that great of an option. I’d like to see animated SVG support for Matplotlib, but I’d wonder if this required moving to something which was stylised using a Document-Object-Model (DOM). Michael Droettboom touched on this in his <a href="http://mdboom.github.com/blog/2013/03/25/matplotlib-lessons-learned/">“Matplotlib Lessons Learned” post</a>. Even for something much more complex than these contrived examples, using JavaScript to animate the SVG is much better option. But for now, a video is the best way.</p>
<p>And that’s about it. One of the advantages of having the Matplotlib provided grid is that the numbers are relatively easy to determine — for my purposes this means hooking the view to the calculations.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn1"><p>I typically use <code>pyplot</code>, rather than <code>pylab</code> to keep the namespace clean. Pylab provides a merging of the Numpy and Matplotlib namespaces to ease transition from MATLAB. It’s not recommended and anyway I’m a programmer — not MATLAB user — first.</p>
<p>And then I’d use the OOP method for embedding in bigger projects, I’ve done this for use in PyQt, for example. The OOP method is slightly more complex, but a better alternative if you need to display multiple, similar plots using different data.<a href="#fnref1">↩</a></p></li>
<li id="fn2"><p>Your colours will probably vary. I use Huy Nguyen’s “<a href="http://www.huyng.com/posts/sane-color-scheme-for-matplotlib/">Sane colour scheme</a>”.<a href="#fnref2">↩</a></p></li>
<li id="fn3"><p>The return value of <code>animate()</code> must contain the items which have changed, but also those inside the figure, otherwise you’ll see a mess of artifacts working their away across the image.<a href="#fnref3">↩</a></p></li>
<li id="fn4"><p>To be more specific, it seems that QuickTime doesn’t support the Planar 4:4:4 YUV pixel format which ffmpeg outputs by default. The <code>-pix-fmt</code> flag specifies using Planar 4:2:0 YUV which it does support.</p>
<p>However, Jake’s <code>save</code> doesn’t have this flag, but it is encoded in 4:2:0. Why? I have no idea.<a href="#fnref4">↩</a></p></li>
</ol>
</div>]]></summary>
</entry>
<entry>
    <title>Digpen VI</title>
    <link href="http://nickcharlton.net/posts/digpen-vi.html" />
    <id>http://nickcharlton.net/posts/digpen-vi.html</id>
    <published>2013-03-24T13:47:00Z</published>
    <updated>2013-03-24T13:47:00Z</updated>
    <summary type="html"><![CDATA[<p>Yesterday was Digpen VI, down at the Eden Project in Cornwall. It was a wonderful day spanning a breadth of different topics, and at a nice location.</p>
<p>It’s quite fantastic to see how far Digpen has come from where it started. Way back when <a href="/posts/the-digital-peninsulas-first-web-unconference.html">in 2011, we had 80 people in a classroom at Plymouth University</a>, to now having a full day of talks, split across two tracks, covering a wide selection of web topics and all at a lovely venue. <a href="http://www.sophiedennis.co.uk/">Sophie</a> put much of it down to the community itself — this is certainly true, it’s a diverse group of people far more happy to put more into it than they take out — but without her (and Andy’s steering) behind it, it wouldn’t be what it is today.</p>
<p>The talks started off with <a href="https://twitter.com/matconnolley">Matt Connelly</a> talking about using some data analysis techniques to trace where <a href="http://www.iteracy.com/">Iteracy</a>’s clients have come from. This was rather fascinating. The root message here was to suggest that whilst certain smaller clients may not seem so worthwhile at the time, without looking at the data you don’t know where this project will lead — it could well be a much larger project.</p>
<p><a href="http://thisisthechris.co.uk/">Chris</a> then went on to talk about the <a href="http://www.mobydickbigread.com/">Moby Dick Big Read</a>, and the technical (and human) challenges that occur when a project relies on a large amount of people (none of whom technical) and suddenly becomes rather popular<sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup>. This was followed by a break, after which we split into two tracks.</p>
<p>I’m not usually much of a fan of conferences with different tracks. <a href="/posts/brussels-fosdem-2012.html">FOSDEM</a> or <a href="/posts/orgcon-2012.html">ORGCon</a> for example, always felt like you were missing out on something. But this was done well. In fact, the track I followed hah a bit of a <a href="/posts/dconstruct-2012.html">dConstruct</a> vibe to it. But, the other track quite successfully seemed to fill in the more technical side (from those I talked to after.)</p>
<p><a href="https://twitter.com/willskates">Will</a> talked about making time for projects outside of the day job, of planning out long term ones and making it all fit in. He emphasised planning out as much as possible, splitting big jobs into managable ones and allowing bits of projects to slot in where they can. He also referenced <a href="http://www.merlinmann.com/">Merlin Mann</a>’s ideas of deliberately planning and making time for everything. Of keeping the devices tucked away when it’s most appropriate and planning blocks of time to keep us present at all of the things that matter.</p>
<p>Following this, <a href="http://bouncingdan.co.uk/">Dan Goodwin</a> talked about not reading and not following everything. Because it’s impossible, and so we shouldn’t feel bad about it. As long, of course, as we are doing something to keep current. After this was lunch, and a chance to explore the Eden Project. Even in a low-season like it is at the moment, it’s a fanastic place to explore.</p>
<p>After lunch, <a href="https://twitter.com/beardygeek">Stuart Marsh</a> talked about how, and the motivations behind building his service, <a href="http://issuepop.com/">Issue Pop</a>. Much like Matt’s talk at the start of the day, it’s great to see people sharing this side of projects and their businesses. Whilst we’re happy to write about or stand up and talk about the design or technical sides of our businesses, it’s still a little taboo to talk about the actual business side. After this, <a href="http://danbarber.me/">Dan</a> gave a nice and accessible introduction to Design for Developers. If you’re in the same boat, I suggest picking up a copy of <a href="http://www.amazon.co.uk/gp/product/1119998956/ref=as_li_ss_tl?ie=UTF8&amp;camp=1634&amp;creative=19450&amp;creativeASIN=1119998956&amp;linkCode=as2&amp;tag=nisbl-21">Design for Hackers</a>, it’ll cover much of what he spoke about and the bits he didn’t quite have time to fit in, too.</p>
<p>To close off the end of the day was <a href="http://littlewhalestudio.com/">Jo and Stephen</a> talking about maintaining our creativity. They mostly focused around design and illustration, but everything transfers well to programming too<sup><a href="#fn2" class="footnoteRef" id="fnref2">2</a></sup>. Their tips and stories centred around getting away from everything, and working on other things away from work — especially in other mediums. My main take away from this, was a reminder that if it isn’t fun, what’s the point? And that we can, with a bit of planning, keep our creativity, even at the hardest of times.</p>
<p>The whole day was wonderful, especially for catching up with all of the friends I’ve made over the years over Devon and Cornwall. The last few weeks have been damn hard, so it also worked as a perfectly timed burnout antidote.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn1"><p>And yes, it was me who moved it over to the different server. The host hadn’t done anything to transfer it properly. But, fortunately, Wordpress (and Apache, MySQL, etc) is easy and simple enough to configure.<a href="#fnref1">↩</a></p></li>
<li id="fn2"><p>Programming is as creative as anything else is. It just has a lot of other constraints, be it design patterns, architectures or technical limitations. Programming is nothing like building widgets. Even if you’ve built a very similar product before.<a href="#fnref2">↩</a></p></li>
</ol>
</div>]]></summary>
</entry>
<entry>
    <title>Blog Updates</title>
    <link href="http://nickcharlton.net/posts/blog-updates.html" />
    <id>http://nickcharlton.net/posts/blog-updates.html</id>
    <published>2012-10-17T01:43:00Z</published>
    <updated>2012-10-17T01:43:00Z</updated>
    <summary type="html"><![CDATA[<p>For a project several weeks in the making, I’ve just pushed up the changes to this, my site. I started working on all of this way back when I was still on placement, but then also through Young Rewired State and intermittently since. It’s been at once the bane of my todo list, and a joy to work on, experimenting, refactoring and of course, writing.</p>
<p>It’s in no-way perfect, but it’s a significant improvement from my orignal version.</p>
<p>Like most of my projects, it’s also up on <a href="https://github.com/nickcharlton/nickcharlton.net">GitHub</a>.</p>
<h2 id="posts">Posts</h2>
<p>There’s a few posts which I’ve finally been able to post. Most of these had been sat around as drafts, others needed a bit of completion. But, without further ado, my last few months:</p>
<ul>
<li><a href="/posts/nsconf-mini.html">NSConf Mini: Developers vs. Designers</a></li>
<li><a href="/posts/dconstruct-2012.html">dConstruct 2012</a></li>
<li><a href="/posts/young-rewired-state-2012.html">Young Rewired State 2012</a></li>
<li><a href="/posts/finishing-at-rokk-media.html">Finishing at Rokk Media</a></li>
</ul>
<p>I’m now a good few weeks into the final-year of my degree and so my focus has (necessarily) shifted quite a bit. My focus from now on will be mostly centred around <a href="http://python.org/">Python</a>, <a href="http://qt.digia.com">Qt</a> (using <a href="http://www.riverbankcomputing.co.uk/software/pyqt/intro">PyQt</a> and some OpenGL), Robotics, <a href="http://www.nvidia.com/object/cuda_home_new.html">GPU Computation using CUDA</a> and various AI topics. I already have a few drafts relating to these in the works (I find it a great way to learn). I will also be occasionally posting about my degree project — a Quadrotor platform, Simulator and associated mapping algorithms. It’s going to be an interesting year.</p>
<h2 id="a-colophon">A Colophon</h2>
<p>This version is based upon <a href="http://jaspervdj.be/hakyll/index.html">Hakyll</a>. It’s a static site generator written in Haskell. Before this, I tried out multiple others, from <a href="http://hyde.github.com/">Hyde</a> to <a href="http://mynt.mirroredwhite.com/">Mynt</a>, and the original, <a href="https://github.com/mojombo/jekyll">Jekyll</a>. But each had issues in one sense or another and didn’t work all that well for me. Obviously, your requirements will vary.</p>
<p>But, the key part of Hakyll is it’s use of <a href="http://johnmacfarlane.net/pandoc/">pandoc</a>. This is a document conversion tool (also written in Haskell) that I’ve since started using for generating documents for print. It also had the <a href="http://daringfireball.net/projects/markdown/">Markdown</a> extensions that I wanted (footnotes, citations, LaTeX maths support, tables, etc.)</p>
<p>The design itself is responsive<sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup> — albeit, not tested absolutely everywhere — but not mobile first (because I’d written it desktop first), I’ll probably fix this at some point.</p>
<p>It uses TypeKit to provide “Proxima Nova” for headings, and “Adelle” for the body text. The icons are font-icons from <a href="http://pictos.cc/server">Pictos Server</a>.</p>
<p>Syntax highlighting is provided in <code>&lt;pre&gt;</code> and <code>&lt;code&gt;</code> blocks using <a href="http://pygments.org/">Pygments</a>. Mathematics symbols are through <a href="http://www.mathjax.org/">MathJax</a>.</p>
<p>It’s deployed by pushing a Git repository to a VPS hosted with <a href="http://prgmr.com/">Prgmr.com</a>, which I’ve used for several years now.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn1"><p>People who aren’t building sites this way should be shot, even for side projects like this.<a href="#fnref1">↩</a></p></li>
</ol>
</div>]]></summary>
</entry>
<entry>
    <title>NSConf Mini: Developers vs. Designers</title>
    <link href="http://nickcharlton.net/posts/nsconf-mini.html" />
    <id>http://nickcharlton.net/posts/nsconf-mini.html</id>
    <published>2012-09-20T12:00:00Z</published>
    <updated>2012-09-20T12:00:00Z</updated>
    <summary type="html"><![CDATA[<p>On Monday, it was NSConf Mini: “Developers vs. Designers”. This was a 1-day event held up in Leicester by Scotty and the rest of <a href="http://ideveloper.tv">iDeveloper TV</a>. The premise of the event was to get developers (both Mac and iOS) thinking about design and how to improve their products, or the services that they provide to their clients.</p>
<p><a href="http://johnnye.net">John</a> and I went up horrifically early in the morning and got in just after Matt Gemmell’s talk started.</p>
<p><strong>Matt Gemmell</strong> talked about crafting applications. Focusing on experiences over features, locking to the core idea and apply this to people’s needs and using people’s emotions to help improve the experience.</p>
<p><strong>Jaime Newbury</strong> talked about problem solving in projects and what to do (including how to avoid) problems that (always) occur during projects. The core message was communication. Typically, either the client or the service provider fails to communicate properly on one side, causing issues to either occur quite quickly, or slowly build up over time causing misery for everyone involved.</p>
<blockquote>
<p>Communication -&gt; Understanding -&gt; Confidence -&gt; Trust</p>
</blockquote>
<p>But also, to have standards. Firing client is okay, and it’s what will differentiate you.</p>
<p><strong>Cathy Shire</strong> talked about both the frameworks that we use and the interactions between designers and developers on iOS and Mac projects.</p>
<blockquote>
<p>I have a really hard time seperating the design of the product with the application. To me, there the same thing.</p>
</blockquote>
<p>She advocated putting designers and developers at the same cluster of tables (as had been done at Sofa). There’s always design work, so designers won’t get bored. At Sofa, tables were organised per project, this involved a designer and developer in close proximity. If the developer can access the designer (and vice-versa), queries and assumptions can easily be talked through, saving issues later on — and avoiding the divide.</p>
<p>On the side of code: Go for adaptability and resiliance, not reuse. The frameworks (say, Cocoa, et. al.) provide the reuse for us. Because of this, we should build frameworks for specific jobs (as Cocoa does for seperable parts.)</p>
<p><strong>Dave Wiskus</strong> gave us a story (a rather entertaining one, actually, fitting for just after lunch.) He stated that “Design is what happens when you create and care at the same time”.</p>
<p><strong>Josh Clark</strong> talked about buttons. They’re a hack, they work, but we can often do better. Big screens want for big gestures. Whilst your application can be featureful, your interface shouldn’t be. UI is a social convention, and it varies from place to place.</p>
<p>If the content can be navigable, let it be so. Abstractions need to be learned, so if you can borrow from other areas and keep it obvious, you are improving the experience for the user. But, if you’re going to take the effort to implement an stylistic interface, you really should be taking into account all of the other aspects of it.</p>
<p>Importantly, remember what it was like when you were getting where you are today. What was it like when you started? Hard? Well, help make it easier for everyone.</p>
<p>After this, most of us went for a curry, followed by a few pub visits. It was great spending a bunch of time talking to different iOS and Mac developers — something you don’t get in Devon very often.</p>
<p>In the process of this I ended up finally talking to <a href="http://babilim.co.uk/">Alasdair Allan</a>, briefly catching up with <a href="http://www.goosoftware.co.uk/">Simon Whitaker</a>, and also meeting; <a href="http://twitter.com/duncanlowrie">Duncan Lowrie</a>, <a href="http://torbjornlunde.com/">Torbjørn Vik Lunde</a>, a few people from <a href="http://blackpixel.com/">Black Pixel</a> and several others. So, all in all, it was a rather good event.</p>]]></summary>
</entry>
<entry>
    <title>dConstruct 2012</title>
    <link href="http://nickcharlton.net/posts/dconstruct-2012.html" />
    <id>http://nickcharlton.net/posts/dconstruct-2012.html</id>
    <published>2012-09-08T12:00:00Z</published>
    <updated>2012-09-08T12:00:00Z</updated>
    <summary type="html"><![CDATA[<p>Yesterday was <a href="http://2012.dconstruct.org/">dConstruct</a>. I went to dConstruct last year, too and it was excellent. But this year, it was quite fantastic. It had the right mix of “yes, this!”, “huh, yeah, I hadn’t thought of that” and “wow”. <a href="http://adactio.com/">Jeremy</a> and the rest of the people at <a href="http://clearleft.com/">Clearleft</a> did a fantastic job. Of course, with people from Ben Hammersley to James Burke, it was going to be good.</p>
<p>After picking up my conference pass on Thursday, I met up with <a href="http://pauladamdavis.com/">Paul Adam Davis</a> for burgers. From there I caught <a href="http://preppeller.tumblr.com">Andrew</a> and <a href="http://www.thatcanadiangirl.co.uk">Vero</a> of <a href="http://alfredapp.com/">Alfred</a><sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup> along with <a href="http://blog.fatbusinessman.com">David Thompson</a>. We then had some (rather nice) cocktails before heading off to the pre-party, where I ended up talking with people from <a href="http://aralbalkan.com">Aral Balkan</a> to <a href="http://tantek.com">Tantek Çelik</a> and many more nice people too.</p>
<h2 id="talks">Talks</h2>
<p><strong>Ben Hammersley</strong> talked about beauty being everywhere, but something that we need to fight for. He cited the web as a good example of this, from what was once a horrible mess of marquee tags has propped up both a social and cultural evolution — art pieces to well organised centres of knowledge. But, also important: We’re the first generation to see exponential growth, and as a species, we don’t quite know how to deal with it. But, we’ll work it out over time.</p>
<p><strong>Jenn Lukas</strong> talked about learning. There’s tons of stuff that we’d like to learn. But, more specifically, people from all different corners of the world, with various different backgrounds are interested in learning to code. Putting together a shared curriculum gives us a far better way of visualising progress, and hell, excitement. More importantly, though, just share what you know.</p>
<p><strong>Scott Jensen</strong> talked about “default thinking” — where we use a new product or service in exactly the same way as we used the last new product or service until we stumble across the best way to use it.</p>
<p>And then, he announced that he’d: “work[ed] on the Newton”. There was a huge round of applaus.</p>
<p>His core direction was, however pointed towards “apps”. This is something that fits quite closely to my own thoughts &amp;mash; “Apps aren’t needed for everything — we need a better interface model.” Currently, we’ve fallen onto the wrong side of a “Value : Pain” ratio. There are far too many individual (and pointless) applications available to us that it causes us some form of pain (be it findability, terrible user experiences, etc.)</p>
<p>How about we flip the app idea into the devices themselves? Instead the application will react with it’s environment, rather than the other way around<sup><a href="#fn2" class="footnoteRef" id="fnref2">2</a></sup>. This fits well into the Spimes concept<sup><a href="#fn3" class="footnoteRef" id="fnref3">3</a></sup>. Instead of what we currently have, we can move towards a “just in time interaction” model. We’ll see stuff available when we want to interact with it, but it won’t pester us in general. So far, we’ve succeeded at location-based reminders. We can do much better.</p>
<p>The mobile web is a fantastic thing, but we need to cut down the pain of accessing resources and processing the information around us. And so, a model of more internet and less web would be quite fantastic (and so, more distributed, none of this single web property everyone uses.)</p>
<p><strong>Ariel Waldman</strong> talked about her work with NASA, design and pushing of projects such as Space Hack and Science Hack Day.</p>
<blockquote>
<p>“When I look at blackholes, I just see massive hackspaces” — Ariel Waldman.</p>
</blockquote>
<p><strong>Lauren Beukes</strong> talked about the role fiction and storytelling has in connecting to other people and understanding another persons’ perspective and how impressively (and indeed, scarily) real dystopian science fiction can become reality.</p>
<p><strong>Jason Scott</strong> talked about his work with the <a href="http://archive.org">Internet Archive</a> and his opinions on the handling of users’ data. He stated that it’s a crime that we treat people’s data with such little respect and that we shouldn’t (paraphrased) “just delete things because you’re done with it — someone probably wants it.”.</p>
<p>We should store things — there’s always a sideways value to things.</p>
<p>And, if you’re running <em>anything</em> you have both a trust and a responsibility towards that data. You should certainly provide export capabilities.</p>
<p><strong>Tom Armitage</strong> talked about toys. Toys make a good caracature of real-life things — and they can be anything. But they also work as a definition of a craft.</p>
<p>Utility and purpose is not the same thing. Something can be useful without serving a purpose. Or the use might evolve from play. Joan Erikson said: “The opposite of play is obey, not work”. You can indeed play for work.&quot;</p>
<p>Making is analogous to playing.</p>
<p><strong>James Burke</strong> talked about how the past can help us work with the future. Because we have nowhere else to look.</p>
<p>Everything is, and will continue to be multi-disciplinary and because of this, our education system need to adapt. But similarly, everything is an interconnected web — both concepts and people.</p>
<p>The growth of nano-technology will undermine all of our current theories and philosophies as it’s all based upon scarcity. What happens when something that suddenly breaks can either fix itself, or we can print our own part inside our home?</p>
<p>Humanities’ typical outlook of “business and usual” is analogous to falling off a sky-scraper — it’s going fine until it isn’t, then you realise you’re screwed.</p>
<p>A clear message of the whole event was in moving away from multiple web silos and instead more to a model much more internet like. Collaborating together, distributed around and without the risks we currently have with both our data and our futures with the way we’re currently using the web.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn1"><p>They really are quite a lovely. I don’t quite know how they handled me hovering around them for the few days. Also, <a href="http://www.alfredapp.com/purchase/">buy Alfred</a>.<a href="#fnref1">↩</a></p></li>
<li id="fn2"><p>Of course, we’re seeing this somewhat with Passbook. But, really, we want even more environmental interaction, especially if we continue to add publicly available sensors.<a href="#fnref2">↩</a></p></li>
<li id="fn3"><p>If you’re interested in all of this Sci-Fi stuff from an implementable angle, Scott wrote: <a href="http://designmind.frogdesign.com/blog/of-bears-bats-and-bees-making-sense-of-the-internet-of-things.html">Of Bears, Bats, and Bees: Making Sense of the Internet of Things</a>.<a href="#fnref3">↩</a></p></li>
</ol>
</div>]]></summary>
</entry>
<entry>
    <title>Young Rewired State 2012</title>
    <link href="http://nickcharlton.net/posts/young-rewired-state-2012.html" />
    <id>http://nickcharlton.net/posts/young-rewired-state-2012.html</id>
    <published>2012-08-13T12:00:00Z</published>
    <updated>2012-08-13T12:00:00Z</updated>
    <summary type="html"><![CDATA[<p>Last week, I had the privilege of helping mentor seven young people as part of <a href="http://youngrewiredstate.org/">Young Rewired State</a> in Plymouth, and then at the weekend up in Birmingham for the Festival of Code. It was absolutely fantastic.</p>
<p>It was hosted under the wing of <a href="http://www.i-dat.org">i-DAT, the Plymouth University Institute for Art and Technology</a> who provided rooms and other resources. We started out in the Dome (officially the Immersive Vision Theatre), with an introduction by iDAT’s Director, <a href="http://www.i-dat.org/mike-phillips/">Mike Phillips</a>. After talking through what iDAT did, <a href="http://thisisthechris.co.uk">Chris</a> introduced what the week would be about and then we moved on to what would be are base for the rest of the week, one of the labs in Babbage.</p>
<p>For mentors, we had a pretty nice mix. <a href="http://phalt.tumblr.com">Paul</a> had come along with his brother, <a href="http://projects.drogon.net">Gordon</a> (who’s now somewhat internet-famous for his lower level work with the Raspberry Pi), and also the drop ins of two lecturers, <a href="http://www.plymouth.ac.uk/pages/dynamic.asp?page=staffdetails&amp;id=s1atkinson">Shirley Atkinson</a>, one of Paul and I’s and then <a href="http://www.i-dat.org/chris-saunders/">Chris Saunders</a> from iDAT. And of course, Chris and myself.</p>
<p>We opened with a short brainstorm of resources we could work with. The goal of Rewired State is to do smart things with data and this was no different. I also made a suggestion of talking about some of the projects that we (the mentors) had worked on to try and give some potential inspiration for what could be done.</p>
<p>For the rest of the day, they split up into teams and started to formulate project ideas. By the end of day one, we had four distinct projects on the go.</p>
<p>Over the next few days, projects gradually developed; going from mere figments of imagination on day one, to most of a working product by the Thursday.</p>
<p>Our projects were:</p>
<ul>
<li><a href="http://twit.tone.brkbrkbrk.com">TwitTone</a> by <a href="http://brkbrkbrk.com/">Sam Wray</a> and Simon Barnes.</li>
<li><a href="http://yrsidat.wordpress.com/2012/08/08/satellite-tracker/">Satellite Tracker</a> by Owen Hallet and Ryan Hockett</li>
<li><a href="https://github.com/KingDingDan/space">ODPlayground</a> by <a href="http://www.danielhart.in">Daniel Hart</a> and <a href="https://twitter.com/jynxsp0ck">Michael Maddocks</a></li>
</ul>
<figure>
  
<img src="/resources/images/yrs2012-odplayground.png"> <figcaption>ODPlayground in Action.</figcaption>
</figure>

<p>And on the Friday, we headed up to Birmingham for the Festival of Code.</p>
<p>The Festival of Code was hosted at Birmingham’s <a href="http://www.custardfactory.co.uk">Custard Factory</a>, a rather neat place<sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup> which dubs itself as a “revolutionary new arts and media quarter”. It’s filled with small units, as well as a nightclub, bar, café and other larger areas that were needed to host the Festival of Code. We arrived, registered and positioned ourselves in one of the lower room, as the teams worked on finishing off their projects ready to demonstrate the next day.</p>
<p>Whilst that was underway, Chris and I grabbed some lunch. We also met up with <a href="http://neilcford.co.uk">Neil Ford</a>, <a href="http://blog.amyl.org.uk">Adam McGreggor</a> and, briefly, <a href="http://andypiper.co.uk">Andy Piper</a>, who are always nice to see. After this, we explored the venue, scoping out where everything would be.</p>
<p>After what must have been the biggest delivery of pizza I’d ever seen, then a set of talks by various different people, a dodgy night’s sleep on the Old Theatre’s floor was had. Saturday was judging day. As a group, we filed into Theatre 2 and then sat and watched a fantastic set of demos of projects in our category. This went on for the rest of the day (there were many projects), up until the main event in the evening.</p>
<p>The main event was huge. It bought everyone together to see the projects who had made it in to the final stages. One of our projects, TwitTone also made it into the final!<sup><a href="#fn2" class="footnoteRef" id="fnref2">2</a></sup> Then was the judging, followed by prize giving.</p>
<p>Seeing some of the many projects that had made it into the final was incredible. Even after going to hack days myself, I will be continually amazed by what people can do in a short period of time (very well polished stuff, too) on something that catches their eye. It’s even better when it’s young people.</p>
<p><a href="http://mulqueeny.wordpress.com">Emma</a>, the rest of the people from Rewired State and the many, many volunteers did a fantastic job, making it a very good week for everyone involved.</p>
<p>Want to read more? There’s a <a href="http://www.flickr.com/photos/nickcharlton/sets/72157631761238662/">set of photos I took on Flickr</a> and the <a href="http://yrsidat.wordpress.com">YRS iDAT 2012 site</a>. Some of the code made it’s way to <a href="https://github.com/yrsIDAT">GitHub</a>.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn1"><p>It was once a Birds custard factory. On the train back, I sat next to someone who had worked there. Amazing.<a href="#fnref1">↩</a></p></li>
<li id="fn2"><p>We did have quite a few technical problems in demonstrating, which was a pain. But, they did eventually get to demonstrate it at the end, after installing Chrome over a dodgy 3G connection, and trying it on many different laptops. But, it worked in the end.<a href="#fnref2">↩</a></p></li>
</ol>
</div>]]></summary>
</entry>
<entry>
    <title>Finishing at Rokk Media</title>
    <link href="http://nickcharlton.net/posts/finishing-at-rokk-media.html" />
    <id>http://nickcharlton.net/posts/finishing-at-rokk-media.html</id>
    <published>2012-08-04T12:00:00Z</published>
    <updated>2012-08-04T12:00:00Z</updated>
    <summary type="html"><![CDATA[<p>And, so, that is the end of my placement. The conclusion of a year of working – and learning – is quite a sad one. I’ve really enjoyed it. I’ve been able to work on a diverse range of projects, from web stuff across to several iOS projects. And, ontop of that, working with a great group of people. I’ll miss it quite a lot.</p>
<p>There’s a lot to be said for being able to write code everyday for just over a year. But, on top of this, get advice, support and different constraints from what I’ve previously experienced on my own projects and those through University.</p>
<p>There are often pinacle points in your life where you go “yes, this was damn important and influential”. This was one of them.</p>
<p>So, thanks Adam, Tristan and the other people at Rokk Media. It was a great year.</p>]]></summary>
</entry>
<entry>
    <title>Stuff I'm Working On &amp; Learning</title>
    <link href="http://nickcharlton.net/posts/stuff-im-working-on-learning.html" />
    <id>http://nickcharlton.net/posts/stuff-im-working-on-learning.html</id>
    <published>2012-06-24T12:03:54Z</published>
    <updated>2012-06-24T12:03:54Z</updated>
    <summary type="html"><![CDATA[<p>This morning, <a href="http://rc3.org/">Rafe</a> <a href="http://rc3.org/2012/06/23/stuff-i-needwant-to-spend-time-learning/">posted about the stuff he’d like to be learning</a>. So, I thought that was a nice way to remind myself all the stuff I’m currently working on and the stuff I’m attempting to learn, in various states of completion:</p>
<h3 id="projects">Projects</h3>
<ul>
<li>Bat Finder: Since the <a href="http://nickcharlton.net/post/bats-hacks-and-fieldwork">FSC Hack Day</a>, I’ve been learning Core Audio and starting to understand audio analysis and visualisation. It’s hard stuff. It’ll be a while before I have anything significant, I suspect.</li>
<li>Predict the Sky: The end result of the <a href="http://nickcharlton.net/post/nasa-space-apps-challenge-predict-the-sky">NASA Space Apps Challenge at the Met Office</a> back in April. We’re not <em>that</em> far from a testable end product.</li>
<li>RepRap: Just over a month ago, I bought a Prusa Mendel RepRap Kit. I’ve since been slowly assembling and testing it. It’s intended to be for robotics prototyping, but I’m sure I’ll end up with endless printed trinkets along the way, too.</li>
<li>Quadcopter: This is intended to be the culumation of several of these projects and things I’m learning. It needs: electronics, control code<sup><a href="#footnote_quad_1" id="identifier_quad_1" class="footnote-link">1</a></sup> and then I can look into swarming behaviour and mapping.</li>
<li>Environmental Monitoring: Energy usage. Common behaviours. What can we discover by logging everything over an academic year? This is a little project for October onwards.</li>
</ul>
<h3 id="learning">Learning</h3>
<ul>
<li>Maths (matrices, compound event probability, calculus): All as a foundation to the rest of the stuff I’m doing. It’s often hard, but <strong>amazing</strong><sup><a href="#footnote_maths_2" id="identifier_maths_2" class="footnote-link">2</a></sup>.</li>
<li>Statistics: <a href="http://www.udacity.com/overview/Course/st101/CourseRev/1">Udacity’s “Intro to Statistics”</a> starts tomorrow. There’s data everywhere. We’re producing more at an exponential rate. The power is in those who can do stuff with it.</li>
<li>AI: As I go into my final year<sup><a href="#footnote_degree_3" id="identifier_degree_3" class="footnote-link">3</a></sup>, this is everything. My current overall objective is to learn as much is humany possible to make next year go smoothly. I’ve been doing <a href="https://www.ai-class.com/">AI Class</a> on-and-off over the past month.</li>
<li>iOS 6 &amp; Mountain Lion Additions: I’ve spent the last year doing this. I still find it a fantastic platform to develop for. There is a ton of stuff added at the developer level. Lots of improved things, as well as new APIs to learn.</li>
</ul>
<p>So, yes. I like to keep myself busy. Some of this (the bat detection stuff, certainly) I do intend to document here (outside of textbooks, this kind of programming isn’t well written about). But most of that will come with time. Pester me if something is specifically interesting. Otherwise I assume it’s all easy to learn stuff.</p>
<hr />
<ol class="footnotes">
    <li id="footnote_quad_1">
Whilst quadcopters are fantastically agile machines (they can be anywhere in a given space), they have no inherant stability. Just getting one to hover is the first challenge.<a href="#identifier_quad_1">↩</a>
</li>
    <li id="footnote_maths_2">
I can recommend <a href="http://www.amazon.co.uk/gp/product/0199142432/ref=as_li_ss_tl?ie=UTF8&tag=nisbl-21&linkCode=as2&camp=1634&creative=19450&creativeASIN=0199142432">“Understanding Pure Mathematics” by Sadler and Thorning</a> (which covers basic algebra, matrices and some calculus, etc.), which was kindly lent to me by a friend. But also <a href="http://www.khanacademy.org/">Khan Academy</a>.<a href="#identifier_maths_2">↩</a>
</li>
    <li id="footnote_degree_3">
Holy shit. I’ve nearly finished my degree.<a href="#identifier_degree_3">↩</a>
</li>
</ol>


]]></summary>
</entry>
<entry>
    <title>Bats, Hacks &amp; Fieldwork</title>
    <link href="http://nickcharlton.net/posts/bats-hacks-and-fieldwork.html" />
    <id>http://nickcharlton.net/posts/bats-hacks-and-fieldwork.html</id>
    <published>2012-05-29T23:13:06Z</published>
    <updated>2012-05-29T23:13:06Z</updated>
    <summary type="html"><![CDATA[<p>Two weekends ago, I was in Slapton at the <a href="http://field-studies-council.org/">Field Studies Council</a> for their first hack day. It aimed to bring together both people in education and those in technology and see what could be done when you bashed their two heads together. And it was bloody good.</p>
<p>Set in the picturesque Devon countryside, a bunch of us turned up not quite knowing what to expect. For most, it’d been quite a while since Geography lessions in school, let alone any fieldwork.</p>
<p>The hackday had been organised by <a href="https://twitter.com/FolkPrincess">Harriet White</a> of the FSC, <a href="http://reithian.blogspot.co.uk/">Ant Miller</a> of BBC R&amp;D, and <a href="http://about.me/johnbevan">John Bevan</a> of Mozilla. But we also had people from elsewhere in the BBC, a few associated with <a href="http://rewiredstate.org/">Rewired State</a>, FSC tutors on hand and designers and developers of various afflictions. We were also lucky to have a few people from the <a href="http://bristol.hackspace.org.uk/">Bristol Hackspace</a>, too.</p>
<figure>
<img src="http://nickcharlton.net/resources/bats_hacks_fieldwork/pub.jpg" width="500" alt="The Tower — The Lovely Local Pub"> <figcaption>The Tower — The Lovely Local Pub.</figcaption>
</figure>

<h3 id="bat-detection">Bat Detection</h3>
<figure>
<img src="http://nickcharlton.net/resources/bats_hacks_fieldwork/bat_guide.jpg" width="500" alt="The FSC's Guide to British Bats"> <figcaption>The FSC’s Guide to British Bats.</figcaption>
</figure>

<p><a href="http://mike.saunby.net/">Mike</a> and I worked on a low-cost bat detector. Mike had picked up an off-the-shelf bat detector and had been experimenting with outputting typical British bat tones (in the 40kHz to 110Khz range) using a multitude of different devices. In the end, he’d found that it was possible with expensive external sound cards and really cheap internal sound cards (we concluded that manufacturers are unlikely to ensure output is kept to a sensible range at the low end, but unlike the expensive stuff it certainly wouldn’t be optimised for being used like it.)</p>
<p>This allowed us to simulate bat calls indoors, at any time. For us, this was vital. But has the additional effect of being mightily useful in the classroom. On a weekend of fieldwork, there would not be much chance for evenings spent hunting around for bats; a simulator could provide a demonstration of what it’ll be like using bat detectors and what you would be likely to discover.</p>
<p>After experimenting with a few different bat detectors, we talked about what we could do to make bat finding more accessible. In the morning of the first day, <a href="http://daviderogers.blogspot.co.uk/">David Rogers</a> of the <a href="http://prioryschool.wordpress.com/">Priory School</a> in Portsmouth had talked about student devices and what he (and other teachers) had been doing to use them to aid learning. Whilst the <abbr title="Bring Your Own Device">BYOD</abbr> model seems slightly problematic for our case<sup><a href="#footnote_mobile_1" id="identifier_byod_1" class="footnote-link">1</a></sup>, a universal bit of hardware seemed a good place to start.</p>
<p>Off the shelf bat detectors use frequency shifting to take the bat’s ultrasonic clicks and squeaks and turn it into human audible frequencies. In the UK, bats are typically somewhere around 45Khz. (Human hearing is somewhere between 20Hz-20Khz.) Fortunately, doing this is quite typical (its how transistor radios work) and relatively cheap to do. So, with this in mind, we came up with the idea of a <a href="https://squareup.com/square">Square</a> like dongle which is inserted into the audio input of a mobile device. The device can then “listen” in to the audio signal and provide some sort of output.</p>
<p>Mike spent the rest weekend working on the circuit, and quite quickly got something working. He then iterated over it to attempt to reduce the amount of components, and try different microphones to see which was best. <a href="http://mike.saunby.net/">I’m sure he’ll blog about it soon</a>.</p>
<p>In the mean time, I looked into how we could analyse and present the audio data as it came in, and what the audio range of the iPhone<sup><a href="#footnote_platforms_2" id="identifier_platforms_2" class="footnote-link">2</a></sup> was like. I didn’t go much further with looking at the audio range, other than concluding that it was at least slightly outside of standard Human hearing range, but seemingly not up to ultrasonic.</p>
<p>I quickly discovered that audio programming is hard. Or at least, low-level audio programming is. Exploring the lower-level <a href="https://developer.apple.com/library/ios/#documentation/MusicAudio/Conceptual/CoreAudioOverview/Introduction/Introduction.html">Core Audio APIs</a> was a little beyond hacking at a weekend. I did however recall reading about <a href="http://alexbw.github.com/novocaine/">Novacaine</a> and a few other audio recording projects which kickstarted pulling in audio data.</p>
<p>I was quite surprised to find that graphing the data was also not easy. With libraries for most things, you assume it’ll be easy to put together a time-series graph of live data. Whilst the likes of <a href="https://code.google.com/p/core-plot/">Core Plot</a> exist, it’s not as elegant as it could be. Subsequently I’ve spent last weekend working on something to solve it. It’s common for bat detectors to use frequency-histograms to show ‘loud’ points in the past over various frequencies at once, as this helps with detection, too. So I also need to work out how to do that. Graphing additionally comes with the advantage of being far more accessible than an audio output. We’re already shifting sounds that we, as humans are unable to hear, so why do we limit it to outputting just human audible sound?</p>
<p>Handily, Novacaine is extracted from a few audio analysis projects which in the end I used to demonstrate what we’d found. On the concluding part on the Sunday, the attendants, organisers and judges came around to each lab to see what we’d done. After Mike had run through the basics of bat detection, and the circuit that he’d put together, we demonstrated what could be done using an iPad and <a href="http://itunes.apple.com/us/app/oscope/id344345859?mt=8">oScope</a>. You could clearly see the bat calls on the oscilloscope display, as played through a cheap netbook and the speakers in the room.</p>
<p>It also turned to demonstrate the phenomena of <a href="http://en.wikipedia.org/wiki/Presbycusis">presbycusis</a> or age-related hearing loss, as the room speakers spread across the audial-range of the bat recordings more than on the netbook did on its own. People under the age of ~35 were unable to hear this noise, but those below could. (It’s like a very high-pitched, uncomfortable drone.) We also discovered that modern (especially cheap) digital electronics are remarkably noisy in the ultrasonic range. Passing one of the bat detectors over certain devices in various different ranges lead to a lot of background noise.</p>
<h3 id="winning-an-award">Winning an Award</h3>
<p>We were in Lab 1 and went first. After we’d done our demonstration, we went through the other labs to see what had been done. Everyone did something fantastic. From 3D printed representations of beach profiles, to Arduino powered data logging and applications for collecting data in the field, to tools for anaylising that data back in the classroom. Everyone attempted to solve — with a sane use of technology — the problems that the team have at the FSC.</p>
<p>On the blog, <a href="http://fschackday.wordpress.com/2012/05/22/fsc-hack-winners/">Ant has written up about all of the projects and the winners</a>. Which you should go and read.</p>
<p>Done that? Good. Well, there were four awards. And we won one of them!</p>
<p>We won the “People’s Choice Award”, awarded by putting stones into tubs after we’d all looked at the different projects. It was extremely satisfying to gain the approval of all of the other people there. It was fantastic to see so many people interested in what we had been doing.</p>
<h3 id="documeting-it-all">Documeting it All</h3>
<p>Before and during the weekend we had <a href="http://rowstar.blogspot.co.uk/">Rowan Stanfield</a> and others documenting the event. I’m pretty sure I haven’t seen it done to this much detail before. Looking back it was quite a marvellous idea. The whole weekend is laid out for us to look back onto, as well as for others to see what was done. It provides a fantastic documented legacy of the whole event.</p>
<p>You can see all of this on the <a href="http://fschackday.wordpress.com/">Fieldwork Hackday</a> site.</p>
<h3 id="result-showcase-event">Result Showcase Event</h3>
<p>On Wednesday there is a <a href="http://lanyrd.com/2012/fschackresults/">wrap up/project show off event up in London</a> at the Mozilla Space. I’ll be there presenting the bat stuff (with hardware, too!)</p>
<p>I understand it’s going to be streamed — as well as showing off the video that was produced of the event. I’ll write up something else after the event, probably with more pictures.</p>
<hr />
<ol class="footnotes">
    <li id="footnote_byod_1">
It’s hard plan out where you dedicate resources to an almost unlimited amount of possible devices. Especially on a project like this. But, more importantly, it’s unfair to over emphasise finances where we want people learning.<a href="#identifier_byod_1">↩</a>
</li>
    <li id="footnote_platforms_2">
Given I’ve spent the last year doing iOS development it was the right thing to start on. But, there’s absolutely no reason why it wouldn’t work elsewhere too.<a href="#identifier_platforms_1">↩</a>
</li>
</ol>


]]></summary>
</entry>
<entry>
    <title>NASA Space Apps Challenge &amp; Predict the Sky</title>
    <link href="http://nickcharlton.net/posts/nasa-space-apps-challenge-predict-the-sky.html" />
    <id>http://nickcharlton.net/posts/nasa-space-apps-challenge-predict-the-sky.html</id>
    <published>2012-05-06T11:15:16Z</published>
    <updated>2012-05-06T11:15:16Z</updated>
    <summary type="html"><![CDATA[<p>Two weekends ago I was at the <a href="http://metoffice.gov.uk/">Met Office</a> for the <a href="http://spaceappschallenge.org/">NASA International Space Apps Challenge</a>. It was quite a fantastic weekend. Four or so teams of people worked on a set of preset challenges (suggested by the leaders of those teams in the weeks running up to the event) and the rest of us congregated around the group we were most interested in.</p>
<p>The group I was in worked on a project which we dubbed ‘Predict the Sky’. The idea was to take astronomical passovers and combine that with weather data to provide a useful indication of what you would be able to see in the night sky and it worked remarkably well. We ended up implementing a web service, iOS &amp; Android applications and began on a web frontend. <a href="http://vimeo.com/40825160">At the end we demonstrated it using a video walkthrough of the two applications and sections of the design process</a>.</p>
<p>We had a fantastic team (consisting of: <a href="https://twitter.com/bushbaby2511">Tom Bell</a>, <a href="https://twitter.com/sophiedennis">Sophie Dennis</a>, <a href="https://twitter.com/robjglover">Rob Glover</a>, <a href="https://twitter.com/ehibling">Emma Hibling</a>, <a href="https://twitter.com/stevehadd">Stephen Haddad</a>, <a href="https://twitter.com/angerelle">Angela Relle</a> &amp; <a href="http://adamretter.org.uk/">Adam Retter</a>.), who were all a pleasure to work with. Quite a few people commented on both how organised and on the amount we achieved in the time. I couldn’t have had a better team of people to work with.</p>
<p>The other teams &amp; challenges were pretty fantastic too. The winners of the event where <a href="http://spaceappschallenge.org/challenge/growers-nation/">Growers Nation</a> and <a href="http://spaceappschallenge.org/challenge/welovedata-challenge/">We Love Data</a>. The former aims to crowdsource crop growing information, combined with climate and soil data to give the best indication on when crops should be planted. We Love Data aimed to give a bunch of demonstrations on what could be done with data “in the real world” using a bunch of Arduino’s and related hardware. They produced a rather impressive wave machine using the stream running through the “Street” in the middle in the Met Office building that would activate and push through a floating “ISS Duck” when the International Space Station would pass over. It worked rather well on the Saturday night. They also produced a clever 3D-printed pollen grain which would colour according to Met Office-provided pollen counts. The idea behind this was to provide smart, internet connected objects which wouldn’t necessarily be connected to a computer. These kind of products (much like the wider <a href="http://en.wikipedia.org/wiki/Internet_of_Things">Internet of Things</a> concept) have the power to open up data (like pollen counts) to those who wouldn’t want a ‘widget’ or application to handle it on a more general purpose computer. <a href="http://www.interactivewearables.co.uk/?p=96">Dougie Kinnear, one of the team members produced a rather comprehensive write up</a>.</p>
<p>Over the weekend we got impressively far through the project. But not quite enough to release it. On the iOS side (the bit I worked on) I got the stage where we just needed to wire up the network request to the view. It looks like we’ll be doing some sort of workshop-like session in the next few weeks to iron out the rest and figure out where we see it in the future.</p>
<p>However. If you’d like to look it at now. <a href="https://github.com/MetOfficeSpaceApps/PredictTheSky">It’s all on GitHub</a>. <a href="http://www.adamretter.org.uk/blog/entries/nasa-space-apps.xml">Adam also wrote up what happened</a>.</p>]]></summary>
</entry>
<entry>
    <title>ORGCon 2012</title>
    <link href="http://nickcharlton.net/posts/orgcon-2012.html" />
    <id>http://nickcharlton.net/posts/orgcon-2012.html</id>
    <published>2012-03-29T22:56:22Z</published>
    <updated>2012-03-29T22:56:22Z</updated>
    <summary type="html"><![CDATA[<p>On Saturday, I was at the <a href="http://www.openrightsgroup.org/">Open Rights Group</a> Conference at the University of Westminster in London. It was a very good day, full of interesting talks from the likes of Cory Doctorow, Wendy Seltzer and Laurance Lessig. It was the first time I’ve seen these talk in person (Lessig was notably impressive - especially with his slides.) Below are some of the notes I made.</p>
<h3 id="cory-doctorow-the-coming-war-on-general-purpose-computing">Cory Doctorow: The Coming War on General Purpose Computing</h3>
<p>This was about the progression towards specific computers - not ones which can crunch any numbers that you throw at it, but tailored and locked down to a specific purpose.</p>
<ul>
<li>Original ”early” DRM -&gt; Easy to break. Broken because it was more convenient with it removed.</li>
<li>The early information age was very much a ”charge for all the things” charging module. Skipping, pausing, etc.</li>
<li>DRM is exponentially problematic, one use opens up many more problems and as you solve those the problems just get bigger.</li>
<li>Complete failure of the UN’s (WIPO) copyright laws.
<ul>
<li>they posed unrealistic demands upon reality.</li>
<li>it’s a good example of a worldwide treaty which solves a of the wrong problems.</li>
</ul></li>
<li>Law makers represent populations of people, not subject areas. They use heuristics to balance good rules for the population.</li>
<li>But these heuristics utterly fail for technology.</li>
<li>General Purpose Computing is much like the wheel is to the car.</li>
<li>As control is aimed at General Purpose Computing, appliances look like a solution.</li>
<li>Unfortunately, this opens up more issues: SOPA, Human Rights, etc.</li>
<li>Copyright however is usually considered less economically important (certainly in comparison to food, water, etc), even though computers now essentially make up everything around us.</li>
<li>Every big industry will turn to the easy solution of locking down General Purpose Computing.</li>
<li>Thus, the fight will only get harder.</li>
</ul>
<p>This talk was an updated version of a previous one, and also <a href="http://boingboing.net/2012/01/10/lockdown.html">an article on BoingBoing</a>.</p>
<h3 id="wendy-seltzer-organising-for-the-open-net">Wendy Seltzer: Organising for the Open Net</h3>
<ul>
<li>With SOPA/PIPA, representatives finally saw the power of the Internet.</li>
<li>There is a long history of stupid, naïve attempts at legislation in the States (<a href="http://en.wikipedia.org/wiki/Higher_Education_Opportunity_Act#2008_reauthorization">HEOA</a>, <a href="http://en.wikipedia.org/wiki/Combating_Online_Infringement_and_Counterfeits_Act">COICA</a>.)</li>
<li>You cannot control the Internet without fundamentally breaking it.
<ul>
<li>the Internet would not have grown to be what it is with significant control.</li>
</ul></li>
<li>And, how can it be right that one Government Department can prop up a dying business model?
<ul>
<li>whilst one part of the US Government was praising the freedom of speech aspect, others were going in the opposite direction.</li>
</ul></li>
<li>The power of the hivemind for real world events cannot be understated. Even the effect that changing a Twitter avatar has is greater than one would expect. (Even if it does appear to be “<a href="http://en.wikipedia.org/wiki/Slacktivism">slactivism</a>”)</li>
<li>The “white blood cell”/vaccine metaphor fits quite well. But, can following such a model actually make us more resilient against future issues?</li>
<li>But an immune system can also kill itself if it overreacts. We (as the internet), have to be careful to not cry wolf at the next piece of legislation to rear its head.</li>
<li>Motivation to keep fighting can and will come from the very specific niche interest that makes the general purpose Internet amazing.</li>
</ul>
<h3 id="panel-is-all-this-data-doing-us-any-good">Panel: Is all this data doing us any good?</h3>
<p>This session was a panel, with <a href="https://twitter.com/#!/CountCulture">Chris Taggart</a> of <a href="http://OpenCorporates.com/">OpenCorporates</a>, <a href="http://rufuspollock.org/">Rufus Pollock</a> (of Open Knowledge Foundation) and <a href="http://heatherbrooke.org/">Heather Brooke</a> (who worked on uncovering the MP’s expenses scandal). It was split into questions, but some notes ended up merged into others.</p>
<h4 id="who-are-we-empowering">Who are ”we” empowering?</h4>
<ul>
<li>Only about 1% of all Government data (in the UK) is being opened up.</li>
<li>That is mostly because it is sold, and a business model has been built around it.</li>
<li>Stops Innovation. “If your business model doesn’t match, you can’t play.”</li>
<li>Closed data is growing exponentially, far faster than that which is being open.</li>
<li>We’re empowering everyone. But, the small guy has far more power even with smaller resources.</li>
<li>The American journalism model relies upon public records. In the UK, we don’t have this. Unfortunately, this leads to a patronage network - making it harder for new people to get in.</li>
</ul>
<h4 id="value">Value</h4>
<ul>
<li>Governments may very well agree with opening up data, but it is expensive (it needs to be organised, packaged, etc.)</li>
<li>Government need to understand the bigger social value other than the direct business profit.</li>
<li>However; data without tools isn’t useful.
<ul>
<li>tools, analytics, etc is a resource problem.</li>
</ul></li>
<li>“Pirate” Data Sets are good and bad.
<ul>
<li>The MPs expenses leak was good - it raised public awareness of an ongoing issue.</li>
<li>The Wikileaks “cablegate” wasn’t good - it hurt government’s opinions on transparency (not everything is appropriate open.)</li>
</ul></li>
<li>Journalists need tools and education to be able to utilise data for the “common man”. Just opening up stuff isn’t useful.</li>
</ul>
<h4 id="opening-up-data">Opening Up Data</h4>
<ul>
<li>It’s a politcal, rather than legal issue.
<ul>
<li>even though it might well be against usage terms and conditions, organisations are often happy to ignore them to see people doing good things with it.</li>
</ul></li>
<li>The ease of getting data opened is somewhat because someone isn’t fighting the other way (unlike copyright, for example.)</li>
<li>Do it, appologise later. “Generally” not much has happened to people doing precisely that.</li>
<li>A good way forward would be “open by default” - no more Crown Copyright, for example.</li>
<li>But, people need to ask for data that they wish to use - organisations may just assume people aren’t interested otherwise.</li>
<li>And, uncovering something like corruption because of open data wouldn’t hurt at all.</li>
</ul>
<h3 id="ross-anderson-how-secure-is-the-anonymisation-of-open-data">Ross Anderson: How Secure is the Anonymisation of Open Data?</h3>
<p>This session was given by <a href="http://www.cl.cam.ac.uk/~rja14/">Ross Anderson, a Security Professor at Cambridge Computer Lab</a>. It mostly focused upon medical data, and the information than can be inferred from disparate data sets.</p>
<ul>
<li>Back in 1979, it was shown that you can find more data than anyone had previously expected in US Census Data.</li>
<li>In the ’90’s, it was shown that a State Senator could be identified through health data.</li>
<li>The same happened in the UK with NHS data.</li>
<li>Generally, if you know enough information about a place (e.g. Cambridge Computer Lab.) you can easily glean a lot from publicly available data (for example, there is only one female professor, and the University publish average salary statistics.)</li>
<li>It is very hard to stop data leakage through inference unless you know all of the cases where it can be “attacked”.</li>
<li>The more data that is opened up (inc. social network data), the more patterns that can be seen.</li>
</ul>
<h3 id="mozilla-do-not-track">Mozilla: Do Not Track</h3>
<ul>
<li>Aims to give users a universal, simple opt-out from advertising based data collection.</li>
<li>It is being standardised, by consensus by the W3C (from a mix of privacy advocates, advertisers and governments.)</li>
<li>Implemented as an HTTP Header, and an accompanying JSON status file.</li>
<li>In general, the policies define the levels of sharing between first and third parties on a given website (e.g.: a Twitter “Tweet” button is a third party to the New York Time’s site, until you click on it.)</li>
<li>It also defines “outsource” providers for analytics and CDNs.</li>
</ul>
<p>My initial thought with this was about it’s “opt-out” nature and requirement that organisations implement it at their end. The well-behaving organisations are likely happy to be involved and implement it - but they’re probably already not doing crappy things with data collected from our browsing sessions.</p>
<p>You can read more about <a href="http://dnt.mozilla.org/">Mozilla’s Do Not Track Project here</a>.</p>
<h3 id="the-upcoming-data-protection-act-changes">The Upcoming Data Protection Act Changes</h3>
<ul>
<li>The original, “business friendly” <a href="http://en.wikipedia.org/wiki/Data_Protection_Act_1998">Data Protection Act</a> will be (in about four years) replaced.</li>
<li>In general, this will balance out the laws throughout the EU.</li>
<li>Industry should see less red-tape.</li>
<li>Notably however, instead of two sets of data being considered seperate (where one could be identified from the merging of the two), this would no longer be allowed. [See &quot;How Secure is the Anonymisation of Open Data?, above.]</li>
<li>What defines “personal data” is being redefined (e.g.: IP addresses, cookies, etc.). Some of this is still undefined.</li>
<li>It is also possible that there will be a clause requiring individuals to request data from companies that is stored about them.</li>
<li>And it is also possible that there will be a clause requiring companies to comply with user’s requests to remove data stored about them (this may cause issues for search engines, social networks, etc.)</li>
</ul>
<h3 id="laurence-lessig-recognizing-the-fight-were-in">Laurence Lessig: Recognizing The Fight We’re In</h3>
<p><a href="http://www.lessig.org/">Lessig</a> is a fantastic speaker. This talk was an outcry to release how important the fight for which the ORG stands for is. It spreads from the model of spectrum allocation for managing radio standards to corruption in modern politics.</p>
<ul>
<li>Spectrum allocation (and property) only works on big, wide broadcasts, not the small scale usage we generally see now (e.g.: wifi, bluetooth, etc.)</li>
<li>Why can’t the TCP/IP model work?
<ul>
<li>defined as scalable usage with users, rather than applying scarcity.</li>
</ul></li>
<li>It stays as property because of lobbyist.
<ul>
<li>We need to rememeber to askt he question: “Who makes money from this?”.</li>
</ul></li>
<li>Poor broadbad, copyright extensions &amp; SOPA insanity is all driven by greed.</li>
<li>Fundamental copyright is necessary. However, it needs to benefit the creators &amp; authors - not publishers.</li>
<li>Locking up academic information in exclusivity is an ethical problem.
<ul>
<li>How can it be right that publically funded research makes money for private publishing organisations?</li>
</ul></li>
<li>The state of US politics is a kind of corruption - relative to the baseline on which it was founded.</li>
<li>Most people do not vote because they have no belief in the system.
<ul>
<li>it is thought that corporate interests rule the way and that voting alone is pointless.</li>
</ul></li>
<li>The growth of citizen politics is leading to an international anti-corruption movement. This is a fantastic thing.</li>
</ul>
<p>You can watch <a href="https://vimeo.com/39188615">the video of Lessig’s talk here</a>.</p>]]></summary>
</entry>
<entry>
    <title>#digpen IV Git Workshop</title>
    <link href="http://nickcharlton.net/posts/git-workshop.html" />
    <id>http://nickcharlton.net/posts/git-workshop.html</id>
    <published>2012-03-12T10:30:07Z</published>
    <updated>2012-03-12T10:30:07Z</updated>
    <summary type="html"><![CDATA[<p>On Saturday, <a href="http://thisisthechris.co.uk/">Chris Hunt</a> and I gave a workshop on Git at Digpen IV in Exeter. It seemed to go rather well.</p>
<p>In fact, the whole day was excellent. An afternoon of interesting, detailed and well choreographed sessions. You can find a collection of them over on <a href="http://lanyrd.com/2012/digpen/">Lanyrd</a>. Most have slides and there’s videos, too.</p>
<p>The slides are embedded below, but you can also find them on <a href="http://speakerdeck.com/u/nickcharlton/p/getting-started-with-source-control-and-git">Speaker Deck</a>. There’s a <a href="http://github.com/nickcharlton/git-workshop">repository over on GitHub</a> with the rest of the resources.</p>
<script src="http://speakerdeck.com/embed/4f5dce08dfe51b0022015048.js">

</script>


<p>I gather I also agreed to do a follow on session at a future one. So, with that in mind, shout if you have something in mind that you’d like covered.</p>]]></summary>
</entry>
<entry>
    <title>Review: Hacking and Securing iOS Applications by Jonathan Zdziarski</title>
    <link href="http://nickcharlton.net/posts/review-hacking-and-securing-ios-applications.html" />
    <id>http://nickcharlton.net/posts/review-hacking-and-securing-ios-applications.html</id>
    <published>2012-02-26T22:47:50Z</published>
    <updated>2012-02-26T22:47:50Z</updated>
    <summary type="html"><![CDATA[<p>I started this just after the <a href="http://nickcharlton.net/post/mobile-security">Path fiasco</a>. It seemed timely to brush up on my security knowledge, especially for iOS intricacies, recommended practices and understanding obvious flaws. At the same time, O’Reilly had published <a href="http://shop.oreilly.com/product/0636920023234.do">“Hacking and Securing iOS Applications” by Jonathan Zdziarski</a>, so I got a copy. This book provides exactly what I wanted; it’s a great next-step if you’ve been developing for iOS or the Mac for a while. Fortunately it assumes that, which allows the book to quickly jump into examples and solutions.</p>
<p>After debunking some common myths, the book delves into pushing code onto a jailbroken device. It was quite an eye opener to see how simple it was (this isn’t something I’ve done since back on iPhone OS 1.3.3, or so.) If you can compile something using gcc, you can just about as easily (and quickly) push something onto a device.</p>
<p>Related to the Path fiasco, the next fuller example (in Chapter 2) is about pushing the Address Book over the network. I found that quite amusing.</p>
<p>The book then descends into exploiting the filesystem, and other common attack vectors. This is followed by sections on manipulating the Objective-C runtime and examples in applications which are the time of writing claimed to be “secure”, but suffered from simple to discover flaws.</p>
<p>The second half of the book delves into advice on writing secure applications. Its “now you know what you can do, here’s how to engineer around it” style works fantastically and provides the most value - especially if you’re building something which is security conscious. Notable here was the chapter on encryption. It covered implementing SSL and flaws relating to it, as well as delving into using public-key encryption along with SSL when passing data around.</p>
<p>After this, the book delves into ways to obfuscate methods and protect the data the application is working with. For example, providing traps which when executed would erase any useful encryption keys, or phone home (passing logs and/or GPS coordinates) to help mitigate any knock-on effects of a breached application. Some of these security holes are due to the reflective nature of Objective-C, which allows you to modify the runtime as it is executing - catching tampering attempts, or placing honey traps for attackers can be used as another line of defence.</p>
<p>But, more importatly, the book aims to bring across a fundamental of security and penetration testing: You need to think and act like an attacker to see potential flaws and attacks. For this it is organised well, and because of that, it’s a great position to leap off from.</p>
<p><em>O’Reilly provided a copy of the book for to review for free, as part of their Bloggers Programme.</em></p>]]></summary>
</entry>
<entry>
    <title>Mobile Security: I Don't Even Know Where to Begin</title>
    <link href="http://nickcharlton.net/posts/mobile-security.html" />
    <id>http://nickcharlton.net/posts/mobile-security.html</id>
    <published>2012-02-13T20:01:09Z</published>
    <updated>2012-02-13T20:01:09Z</updated>
    <summary type="html"><![CDATA[<p>With the <a href="http://mclov.in/2012/02/08/path-uploads-your-entire-address-book-to-their-servers.html">recent Path debacle</a>, the security and privacy practices of various mobile application developers has come to light. Generally, this has focused around the use of Address Book data; here, developers are balancing violating individual privacy with easier connections - the metric of importance for such apps. On its own, this is fine — providing you have the user’s permission — the issue is in how developers are going about implementing it.</p>
<p>Security is a numbers game. Nothing is or will ever be perfectly secure<sup><a href="#footnote_mobile_1" id="identifier_mobile_1" class="footnote-link">1</a></sup>, but the whole notion of attempting to protect users seems to have been entirely ignored. In most cases (Path, for example) this is just blind ignorance, but <a href="http://mybroadband.co.za/news/cellular/43301-zing-mobile-messaging-app-all-the-details.html">others seem to be actively avoiding such simple things as hashing</a>.</p>
<p>I’m not sure which is worse. Is it worse that developers simply did not consider encrypting the data they were passing around, or another developer actively decided against it? At least if users know that their data is not being encrypted along the wire, and is being stored in plain text they can make a decision about whether or not to use it<sup><a href="#footnote_mobile_2" id="identifier_mobile_2" class="footnote-link">2</a></sup>. I suspect the bigger issue is education. The open nature of the Web is a fantastic thing and to some extent this is transferring to mobile development, too.</p>
<p>But this means that developers do not have a well rounded conceptial understanding of what they are doing. Developers like Matt Gemmell shouldn’t have to write articles like: “<a href="http://mattgemmell.com/2012/02/11/hashing-for-privacy-in-social-apps/">Hashing for privacy in social apps</a>” and <a href="http://twitter.com/mattgemmell/status/169039433226649600">receive responses from other developers</a>.</p>
<p>On iOS, the Address Book API calls have almost entirely been pulled over from the Mac. Only the picker tool is Cocoa, the rest is Core Foundation (C). I suspect the lack of user permissions is because of this, rather than any malicious intent. <a href="https://developer.apple.com/appstore/guidelines.html">Regardless, it’s against the developer agreement</a>.</p>
<p>I certainly don’t think that a CS degree should be a prerequisite for building any software; but somewhere we, as developers need to build up interest into. Just throwing in a little bit of hashing and salting at the end of a project cannot be a valid security standpoint to take for software that is used by a wide variety of users.</p>
<ol class="footnotes">
    <li id="footnote_mobile_1">
In iOS’s case, whilst the filesystem is encrypted, it’s still like keeping your house keys under your doormat. You cannot unlock the filesystem without also shipping the keys with the device. <a href="#identifier_mobile_1">↩</a>
</li>
    <li id="footnote_mobile_2">
But I don’t think this is a good excuse. As app developers it is our, as much as the platform providers’, responsibility to protect our users. <a href="#identifier_mobile_2">↩</a>
</li>
</ol>


]]></summary>
</entry>
<entry>
    <title>Brussels &amp; FOSDEM 2012</title>
    <link href="http://nickcharlton.net/posts/brussels-fosdem-2012.html" />
    <id>http://nickcharlton.net/posts/brussels-fosdem-2012.html</id>
    <published>2012-02-12T21:44:16Z</published>
    <updated>2012-02-12T21:44:16Z</updated>
    <summary type="html"><![CDATA[<p>Last weekend, I was in Brussels for <a href="http://fosdem.org/2012/">FOSDEM</a>. It was an excellent weekend. I didn’t go too that many sessions at FOSDEM, but the ones I did go to were pretty good and have pushed me into finding out a few more things in detail.</p>
<p>The first session I went to was titled <a href="http://fosdem.org/2012/schedule/event/javalinuxapps">“Why Java for Linux applications?”</a>. It was interesting to see someone’s approach to implementing something that needed to be cross-platform, but I find both the development environment and the eventual product of <a href="http://en.wikipedia.org/wiki/Swing_(Java)">Swing</a> hard to take as a recommendation. The next session was <a href="http://fosdem.org/2012/schedule/event/debian_packaging">“Debian packaging for beginners”</a>. I’ve done some repackaging before, but nothing completely from scratch. It was interesting to see the process done, it’s not as complex as it first makes out. After these, I headed over to the GNUstep Devroom.</p>
<p>Since spending a large amount of time developing for iOS, and some for the Mac, I’m obviously heavily invested in Objective-C and Cocoa. The <a href="http://fosdem.org/2012/schedule/event/new_objc_features">talk on the newer features of Obj-C</a>, by <a href="http://www.cs.swan.ac.uk/~csdavec/">David Chisnall</a> was especially interesting. Support for the likes of Automatic Reference Counting and blocks is far more comprehensive than I expected, and in some cases far better than Apple’s own implentation. I’ll be interested to see how the <a href="http://etoileos.com/">Étoilé</a> project and others progress.</p>
<p>On the other hand, the final talk of the day, <a href="http://fosdem.org/2012/schedule/event/quantumstep_future">QuantumSTEP</a> was less impressive. It provides an implementation of Objective-C and Cocoa for the <a href="http://www.quantum-step.com/">GTA05 Open Source Phone platform</a>. It seemed to be a little too much about slowly chasing up iOS, which itself is moving rather fast. It was interesting, though.</p>
<p>On the Sunday, I primarily spent time in the Virtualisation &amp; Cloud Devroom. I had previously heard about <a href="http://www.ovirt.org/">oVirt</a>, but without an official release hadn’t looked too deeply into it. The introduction talk, <a href="http://fosdem.org/2012/schedule/event/ovirt_intro">“Virtualization Management the oVirt way”</a> and the subsequent talks outlined the architecture that was being implemented.</p>
<p>oVirt is intended to be an open source version of <a href="http://www.vmware.com/products/vsphere/mid-size-and-enterprise-business/overview.html">VMware’s vSphere</a> product, but using <a href="http://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine">KVM</a>. The goal here is to provide a managed environment for running VMs, either for servers or “virtual desktops” for end users. This arrangement provides failover and general management on the server, rather than at the application level - something more common with traditional, non-web application infrastructure.</p>
<p>Unfortunately, it seemed a brittle solution to the problem. I’m not a fan of projects that are made up of many complex interconnecting parts to form a whole. At least not when they depend on a core central component. There also seemed to be a little confusion in the Q&amp;A about what would happen if you upgraded the frontend (nothing bad, as it happens), which was a little disconcerting. But, at the time, it hadn’t yet been released (this happened on the 9th Feb). I shall likely be giving it ago at some point.</p>
<p>Other than sessions themselves, I met up with <a href="https://twitter.com/bob_moss">Bob</a> on the Friday for an eventful, but good evening at the <a href="http://fosdem.org/2012/beerevent">FOSDEM Beer Event</a>. There, I also met Kostas Georgiou &amp; Elaine McLeod from <a href="http://opengamma.com/">OpenGamma</a>, who are working on an open platform for the financial services industry. Interesting stuff.</p>
<p>On Sunday afternoon, I met up with <a href="http://www.flickr.com/photos/tesfruitsmonjus/">Goedele</a>, which was good fun. After grabbing some lunch, we went to this odd bar which serves beer in skulls. The music was good, too.</p>
<p>Belgium was exceptionally cold for much of the time. When Ben and I arrived, it’d already been snowing for quite a while. I gather on the Friday night it got down to somewhere around -12°.</p>
<p>Belgium is a lovely country, which topped off an excellent weekend.</p>]]></summary>
</entry>
<entry>
    <title>PAM for OmniAuth: omniauth-pam</title>
    <link href="http://nickcharlton.net/posts/pam-for-omniauth.html" />
    <id>http://nickcharlton.net/posts/pam-for-omniauth.html</id>
    <published>2012-01-15T00:10:56Z</published>
    <updated>2012-01-15T00:10:56Z</updated>
    <summary type="html"><![CDATA[<p>I have a couple of small web applications that I have built for myself (wiki, system monitoring, etc.) There didn’t seem much point in adding a database for authentication, so I put together a strategy for using <a href="http://en.wikipedia.org/wiki/Linux_PAM">PAM</a> and <a href="https://github.com/intridea/omniauth/">OmniAuth</a>.</p>
<p>It depends on OmniAuth (~&gt; 1.0), <a href="https://github.com/canweriotnow/rpam-ruby19"><code>rpam-ruby19</code></a> and the PAM headers (that’s the <code>libpam0g-dev</code> package on <a href="http://packages.debian.org/squeeze/libpam0g-dev">Debian</a> and Ubuntu.)</p>
<p>It has only been tested on Debian 6.0 using Ruby 1.9.3-p0 (but there’s no reason why it won’t work elsewhere.)</p>
<p><a href="http://github.com/nickcharlton/omniauth-pam">The project is on GitHub</a>. Log an issue if something doesn’t work as you expect.</p>
<h3 id="usage">Usage</h3>
<p>Include provider type:</p>
<pre><code>use Rack::Session::Cookie
use OmniAuth::Strategies::PAM</code></pre>
<p>Implement the callback (as in the OmniAuth documentation), and then navigate to: <code>/auth/pam</code>.</p>
<p>It uses the authenticated user as the UID, as on a Linux system this would be unique.</p>
<h3 id="supporting-ruby-1.8">Supporting Ruby 1.8</h3>
<p>There is an older gem available for Ruby 1.8 for supporting PAM. The syntax is slightly different, but only a small change if you wanted it.</p>
<p>Instead of including <code>rpam-ruby19</code> instead use <a href="http://rpam.rubyforge.org/"><code>rpam</code></a> and change the implementation of <code>callback_response</code> in <code>lib/omniauth/strategies/pam.rb</code> to:</p>
<pre><code>def callback_phase
    unless authpam(request[&#39;username&#39;], request[&#39;password&#39;])
        return fail!(:invalid_credentials)
    end

    super
end</code></pre>
<p>You will also need to add <code>include Rpam</code> beneath <code>include OmniAuth::Strategy</code>.</p>
<p>As it’s only small (the whole thing is tiny as it is) I figured it’d be best to document the difference, rather than aim to support two different gems.</p>]]></summary>
</entry>
<entry>
    <title>Configuring Apache &amp; PHP on Lion</title>
    <link href="http://nickcharlton.net/posts/configuring-apache-and-php-on-lion.html" />
    <id>http://nickcharlton.net/posts/configuring-apache-and-php-on-lion.html</id>
    <published>2012-01-10T15:03:29Z</published>
    <updated>2012-01-10T15:03:29Z</updated>
    <summary type="html"><![CDATA[<p>There are too many terrible articles on configuring Apache and PHP on the Mac, especially for Lion. Even worse are the suggestions of using other versions, or overly complex configuration methods.</p>
<p>Apache &amp; PHP are included with Lion by default, but various parts are disabled. This will show you how to enable them without breaking the local install.</p>
<h3 id="configuration-files">Configuration Files</h3>
<p>The Apache config files are located in <code>/etc/apache2</code> (the standard place.)</p>
<p>The most important part of this directory is <code>httpd.conf</code>. This is the main configuration file. In the <code>users/</code> subdirectory are the configurations for local users (accessible through <code>http://localhost/~&lt;username&gt;</code>.)</p>
<p>The PHP configuration file (<code>php5.conf</code>) is held under <code>other/</code>.</p>
<p>The global virtual-hosts config file is held under <code>extra/httpd-vhosts.conf</code>. Although, by default this is commented out in <code>httpd.conf</code>.</p>
<p>The rest is mostly Apple specifics, including some of the tools included with Lion Server, and other areas of the config you are unlikely to need to change.</p>
<h3 id="permissions">Permissions</h3>
<p>By default, the main <code>httpd.conf</code> file is set to only be readable by all (444.) I would assume this is so users do not inadvertantly break the defaults.</p>
<p>To change it to be writeable by it’s own user (root), change it to 644 (readable by all, readable by it’s owner.) like so:</p>
<pre><code>chmod 644 httpd.conf</code></pre>
<p>You can then edit it using sudo, in your favourite editor.</p>
<h3 id="enabling-php">Enabling PHP</h3>
<p>Apple have always shipped with PHP disabled by default (even in Lion Server, you need to select a checkbox to specifically enable it.)</p>
<p>In <code>httpd.conf</code>, it is located somewhere around line 111, towards the end of the other <code>LoadModule</code> statements. This line is commented out. You need to remove the hash to it looks something like this:</p>
<pre><code>LoadModule alias_module libexec/apache2/mod_alias.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so                                    

#Apple specific modules
LoadModule apple_userdir_module libexec/apache2/mod_userdir_apple.so</code></pre>
<p>After doing this, you will need to restart Apache. You can do that from System Preferences/Sharing, or like so:</p>
<pre><code>sudo apachectl restart</code></pre>
<h3 id="virtual-hosts">Virtual Hosts</h3>
<p>For local development (for PHP this isn’t so often), I usually add a virtual host for the project I’m working on, and then adjust <code>/etc/hosts</code> to give it a usable domain.</p>
<p>You’ll need to edit <code>httpd.conf</code> again. There is an include for <code>httpd-vhosts.conf</code> quite a way in, somewhere around line 623.</p>
<p>You’ll find you’ll want to remove most of the default example content from <code>extras/httpd-vhost.conf</code> (by default accessing anything will give you a 403: Forbidden error.)</p>
<p>From there, each project/application/etc will need a VirtualHost block configured for it. This allows Apache to respond to a given domain.</p>
<p>The logging entries inside the block are optional, but recommended. Console.app is useful to keep an eye on the logs (it will automatically refresh when it changes.)</p>
<pre><code>&lt;VirtualHost *:80&gt;
	DocumentRoot /path/to/files
	ServerName project.example.com

	ErrorLog /path/to/files/logs/error.log
	LogLevel warn
&lt;/VirtualHost&gt;</code></pre>
<p>To get the domain working, you need to edit <code>/etc/hosts</code> and add a line something like this (below the comments, before the rest.):</p>
<pre><code>127.0.0.1	project.example.com</code></pre>
<p>Now, you should be able to navigate to that domain and access it.</p>
<hr />
<p>This is probably the most elegant way of running PHP applications locally. It keeps the already present tools, but makes them work as expected - which is far nicer than hacking other tools and configurations in place.</p>]]></summary>
</entry>
<entry>
    <title>Christmas Books</title>
    <link href="http://nickcharlton.net/posts/christmas-books.html" />
    <id>http://nickcharlton.net/posts/christmas-books.html</id>
    <published>2012-01-06T12:07:33Z</published>
    <updated>2012-01-06T12:07:33Z</updated>
    <summary type="html"><![CDATA[<p>I read quite a few things over Christmas, here’s some notes on a few of them:</p>
<h3 id="mobile-first-emotional-design"><a href="http://www.abookapart.com/products/mobile-first">Mobile First</a> &amp; <a href="http://www.abookapart.com/products/designing-for-emotion">Emotional Design</a></h3>
<p>These were probably the shortest two that I read, but both jam packed with some quite useful information. With Mobile First, some of it was already preaching to the converted, but the examples and approaches were useful to see.</p>
<p>Emotional Design, however, made me think. It’s about optimising designs for the way human emotions operate. And, it works very well.</p>
<p>Much of the book outlines case studies, some from Aarron’s work with MailChimp, and others from elsewhere. It does a very good job of making its case - something that I’ll think about in the future.</p>
<h3 id="a-phd-is-not-enough"><a href="http://www.amazon.co.uk/gp/product/0465022227/ref=as_li_ss_tl?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0465022227">A PhD is Not Enough</a></h3>
<p>I read this after spending a good chunk of time reading <a href="http://matt.might.net/">Matt Might</a>’s blog. It’s a book about academic careers and attempts to reveal exactly what that entails.</p>
<p>Like most books on the same subject, it’s US centric, but still valuable. If the thought of academic is on the horizon, I’d suggest you give it a read.</p>
<h3 id="the-passionate-programmer"><a href="http://www.amazon.co.uk/gp/product/1934356344/ref=as_li_ss_tl?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=1934356344">The Passionate Programmer</a></h3>
<p>This is about programming careers. I think it’s well targeted at those soon to be leaving University or in University studying something programming related.</p>
<p>I find what most people say on careers to be simply offensive, this is good.</p>
<p>A big pain point I see in people is seeing what they’re being taught at University to be the be-all and end-all of what they need to know to get a job. For some, this is obvious, but for others not so. The book makes a good point of suggesting that you firstly should be problem, not tool orientated, and that also you should be pushing out into other technologies. Especially new ones.</p>
<p>For the former, this means pushing far out of your comfort zone. Used to Java? Learn Ruby, or Objective-C. Or, even better go functional and learn something like Haskell. But, more important is to remember what you’re working on now is just the thing of the moment. If you keep that view, you can keep ploughing forward. And anyway, if you learn around your favourite technology and methodologies enough, you are still improving on the original one.</p>
<p>It is a little dry at times, and somewhat fear driven (there’s lots about the risk of having your job outsourced), but overall it’s a good book. It has some nice personal case studies, too.</p>
<h3 id="the-macintosh-way"><a href="http://en.wikipedia.org/wiki/The_Macintosh_Way">The Macintosh Way</a></h3>
<p>This wasn’t what I expected. It’s a book about applying the way the Macintosh was created to other companies. Some things are a little dated (it was published in 1990.)</p>
<p>It doesn’t contain a gushing history, but a a slightly rose tinted, but critical look at how the Macintosh was crafted (and maintained after Jobs left.)</p>
<p>The point of the book is how to apply this to other companies. Beware of the dating chapter. It’s painful.</p>
<h3 id="core-data-for-ios"><a href="http://www.amazon.co.uk/gp/product/0321670426/ref=as_li_ss_tl?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0321670426">Core Data for iOS</a></h3>
<p>This has got to be the first book that has made me enjoy dealing with data. Up until this point, I had avoided Core Data (it is a complex framework.) But, I got this as a Christmas Present.</p>
<p>For iOS, Core Data is essentially a wrapper and set of tools for dealing with SQLite. I’ve not finished reading it yet, but so far this has given a enjoyable discussion of the way Core Data works and how to go about using it. It has some nice tips on performance, too - especially important if you are handling large data sets.</p>
<p>The information is not limited to just iOS, either. Whilst this is the primary focus, it does cover enough if you are looking into the Mac, too.</p>
<hr />
<p>I did read a lot of other things, too (mostly catching up.) You can find those <a href="http://pinboard.in/u:nickcharlton">over on Pinboard</a>.</p>]]></summary>
</entry>
<entry>
    <title>Postgres on Lion</title>
    <link href="http://nickcharlton.net/posts/postgres-on-lion.html" />
    <id>http://nickcharlton.net/posts/postgres-on-lion.html</id>
    <published>2011-11-28T23:07:46Z</published>
    <updated>2011-11-28T23:07:46Z</updated>
    <summary type="html"><![CDATA[<p>I’ve recently been picking up <a href="http://www.postgresql.org/">PostgreSQL</a>. It’s very nice. Unfortunately, I had a few issues with it and Lion. Lion Server now uses Postgres as its default database (replacing MySQL), and consequently it looks like Apple included a bunch of tools in standard Lion, too.</p>
<p>Unfortunately, these clash a if you attempt to install and use the database daemon.</p>
<h2 id="install-configure">Install &amp; Configure</h2>
<p>To start with, install Postgres from <a href="http://mxcl.github.com/homebrew/">Homebrew</a>:</p>
<pre><code>brew install postgres</code></pre>
<p>Then (as told) initialise the database:</p>
<pre><code>initdb /usr/local/var/postgres</code></pre>
<p>But ignore the rest (as in, don’t add the LaunchAgent).</p>
<p>Next, it is necessary to adjust your <code>$PATH</code> slightly. On OS X, this is stored in <code>/etc/paths</code>. You need to push <code>/usr/local/bin</code> to be searched before <code>/usr/bin</code>. This will ensure that the homebrew compiled binaries are used instead of the system ones.</p>
<h2 id="control">Control</h2>
<p>The LaunchAgent step that was skipped is so that you can control Postgres yourself. If this is setup, it will interfere with the <code>pg_ctl</code> command. Usually, the LaunchAgent would be used to manage it all for you.</p>
<h3 id="startingstopping-postgres">Starting/Stopping Postgres</h3>
<pre><code>pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

pg_ctl -D /usr/local/var/postgres stop -s -m fast</code></pre>
<p>These commands will start and stop Postgres, respectively. The <code>-m fast</code> flag on the stop command ignores the presence of other clients as it goes down.</p>
<h3 id="aliases">Aliases</h3>
<p>As these are a little long, I have these aliased to <code>pgstart</code> and <code>pgstop</code>. <a href="https://github.com/nickcharlton/dotfiles/blob/master/_bash_aliases">Done like this</a>:</p>
<pre><code>export PGDATA=&#39;/usr/local/var/postgres&#39;
alias pgstart=&#39;pg_ctl -l $PGDATA/server.log start&#39;
alias pgstop=&#39;pg_ctl stop -m fast&#39;</code></pre>
<hr />
<p>So, there you go. That’s how to setup Postgres properly on Lion. My next challenge is to make libpq (the C library for Postgres) up and running.</p>]]></summary>
</entry>
<entry>
    <title>Drawing Primitives with Quartz</title>
    <link href="http://nickcharlton.net/posts/drawing-primitives-with-quartz.html" />
    <id>http://nickcharlton.net/posts/drawing-primitives-with-quartz.html</id>
    <published>2011-11-26T23:13:28Z</published>
    <updated>2011-11-26T23:13:28Z</updated>
    <summary type="html"><![CDATA[<p>I’ve always found drawing graphics complicated. Not that because maths is involved (that’s the good bit), but finding simple examples to work out what the hell is going on. Usually, the calls required are a little different, and required to ensure something actually gets drawn — Quartz is no different. This intends to serve as a few notes on using the basics of QuartzCore, the drawing tools present in iOS and on Mac OS X.</p>
<p>Most of the calls are just C, but the example (linked at the bottom) shows all of the examples drawn inside a UIView on iOS. The rest of this assume you know what I have just written, and what <code>CGRectMake()</code> does.</p>
<h2 id="requirements">Requirements</h2>
<p>You need to add the <code>QuartzCore</code> framework to your project in Xcode. Then you need to import the headers in relevant files. All that is required for the examples here is: <code>#import &lt;QuartzCore/QuartzCore.h&gt;</code>.</p>
<h2 id="a-bit-of-theory">A Bit of Theory</h2>
<p>Quartz works similar to a pen on paper, especially for lines and rectangles. Much like picking the right type of pen before making marks on paper, Quartz works in a similar way. Changing the attributes of lines (the pen) is done just before drawing. Drawings also layer in a similar manner. If you tell Quartz to draw over a point that you have already drawn on, it will be layered on top of it.</p>
<pre><code>// get the initial context
CGContextRef context = UIGraphicsGetCurrentContext();

// save the current state, as we&#39;ll overwrite this
CGContextSaveGState(context);

// draw stuff

// do the actual drawing
CGContextStrokePath(context);

// restore the state back after drawing on it.
CGContextRestoreGState(context);</code></pre>
<p>The rest of these examples assume the above. This gets the current drawing context (in this case, the UIView we are going to draw onto, but this could be almost anything, including a PDF). It saves the current state, as this is what we’ll be accessing.</p>
<p>After the drawing statements, we proceed to do the actual drawing, and then save it back to the context we were working with. This then renders the drawing on the relevant view.</p>
<h2 id="lines">Lines</h2>
<p>The simplest primitive to draw is a line. These (and arcs) make up the majority of work done with Quartz. It also fits the best within the real-world drawing metaphor.</p>
<p>First, you need to position the pen, then you can draw a line to the next coordinate:</p>
<pre><code>// move the pen to the starting point
CGContextMoveToPoint(context, 10, 10);

// draw a line to another point
CGContextAddLineToPoint(context, 290, 10);</code></pre>
<p>This starts at position 10, 10 and draws a line parallel to the top of the view to the other side. It looks like this:</p>
<div class="figure">
<img src="http://nickcharlton.net/resources/drawing-primitives/line.png" alt="A line drawn on a UIView" /><p class="caption">A line drawn on a UIView</p>
</div>
<p><strong>The pixels are relevant to the view they are created in.</strong> So, drawing to 100, 100 would draw a line at a 45° angle pointing down towards the middle of the view.</p>
<h2 id="styling">Styling</h2>
<ul>
<li>By default, a line is 1px thick. You can change this by setting the second parameter of: <code>CGContextSetLineWidth(context, 5)</code>.</li>
<li>To set the colour: <code>CGContextSetRGBStrokeColor(context, 1, 0, 0, 1);</code>. Where the numbers are RGBA values.</li>
<li>By default, the stroke straddles both sides of the line. If you’re positioning elements with a 5px stroke, you will want to offset the position by 2.5px.</li>
<li>Each call to <code>CGContextStrokePath(context);</code> commits the drawing to the canvas. If you want to set different styling for different elements, you need to commit it first. Then ‘pick up the pen’ with the next element.</li>
</ul>
<h2 id="rectangles">Rectangles</h2>
<p>For shapes, the position is based upon a CGRect. This makes it handy for colouring the position of elements if you are drawing/comparing more complex shapes. This also means that it doesn’t use the notion of a pen.</p>
<pre><code>CGContextAddRect(context, CGRectMake(10, 20, 280, 30));</code></pre>
<p>This would draw a rectangle just below the line, 30px high. Rectangles are rendered from their origin point (top left corner) and drawn out from there.</p>
<div class="figure">
<img src="http://nickcharlton.net/resources/drawing-primitives/box.png" alt="A box drawn on a UIView" /><p class="caption">A box drawn on a UIView</p>
</div>
<h2 id="circles">Circles</h2>
<p>Circles (also called arcs and ellipses) are more complicated. There are two ways to define a complete circle, and various other ways to define different types of arc — including Bézier curves. The snippet below just describes circles, however:</p>
<p>The simplest way to define a circle is placing one inside a <code>CGRect</code>. The circle will be drawn to fit the best it can inside the rectangle.</p>
<pre><code>CGContextAddEllipseInRect(context, CGRectMake(50, 70, 200, 200));</code></pre>
<p>This will draw a circle with 200px in diameter below the other elements.</p>
<div class="figure">
<img src="http://nickcharlton.net/resources/drawing-primitives/circle.png" alt="A circle drawn on a UIView" /><p class="caption">A circle drawn on a UIView</p>
</div>
<h2 id="memory-management">Memory Management</h2>
<p>Assuming you are not using ARC, the general rules apply from Core Foundation:</p>
<ul>
<li>If you call a function that has ‘Create’ or ‘Copy’ in the name, it’s yours.</li>
<li>If you get an object from elsewhere you don’t own it, unless you explicitly retain it.</li>
<li>And to release you should call <code>CFRelease</code>.</li>
</ul>
<h2 id="example-project">Example Project</h2>
<p>You can <a href="http://nickcharlton.net/resources/drawing-primitives/project.zip">download an example project here</a>. It contains the examples above, but put all into a single view. The object of importance is <code>PrimitivesView</code>. This provides the drawing, the rest is just a simple FlipSideViewController based project using Storyboards and ARC (for ease.) The <a href="http://github.com/nickcharlton/DrawingPrimitives">repository is also on GitHub</a>.</p>]]></summary>
</entry>
<entry>
    <title>"The Social Graph" &amp; Thoughts on Identity</title>
    <link href="http://nickcharlton.net/posts/the-social-graph-identity.html" />
    <id>http://nickcharlton.net/posts/the-social-graph-identity.html</id>
    <published>2011-11-09T18:58:50Z</published>
    <updated>2011-11-09T18:58:50Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://blog.pinboard.in/2011/11/the_social_graph_is_neither/">Maciej Ceglowski on “The Social Graph is Neither”</a>…</p>
<blockquote>
<p>“Asking computer nerds to design social software is a little bit like hiring a Mormon bartender. Our industry abounds in people for whom social interaction has always been more of a puzzle to be reverse-engineered than a good time to be had, and the result is these vaguely Martian protocols.”</p>
</blockquote>
<p>Attempting to apply a graph to people works in the first instance. But, whilst we are all connected, we are connected to each other in mind bogglingly different ways. And, people care about that.</p>
<blockquote>
<p>“Social networks exist to sell you crap. The icky feeling you get when your friend starts to talk to you about Amway, or when you spot someone passing out business cards at a birthday party, is the entire driving force behind a site like Facebook.”</p>
</blockquote>
<p>And:</p>
<blockquote>
<p>“Now tell me one bit of original culture that’s ever come out of Facebook.”</p>
</blockquote>
<p>Facebook and Google+ are passing phases. Hopefully the end of this phase will hurry up. Pictures of kittens might get tedious, but I can’t imagine a web without them. And anyway, <a href="http://zachholman.com/posts/shit-work/">“Liking” is “shit work”.</a>.</p>
<hr />
<p>To me, a more important problem to solve is that of identity. A lot of <a href="http://factoryjoe.com/blog/">smart</a> <a href="http://davidrecordon.com/">people</a> were working on things like <a href="http://openid.net">OpenID</a> (and then they went to work for Google &amp; Facebook. <em>sigh</em>.) Whilst I think OpenID had its flaws, every design can be iterated on. The growth of “Sign in with [Twitter/Facebook/Google/etc.]” makes me sad.</p>
<p>I talked about this briefly at the weekend with <a href="http://bma.li">Ben</a>. We didn’t come to much of a solution, other than thinking that something like ssh-agent might work.</p>
<p>As humans, we are too ready and willing to give up the one thing we truly defines us: Our Identity.</p>]]></summary>
</entry>
<entry>
    <title>Introducing UrbanScraper, and an Alfred Extension</title>
    <link href="http://nickcharlton.net/posts/introducing-urbanscraper.html" />
    <id>http://nickcharlton.net/posts/introducing-urbanscraper.html</id>
    <published>2011-10-28T23:46:48Z</published>
    <updated>2011-10-28T23:46:48Z</updated>
    <summary type="html"><![CDATA[<p>Over the last two evenings, I’ve been working on a little toy. Well, two. The first one is a web service for getting definitions from <a href="http://urbandictionary.com">Urban Dictionary</a> and the other is an Alfred Extension to allow you to get those definitions using your keyboard.</p>
<h2 id="urbanscraper"><a href="http://urbanscraper.herokuapp.com/">UrbanScraper</a></h2>
<p>It lead from a conversation with someone where I ended up having to reference some stuff a few times, I have a terrible memory for abbreviations and acronyms. I wanted to be able to find the definitions using Alfred, but Urban Dictionary didn’t have an API.</p>
<p>Apparently, there used to be an API (albeit, SOAP), and there appeared to be other stuff around, but I figured I’d take a hack at it myself.</p>
<p>UrbanScraper scrapes the definitions (on demand) from Urban Dictionary and outputs simple JSON for you to use. It mostly uses XPath.</p>
<p>It’s not exactly speedy (XPath isn’t terribly fast), but it does the job with very little code. I’ve put it up on <a href="http://github.com/nickcharlton/urbanscraper">GitHub</a>. For the time being, it’s hosted up on Heroku.</p>
<p><em>For the love of god, please don’t use this as an example of how to build Sinatra/Ruby apps, how to do Screen Scraping, or how to build RESTful Web Services. It was hacked together pretty quickly.</em></p>
<h2 id="the-alfred-extension">The Alfred Extension</h2>
<p><a href="/resources/urban_dictionary.alfredextension">You can download the extension here</a>. Obviously, you’ll need <a href="http://alfredapp.com">Alfred</a> and the <a href="http://www.alfredapp.com/powerpack/">Powerpack</a> to use it. But damn, is it worth it.</p>
<p>It’s setup with the keyword <code>urban</code>. Passing something like “zomg” will give you a Growl notification containing: “zOMG is a variant of the all-to-popular acronym”OMG“, meaning”Oh My God“. The”z&quot; was originally a mistake while attempting to hit the shift…&quot;.</p>
<p>It (like UrbanScraper), just grabs the first result. So it might not always be very good.</p>
<p><a href="/about">Shout</a> if anything breaks.</p>]]></summary>
</entry>
<entry>
    <title>Jacks: A place to start web projects</title>
    <link href="http://nickcharlton.net/posts/jacks-a-place-to-start-web-projects.html" />
    <id>http://nickcharlton.net/posts/jacks-a-place-to-start-web-projects.html</id>
    <published>2011-10-22T21:37:54Z</published>
    <updated>2011-10-22T21:37:54Z</updated>
    <summary type="html"><![CDATA[<p>A couple of weeks ago, I started a project which intended to pull together all of the stuff that I had learnt about responsive design. I also wanted to have a generic starting point for web projects. I came up with Jacks, a simple web “framework” which does exactly that.</p>
<h3 id="being-responsive">Being Responsive</h3>
<p>Responsive Design is all about providing one singular web experience that is optimal for many different devices. With the growth of what some call the “mobile web”, you’ve probably come across some horrible web experiences.</p>
<p>I believe that we should present an optimal experience for as many browsers, in as many situations, as possible.</p>
<p>Jacks uses a fluid grid which is tamed with the use of media queries. It’s very much based around the work done by <a href="http://unstoppablerobotninja.com/">Ethan Marcotte</a>, in his book, “<a href="http://www.abookapart.com/products/responsive-web-design">Responsive Web Design</a>”. If you’re interested in this at all, I urge you to go ahead and read it. It does a much better explanation than I could ever aim to do.</p>
<h3 id="jacks-gives">Jacks Gives</h3>
<p>So, what does this actually do? Jacks provides you a bunch of presets to work off of.</p>
<p>These presets include:</p>
<ul>
<li>Some default libraries:
<ul>
<li>Eric Meyer’s CSS Reset</li>
<li>jQuery</li>
<li>LESS CSS</li>
</ul></li>
<li>An example HTML page to start off with.</li>
<li>Some basic CSS styles for:
<ul>
<li>Typography</li>
<li>Colours</li>
<li>Common Effects (shadows, rounded corners, etc)</li>
<li>Flexible Media Blocks (aka, max-width: 100%)</li>
<li>Media Queries for common display sizes.</li>
</ul></li>
</ul>
<p>It uses <a href="http://lesscss.org/">LESS</a> to make CSS easier and more maintainable.</p>
<p>Jacks uses media queries to tame the fluid grid. The default layout is assumed to be approximately 960px (which you’ve probably already been doing), then it provides increasingly smaller steps until a much larger block for handling large browser windows (&gt;1200px).</p>
<p>I call this the upside-down triangle on a shelf method. I find it works quite well.</p>
<h3 id="github"><a href="http://github.com/nickcharlton/jacks">GitHub</a></h3>
<p>Like most of my projects, <a href="http://github.com/nickcharlton/jacks">it’s up on GitHub</a>. It’s licensed under the MIT license. I intend to improve and adjust this as I go.</p>
<p>I encourage you to fork and add your own changes. Do a pull request if you want it to be pushed up into the main repository.</p>
<p>It’s been used in one production project so far. I’d certainly be interested in hearing if it’s used elsewhere!</p>]]></summary>
</entry>
<entry>
    <title>Configuring Gitosis on Debian</title>
    <link href="http://nickcharlton.net/posts/configuring-gitosis-on-debian.html" />
    <id>http://nickcharlton.net/posts/configuring-gitosis-on-debian.html</id>
    <published>2011-09-21T22:45:32Z</published>
    <updated>2011-09-21T22:45:32Z</updated>
    <summary type="html"><![CDATA[<p>Gitosis is a tool for easing the hosting of Git repositories. For pushing to remote [servers], Git uses SSH. Which is great. But, what if you don’t want those users to have shell accounts, and you want to be able to control who has access to repositories? Well, that’s what Gitosis does.</p>
<p>Gitosis is in Debian’s package manager, but I wasn’t too keen on the Debian provided configuration, so here’s a few steps to sanitise it:</p>
<p>First, install it. You’ll obviously need the dependencies.</p>
<pre><code>$ sudo apt-get install gitosis</code></pre>
<p>Next, we’ll change a few settings. You might find the documentation useful for this, you’ll find that under: <code>/usr/share/doc/gitosis</code>.</p>
<p>Gitosis stores is config in a Git repository. This also means that it doesn’t have a configuration until you initialise it. Now, I’d rather use <code>git</code> as the user rather than <code>gitosis</code>. So first, create a new user:</p>
<pre><code>$ sudo adduser \
    --system \
    --shell /bin/sh \
    --gecos &#39;Git&#39; \
    --group \
    --disabled-password \
    --home /home/git \
    git</code></pre>
<p>You can also remove the gitosis user: <code>sudo userdel gitosis</code>.</p>
<p>Next, you’ll need your public key somewhere. Then, setup the admin repository:</p>
<pre><code>$ sudo -H -u git gitosis-init &lt; &lt;path to your public key&gt;</code></pre>
<p>Now, on your local machine, you can pull down the newly initialised Gitosis admin repository.</p>
<pre><code>$ git clone git@server:gitosis-admin.git</code></pre>
<p>The <code>gitosis-admin</code> directory contains the main config file (<code>gitosis.conf</code>) and the public keys of all of the users able to access repositories.</p>
<p>A few notes:</p>
<ul>
<li>The members line in the config file needs to match up with a user in <code>keydir</code>. But without the .pub extension.</li>
<li>Groups are used to split up users and/or projects. You define a group, which holds a repository and the users with that permission.</li>
<li>You can set read/write or read only privileges on groups. But, you’ll need to create a new group to define the different privileges for different users.</li>
<li>Members are separated by spaces.</li>
<li>A group can also be used to define members, which then can be assigned to another group. (You access the members as a variable by prefixing @).</li>
<li>When you define a repository in Gitosis, it will be created on the server when you push it.</li>
</ul>
<p>You’ll find <a href="http://progit.org/book/ch4-7.html">Pro Git probably gives you a better explanation of some of the other features</a>. But you should (after this) be able to setup Gitosis on Debian quite nicely.</p>]]></summary>
</entry>
<entry>
    <title>I forked QuickDialog</title>
    <link href="http://nickcharlton.net/posts/i-forked-quickdialog.html" />
    <id>http://nickcharlton.net/posts/i-forked-quickdialog.html</id>
    <published>2011-09-19T18:58:04Z</published>
    <updated>2011-09-19T18:58:04Z</updated>
    <summary type="html"><![CDATA[<p>A couple of weeks ago, <a href="http://escoz.com/">Eduardo Scoz (ESCOZ, Inc)</a> released <a href="http://escoz.com/quickdialog-released/">QuickDialog</a>, a rather nice way of producing UITableView based dialog controls on iOS.</p>
<p>In my own projects, and some of those I’ve been working on <a href="http://nickcharlton.net/post/starting-at-rokk-media">at work</a>, I’ve wanted to be able to use QuickDialog to make development faster. Unfortunately, it requires Automatic Reference Counting, and I usually work on the current stable version of iOS.</p>
<p>Whilst I do think ARC is a good thing, I wanted to use QuickDialog now. So, I forked it and adjusted it where needed to make it compile under iOS 4.3 and the Xcode 4.1 toolchain without errors.</p>
<p>It’s not completely tested and I don’t intend to closely track the original branch, nor actively maintain it once iOS 5 is released. But, it’s there and working if you want it.</p>
<p><em>Note: In the future, I intend to push changes back into the original QuickDialog (especially when I find I want different controls.)</em></p>
<p><a href="https://github.com/nickcharlton/QuickDialog/">You can get it over on GitHub</a>.</p>]]></summary>
</entry>
<entry>
    <title>Where's Next? 1.0.1 Release</title>
    <link href="http://nickcharlton.net/posts/wheres-next-101-release.html" />
    <id>http://nickcharlton.net/posts/wheres-next-101-release.html</id>
    <published>2011-08-18T21:03:58Z</published>
    <updated>2011-08-18T21:03:58Z</updated>
    <summary type="html"><![CDATA[<p>After a bit of an issue with the original launch, <em>Where’s Next?</em> 1.0.1 has now been approved and is <a href="http://itunes.apple.com/gb/app/wheres-next/id454450198?mt=8">in the App Store</a>.</p>
<p>This fixes the crashing on load bug which ended up falling through testing (if you saw it, you’d have thought I didn’t test it, but I did, but obviously not well enough).</p>
<p>For the those who are interested, it was a pointer to integer comparison that caused the problem. Oddly, it was not caught by GCC/LLVM. Unfortunately, that’s one of the disadvantages of an unmanaged memory model.</p>
<p>But anyway. I’m pleased it is finally in the store.</p>]]></summary>
</entry>
<entry>
    <title>Where's Next? Now In the App Store.</title>
    <link href="http://nickcharlton.net/posts/wheres-next-now-in-the-app-store.html" />
    <id>http://nickcharlton.net/posts/wheres-next-now-in-the-app-store.html</id>
    <published>2011-08-12T05:38:29Z</published>
    <updated>2011-08-12T05:38:29Z</updated>
    <summary type="html"><![CDATA[<p>After many, many months of development, my first iOS project is now in the App Store. It’s a utility app for sorting places into the most efficient way to get there, from the site:</p>
<blockquote>
<em>Where’s Next?</em> takes the places you need to visit and according to where you are now tells you the quickest way to visit them.
</blockquote>

<p>I’ve spent the last month or two slowly polishing off and fixing bugs on the project I started before the start of this year with the intent of learning iOS development.</p>
<p>I could have released (and “finished”) it a long time ago, but being a perfectionist, it had to be right before I submitted it. With it’s limited feature set, I now think it is ready for release. It’s said that you should be embarrassed with your 1.0 and I am. It only implements the core idea, but this means that there are many possibilities for the future.</p>
<p>With all projects, this wouldn’t have happened without those who I leaned on:</p>
<ul>
<li>Without <a href="http://www.plymouth.ac.uk/staff/noutram">Dr Nick Outram</a>’s iPhone Programming Course, I’d probably still be trying to master Cocoa and not releasing my own apps and <a href="http://nickcharlton.net/post/starting-at-rokk-media">having a job doing it</a>.</li>
<li>The icon was produced by <a href="http://ulrikstoch.com/">Ulrik Stoch Jensen</a>, a young icon designer from Denmark who I found through Dribbble. He’s fantastic to work with and even put up with my backseat designing.</li>
<li>Those who helped test: <a href="http://thisisthechris.co.uk/">Chris Hunt</a>, <a href="http://manateegames.co.uk/">Luke Davies</a> and <a href="http://georgiejabbers.com/">Georgie Aggett</a> and provided valuable feedback.</li>
<li>Those on <a href="http://forrst.com/posts/Little_project_Ive_been_working_on-sYT">Forrst</a> who provided me some confidence in the site design.</li>
<li>and many others who I’ve spent hours and hours talking to about it.</li>
</ul>
<p>Thanks guys, you’re awesome.</p>
<p>You can you <a href="http://wheresnextapp.com/">read more at the App’s website here</a>. Or <a href="http://itunes.apple.com/gb/app/wheres-next/id454450198?mt=8">go directly to iTunes</a>.</p>
<p>If you like it, please mention it to others, it’d be greatly appreciated!</p>]]></summary>
</entry>
<entry>
    <title>Starting at Rokk Media</title>
    <link href="http://nickcharlton.net/posts/starting-at-rokk-media.html" />
    <id>http://nickcharlton.net/posts/starting-at-rokk-media.html</id>
    <published>2011-07-26T16:19:07Z</published>
    <updated>2011-07-26T16:19:07Z</updated>
    <summary type="html"><![CDATA[<p>Today marks the start of the second week of my placement (actually, the second day of the second week); doing iOS Development at Rokk Media on the outskirts of Exeter.</p>
<p>My first week has been rather good. The focus so far has been figuring out a few things in iOS on some projects which I hadn’t yet come across (including some sensor stuff and 2D game programming, which is rather interesting). I’ve also pitched in with a couple of web projects.</p>
<p>I’m currently commuting from Plymouth (via Newton Abbot and then onto Exeter St. Thomas) to the office each day. Whilst it does work, it’s unfortunately quite exhausting, so the intention is to move to Exeter in the next few weeks (any tips would be awesome!).</p>
<p>So far, all is going well. They’re a great bunch of people to work for, so it looks like I’m about to have a pretty good placement year.</p>]]></summary>
</entry>
<entry>
    <title>Thoughts on the UoP Intellectual Property Agreement</title>
    <link href="http://nickcharlton.net/posts/thoughts-on-the-uop-intellectual-property-agreement.html" />
    <id>http://nickcharlton.net/posts/thoughts-on-the-uop-intellectual-property-agreement.html</id>
    <published>2011-06-13T16:12:24Z</published>
    <updated>2011-06-13T16:12:24Z</updated>
    <summary type="html"><![CDATA[<p>Today, the <a href="http://www.plymouth.ac.uk/pages/view.asp?page=36193">University announced that they had entered into an Intellectual Property agreement</a>. For 10 years. I think this is a terrible idea.</p>
<h2 id="good">Good</h2>
<ul>
<li>The University could become a leader in “<a href="https://twitter.com/danbjorn/status/80291278654423041">actual, real, commercial products</a>”.</li>
<li>In turn, the University could have more income streams, which could put fees down, or improve resources.</li>
</ul>
<h2 id="bad">Bad</h2>
<ul>
<li>Unprofitable but valuable research could be scrapped.</li>
<li>The focus for new research projects could be towards quick profits and not long term innovation. So, frivolous, but profitable research could become the mainstay of research groups.</li>
<li>Potential to take the very best of the Universities’ lecturers away from teaching and out into external ventures.</li>
<li>Potential to remove the option for students in accessing the research groups for final year, or Masters projects.</li>
<li>By pushing the IP out into other ventures, the University will no longer be able to take direct credit for the achievements of various projects.</li>
<li>The research groups of the University can be a pulling force for new students, by pushing out the interests might stop that happening.</li>
</ul>
<p>It looks like we’re stuck with it. But let’s hope it’s not contagious. The sight of a country of profit driven research feels pretty grim, to me. On top of that, let’s hope the good points come to be true, rather than the possible downsides. That will come in the future.</p>]]></summary>
</entry>
<entry>
    <title>Digital Peninsula Unconference III, Falmouth</title>
    <link href="http://nickcharlton.net/posts/digital-peninsula-unconference-iii-falmouth.html" />
    <id>http://nickcharlton.net/posts/digital-peninsula-unconference-iii-falmouth.html</id>
    <published>2011-06-12T19:14:35Z</published>
    <updated>2011-06-12T19:14:35Z</updated>
    <summary type="html"><![CDATA[<p>Yesterday was the third iteration of the Digital Peninsula Unconference, at <a href="http://www.falmouth.ac.uk/">University College Falmouth, Tremough</a>.</p>
<p>Once again, it was a great event, with a panel/session on Agile methodologies, a focus on two possible projects (website and store), and once again a set of lightening talks by various people. Then there was a BBQ down on the beach (though, I didn’t go to that bit.)</p>
<p>I also took photos this time. The lighting was much better at this venue than in <a href="http://nickcharlton.net/post/digital-peninsula-unconference-ii-exeter">Exeter</a>, but there still was a lot of blurry shots. They certainly could have been better (shooting these things with a 50mm is quite an impractical pain…), but I’m not too displeased with them.</p>
<p>Anyway; <a href="http://www.flickr.com/photos/nickcharlton/sets/72157626820736307/">you can find them here on Flickr</a>, as always.</p>]]></summary>
</entry>
<entry>
    <title>Digital Peninsula Unconference II, Exeter</title>
    <link href="http://nickcharlton.net/posts/digital-peninsula-unconference-ii-exeter.html" />
    <id>http://nickcharlton.net/posts/digital-peninsula-unconference-ii-exeter.html</id>
    <published>2011-05-15T21:02:39Z</published>
    <updated>2011-05-15T21:02:39Z</updated>
    <summary type="html"><![CDATA[<p>On Saturday, the second version of the <a href="http://lanyrd.com/2011/digpenII/">Digital Peninsula Unconference</a> was hosted in Exeter, at the Phoenix. After being <a href="http://twitter.com/#!/teddilybear/status/68722214702301185">volunteered to take some photographs</a>, I spent much of the event running about taking them (that’s the flaw in having only a 50mm lens available to you). I’ve posted them on Flickr, but below are a few of the ones I liked best.</p>
<p>The conference overall was pretty good, although it did feel like some of the people were pitching a little bit too much. Given the mostly technical community, it would be nice to hear more about the decisions made behind projects - stuff that’s useful to all.</p>
<figure>
<a href="http://www.flickr.com/photos/nickcharlton/5722585712/" title="On Stage Tech Support by nickcharlton, on Flickr"><img src="http://farm3.static.flickr.com/2091/5722585712_953fd4b22c.jpg" width="500" height="334" alt="On Stage Tech Support"></a> <figcaption>A little bit of on stage tech support.</figcaption>
</figure>

<figure>
<a href="http://www.flickr.com/photos/nickcharlton/5722002007/" title="The Waving Crowd by nickcharlton, on Flickr"><img src="http://farm3.static.flickr.com/2412/5722002007_1054243cfc.jpg" width="334" height="500" alt="The Waving Crowd"></a> <figcaption>The Waving Crowd</figcaption>
</figure>

<p><a href="http://www.flickr.com/photos/nickcharlton/sets/72157626728344858/">You can see the rest of the images here on Flickr.</a></p>
<p>All of these were shot on a Canon 400D, with a 50mm lens. They were shot at ISO1600. It was quite a dark room, so many of the shots taken didn’t work out too well. In other news, if <a href="http://nickcharlton.net/contact">someone wants me to build something for them</a>, I could probably get a better lens.</p>]]></summary>
</entry>
<entry>
    <title>Building Custom Android ListViews</title>
    <link href="http://nickcharlton.net/posts/building-custom-android-listviews.html" />
    <id>http://nickcharlton.net/posts/building-custom-android-listviews.html</id>
    <published>2011-05-11T18:20:14Z</published>
    <updated>2011-05-11T18:20:14Z</updated>
    <summary type="html"><![CDATA[<p>The documentation for Android’s <code>ListView</code>’s is a little sparse. The examples around on the web are also not too great. This article intends to be the one I was searching for in trying to understand how to display some more advanced data, and deal with events.</p>
<h2 id="introduction">Introduction</h2>
<p><code>ListView</code>’s are the solution to most data problems on Android (much like <code>UITableView</code> is used extensively in iOS). However, they are a little undocumented. The rest of this article should allow you to go from having a basic <code>ListView</code>, to one much more complex and useful.</p>
<h3 id="the-project">The Project</h3>
<p>This is implemented using Android 2.2, but it will work with more recent versions. These are the project settings used:</p>
<pre><code>Project name: HelloListView
Build target: Android 2.2
Application name: CustomListViews
Package name: org.example.hellolistview
Create Activity: HelloListView
Min SDK Version: 8</code></pre>
<h3 id="prerequisites">Prerequisites</h3>
<p>Firstly, I assume you have tried building a basic <code>ListView</code> (<a href="http://developer.android.com/resources/tutorials/views/hello-listview.html">This tutorial is good for that</a>). Secondly, I assume your data source is an <code>ArrayList</code>, containing objects for each element of data.</p>
<p>Once you have followed the basics of this guide, you will find that you can use the latter sections as you wish.</p>
<p>At 2010’s Google IO, there was an hour long session which talked about <code>ListView</code>’s extensively, you may wish to watch that first. <a href="http://www.google.com/events/io/2010/sessions/world-of-listview-android.html">You’ll find it here</a>.</p>
<h2 id="building-the-foundations">Building the Foundations</h2>
<p>This starts with building a basic view which is backed onto an <code>ArrayList</code>. You can expand on the complexity from here.</p>
<h3 id="extending-listactivity">Extending ListActivity</h3>
<p>The first step is to subclass <code>ListActivity</code> instead of <code>Activity</code>. This provides us with some functionality specific to lists. Of note, if we have no data we can easily provide an alternative.</p>
<pre><code>public class HelloListView extends ListActivity {
    // ....
}</code></pre>
<h3 id="the-view-xml-main.xml-list_item.xml">The View XML (main.xml, list_item.xml)</h3>
<h4 id="main.xml">main.xml</h4>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;

&lt;LinearLayout 
	xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;&gt;

    &lt;ListView 
    	android:id=&quot;@android:id/list&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot; /&gt;

    &lt;TextView
    	android:id=&quot;@android:id/empty&quot;
    	android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/empty&quot; /&gt;
&lt;/LinearLayout&gt;</code></pre>
<p>This defines the main view. It contains a layout which fills the screen, which in turn contains two subviews. The <code>ListView</code> defines the view, and the <code>TextView</code> is the backup which is called by <code>ListActivity</code> when there is no data to display.</p>
<h4 id="list_item.xml">list_item.xml</h4>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;

&lt;LinearLayout 
	xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
	android:layout_width=&quot;wrap_content&quot; 
	android:layout_height=&quot;wrap_content&quot; 
	android:background=&quot;#000000&quot;&gt;
	&lt;TextView 
		android:layout_width=&quot;wrap_content&quot;
		android:layout_height=&quot;wrap_content&quot; 
		android:id=&quot;@+id/text&quot;&gt;
	&lt;/TextView&gt;
&lt;/LinearLayout&gt;</code></pre>
<p>This defines a very basic view. A screenshot is shown below. You do need to provide <code>android:layout_width</code> and <code>android:layout_height</code> declarations for each, otherwise it will not render.</p>
<figure>
<img src="/resources/android-list-views/listview_foundations.png" alt="ListView Basics"> <figcaption>ListView Basics</figcaption>
</figure>

<h3 id="data-source-and-adapter">Data Source and Adapter</h3>
<p>To display what is shown in the screenshot above, the following code is used. It’s not necessarily the most concise, but you should find it simple to follow.</p>
<h4 id="hellolistview.java">HelloListView.java</h4>
<pre><code>public class HelloListView extends ListActivity {
	// define the data source
	private ArrayList&lt;String&gt; data;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // setup the data source
        this.data = new ArrayList&lt;String&gt;();

        // add some objects into the array list
        this.data.add(&quot;List Item 1&quot;);
        this.data.add(&quot;List Item 2&quot;);
        this.data.add(&quot;List Item 3&quot;);

        // use main.xml for the layout
        setContentView(R.layout.main);

        // setup the data adaptor
        ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.list_item, R.id.text, this.data);

        // specify the list adaptor
        setListAdapter(adapter);
    }
}</code></pre>
<p>Here, we are creating the <code>ArrayList</code> holding our data set. Then we are adding the three elements we wish to display.</p>
<p>After this, we are setting up the <code>ArrayAdapter</code> to bridge the <code>ListView</code> to the dataset, and the specific item in the list.</p>
<p>The <code>ArrayAdaptor</code> translates the objects given to it (the last parameter) using a <code>.toString()</code>. This places the value inside the element with id <code>@+id/text</code> inside the <code>list_item.xml</code> file.</p>
<h2 id="displaying-custom-objects">Displaying Custom Objects</h2>
<p>For the rest of this article, the <code>ListItem</code> class is going to be used to display inside the <code>ListView</code>. This contains two members, title and subtitle. This is enough to show off using a custom adaptor.</p>
<h3 id="listitem.java">ListItem.java</h3>
<pre><code>/*
* Defines a simple object to be displayed in a list view.
*/
package org.example.HelloListView;

public class ListItem {
	public String title;
	public String subTitle;

	// default constructor
	public ListItem() {
		this(&quot;Title&quot;, &quot;Subtitle&quot;);
	}

	// main constructor
	public ListItem(String title, String subTitle) {
		super();
		this.title = title;
		this.subTitle = subTitle;
	}

	// String representation
	public String toString() {
		return this.title + &quot; : &quot; + this.subTitle;
	}
}</code></pre>
<p>There are also a few changes to be made to the rest of the project to get this to work.</p>
<h3 id="hellolistview.java-1">HelloListView.java</h3>
<pre><code>// setup the data source
this.data = new ArrayList&lt;ListItem&gt;();

// add some objects into the array list
ListItem item = new ListItem(&quot;Hello&quot;, &quot;Nick&quot;);
this.data.add(item);</code></pre>
<p>You will also need to change any references to <code>ArrayList&lt;String&gt;</code> to <code>ArrayList&lt;ListItem&gt;</code>.</p>
<p>By default, this will still display in the current incarnation. This is because we’re simply outputting a string representation of the object. To display more complex information, the <a href="http://developer.android.com/reference/android/widget/SimpleAdapter.html">SimpleAdaptor class</a> can render checkable objects (like a <code>CheckBox</code>), Strings and Images. Anything more complicated would require building a custom data adaptor.</p>
<figure>
<img src="/resources/android-list-views/listview_custom_object.png" alt="ListView Custom Object"> <figcaption>ListView Custom Object</figcaption>
</figure>

<h2 id="complex-listviews-with-simpleadapter">Complex ListViews with SimpleAdapter</h2>
<p>SimpleAdapter can be used for building more complex <code>ListViews</code>. Compared to the <code>ArrayAdapter</code> class, SimpleAdaptor takes a few more arguments to map more data to more views.</p>
<p>Unfortunately, SimpleAdapter requires a collection of Maps to define the data. There are two ways to put together the objects wanted, the first is to create all new objects, and the second is to build a simple wrapper around Map on our original <code>ListItem</code> class. The former is shown below:</p>
<h3 id="creating-new-objects">Creating new Objects</h3>
<h4 id="hellolistview.java-2">HelloListView.java</h4>
<pre><code>public class HelloListView extends ListActivity {
	// define the data source
	private ArrayList&lt;Map&gt; data;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // setup the data source
        this.data = new ArrayList&lt;Map&gt;();

        // add some objects into the array list
        Map m = new HashMap();
        m.put(&quot;title&quot;, &quot;Hello&quot;);
        m.put(&quot;subtitle&quot;, &quot;Nick&quot;);

        this.data.add(m);

        // use main.xml for the layout
        setContentView(R.layout.main);

        // setup the data adaptor
        String[] from = {&quot;title&quot;, &quot;subtitle&quot;};
        int[] to = {R.id.title, R.id.subtitle};
        SimpleAdapter adapter = new SimpleAdapter(this, (List&lt;? extends Map&lt;String, ?&gt;&gt;) this.data, R.layout.list_item, from, to);

        // specify the list adaptor
        setListAdapter(adapter);
    }
}</code></pre>
<h4 id="list_item.xml-1">list_item.xml</h4>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;

&lt;LinearLayout 
	xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
	android:layout_width=&quot;wrap_content&quot; 
	android:layout_height=&quot;wrap_content&quot; 
	android:background=&quot;#000000&quot;&gt;

	&lt;TextView 
		android:layout_width=&quot;wrap_content&quot;
		android:layout_height=&quot;wrap_content&quot; 
		android:id=&quot;@+id/title&quot;&gt;
	&lt;/TextView&gt;

	&lt;TextView 
		android:layout_width=&quot;wrap_content&quot;
		android:layout_height=&quot;wrap_content&quot; 
		android:id=&quot;@+id/subtitle&quot;&gt;
	&lt;/TextView&gt;

&lt;/LinearLayout&gt;</code></pre>
<p>Here, we are creating a new object (which is a Map), and placing this into our collection. This is then passed into <code>SimpleAdapter</code>.</p>
<h3 id="extending-map">Extending Map</h3>
<p>By extending Map, we can adjust our <code>ListItem</code> class to appear to be a Map. Here, we will use the members of the class as the key, and their values, as the values.</p>
<h4 id="listitem.java-1">ListItem.java</h4>
<pre><code>public class ListItem implements Map&lt;String, String&gt; {
	public String title;
	public String subTitle;

	// default constructor
	public ListItem() {
		this(&quot;Title&quot;, &quot;Subtitle&quot;);
	}

	// main constructor
	public ListItem(String title, String subTitle) {
		super();
		this.title = title;
		this.subTitle = subTitle;
	}

	// String representation
	public String toString() {
		return this.title + &quot; : &quot; + this.subTitle;
	}

	// Map interface classes

	// return a count of our members
	public int size() {
		return 2;
	}

	// set the values of the object to null
	public void clear() {
		this.title = null;
		this.subTitle = null;
	}

	// return all of the values as a collection
	public ArrayList&lt;String&gt; values() {
		ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();

		list.add(title);
		list.add(subTitle);

		return list;
	}

	// if the values of the members are null, return true
	public boolean isEmpty() {
		if ((this.title == null) &amp;&amp; (this.subTitle == null)) {
			return true;
		} else {
			return false;
		}
	}

	// return a set of the members
	public Set&lt;String&gt; keySet() {
		Set&lt;String&gt; s = new HashSet&lt;String&gt;();

		s.add(&quot;title&quot;);
		s.add(&quot;subTitle&quot;);

		return s;
	}

	// return a set of the member values
	public Set entrySet() {
		Set&lt;String&gt; s = new HashSet&lt;String&gt;();

		s.add(this.title);
		s.add(this.subTitle);

		return s;
	}

	// return the value of the given key
	public String get(Object key) {
		if (key.equals(&quot;title&quot;)) {
			return this.title;
		}
		if (key.equals(&quot;subTitle&quot;)) {
			return this.subTitle;
		}
		// if we can&#39;t return a value, throw the exception
		throw new ClassCastException();
	}

	// set the value of a given key
	public String put(String key, String value) {
		if (key.equals(&quot;title&quot;)) {
			this.title = value;
		}
		if (key.equals(&quot;subTitle&quot;)) {
			this.subTitle = value;
		}
		return value;
	}

	// remove a key (nullify)
	public String remove(Object key) {
		String value = null;
		if (key.equals(&quot;title&quot;)) {
			value = this.title;
			this.title = null;
		}
		if (key.equals(&quot;subTitle&quot;)) {
			value = this.subTitle;
			this.subTitle = null;
		}
		return value;
	}

	// return boolean if we have a member
	public boolean containsKey(Object key) {
		if (key.equals(&quot;title&quot;)) {
			return true;
		}
		if (key.equals(&quot;subTitle&quot;)) {
			return true;
		}
		return false;
	}

	// return boolean if we have a member&#39;s value
	public boolean containsValue(Object value) {
		if (value.equals(this.title)) {
			return true;
		}
		if (value.equals(this.subTitle)) {
			return true;
		}
		return false;
	}

	// set the values of this map to that of another
	public void putAll(Map&lt;? extends String, ? extends String&gt; arg0) {
		// we only need the stub.
	}

}</code></pre>
<p>This implements all of the methods required by the <a href="http://download.oracle.com/javase/6/docs/api/java/util/Map.html">Map interface</a>. You may not need all of them to support SimpleAdapter. I’d suggest subclassing the class above, and making this abstract. Then you can implement just what you need.</p>
<p>In <code>HelloListView.java</code>, the original object, then map declarations can then be replaced with:</p>
<pre><code>// add some objects into the array list
ListItem item = new ListItem(&quot;Hello&quot;, &quot;Nick&quot;);

this.data.add(item);</code></pre>
<p>The view will then look like the previous screenshot.</p>
<h2 id="creating-a-custom-data-adaptor">Creating a Custom Data Adaptor</h2>
<p><code>ArrayAdapter</code> provides a simple way to add an array of strings to a <code>ListView</code>. <code>SimpleAdapter</code> provides a way to specify a more complex object (mostly containing strings) and place those into a <code>ListView</code>.</p>
<p>However, if you want to do anything more complicated you need to roll your own Adaptor. The Data Adaptor provides the link between the data and the View. It implements the methods of <code>BaseAdapter</code> to provide what is needed by the <code>ListView</code>. Here, we are assuming that you wish to stick with XML for layout (it’s the suggested way). If you wish to do it just in code, <a href="http://www.anddev.org/novice-tutorials-f8/checkbox-text-list-extension-of-iconified-text-tutorial-t771.html">here’s an example</a>.</p>
<p><em>For this section, we are starting again with the basic list view implemented earlier.</em></p>
<h3 id="hellolistview.java-3">HelloListView.java</h3>
<pre><code>public class HelloListView extends ListActivity {
	private ArrayList&lt;ListItem&gt; data;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // setup the data source
        this.data = new ArrayList&lt;ListItem&gt;();

        // create some objects
        ListItem item1 = new ListItem(&quot;Title&quot;, &quot;Subtitle&quot;);

        // add them into the array list
        this.data.add(item1);

        // use main.xml for the layout
        setContentView(R.layout.main);

        // setup the data adaptor
        CustomAdapter adapter = new CustomAdapter(this, R.layout.list_item, this.data);

        // specify the list adaptor
        setListAdapter(adapter);
    }
}</code></pre>
<h3 id="customadapter.java">CustomAdapter.java</h3>
<pre><code>public class CustomAdapter extends BaseAdapter {
	// store the context (as an inflated layout)
	private LayoutInflater inflater;
	// store the resource (typically list_item.xml)
	private int resource;
	// store (a reference to) the data
	private ArrayList&lt;ListItem&gt; data;

	/**
	 * Default constructor. Creates the new Adaptor object to
	 * provide a ListView with data.
	 * @param context
	 * @param resource
	 * @param data
	 */
	public CustomAdapter(Context context, int resource, ArrayList&lt;ListItem&gt; data) {
		this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.resource = resource;
		this.data = data;
	}

	/**
	 * Return the size of the data set.
	 */
	public int getCount() {
		return this.data.size();
	}

	/**
	 * Return an object in the data set.
	 */
	public Object getItem(int position) {
		return this.data.get(position);
	}

	/**
	 * Return the position provided.
	 */
	public long getItemId(int position) {
		return position;
	}

	/**
	 * Return a generated view for a position.
	 */
	public View getView(int position, View convertView, ViewGroup parent) {
		// reuse a given view, or inflate a new one from the xml
		View view;

		if (convertView == null) {
			view = this.inflater.inflate(resource, parent, false);
		} else {
			view = convertView;
		}

		// bind the data to the view object
		return this.bindData(view, position);
	}

	/**
	 * Bind the provided data to the view.
	 * This is the only method not required by base adapter.
	 */
	public View bindData(View view, int position) {
		// make sure it&#39;s worth drawing the view
		if (this.data.get(position) == null) {
			return view;
		}

		// pull out the object
		ListItem item = this.data.get(position);

		// extract the view object
		View viewElement = view.findViewById(R.id.title);
		// cast to the correct type
		TextView tv = (TextView)viewElement;
		// set the value
		tv.setText(item.title);

		viewElement = view.findViewById(R.id.subTitle);
		tv = (TextView)viewElement;
		tv.setText(item.subTitle);

		// return the final view object
		return view;
	}
}</code></pre>
<h3 id="list_item.xml-2">list_item.xml</h3>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;

&lt;LinearLayout 
   	xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
   	android:layout_width=&quot;wrap_content&quot; 
   	android:layout_height=&quot;wrap_content&quot; 
   	android:background=&quot;#000000&quot;&gt;
   	&lt;TextView 
   		android:layout_width=&quot;wrap_content&quot;
   		android:layout_height=&quot;wrap_content&quot; 
   		android:id=&quot;@+id/title&quot;&gt;
   	&lt;/TextView&gt;
   	&lt;TextView 
   		android:layout_width=&quot;wrap_content&quot;
   		android:layout_height=&quot;wrap_content&quot; 
   		android:id=&quot;@+id/subTitle&quot;&gt;
   	&lt;/TextView&gt;
&lt;/LinearLayout&gt;</code></pre>
<p>The same source as above was used for the <code>ListItem</code> class.</p>
<p>The <code>bindData</code> method is where the most customisation will be required. This extracts the given view objects (the XML TextView, in this case), and binds the value of the members to it. Here, we have just used TextViews, but something similar would be used for other parts of the view.</p>
<h2 id="handling-events">Handling Events</h2>
<h3 id="single-taps">Single Taps</h3>
<p>The most obvious case for handling events is handling when a user taps (or clicks) a row. To do this, you define the <code>onItemClick()</code> method, and then inside this you can extract the original object back out to do stuff with it.</p>
<pre><code>    ListView lv = getListView();
    lv.setTextFilterEnabled(true);

    lv.setOnItemClickListener(new OnItemClickListener() {
      public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
    	  // When clicked, show a toast with the TextView text
    	  Toast.makeText(getApplicationContext(), parent.getItemAtPosition(position).toString(),
            Toast.LENGTH_SHORT).show();
      }
    });</code></pre>
<p>This defines the on <code>onItemClick()</code> method for handling the event. When a user taps on the item, it prints out the string representation of the object. It uses <a href="http://developer.android.com/reference/android/widget/Toast.html">“Toast”, Android’s discrete notifications class</a>.</p>
<p>The important call is <code>parent.getItemAtPosition(position)</code>. This extracts the selected object from the <code>ListAdapter</code>.</p>
<h3 id="long-taps">Long Taps</h3>
<p>“long taps” are perceived to be the equivalent to right-clicks on the desktop. On a list item, you would take this to mean a desire for more information about an item.</p>
<p>Implementing <code>LongClick</code> is much the same as normal clicks (taps). The difference is merely in the method calls which are defined:</p>
<pre><code>lv.setOnItemLongClickListener(new OnItemLongClickListener() {
    public boolean onItemLongClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
      	  // When clicked, show a toast with the TextView text
      	  Toast.makeText(getApplicationContext(), &quot;You long clicked on: &quot; + parent.getItemAtPosition(position).toString(),
              Toast.LENGTH_SHORT).show();

      	  return true;
    }
});</code></pre>
<h2 id="adjusting-data-in-the-view">Adjusting Data in the View</h2>
<p>This is a bit of a hack. The intention here is to show how to add and notify the adaptor of changes, rather than suggest a good way to go about doing it.</p>
<h3 id="adding-new-data">Adding New Data</h3>
<p>The simplest way to demonstrate this is to make the list item duplicate itself on tap (or click). Add the following before the <code>Toast</code> declarations, and the data model will be updated:</p>
<pre><code>// on press, duplicate the object
ListItem item = (ListItem)parent.getItemAtPosition(position);
ListItem newItem = new ListItem(item.title, item.subTitle);
data.add(newItem);</code></pre>
<p>The next step is to notify the <code>ListView</code> that the data is invalid. This will reload the data from the data model, and the new object will appear.</p>
<pre><code>// get the adaptor
SimpleAdapter adapter = (SimpleAdapter)parent.getAdapter();
adapter.notifyDataSetChanged();</code></pre>
<p>The same goes for handling editing and deleting functions on the underlying data. You just need to make sure you keep adjust the data set, and keep the adapter informed - then the most recent data is both saved and displayed.</p>
<h2 id="code">Code</h2>
<p>For each of the sections in this article, I have put together a set of examples. They are Zip archives of the Eclipse projects which were created whilst I was writing this.</p>
<p>The projects are targeted at Android 2.2, and were used with Eclipse 3.5.2 (Helios). The code is licensed under the MIT license.</p>
<p><a href="http://nickcharlton.net/resources/android-list-views/code.zip">You can find the code here</a>.</p>
<h2 id="further-reading">Further Reading</h2>
<p>To move along from here, I would suggest reading Chapter 9 (Putting SQL to Work) of <a href="http://www.amazon.co.uk/gp/product/1934356565/ref=as_li_ss_tl?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=1934356565">Hello, Android (3rd Edition) by Ed Burnette</a>. This provides a basic introduction to ListViews, but more importantly talks about hooking up a <code>ListView</code> to <a href="http://www.sqlite.org/">SQLite</a>.</p>
<p>As mentioned earlier, the <a href="http://developer.android.com/resources/tutorials/views/hello-listview.html">basic ListView tutorial</a> and the <a href="http://developer.android.com/reference/android/app/ListActivity.html">ListActivity Class Reference</a> should also be of use to you.</p>
<h2 id="conclusion">Conclusion</h2>
<p>Android’s <code>ListView</code> is pretty powerful, unfortunately, the documentation isn’t go great. Hopefully this will give people new to Android a kick-start in using the <code>ListView</code>.</p>
<p>Thanks to <a href="http://phalt.co.uk/">Paul Hallet</a> for reviewing this before posting.</p>]]></summary>
</entry>
<entry>
    <title>Review: Arduino Cookbook by Michael Margolis</title>
    <link href="http://nickcharlton.net/posts/review-arduino-cookbook-by-michael-margolis.html" />
    <id>http://nickcharlton.net/posts/review-arduino-cookbook-by-michael-margolis.html</id>
    <published>2011-03-22T12:17:24Z</published>
    <updated>2011-03-22T12:17:24Z</updated>
    <summary type="html"><![CDATA[<p>For a while, I’ve wanted to play around with the <a href="http://arduino.cc/">Arduino</a>; the open source embedded hardware that’s stuck it’s claws into everything from the arts, to personal projects and much more. Then, <a href="http://oreilly.com/catalog/9780596802486/">Arduino Cookbook</a> came up on the O’Reilly Blogger Review Program, and I couldn’t say no to having a pushed look into it.</p>
<p>I think the Arduino Cookbook will fill the void between books for which their intention is to cover lots of programming fundamentals, and books which only cover the Arduino boards with a cursory mention.</p>
<p>Like most of O’Reilly’s cookbooks, they intend to provide a group of solutions to common problems. Sometimes they feel a little filled out; the thought that this recipe and solution are only in there to fill a gap often comes to mind. With my limited Arduino experience, I didn’t see this as much as with others, as a somewhat experienced programmer, the programming Chapters did feel a little bit long, but what is there does cover issues where you’d rather have an instant answer than not understand why something is the case.</p>
<p>Overall, I was impressed by what it covered. Notably, serial communication, sensors, driving motors, I2C communication and networking stand out. These are all required for the few projects I have in mind.</p>
<p>If you have any experience with lower-level microcontrollers (I have a little bit of experience with C on Microchips’ PIC24 chip), you’ll find some more advanced stuff like interrupts and timers towards the end. This is a welcome addition.</p>
<p>The appendixes should be rather useful for most; they cover a basic introduction to electronics, but, as the author says himself, it’s not a replacement for a proper book on the subject.</p>
<p>The author suggests that it would be good for a variety of readers, personally, I think it will slot rather nicely into the likes of most programmers - especially those who wish to add something physical to their projects.</p>
<p>If you are looking for something to help complete a project, or just get started with the Arduino quickly this is probably the best bet. You’ll find plenty in here to get you going.</p>
<p><em>In the spirit of transparency, this review was written for the O’Reilly Blogger Review Program, because of that, they gave me a copy of the ebook for free.</em></p>]]></summary>
</entry>
<entry>
    <title>The Digital Peninsula's First Web Unconference</title>
    <link href="http://nickcharlton.net/posts/the-digital-peninsulas-first-web-unconference.html" />
    <id>http://nickcharlton.net/posts/the-digital-peninsulas-first-web-unconference.html</id>
    <published>2011-03-07T09:45:08Z</published>
    <updated>2011-03-07T09:45:08Z</updated>
    <summary type="html"><![CDATA[<p>On Saturday I gave a quick talk about <a href="http://termisoc.org/">TermiSoc</a> at the <a href="http://medworm.eventbrite.com/">Unconference</a> in the University. <a href="https://twitter.com/#!/frankiedolan">Frankie</a> put together a great event, with a really good turn out, with more than 80 people showing up, from down in Cornwall, all the way up to Bristol.</p>
<p>It was my first time speaking in front of more than about ten people. And as I quipped on Twitter just after, “<a href="http://twitter.com/#!/nickcharlton/status/44047505373151232">OH GOD, THATS A LOT OF PEOPLE</a>”. I did however enjoy it enough that I would likely agree to do it again.</p>
<p>Afterwards a couple of people came up to ask me about the kinds of people in TermiSoc, and many more mentioned that they’d wanted to come to one of our Monday Workspace evenings.</p>
<p>As fluffy as it sounds, I hope that we can stay connected with the rest of the South West Web community, they’re all a great bunch.</p>
<p>The general complaint was that it just wasn’t long enough, which I totally understand, I would like to have talked to many more people.</p>
<p>The next event is apparently going to take place in Exeter, so see you all there!</p>]]></summary>
</entry>
<entry>
    <title>Using ruby-oci8 on Ubuntu/Debian</title>
    <link href="http://nickcharlton.net/posts/using-rubyoci8-on-ubuntudebian.html" />
    <id>http://nickcharlton.net/posts/using-rubyoci8-on-ubuntudebian.html</id>
    <published>2011-03-02T14:43:36Z</published>
    <updated>2011-03-02T14:43:36Z</updated>
    <summary type="html"><![CDATA[<p>With this year’s integrating project, we were required to write a web service to integrate Android with the University’s Oracle server. After asking to use Ruby (and succeeding), I was then left with the obstacle of hooking up to the Oracle database. These a few notes on getting this working.</p>
<p><em>Note: You’ll need to follow these steps if you are installing via the <a href="http://rubygems.org/gems/ruby-oci8">gem</a> or <a href="http://ruby-oci8.rubyforge.org/en/">doing it manually</a></em></p>
<h2 id="prerequisites">Prerequisites</h2>
<p>Firstly; you’ll need to install the <code>libaio-dev</code> package, as instant client relies upon it.</p>
<pre><code>sudo apt-get install libaio-dev</code></pre>
<h2 id="oracle-instant-client">Oracle Instant Client</h2>
<p>After this, you’ll need to <a href="http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html">pick up the Instant Client Basic and Instant Client SDK packages from Oracle’s site</a>. <em>Note: You’ll need to register to access these.</em></p>
<p>Jump into <code>/opt/oracle</code> and extract them.</p>
<p>You will then end up with a folder such as <code>instant-client_11_2</code> (the SDK will end up in the same folder).</p>
<p>Inside this folder, you will want to create a symlink to the current version of the <code>libclntsh.so.*</code> library:</p>
<pre><code>sudo ln -s libclntsh.so.11.1 libclntsh.so</code></pre>
<h2 id="add-to-your-path">Add to your PATH</h2>
<p>To tell Ruby where to find the instant client libraries, you need to add the newly setup folder into your PATH. You can do this by doing something similar to the following:</p>
<pre><code>export LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2</code></pre>
<p>If you don’t add the libraries to your PATH, Ruby will not be able to access them. If you don’t add them to something like your <code>.bashrc</code>, they will be forgotten on reboot and when using the OCI8 gem, Ruby will complain at you.</p>
<h2 id="install-the-gem">Install the gem</h2>
<p>Next you need to install the Ruby library itself. You can find out about <a href="http://ruby-oci8.rubyforge.org/en/InstallForInstantClient.html">compiling it yourself here</a>.</p>
<p>To install you will need superuser access, however <code>sudo</code> will not pass in the library location, to get around this we can deliberately pass in the library path to the gem installer.</p>
<pre><code>sudo env LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 gem install ruby-oci8</code></pre>
<hr />
<p>At this point, everything should be working. Shared Library errors are generally caused by an issue with Oracle’s instant client, especially when the PATH has been reset. This article was based on a few others, you can <a href="http://ruby-oci8.rubyforge.org/en/InstallForInstantClient.html">read</a> <a href="http://www.it-wikipedia.com/web/how-to-install-ruby-oci8-on-ubuntu-server.html">those</a> <a href="http://2muchtea.wordpress.com/2007/12/23/installing-ruby-oci8-on-ubuntu/">here</a>.</p>]]></summary>
</entry>
<entry>
    <title>TermiSoc Hack Weekend 2011</title>
    <link href="http://nickcharlton.net/posts/termisoc-hack-weekend-2011.html" />
    <id>http://nickcharlton.net/posts/termisoc-hack-weekend-2011.html</id>
    <published>2011-02-08T16:54:27Z</published>
    <updated>2011-02-08T16:54:27Z</updated>
    <summary type="html"><![CDATA[<p><em>I intend for this post to hold all of the presentations and sessions that we’ve hosted for the TermiSoc Hack Weekend 2011. This post will expand in the future as more content is covered.</em></p>
<h2 id="introduction">Introduction</h2>
<iframe frameborder='0' style='width:460px;height:375px;' src='http://public.iwork.com/embed/?d=Hack_Weekend_2011_58__Introduction.key&a=p1051018750&h=600&w=800&sw=458'>

</iframe>

<p>This first session was intended to explain the overall plan, how I intended to approach the prior sessions, but to overall drum up some enthusiasm about what we should build.</p>
<p>Overall, we ended up with a set of ideas ranging from games, to Arduino projects, to more complicated stuff using open data sets, algorithms and natural language processing.</p>
<p>The plan so far is to target mobile devices, add in location services and then add some element of gaming to it. This means that I will likely run some sessions covering things from HTML5/CSS &amp; JavaScript to Python for handling the backend. If I get time, I’ll likely cover some Google App Engine stuff, too.</p>
<p>It really is however based upon the idea itself. Something that will be talked about on the <a href="http://lists.termisoc.org/listinfo/termilist">mailing list</a>, over the next week or so.</p>
<p>If you’re reading this and not part of <a href="http://termisoc.org/">TermiSoc</a>, feel free to give me a shout. I don’t wish to run a closed event, but I also hope that people will show up to each of the prior sessions. Then we can be sure we’ll hit the ground running.</p>
<h2 id="refresh-html5-the-new-javascript-apis">Refresh: HTML5 &amp; The New JavaScript APIs</h2>
<figure>

<iframe frameborder='0' style='width:460px;height:375px;' src='http://public.iwork.com/embed/?d=Refresh_-_HTML5__38__JavaScript.key&a=p1051018750&h=600&w=800&sw=458'>

</iframe>

</figure>

<p>This second session was to go over some of the new HTML5 technologies which are at our disposal. It worked out as a not too bad ~40 minute talk, although, I think I could have gone into more detail in certain areas, especially where using it now is concerned.</p>
<p>We seem to be on track so far, but the idea is still an issue. Give me a shout if you have any ideas!</p>
<h2 id="version-control-with-git">Version Control with Git</h2>
<p>The idea of this session was to introduce the concept of version control, but also to introduce <a href="http://git-scm.com/">Git</a> as a tool itself. Instead of relying on a set of slides, the idea of the evening was to explain things at everyones pace.</p>
<p>As this is not something that’s covered on most people’s degree courses, it’s relevant to all.</p>
<p><a href="http://nickcharlton.net/resources/guide_to_git.pdf">Here is the Guide to Git which I had written beforehand</a>. It was mostly put together through a series of notes I already had, and then formatted. Some sections could be incorrect, so use with caution, and <script type="text/javascript">
<!--
h='&#110;&#x69;&#x63;&#x6b;&#x63;&#104;&#x61;&#114;&#108;&#116;&#x6f;&#110;&#46;&#110;&#x65;&#116;';a='&#64;';n='&#104;&#x65;&#108;&#108;&#x6f;';e=n+a+h;
document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+'complain where necessary'+'<\/'+'a'+'>');
// -->
</script><noscript>&#x63;&#x6f;&#x6d;&#112;&#108;&#x61;&#x69;&#110;&#32;&#x77;&#104;&#x65;&#114;&#x65;&#32;&#110;&#x65;&#x63;&#x65;&#x73;&#x73;&#x61;&#114;&#x79;&#32;&#40;&#104;&#x65;&#108;&#108;&#x6f;&#32;&#x61;&#116;&#32;&#110;&#x69;&#x63;&#x6b;&#x63;&#104;&#x61;&#114;&#108;&#116;&#x6f;&#110;&#32;&#100;&#x6f;&#116;&#32;&#110;&#x65;&#116;&#x29;</noscript>.</p>
<p>This session went rather well, with people saying nice things about it afterwards. At the <a href="http://nickcharlton.net/post/the-digital-peninsulas-first-web-unconference">Unconference</a>, <a href="http://www.fuel-communications.co.uk/">Ben Masters of Fuel</a> said that it had been useful to him. Because of this, I will likely turn it into it’s own blog post soon.</p>
<h2 id="getting-started-with-python">Getting Started with Python</h2>
<p>This session was intended to be a basic introduction to <a href="http://python.org/">Python</a>. It’s the language I intend to use in projects for <a href="http://termisoc.org/">TermiSoc</a> from this point onwards. In the session, I talked a little about the language itself (thus the slides), and then moved on to the guide I had prepared.</p>
<p>You will find the slides below and the <a href="http://nickcharlton.net/resources/getting_started_with_python.pdf">guide linked here</a>.</p>
<figure>

<iframe frameborder='0' style='width:460px;height:375px;' src='http://public.iwork.com/embed/?d=Getting_Started_with_Python.key&a=p1051018750&h=600&w=800&sw=458'>

</iframe>

</figure>

<p>The next few sessions intend to expand upon where we started here, going over some of the nice build in data structures, using libraries and moving on to some web application stuff. I also intend to start talking about what we’d like to build.</p>
<p><em>Note: Please use any of the PDFs or slides linked above and modify them; but please don’t sell them, and make sure that you link back. If you want a more formal license, it’s <a href="http://creativecommons.org/licenses/by-nc-sa/2.0/uk/">CC BY-NC-SA</a>. Also; please give me a shout if you’re using them somewhere, I’d love to know how they can be improved.</em></p>]]></summary>
</entry>
<entry>
    <title>An Ultra-simple Guide to Reading XML in Java, using SAX</title>
    <link href="http://nickcharlton.net/posts/guide-to-sax-in-java.html" />
    <id>http://nickcharlton.net/posts/guide-to-sax-in-java.html</id>
    <published>2011-02-06T14:17:43Z</published>
    <updated>2011-02-06T14:17:43Z</updated>
    <summary type="html"><![CDATA[<p>For the piece of work I have been dealing with recently, I was required to implement persistence using XML in Java. I figured this would be simple. Java and XML are used all the time, right? Should be easy.</p>
<p>However, after reading various bits of writing on the subject, from <a href="http://www.cafeconleche.org/books/xmljava/chapters/ch05.html">Chapter 5 of Java and XML</a> to this O’Reilly OnJava article on <a href="http://onjava.com/pub/a/onjava/2002/06/26/xml.html">Simple XML Parsing with SAX and DOM</a>, as suggested by <a href="http://www.chrisbunney.com/">Chris</a>, it still didn’t cut the ultra simplicity I wanted to Just Get the Damn Thing Done™.</p>
<h2 id="sample-xml-file">Sample XML File</h2>
<p>For this example, I’m just going to show you how to deal with a single element inside an XML document. Obviously, in the real world, it wouldn’t be this simple, but it should be enough to provide the understanding you need.</p>
<pre><code>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;people&gt;
	&lt;person&gt;
		&lt;age&gt;50&lt;/age&gt;
	&lt;/person&gt;
&lt;/people&gt;</code></pre>
<h2 id="opening-the-file">Opening the File</h2>
<p>The block below opens up the file, parses it’s contents, then closes it back up. It does this by opening up the file in a stream, then passing this stream into the SAX parser.</p>
<pre><code>import java.io.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;

public class SAXClient {
    public static void main(String[] args) {
        try {
            // specify the SAXParser
            XMLReader parser = XMLReaderFactory.createXMLReader(
                &quot;com.sun.org.apache.xerces.internal.parsers.SAXParser&quot;
            );
            // setup the handler
            ContentHandler handler = new Handler();
            parser.setContentHandler(handler);
            // open the file
            FileInputStream in = new FileInputStream(&quot;file.xml&quot;);
            InputSource source = new InputSource(in);
            // parse the data
            parser.parse(source);
            // print an empty line under the data
            System.out.println();
            // close the file
            in.close();
        }
        catch (Exception e) {
            System.err.println(e); 
        }
    }
}</code></pre>
<h2 id="handling-the-content">Handling the Content</h2>
<p>We implement a class which extends the DefaultHandler, which handles what happens when it reaches each part of the XML document.</p>
<p>When the handler reaches the start of the element, a flag is set to true. When it reaches the end of the tag, this flag is set to false. When it is inside the tag, the contents is printed out.</p>
<pre><code>import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;

public class Handler extends DefaultHandler {
    private boolean inAge = false;

    public void startElement(String namespaceURI, String localName, String qualifiedName, Attributes atts) throws SAXException {
        if (localName.equals(&quot;age&quot;)) inAge = true;
    }

    public void endElement(String namespaceURI, String localName, String qualifiedName) throws SAXException {
        if (localName.equals(&quot;age&quot;)) inAge = false;
    }

    public void characters(char[] ch, int start, int length) throws SAXException {
        if (inAge) {
            for (int i = start; i &lt; start+length; i++) {
                System.out.print(ch[i]); 
            }
        }
    }
}</code></pre>
<p>To deal with the output, you’ll need to implement some form of data structure to hold the data. A good tip that can be provided here is that the parser will follow from the top to the bottom when navigating your XML structure. This can be taken advantage of when dealing with the pending data.</p>]]></summary>
</entry>
<entry>
    <title>ProgComp: A Programming Competitions Blog</title>
    <link href="http://nickcharlton.net/posts/progcomp-a-programming-competitions-blog.html" />
    <id>http://nickcharlton.net/posts/progcomp-a-programming-competitions-blog.html</id>
    <published>2010-12-26T21:47:36Z</published>
    <updated>2010-12-26T21:47:36Z</updated>
    <summary type="html"><![CDATA[<p>Last week I launched <a href="http://progcomp.tumblr.com/">ProgComp</a>. The idea is to produce a continuing flow of curated programming competitions.</p>
<p>I think competitions are a great way to stretch peoples’ minds on problems they would not otherwise encounter. There are lots of things to learn across many different fields in Computer Science, from data handling algorithms to neural networks in AI and Physics in games.</p>
<p>The hope is to over time produce a site where you can find open and available competitions, covering a variety of different subject areas.</p>
<p>Obviously, I cannot do this alone, so, if you hear of any upcoming competitions, please <a href="http://progcomp.tumblr.com/submit">submit it here</a>.</p>]]></summary>
</entry>
<entry>
    <title>BCS Lecture Series: Physical Security in IT</title>
    <link href="http://nickcharlton.net/posts/bcs-lecture-series-physical-security-in-it.html" />
    <id>http://nickcharlton.net/posts/bcs-lecture-series-physical-security-in-it.html</id>
    <published>2010-11-10T00:25:21Z</published>
    <updated>2010-11-10T00:25:21Z</updated>
    <summary type="html"><![CDATA[<p>This month’s lecture was delivered by <a href="http://www.hackner-security.com/">Thomas Hackner</a>, from the <a href="http://www.fh-ooe.at/en/">University of Applied Sciences, Hagenberg, Upper Austria</a>.</p>
<p>It was certainly an interesting talk, he covered the various standards (ISO 27001:2005), and pointed out a few case studies, and points often over looked. This was then followed up with a demonstration, and “practical” showing lock picking.</p>
<h2 id="points">Points</h2>
<ul>
<li>Electronic door access systems often just control the door latch, rather than the deadbolt itself.
<ul>
<li>this means that typically, it is possible to circumvent the latch using a piece of plastic. Most systems will also not log door openings, leaving such entrances undetected.</li>
</ul></li>
<li>Entry systems that use PIN code systems should be changed regularly, otherwise it will eventually be obvious to a casual visitor what the code is.</li>
<li>There is usually a simple to identify weakest link in a Physical system, much like any other system.
<ul>
<li>an example given was an industrial fridge in student accommodation in Austria. To open the whole fridge it was secured by a much simpler lock than the individual compartments.</li>
</ul></li>
<li>People generally disclose more information over an internal phone system.
<ul>
<li>this is most likely because they assume you are trusted for using it.</li>
</ul></li>
<li>In a report in 2008, the Financial Services Authority found that 10/39 small and large companies in the financial industry had basic lapses of security.
<ul>
<li>in most cases they had implemented solutions like CCTV, and PIN code access on doors, but simply left those doors open, for example.</li>
</ul></li>
<li>Other examples highlighted oversights such as:
<ul>
<li>access to server rooms with visitor passes</li>
<li>keypad entry systems, but leaving main doors open</li>
<li>in companies where they had been implemented, 8/10 of the employees questioned had no idea, or only a cursory understanding of a clear desk policy.</li>
</ul></li>
<li>Another example given was of an <a href="http://www.securitypitfalls.org/2010/02/security-is-no-matte.html">Airport in Rome which had no security overnight</a>. This meant that someone was able to walk through the airport, potentially planting banned objects.</li>
</ul>
<h2 id="in-conclusion">In Conclusion</h2>
<p>Overall, it was a good talk. The examples showed where people often overlook potential security policies, and the relevance of physical penetration testing. On display where <a href="ttp://www.amazon.co.uk/gp/product/1597496111?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=1597496111">Practical Lock Picking: A Physical Penetration Tester’s Training Guide</a> and <a href="http://www.amazon.co.uk/gp/product/0470747617?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0470747617">Unauthorised Access: Physical Penetration Testing for IT Security Teams</a> which should hopefully stir on my initial interest further.</p>]]></summary>
</entry>
<entry>
    <title>BCS Lecture Series: Apple (The Birth of a Third Platform)</title>
    <link href="http://nickcharlton.net/posts/bcs-lecture-series-apple-the-birth-of-a-third-platform.html" />
    <id>http://nickcharlton.net/posts/bcs-lecture-series-apple-the-birth-of-a-third-platform.html</id>
    <published>2010-09-29T09:24:06Z</published>
    <updated>2010-09-29T09:24:06Z</updated>
    <summary type="html"><![CDATA[<p>Yesterday evening, <a href="http://twitter.com/thisisthechris">Chris Hunt</a> and myself went along to a talk at the BCS from Apple, entitled “The Birth of a Third Platform, Mobile Computing in HE”. Overall, it was a good talk, even with the heavy Apple marketing angle.</p>
<p>The talk was hosted by Lawrence Stevenson, who I assume holds a job title like “HE Evangelist”, or such like.</p>
<p>The majority of the talk focused on covering the usage of mobile technologies in HE. From mobile optimised web apps which would tell you about the status of washing machine in halls (<a href="http://housing.uiowa.edu/departments/facilities/laundry.htm">such as at the University of Iowa</a>), to iPad’s in class being used by students to find out information during lectures.</p>
<h2 id="figures">Figures</h2>
<p>Some interesting figures were given out during the presentation.</p>
<ul>
<li>Since 2009, mobile device shipments have declined 10% year on year.</li>
<li>But, smartphones grew 20%, and now account for 17% of mobile devices.</li>
<li>Smartphones are projected to take 37% of the market by 2012.</li>
<li>In US HE, smartphone use has gone from 1.28% in 2005, to 51.2% in 2009.</li>
<li>Graduate skill sets have changed from a dominance on physical skills to skills relating to IT (intellectual). In the last 50 years, this has changed from less than 40% to over 65%, today.</li>
</ul>
<h2 id="other-points">Other Points</h2>
<p>Some other points made were:</p>
<ul>
<li>“Mobile computing is about producing context and engagement”.</li>
<li>“We’ve gone from what is your mobile strategy to where is your mobile strategy”.</li>
<li>Slowness in HE integration can route back to lecturers not wanting their jobs to change. Links to Darwin were made on that point.</li>
<li>There isn’t an education discount for the iPad because the demand is so high.</li>
</ul>
<h2 id="in-conclusion">In Conclusion</h2>
<p>Unfortunately, towards the end we didn’t get a chance to catch him and ask a few questions. He was swamped with people asking about iOS SDK related things, those which are <a href="http://www.apple.com/hotnews/thoughts-on-flash/">widely</a> <a href="http://daringfireball.net/2010/09/app_store_guidelines">reported</a> too.</p>]]></summary>
</entry>
<entry>
    <title>On Long Way Down</title>
    <link href="http://nickcharlton.net/posts/on-long-way-down.html" />
    <id>http://nickcharlton.net/posts/on-long-way-down.html</id>
    <published>2010-09-17T00:18:39Z</published>
    <updated>2010-09-17T00:18:39Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://www.amazon.co.uk/gp/product/0751538957?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0751538957">Long Way Down</a> was a good series. Back in 2007, Ewan McGregor and Charley Boorman set out on a motorcycle trip from John O’Groats to Cape Town. I just finished reading the accompanying book, that’s been on my book shelf for quite a while.</p>
<p>All in all, it was a good book. It’s laid out as a dialogue between the two, and in general split into chapters at country borders.</p>
<p>I think it is a book where, through the eyes of the authors, you get an idea of what travelling through many different places is like. For me at least; it’s spurred me on to other books, like <a href="http://www.amazon.co.uk/gp/product/0140054103?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0140054103">Ted Simon’s Jupiter’s Travels</a>, the story of another adventure on a Motorbike.</p>
<p>In the process of <a href="http://twitter.com/nickcharlton/status/24594581601">tweeting about it</a>, I did the (probably stupid) thing of reading the reviews from Amazon. All-in-all, they were pretty awful. Most of them were centred around them being well known elsewhere, or the ghost writing. Others on the convoy they travelled with.</p>
<p>I can certainly agree with some of it, the travelling does feel a little bit over done for what they talked about in both the series and the book. Mostly, the book replays the series, not adding much to the original story.</p>
<p>I think this is a shame. Whilst some come would come to a book to hear about the adventure, I hoped it would come with the hope that it would give a far greater depth. There’s no answer to the ‘Why?’. Why did they pick this route? Why the specific bikes? What about the choice of the rest of the equipment? None of these were answered.</p>
<p>Another point made was the focus on the timetable. Whilst it’s quite easy to plan traveling around somewhere like Europe, travelling through Africa is unpredictable - almost entirely because of the road surfaces. Setting up commitments to meet with Aid Agencies, or ferries seems to me to have been a mistake. Though; I suspect some of this comes from their status, and the filming.</p>
<p>All of these things aside though, it’s a good read. I think it’s a good springboard onto other books, like Jupiter’s Travels, or classics like <a href="http://www.amazon.co.uk/gp/product/0140095144?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0140095144">Thesiger’s Arabian Sands</a> (which I must read).</p>]]></summary>
</entry>
<entry>
    <title>CSS3 Bundle</title>
    <link href="http://nickcharlton.net/posts/css3-bundle.html" />
    <id>http://nickcharlton.net/posts/css3-bundle.html</id>
    <published>2010-07-10T11:49:40Z</published>
    <updated>2010-07-10T11:49:40Z</updated>
    <summary type="html"><![CDATA[<p>The default CSS bundle in TextMate doesn’t include any of the new features of CSS3. I’d tried other TextMate CSS3 plugins, but in general they didn’t cover enough and seemed unmaintained.</p>
<p>So I made this.</p>
<h2 id="features">Features</h2>
<ul>
<li>border-radius</li>
<li>box-shadow</li>
<li>Odd/Even Selectors</li>
<li>Columns (WebKit only)</li>
<li>Text Stroke (WebKit only)</li>
<li>text-shadow</li>
<li>opacity</li>
<li>display-inline</li>
</ul>
<h2 id="where-to-find-it">Where to Find it</h2>
<p>You can find <a href="http://github.com/nickcharlton/CSS3-Bundle" title="nickcharlton&#39;s CSS3-Bundle at master - GitHub">the source on GitHub</a>, <a href="http://github.com/downloads/nickcharlton/CSS3-Bundle/CSS3.tmbundle">a download here</a>. And <a href="http://github.com/nickcharlton/CSS3-Bundle/issues" title="Issues - nickcharlton/CSS3-Bundle - GitHub">the issues page here</a>, where you can suggest new features.</p>
<p><em>Contributions are very welcome, it’s certainly not complete.</em></p>]]></summary>
</entry>
<entry>
    <title>New Project</title>
    <link href="http://nickcharlton.net/posts/new-project.html" />
    <id>http://nickcharlton.net/posts/new-project.html</id>
    <published>2010-05-30T00:42:13Z</published>
    <updated>2010-05-30T00:42:13Z</updated>
    <summary type="html"><![CDATA[<p>After a few weeks of work, this is “Version 4”, of my blog. I have a slightly different design, and a different focus which should represent changes in me.</p>
<p>I do have a like of redoing some aspect of this every 6 months. I think it’s a cross between me changing as a person, and my desire to have this as a reflection of that.</p>
<p>This is a little app written in <a href="http://www.sinatrarb.com/" title="Sinatra">Sinatra</a>, utilising <a href="http://daringfireball.net/projects/markdown/" title="Daring Fireball: Markdown">Markdown</a> for the markup (handled by <a href="http://github.com/nex3/maruku" title="nex3&#39;s maruku at master - GitHub">Maruku</a>), backed up by MySQL. It’s hosted on Apache/Passenger at <a href="http://prgmr.com/xen/" title="Linux and NetBSD Xen VPS hosting.">Prgmr.com</a>.</p>
<p>The code is also on <a href="http://github.com/nickcharlton/nickcharlton.net" title="nickcharlton&#39;s nickcharlton.net at master - GitHub">GitHub</a>. Including most of the content.</p>
<h2 id="plans">Plans</h2>
<ul>
<li>Open Source the underlying “blogging engine”, as a project called “Sinba”.</li>
<li>Use it to dump notes as I work on projects.</li>
<li>Document a few things released, or nearing release.</li>
</ul>
<h2 id="future">Future</h2>
<p>Over the Summer I have (through my Dad) scored a two month Sysadmin Job at ADNEC, in Abu Dhabi. Around this time last year, I spent two days doing some work experience. Which, apart from being brilliant (there’s nowhere you can find a better mix of people than abroad) and educational, was very useful to me.</p>
<p>For the evenings, I have a few things rolled up my sleeve. As usual, there’s a lot of things I’d like to learn, from iPhone OS Programming, to some C stuff. But, mostly, I want to go into September with at least a few simple projects up my sleeve, and something bid nearly there.</p>
<p>Ready? Let’s Begin.</p>]]></summary>
</entry>
<entry>
    <title>SQLite, ADO.NET & CSharp</title>
    <link href="http://nickcharlton.net/posts/sqlite-with-csharp.html" />
    <id>http://nickcharlton.net/posts/sqlite-with-csharp.html</id>
    <published>2010-04-14T08:00:00Z</published>
    <updated>2010-04-14T08:00:00Z</updated>
    <summary type="html"><![CDATA[<h3 id="introduction">Introduction</h3>
<p>For a project I wanted to use SQLite for dealing with it’s data. I quite readily found <a href="http://sqlite.phxsoftware.com/" title="System.Data.SQLite">System.Data.SQLite</a>. But, then I needed to figure out how ADO.NET worked. This has resulted in these short notes, mostly compiled from O’Reilly’s out of print, <a href="http://oreilly.com/catalog/9780596003616/" title="ADO.NET in a Nutshell - O&#39;Reilly Media">ADO.NET in a Nutshell</a>.</p>
<p>Most of the rest of these notes are general to ADO.NET, but with a few System.Data.SQLite specifics.</p>
<h3 id="prerequisites">Prerequisites</h3>
<ul>
<li>You’ll need the System.Data.SQLite.dll file.</li>
<li>You’ll need to reference it in the VS Solution.</li>
<li><p>You’ll need to include the namespace at the top of your code.</p>
<p>using System.Data.SQLite;</p></li>
</ul>
<h3 id="connection-string">Connection String</h3>
<p>The first stage is to connect to the DB and to do that you’ll create a “Connection” using a ConnectionString. An example is below:</p>
<pre><code>// initialise the database
SQLiteConnection con = new SQLiteConnection(&quot;Data Source=../../Database.sqlite&quot;);</code></pre>
<h3 id="opening">Opening</h3>
<p>This simply opens the database connection. (See Closing for, ..closing).</p>
<pre><code>con.Open;</code></pre>
<p>You can test the status of the connection by writing:</p>
<pre><code>Console.WriteLine(&quot;Connection is &quot; + con.State.ToString());</code></pre>
<h3 id="queries-and-nonqueries">Queries and NonQueries</h3>
<p>ADO.NET differentiates between “Queries” and “NonQueries”. The difference is dependant on the returned data.</p>
<p>A “NonQuery” is an SQL statement such as “UPDATE”, “DELETE” and “INSERT”, as they do not return data. You will however get a count of how many rows were effected on execution.</p>
<h3 id="command-string">Command String</h3>
<h4 id="nonqueries">NonQueries</h4>
<pre><code>// define our SQL.
string SQL = &quot;UPDATE people SET name=&#39;Someone Else&#39; WHERE id=1&quot;;

// Create the Command
SQLiteCommand cmd = new SQLiteCommand(SQL, con);

// Open the connection (if you haven&#39;t already).
con.Open();

// execute our command.
int rowsAffected = cmd.ExecuteNonQuery();</code></pre>
<p>First we define our SQL query (which is just a string), then instantiate the SQLiteCommand object, and finally run our command.</p>
<h4 id="returning-a-single-result">Returning a Single Result</h4>
<p>The <code>ExecuteScalar()</code> method returns a single value. This would be used to return the result of a calculation. Such as requesting a COUNT.</p>
<pre><code>cmd.ExecuteScalar();</code></pre>
<p>The returned value is an Object of the result.</p>
<p>Example:</p>
<pre><code>string SQL = &quot;SELECT id FROM people WHERE id=&#39;1&#39;;&quot;;

SQLiteCommand cmd = new SQLiteCommand(SQL, con);

con.Open();

object result = cmd.ExecuteScalar();
int convert = Convert.ToInt16(result);

con.Close();
Console.WriteLine(convert.ToString() + &quot; rows.&quot;);</code></pre>
<h4 id="creating-tables">Creating Tables</h4>
<p>Creating tables is done in a similar way to the above, but with just a different SQL command. (So, I won’t mention it here.)</p>
<h4 id="performing-selects-using-datareader">Performing SELECTs / Using DataReader</h4>
<p>The DataReader class provides the methods to iterate over rows in a database. So, this is the function to use to perform SELECT statements that return more than one record.</p>
<p>Example:</p>
<pre><code>string SQL = &quot;SELECT ContactName FROM Customers&quot;;

// Create ADO.NET objects.
SQLiteConnection con = new SQLiteConnection(&quot;Data Source=../../Database.sqlite&quot;);
SQLiteCommand cmd = new SqlCommand(SQL, con);
SQLiteDataReader reader = null;

// Execute the command.
try
{
    con.Open();
    reader = cmd.ExecuteReader();

    // Iterate over the results.
    while (reader.Read())
    {
        lstNames.Items.Add(reader[&quot;ContactName&quot;]);
    }
}
catch (Exception err)
{
    MessageBox.Show(err.ToString());
}
finally
{
    if (reader != null) reader.Close();
    con.Close();
}</code></pre>
<p>You can also run more than one SELECT query, split with a semicolon, like this:</p>
<pre><code>string SQL = &quot;SELECT * FROM Customers; SELECT * FROM Orders;&quot;</code></pre>
<p>To differentiate between the two result sets, you need to apply a <code>reader.NextResult();</code>, like below:</p>
<pre><code>while (reader.Read())
{
    // (Process the category rows here.)
}

reader.NextResult();

while (reader.Read())
{
    // (Process the product rows here.)
}</code></pre>
<p><em>Note: Most of these code examples are from Chapter/Section 5.2.</em></p>
<h3 id="conclusion">Conclusion</h3>
<p>This has hopefully provided you a basic introduction to using the System.Data.SQLite and ADO.NET. Once you understand how ADO.NET works, System.Data.SQLite drops straight in. It follows all of the usual ADO.NET conventions.</p>]]></summary>
</entry>
<entry>
    <title>Fixing Missing Gem Problems on OS X</title>
    <link href="http://nickcharlton.net/posts/fixing-missing-gem-problems.html" />
    <id>http://nickcharlton.net/posts/fixing-missing-gem-problems.html</id>
    <published>2010-02-26T08:00:00Z</published>
    <updated>2010-02-26T08:00:00Z</updated>
    <summary type="html"><![CDATA[<p><em>Disclaimer: This could potentially bugger up Ruby and Ruby Gems on your machine, proceed carefully.</em></p>
<p>Recently I’ve been doing quite a few <a href="http://en.wikipedia.org/wiki/REST" title="Representational State Transfer - Wikipedia, the free encyclopedia">REST</a> API building stuffs with <a href="http://www.ruby-lang.org/en/" title="Ruby Programming Language">Ruby</a>, <a href="http://www.sinatrarb.com/" title="Sinatra">Sinatra</a> and trying to pick up <a href="http://ar.rubyonrails.org/" title="Active Record -- Object-relation mapping put on rails">ActiveRecord</a> to use with Rails. I was however getting quite a lot of problems with Gems loading, but not loading completely.</p>
<p>If when running <code>gem check --alien</code>, you get something similar to below:</p>
<pre><code>rails-1.2.6 has 2 problems
	/Library/Ruby/Gems/1.8/specifications/rails-1.2.6.gemspec:
	Spec file doesn&#39;t exist for installed gem

	/Library/Ruby/Gems/1.8/cache/rails-1.2.6.gem:
	missing gem file /Library/Ruby/Gems/1.8/cache/rails-1.2.6.gem</code></pre>
<p>Clear out all of the gems located in the following directories. You will need to similarly remove anything in the bin/, cache/, doc/, gems/ and specifications/ directories.</p>
<pre><code>/Library/Ruby/Gems/1.8
/Users/&lt;username&gt;/.gem/ruby/1.8
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8</code></pre>
<p>(These directories can be found by entering <code>gem environment</code>).</p>
<p>You will then need to reinstall all of your gems. You may wish to issue a <code>gem check</code> on each of them to ensure it’s all good.</p>]]></summary>
</entry>
<entry>
    <title>Thoughts on the iPad</title>
    <link href="http://nickcharlton.net/posts/thoughts-ipad.html" />
    <id>http://nickcharlton.net/posts/thoughts-ipad.html</id>
    <published>2010-01-27T08:00:00Z</published>
    <updated>2010-01-27T08:00:00Z</updated>
    <summary type="html"><![CDATA[<p>Tablets and small computers have always interested me. My iPhone is a great little mobile computer - the internet in the palm of your hand, and the rest of that..</p>
<p>The thing is, I’ve never seen the actual <em>point</em> of tablets. They are generally not convenient enough to make them worthwhile, the wrong size, too limited and have an awful input mechanism.</p>
<p>There was an <a href="http://news.ycombinator.com/item?id=1077772" title="Hacker News | The Healthcare System: An Apple Tablet&#39;s Biggest Opportunity">interesting discussion on Hacker News</a> earlier today about tablets in medicine. The article itself suggested that tablets would be a great way for doctors to enter information about patients - forgetting of course that paper has worked wonderfully since pre-Nightingale and such an adaption would be an uphill struggle. Anyway, I digress.</p>
<p>From <a href="http://nickcharlton.net/blog/new-macbook-pro" title="nickcharlton.net/blog">my rather biased perspective</a>, I think Apple has done something interesting with the “iPad”.</p>
<p>The interesting bit here, at least, I think, is their showing off of iWork on the device. The biggest issue with such a device is text input. Being just a large screen, there’s not the ability to easily enter text. The iPhone isn’t a bad, if a little small, but still a pretty good mobile keypad, the iPad is similar, although on a larger scale.</p>
<p>What I can’t see though is the gap between the iPhone and the MacBook models. Therefore, I don’t think it’s revolutionary, at all.</p>
<p>I find reading to be quite possible on both my iPhone and MacBook Pro, leading me to not need something to fit in that gap. At least, not with just a LCD screen. e-Ink would be something different entirely, reading of an LCD screen is tiring on the eyes.</p>
<p>I can’t see why you would use such a device for writing a document when a laptop is far nicer and why you would use such a device for watching TV, recorded or otherwise.</p>
<p>What I do think is clever though is the price point. It’s not cheap enough that I would buy one - not least at the 3G end of the scale, but priced cleverly enough to provide another option for people looking for a new machine.</p>
<p>Maybe the revolutionary aspect is producing a excellent, portable device?</p>
<p>I intend to see it pan out, I can’t see me buying one, but it’s interesting, none-the-less.</p>]]></summary>
</entry>
<entry>
    <title>Ideas and University</title>
    <link href="http://nickcharlton.net/posts/ideas-and-university.html" />
    <id>http://nickcharlton.net/posts/ideas-and-university.html</id>
    <published>2009-11-03T08:00:00Z</published>
    <updated>2009-11-03T08:00:00Z</updated>
    <summary type="html"><![CDATA[<p>It’s been a while since I’ve written down a set of thoughts. Most of which occurred before I started University. What I do want to ponder here I will come to in a moment, but now I’ve been at University for nearly 4 months - I’m trailing on to the end of the first term.</p>
<p>It has certainly been a experience, but something I thought would be overly more strenuous and complex. Especially after the first few weeks. Unfortunately, it has not been like what I had hoped. I certainly don’t find the amount of work I’m given hard enough - or even to the level of other’s at different Universities and the topics covered never seem to go into the depth I’d like. All in all, it either feels like I’m not learning anything or that I am rather having to teach myself.</p>
<p>Arguably this is a failing of the University itself and speaking with <a href="http://bma.subvert.org.uk/" title="~bma — Home">others</a> the first year doesn’t appear to change, and <a href="http://twitter.com/rossbearman">some</a> have stated that the second year is not much better.</p>
<p>What I do want to talk about though are ideas. Ideas are those amazing things you dream up doing and in most people’s cases, don’t get the chance to execute them. I used to have a constant flow of such things. Possible projects flying out of my ears just waiting to be executed.</p>
<p>Since getting to Plymouth though, that all seems to have changed. I have ended up having passing possibles, rather than something that sticks for any reasonable amount of time.</p>
<p>Quite possibly this down to not specifically having any problems to solve, or indeed too many options to solve it, neither of them which are worth spending time on.</p>
<p>As an example, I have been meaning to launch something of substance on <a href="http://heroku.com/" title="Heroku | Ruby Cloud Platform as a Service">Heroku</a> for a while. Could do with patching up my Ruby knowledge by writing some client-side apps, rather than simple ideas executed with Sinatra and then abandoned. Similarly, I haven’t used C for a while, would like to learn some Objective-C for Mac development (and Cocoa, obviously) but have no reasons to push ahead with it. No project idea generally means that I merely read and plan about either a project, or something new (like a framework) and not end up with something at the end.</p>
<p>As part of my course, I am supposed to be learning C#, half of my problem here is that I don’t use Windows and therefore I don’t have a need to build anything there. Although, fortunately I seem to be able to pick it up quite easily.</p>
<p>So, instead of spending my time working on something specific I am slowly reading through a mountain of books. To run off a list off the top of my head:</p>
<ul>
<li><a href="http://www.amazon.co.uk/gp/product/0596529864?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0596529864" title="Learning Ruby: Amazon.co.uk: Michael Fitzgerald: Books">Learning Ruby</a></li>
<li><a href="http://www.amazon.co.uk/gp/product/0596102097?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0596102097" title="Learning C# 2005, Second Edition: Amazon.co.uk: Jesse Liberty, Brian MacDonald: Books">Learning C# 2005</a></li>
<li><a href="http://www.amazon.co.uk/gp/product/0470147628?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0470147628" title="Beginning Linux Programming: Amazon.co.uk: Neil Matthew, Richard Stones: Books">Beginning Linux Programming</a></li>
<li><a href="http://www.amazon.co.uk/gp/product/0596529260?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0596529260" title="RESTful Web Services: Amazon.co.uk: Leonard Richardson, Sam Ruby: Books">RESTful Web Services</a></li>
<li><a href="ttp://www.amazon.co.uk/gp/product/1430218096?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=1430218096">Learn C on the Mac</a></li>
<li>and finally: <a href="http://www.amazon.co.uk/gp/product/0321503619?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0321503619" title="Cocoa Programming for Mac OS X: Amazon.co.uk: Aaron Hillegass: Books">Cocoa Programming for Mac OS X</a></li>
</ul>
<p>I do also have a couple of UK-centric business books which I’m slowly attacking, although there is not much point (bar the background reading) to learn about that when I have nothing to execute!</p>
<p><script type="text/javascript">
<!--
h='&#x67;&#x6d;&#x61;&#x69;&#108;&#46;&#x63;&#x6f;&#x6d;';a='&#64;';n='&#110;&#x69;&#x63;&#x6b;&#x63;&#104;&#x61;&#114;&#108;&#116;&#x6f;&#110;&#x39;&#x31;';e=n+a+h;
document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+'You can of course put an idea on a postcard.'+'<\/'+'a'+'>');
// -->
</script><noscript>&#x59;&#x6f;&#x75;&#32;&#x63;&#x61;&#110;&#32;&#x6f;&#102;&#32;&#x63;&#x6f;&#x75;&#114;&#x73;&#x65;&#32;&#112;&#x75;&#116;&#32;&#x61;&#110;&#32;&#x69;&#100;&#x65;&#x61;&#32;&#x6f;&#110;&#32;&#x61;&#32;&#112;&#x6f;&#x73;&#116;&#x63;&#x61;&#114;&#100;&#46;&#32;&#40;&#110;&#x69;&#x63;&#x6b;&#x63;&#104;&#x61;&#114;&#108;&#116;&#x6f;&#110;&#x39;&#x31;&#32;&#x61;&#116;&#32;&#x67;&#x6d;&#x61;&#x69;&#108;&#32;&#100;&#x6f;&#116;&#32;&#x63;&#x6f;&#x6d;&#x29;</noscript></p>
<p>Of course this “lack of ideas” could instead be covering another problem. Instead I may have lost the passion I used to have for simple things that felt worthwhile building. Whether that is a good or bad thing, I’m not sure. Possibly better in the sense that I end up not starting and then stopping projects, but not so great in the sense that in four months I have produced nothing.</p>
<p>Retrospect is a wonderful thing and the last few weeks can be looked back upon with the odd test, only three assignments, and a pretty dodgy sleep pattern for me to look back upon. Don’t get me wrong, University is worth it’s while, however when you feel you are getting nowhere (because it’s too simple), it’s easy to wonder if being somewhere is worth it’s time.</p>
<p>So now, my general week consists of 5/6 lecture slots, sinking my way through some quite heavy books, eventually learning the Guitar and spending just a little too much money. That’s quite a far cry from the last two years. Maybe I shouldn’t complain?</p>]]></summary>
</entry>
<entry>
    <title>Jekyll and GitHub</title>
    <link href="http://nickcharlton.net/posts/jekyll-and-github.html" />
    <id>http://nickcharlton.net/posts/jekyll-and-github.html</id>
    <published>2009-10-05T08:00:00Z</published>
    <updated>2009-10-05T08:00:00Z</updated>
    <summary type="html"><![CDATA[<p>After quite a bit of work, I have finally moved over to using GitHub pages, Jekyll and Markdown to power <a href="http://nickcharlton.net" title="nickcharlton.net">nickcharlton.net</a>.</p>
<p>From now on, this is a Git repository made up of Markdown files and a sprinkling of HTML. This comes with quite a few benefits, those of which I hope to explain below.</p>
<h3 id="versioning-backup">Versioning &amp; Backup</h3>
<p>As it is powered primarily by Git, each post has version tracking without any extra effort. This was recently added to Wordpress, instead of a clean solution, this just turned to make the database even more of a mess than it already was.</p>
<p>Secondly, due to the distributed nature of Git, I always have two copies. One is served up at GitHub, and the other is my working copy stored locally on my main machine. On top of this, other people can fork it, adding more backups.</p>
<h3 id="security-access">Security &amp; Access</h3>
<p>Without the intention of using this primarily as a vehicle for moaning about Wordpress, this is another of it’s issues. Certainly the two most important issues are security and access to the content.</p>
<p>As is typical with any large dynamic project, it’s going to have security issues. This means that new versions of Wordpress are routinely rolled out, this means that you need to keep up-to-date with the latest build to keep your writings safe.</p>
<p>Next, is access of the posts themselves. They’re stored in a MySQL database. This both means that accessing the individual posts requires accessing the database, rather than just opening a file. Opening a flat HTML file will always scale better than a solution which involves reloading the same information from a database on each connection (presuming no caching is used).</p>
<h3 id="the-source">The Source</h3>
<p>You can find the source on <a href="http://github.com/nickcharlton/nickcharlton.github.com">GitHub</a>. Please feel free to reuse any parts which are not posts without attribution. The posts themselves are licensed under a Creative Commons Attribution-Non-Commercial-Share Alike license. You can read more about that in the <a href="http://github.com/nickcharlton/nickcharlton.github.com/blob/master/README.markdown">README</a>.</p>]]></summary>
</entry>
<entry>
    <title>SSH Public Key Screencast Notes</title>
    <link href="http://nickcharlton.net/posts/ssh-public-key-screencast-notes.html" />
    <id>http://nickcharlton.net/posts/ssh-public-key-screencast-notes.html</id>
    <published>2009-09-18T08:00:00Z</published>
    <updated>2009-09-18T08:00:00Z</updated>
    <summary type="html"><![CDATA[<p><em>These are just a few quick notes to accompany <a href="http://vimeo.com/6523718">Peter Upfold’s screencast</a>. If you haven’t ready I would suggest you give it a watch before following this rather brief notes</em></p>
<h2 id="on-the-local-machine">On the local machine</h2>
<ol style="list-style-type: decimal">
<li>run: <code>ssh-keygen -t rsa</code></li>
<li>Accept default path.</li>
<li>Enter a passphrase. (terminal can save this in Keychain)</li>
<li>Finder &gt; Go &gt; Type: “.ssh”</li>
<li>Copy <code>id_rsa.pub</code></li>
</ol>
<h2 id="on-the-remote-machine">On the remote machine</h2>
<ol style="list-style-type: decimal">
<li>run: <code>touch .ssh/authorized_keys</code></li>
<li>Edit the file: <code>.ssh/authorised_keys</code></li>
<li>Paste the contents of the <code>id_rsa.pub</code> file into <code>.ssh/authorized_keys</code></li>
</ol>
<h2 id="permissions-check">Permissions Check</h2>
<ul>
<li>The <code>authorized_keys</code> file needs to be <code>rw</code> for the user.</li>
<li>That is <code>chmod 600</code> to change, if needed.</li>
</ul>
<h2 id="logging-in">Logging in</h2>
<ul>
<li>Login as usual from the Terminal.</li>
<li>When asked for the password to the ssh key, this is the passphrase mentioned earlier.</li>
</ul>
<p><em>Once again, thank you, <a href="http://peter.upfold.org.uk">Peter</a> for recording it for me, and the mention.</em></p>]]></summary>
</entry>
<entry>
    <title>New MacBook Pro</title>
    <link href="http://nickcharlton.net/posts/new-macbook-pro.html" />
    <id>http://nickcharlton.net/posts/new-macbook-pro.html</id>
    <published>2009-09-12T08:00:00Z</published>
    <updated>2009-09-12T08:00:00Z</updated>
    <summary type="html"><![CDATA[<h3 id="intro">Intro</h3>
<p>Yesterday my new MacBook Pro arrived. It’s a 2.66Ghz model with a Matte screen. It really is wonderful. It’s certainly the fastest, and most custom machine I’ve had. Coupled with the <a href="http://nickio.posterous.com/a-few-notes-on-the-apple-education-store" title="A Few Notes on the Apple Education Store - Nick Charlton">Apple Student Discount</a>, it does end up working affordable.</p>
<p>Last night I tested out the power of this machine. There’s various things which I couldn’t do which I now can. Today <a href="http://nickio.posterous.com/macbook-pro-some-photos" title="MacBook Pro: Some Photos - Nick Charlton">I took some photos</a> (ones of the Matte screen are rather thin on the ground).</p>
<h3 id="flash">Flash</h3>
<p>I can play Flash. Especially HD flash, I rather liked watching the HD shorts on Vimeo but this had to come to a halt a while back as I wasn’t able to use it. It got to the point where I couldn’t even use YouTube, so it’s quite a difference.</p>
<p>Last night I watched some iPlayer content in HD - the difference in it not stuttering is quite different.</p>
<p>Interestingly; Flash in Snow Leopard (could have also been before) is now a separate process. So Flash itself uses ~170% CPU, whilst Safari uses &lt;10%.</p>
<h3 id="development">Development</h3>
<p>Development should be faster. I was having lag of minutes at times using TextMate, especially as I typically develop server side using ExpanDrive to aid with using SFTP. This also meant quite a few things have fallen behind where I’d like them, or I haven’t put the effort in where I should. This really was a reflection of my main development environment rather than me, a pain, but now that bottleneck is gone.</p>
<p>So now, hopefully various things will be given a kick up the backside into getting started, finished or otherwise.</p>
<h3 id="in-conclusion">In Conclusion</h3>
<p>All in all, everything is great. Things are slotting together ready for my move over to Plymouth for University. So if you’re around, pop me an email and visit!</p>]]></summary>
</entry>
<entry>
    <title>Public Key Auth Screencast</title>
    <link href="http://nickcharlton.net/posts/public-key-auth-screencast.html" />
    <id>http://nickcharlton.net/posts/public-key-auth-screencast.html</id>
    <published>2009-09-11T08:00:00Z</published>
    <updated>2009-09-11T08:00:00Z</updated>
    <summary type="html"><![CDATA[<p>After a request by <a href="http://twitter.com/nickcharlton/status/3884874880">Peter Upfold</a> on Twitter for ideas for a screencast, I suggested he do something on Public Key Authentication. My wish was made true as he made it up yesterday.</p>
<p class="center"><object width="400" height="300">
<param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6523718&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6523718&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>
</p>

<p>I was rather surprised to hear myself mentioned, so a huge hat tip (presumes a huge hat, I guess…) to Peter for doing that.</p>
<p>Thanks!</p>]]></summary>
</entry>
<entry>
    <title>Configuring Sudo on Debian</title>
    <link href="http://nickcharlton.net/posts/configuring-sudo-on-debian.html" />
    <id>http://nickcharlton.net/posts/configuring-sudo-on-debian.html</id>
    <published>2009-06-26T08:00:00Z</published>
    <updated>2009-06-26T08:00:00Z</updated>
    <summary type="html"><![CDATA[<p>Setting up sudo on Debian can seem daunting at first, but the process is really quite simple.</p>
<p>To do this you must use the command “visudo”. Whilst you do not need to use “vi/vim” to do the actual editing (as it will use your preferred editor as listed in .bashrc), you will not be able to save changes.</p>
<p>From here you will see the config file. Under “# User alias specification” you will want to list the users required to access. You can comma separate values here.</p>
<pre><code># User alias specification
User_Alias STAFF nickcharlton, otheruser</code></pre>
<p>Next, although optional, it is possible to specify the applications that the user can run.</p>
<pre><code># Cmnd alias specification
Cmnd_Alias DEB = /usr/bin/apt-get</code></pre>
<p>Similarly, this section can be comma separated. On a system where it’s users can be trusted at a higher level, it’s not important to drill down tightly on these.</p>
<p>Next, you need to allow access under the “# User privilege specification”. Where no commands have been specified it is appropriate to simply duplicate that of the root user.</p>
<pre><code># User privilege specification
root ALL=(ALL) ALL
MAINTAINERS ALL = DEB
STAFF ALL-(ALL) ALL</code></pre>
<p>And that’s it. Another simple task, which at first can seem a little daunting.</p>
<p><em>Sources: <a href="http://newbiedoc.berlios.de/wiki/How_to_configure_Sudo_to_run_programs_as_a_different_user">NewbieDoc: Configuring Sudo to Run Programs as Another User</a></em></p>]]></summary>
</entry>
<entry>
    <title>Configuring an SSH banner on Debian</title>
    <link href="http://nickcharlton.net/posts/ssh-banner-debian.html" />
    <id>http://nickcharlton.net/posts/ssh-banner-debian.html</id>
    <published>2009-06-24T08:00:00Z</published>
    <updated>2009-06-24T08:00:00Z</updated>
    <summary type="html"><![CDATA[<p>Configuring a “Welcome Banner” is a great way to notify your users about the machine they are about to login to. I personally use this to inform the user of the IP, Hostname, OS version and someone to contact.</p>
<p>Edit the file under “/etc/motd”.</p>
<p>Change this to something informative such as the below:</p>
<pre><code>========================================
=         Welcome to Hitchcock         =
=  IP: 10.10.10.10                     =
=  Hostname: hitchcock.example.com     =
=  OS: Debian 5.01/Lenny               =
========================================</code></pre>
<p>Just a short one this, but useful to know.</p>]]></summary>
</entry>
<entry>
    <title>Introduction to SQLite 2 with PHP 5</title>
    <link href="http://nickcharlton.net/posts/introduction-to-sqlite-2-with-php-5.html" />
    <id>http://nickcharlton.net/posts/introduction-to-sqlite-2-with-php-5.html</id>
    <published>2009-05-18T08:00:00Z</published>
    <updated>2009-05-18T08:00:00Z</updated>
    <summary type="html"><![CDATA[<p>Where a full <acronym title="Relational Database Management System">RDBMS</acronym> is unnecessary, <a href="http://www.sqlite.org/">SQLite</a> provides the perfect stand in. However, most articles are based around the Object-Orientated way of dealing with SQLite in PHP. This article provides an explanation of how to use it procedurally.</p>
<h3 id="points">Points</h3>
<p>A couple of things to note before going ahead and using SQLite are that:</p>
<ul>
<li>The directory and the database need to be writable from the web server.
</li></li>
<li>As it is simply a flatfile, this should be stored where it cannot be accessed by browsers.</li>
<li>Where an “auto_increment” field is used in MySQL, it should be created by specifying “INTEGER PRIMARY KEY” when configuring the table. This is further explained later.</li>
</ul>
<h3 id="opening-a-sqlite-db">Opening a SQLite DB</h3>
<p>Opening an SQLite Database is quite simple. The “sqlite_open” function is assigned to a variable which is then used to indicate that database later on in queries. If the database does not already exist then it will be created upon opening.</p>
<p>The file extension need not be .db, it may be anything, or even have none. The directory which is referenced should be both outside of the web root and writable by the server user. On Debian Etch with Apache, the user is “www-data”.</p>
<pre><code>$db = sqlite_open(&quot;../db/name.db&quot;);</code></pre>
<h3 id="creating-a-table">Creating a table</h3>
<p>Before data can be written or read to a Database, a table needs to be created to hold it. The the line below runs a CREATE query which describes the table which will be created. Whilst I do not wish to explain how to use SQL in this article, the following creates a table with two fields, one (called “id”) which automatically increments in regards to it’s value and is set as a primary key and the second, called “name” containing text of up to 255 characters. The table itself is called “example”. The <a href="http://www.sqlite.org/lang.html">SQLite Documentation</a> provides a good guide behind the syntax.</p>
<pre><code>sqlite_query($db, &quot;CREATE TABLE example (id INTEGER PRIMARY KEY, name CHAR(255))&quot;);</code></pre>
<h3 id="inserting-data">Inserting data</h3>
<p>To insert data, the “sqlite_query” function is used which specifies the database in the first part, and then the query behind it.</p>
<p>The query in this example inserts the name “Nick” into the field “name” in the table “example”. As the field “id” auto increments, it is not necessary to specify a value for it.</p>
<pre><code>sqlite_query($db, &quot;INSERT INTO example (name) VALUES (&#39;Nick&#39;)&quot;);</code></pre>
<h3 id="querying-data">Querying data</h3>
<p>The following line would fetch all of the data in the table “example” and display it as a “printed array”.</p>
<pre><code>$result = sqlite_query($db, &quot;SELECT * FROM table&quot;);
while ($row = sqlite_fetch_array($result)) {
	echo &quot;&lt;pre&gt;&quot;;
	print_r($row);
	echo &quot;&lt;/pre&gt;&quot;;
}</code></pre>
<p>On an alternative note, such a method can be used to see the contents of a query and check the names of fields, at least in development.</p>
<h3 id="further-reading">Further Reading</h3>
<p>Whilst this article focuses on the procedural method built into PHP 5 (which incidentally is limited to SQLite 2), SQLite can also be accessed through <acronym title="PHP Data Objects">PDO</acronym> and through the Object Orientated Method.</p>
<ul>
<li><a href="http://php.net/sqlite">PHP Manual: SQLite</a></li>
<li><a href="http://www.devshed.com/c/a/PHP/Introduction-to-Using-SQLite-with-PHP-5/">Object Orientated SQLite, Devshed</a></li>
<li><a href="http://devzone.zend.com/article/863">SQLite 3 with PDO, Zend DevZone</a></li>
</ul>]]></summary>
</entry>
<entry>
    <title>Installing Ubuntu 9.04 on an SD card</title>
    <link href="http://nickcharlton.net/posts/ubuntu-on-sdcard.html" />
    <id>http://nickcharlton.net/posts/ubuntu-on-sdcard.html</id>
    <published>2009-05-08T08:00:00Z</published>
    <updated>2009-05-08T08:00:00Z</updated>
    <summary type="html"><![CDATA[<p><strong>Note: This article is quite old. It probably doesn’t apply anymore. Your mileage may vary.</strong></p>
<p>
To to this I used a <a href="http://www.amazon.co.uk/gp/product/B000WQKOQM?ie=UTF8&amp;tag=nisbl-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=B000WQKOQM">SanDisk 4GB SDHC card which can be bought for around £6/$9</a>. Better performance could be gained from using a faster card. However, for the most part this card is quite acceptable.
</p>

<p>
<em>Note: Solid state memory (such as SD cards) generally has a limited amount of writes that can be possibly made to it. This means that the card used will not last forever.</em>
</p>

<h2>
Step 1
</h2>

<p>
The first step is to prepare the tools you need and boot from the installation media.
</p>

<ul>
	<li>
Ubuntu 9.04 Desktop ISO image
</li>
	<li>
A CD or thumb drive (to install the image from)
</li>
	<li>
SanDisk 4GB SDHC Card
</li>
	<li>
A machine to try it on
</li>
</ul>

<h2>
Step 2
</h2>

<p>
I chose to first boot into the live environment and run the installer from there. Whilst I have had bad experiences using CD drives for such a procedure, booting off a thumb drive is quite acceptable.
</p>

<p>
Next, start the install.
</p>

<h2>
Step 3
</h2>

<p>
When you reach the partitioning stage you will need to select the SD card, rather than the hard drive. On my system (an HP (2133) Mini) this appeared as “/dev/sdc” as a SCSI device.
</p>

<p>
The naming of the device will vary per system, so could show up as hdc (if it is on an IDE controller) or in another manner.
</p>

<p>
<img class="post" src="http://nickcharlton.net/uploads/ubuntu-sd-install-partitoner.png" alt="Ubuntu Installer: Partitioner" width="450" height="350" />
</p>

<h2>
Finally
</h2>

<p>
Once that is finished all that is required is to boot the system. You could set this in the bios to boot first, in which case it’d boot if an external drive is inserted first, or pick at boot time.
</p>

<h2>
Some Notes
</h2>

<ul>
	<li>
Overall, Ubuntu 9.04 used 2GB (or 50%) of my 2GB drive.
</li>
	<li>
Issues: When suspending I noticed that it would not be able to mount the disk, and thus fail.
</li>
</ul>


]]></summary>
</entry>
<entry>
    <title>Using 'ab', ApacheBench to test Web Server Performance</title>
    <link href="http://nickcharlton.net/posts/using-apachebench.html" />
    <id>http://nickcharlton.net/posts/using-apachebench.html</id>
    <published>2009-04-05T08:00:00Z</published>
    <updated>2009-04-05T08:00:00Z</updated>
    <summary type="html"><![CDATA[<p>
ApacheBench (referred to as ‘ab’ in the terminal) is a tool for testing web server performance by allowing you to test how long a set of requests per second the web server is capable of serving.
</p>

<p>
Whilst this does not reflect a model of real world usage, it can aid in the tweaking and performance improvement of the Web Server itself.
</p>

<p>
This tool is of course aimed at testing Apache servers, however it can be used on others.
</p>

<h2>
Usage
</h2>

<p>
Usage is rather simple. At it’s core, the amount of requests to complete and the url to test are required. On top of this you may inform the application to carry out more than one request at a time, as show in the second example.
</p>

<pre LANG="Bash">
   $ ab -n 100 http://domain/

   $ ab -n 100  -c 3 http://domain/
</pre>

<p>
When this is run the specified web page is downloaded and the time taken for it to happen is measured.
</p>

<h2>
Some Results
</h2>

<p>
These are the results I gained from running this against the server behind this, testing using 3 concurrent connections and 100 requests.
</p>

<pre lang="Bash">
$ ab -n 100 -c 3 http://nickcharlton.net/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking nickcharlton.net (be patient).....done


Server Software:        Apache/2.2.3
Server Hostname:        nickcharlton.net
Server Port:            80

Document Path:          /
Document Length:        34350 bytes

Concurrency Level:      3
Time taken for tests:   13.371 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      3471900 bytes
HTML transferred:       3435000 bytes
Requests per second:    7.48 [#/sec] (mean)
Time per request:       401.120 [ms] (mean)
Time per request:       133.707 [ms] (mean, across all concurrent requests)
Transfer rate:          253.58 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       27  135 160.8     87    1295
Processing:    65  257 562.0    140    5108
Waiting:       31  149 169.3    105    1297
Total:        104  392 617.4    254    5483

Percentage of the requests served within a certain time (ms)
  50%    254
  66%    317
  75%    348
  80%    510
  90%    776
  95%    920
  98%   2311
  99%   5483
 100%   5483 (longest request)
</pre>

<h2>
Limitations
</h2>

<p>
ApacheBench does not however give you a figure to suggest how many requests a server may complete, or reflect the usage which will be shown with a real set of users. This is because any given page or application may consist of many requests
</p>

<h2>
What to do with the Results?
</h2>

<p>
The results which you gain are specifically useful in tweaking settings regarding the web server itself. Whilst ApacheBench cannot directly tell you what needs tweaking, once you start changing settings you can realise what is best for your server.
</p>

<p>
<em>My thanks go out to <a href="http://blog.init.hr/">Ante</a> for helping me improve this post, clearing up mistakes and ensuring that the right information was being given. This post has been slightly edited since it’s original posting.</em>
</p>


]]></summary>
</entry>
<entry>
    <title>DNS Testing Tools</title>
    <link href="http://nickcharlton.net/posts/dns-testing-tools.html" />
    <id>http://nickcharlton.net/posts/dns-testing-tools.html</id>
    <published>2009-02-25T08:00:00Z</published>
    <updated>2009-02-25T08:00:00Z</updated>
    <summary type="html"><![CDATA[<p>
When working with DNS, it can be a painful experience. From the time it takes for the root servers to update with your new records to simple mistakes made when working with large zone files. Here I explain six tools which can help route out DNS problems using the terminal. All of these work out of the box on OSX.
</p>

<h2>
nslookup
</h2>

<p>
nslookup is used to pull up the basic information associated with a domain. Using nslookup is as simple as providing the following arguments:
</p>

<pre lang="Bash">$ nslookup nickcharlton.org.uk</pre>

<p>
A likely response could be similar to the following:
</p>

<pre lang="Bash">Server:		208.67.222.222
Address:	208.67.222.222#53

Non-authoritative answer:
Name:	nickcharlton.org.uk
Address: 78.86.198.208</pre>

<p>
This response tells you the nameserver which was queried, in this case one of those of OpenDNS which I use at home and the response from the name server when it was queried. The last IP is that of my server.
</p>

<h2>
dig
</h2>

<p>
Dig is a most useful tool, it officially stands for Domain Information Gopher and allows you to pull the data from the name server just as your machine would in taking a request. This allows you to pull the public records for the domain.
</p>

<pre lang="Bash">$ dig nickcharlton.org.uk</pre>

<pre lang="Bash">
<<>> DiG 9.4.2-P2 <<>> nickcharlton.org.uk
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4635
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;nickcharlton.org.uk.		IN	A

;; ANSWER SECTION:
nickcharlton.org.uk.	603718	IN	A	78.86.198.208

;; Query time: 19 msec
;; SERVER: 208.67.222.222#53(208.67.222.222)
;; WHEN: Sat Feb 21 03:49:25 2009
;; MSG SIZE  rcvd: 53

</pre>

<p>
What can be taken from here is the A record for the domain. That is the record which takes a domain and points it to the IP of the remote machine.
</p>

<h2>
dig (with @IP/Domain)
</h2>

<p>
Whilst not strictly a tool within it’s own right, it is different from it’s basic no arguments call. This allows you to pull records from a specific server, which is useful for testing the records from a new server before it is live. An example is provided below, and would be used if pulling records from a local server:
</p>

<pre lang="Bash">$ dig @localhost nickcharlton.org.uk</pre>

<p>
And it’s response:
</p>

<pre lang="Bash">
; <<>> DiG 9.4.2-P2 <<>> @kubrick.nickcharlton.org.uk nickcharlton.org.uk
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63435
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;; QUESTION SECTION:
;nickcharlton.org.uk.		IN	A

;; ANSWER SECTION:
nickcharlton.org.uk.	604800	IN	A	78.86.198.208

;; AUTHORITY SECTION:
nickcharlton.org.uk.	604800	IN	NS	ns1.nickcharlton.org.uk.
nickcharlton.org.uk.	604800	IN	NS	ns2.nickcharlton.org.uk.
;; ADDITIONAL SECTION:
ns1.nickcharlton.org.uk. 10800	IN	A	92.243.13.80
ns2.nickcharlton.org.uk. 10800	IN	A	78.86.198.208
;; Query time: 27 msec
;; SERVER: 92.243.13.80#53(92.243.13.80)
;; WHEN: Sat Feb 21 03:50:44 2009
;; MSG SIZE  rcvd: 121
</pre>

<p>
Note the increase in the details of the records. I’m not entirely sure why this happens, so if you could enlighten me, please do. (Also note that the appropriate call I used was towards my server directly, and not local host, as I don’t have a DNS server here.)
</p>

<h2>
rndc
</h2> 

<p>
This tool allows you to deal with your current DNS settings. The most commonly use argument of this is “reload” and that allows you to flush, or reload your DNS settings so that they are all fresh.
</p>

<pre lang="Bash">$ rndc reload</pre> 

<h2>
host
</h2>

<p>
Host translates IP’s from domains and vice versa. This is what happens when you query a domain, you get an IP response. It can also be used backwards.
</p>

<pre lang="Bash">$ host nickcharlton.org.uk</pre>

<pre lang="Bash">
nickcharlton.org.uk has address 78.86.198.208
nickcharlton.org.uk mail is handled by 20 fb.mail.gandi.net.
nickcharlton.org.uk mail is handled by 10 spool.mail.gandi.net.
</pre>

<h2>
whois
</h2>

<p>
Last there is whois. This is obviously the most well known of the lot and provides ownership information for the domain. I will not provide an example here, as it will be very long, but this is simply used as below:
</p>

<pre lang="Bash">$ whois nickcharlton.org.uk</pre>


]]></summary>
</entry>
<entry>
    <title>Converting a sparseimage to a dmg</title>
    <link href="http://nickcharlton.net/posts/converting-a-sparseimage-to-a-dmg.html" />
    <id>http://nickcharlton.net/posts/converting-a-sparseimage-to-a-dmg.html</id>
    <published>2008-11-01T07:00:00Z</published>
    <updated>2008-11-01T07:00:00Z</updated>
    <summary type="html"><![CDATA[<p>The process of converting from one type of disk image to another is usually handled by the software created by it. However on the other hand, if you don’t have enough HD space when say, running a full Carbon Copy Cloner backup of your machine, you may elect to instead just produce an uncompressed sparseimage.</p>
<p>The process for doing this is quite easy and logical, but not so easy to remember.</p>
<pre><code>hdiutil convert -format UDZO Source.sparseimage -o Output.dmg</code></pre>
<p>The process will of course take quite a while, but you will be provided with a simple “..” style progress bar.</p>
<p><code>hdutil</code> is also SMP aware, so it can use more than one CPU. This not only faster, but will also hammer your machine. With this reason in mind, I’m not sure if it would be wise to run it with a low process number, if you are planning on doing a lot at the same time, maybe this would be a good idea.</p>]]></summary>
</entry>
<entry>
    <title>Setting Up lm-sensors on Debian Etch</title>
    <link href="http://nickcharlton.net/posts/setting-up-lm-sensors-on-debian-etch.html" />
    <id>http://nickcharlton.net/posts/setting-up-lm-sensors-on-debian-etch.html</id>
    <published>2008-06-24T08:00:00Z</published>
    <updated>2008-06-24T08:00:00Z</updated>
    <summary type="html"><![CDATA[<p>lm-sensors is a package which provides temperature monitoring under Linux. This guide explains how to setup lm-sensors under Debian Etch.</p>
<p>To install it under Debian, use:</p>
<pre><code>apt-get install lm-sensors</code></pre>
<p>Although there are other pre-requisites, a default install of Etch will work quite nicely.</p>
<p>Next, you need to load the i2c-dev module. This allows you to access some of the chips on your motherboard which are hooked up to temperature sensors.</p>
<pre><code>modprobe i2c-dev</code></pre>
<p>Now you need to detect the sensors on your system using the wizard in the following command. I just stack to the defaults.</p>
<pre><code>sensors-detect</code></pre>
<p>At the end of this you will be told a list of devices, these need to be loaded too, as an example:</p>
<pre><code>modprobe -a i2c-viapro i2c-isa eeprom w83627hf</code></pre>
<p>By loading the:</p>
<pre><code>sensors</code></pre>
<p>app you will be thrown at with a list of devices, it will also tell you some voltages, however for me the CPU temp, fan sped, and system temperature.</p>
<p>Hard Disk temperature can also be watched, this is slightly easier however as you simply need to install hddtemp and specify the drives.</p>
<pre><code>apt-get install hddtemp

hddtemp /dev/hd?</code></pre>
<p>if your system sees your drives as SCSI, or you have SCSI drives that is…</p>
<p><em>Produced in aid of: <a href="http://www.debian-administration.org/articles/327">http://www.debian-administration.org/articles/327</a></em></p>]]></summary>
</entry>

</feed>
