<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Michael Duerinckx</title>
	<atom:link href="http://michd.me/feed/" rel="self" type="application/rss+xml" />
	<link>http://michd.me</link>
	<description>Web developer, music and electronics enthusiast</description>
	<lastBuildDate>Thu, 06 Jun 2013 14:29:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Embedding a player on Facebook: A guide</title>
		<link>http://michd.me/blog/embedding-a-player-on-facebook/</link>
		<comments>http://michd.me/blog/embedding-a-player-on-facebook/#comments</comments>
		<pubDate>Thu, 30 May 2013 10:50:42 +0000</pubDate>
		<dc:creator>Mich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Embed]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Open Graph]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://michd.me/?p=745</guid>
		<description><![CDATA[I talk through setting up a player that gets embedded on Facebook feeds when your webpage is linked to. From ActionScript to meta tags and SSL.]]></description>
			<content:encoded><![CDATA[<p>Last weekend I had a mission: to build a player component for <a title="Shameless plug" href="http://instaud.io">instaud.io</a> that could play audio people linked to, right in Facebook news feeds. I found that there are plenty of excerpts on how to go about this, but most of them are based on outdated links to Facebook developer documentation. It bugged me greatly that Facebook didn&#8217;t bother setting up redirects to relevant pages after restructuring their docs.</p>
<p>Anyway, I think this would work best as a step by step guide. I&#8217;ll go through the steps I&#8217;ve had to learn about; you may want to skip over some if you&#8217;re already know what you&#8217;re doing in them.</p>
<h2 id="build-your-player">1. Build your player in Flash</h2>
<p>I downloaded the Adobe Flash trial for this. You&#8217;ll want to create a stage that is not much wider than 500 pixels. I went with 504px. What you&#8217;re going to be playing depends entirely on you. My purpose was simply to play audio files (MP3s), so I used <code>Sound</code> and <code>SoundChannel</code> to control that. The audio file to be played was requested with an <code>URLRequest</code> object.</p>
<p>If you want a more thorough introduction on how to set up a simple sound player, this video from 2008 is still a good starting point, even with the latest version of Flash (12, CS6):  <a href="http://www.youtube.com/watch?v=Q6N8EpNYU5o" target="_blank">Build Simple Sound Player: Flash Tutorial AS 3.0</a></p>
<h3 id="using-parameters">Using parameters</h3>
<p>The important part about the ActionScript is using parameters. Parameters will be passed to the eventual SWF through the querystring, that is, the bold part in this URL: <code>http://example.com/my-player.swf<strong>?param=value&amp;otherparam=value</strong></code></p>
<p>In ActionScript (3), you can access these variables the following way:</p>
<pre class="brush: as3">loaderInfo.parameters.parameterName</pre>
<p>To check if a parameter is actually present:</p>
<pre class="brush: as3">loaderInfo.parameters.hasOwnProperty('parameterName')</pre>
<p>This way you can use default values for parameters:</p>
<pre class="brush: as3">var myParam = loaderInfo.parameters.hasOwnProperty('myParam') ?
    loaderInfo.parameters.myParam :
    'defaultValue';</pre>
<p>Since <code>hasOwnProperty</code> returns a boolean value (<code>true</code> or <code>false</code>), this statement assigns either the value of <code>myParam</code> from the querystring, or <code>'defaultValue'</code> if no such parameter was specified, to the <code>myParam</code> variable. It uses a <a href="http://en.wikipedia.org/wiki/%3F:">ternary operator</a>.</p>
<h2 id="include-swf">2. Export the SWF file and include it in your website&#8217;s assets</h2>
<p>This is fairly straightforward. You&#8217;ll want the swf to live someplace where it&#8217;s directly accessible. I let mine live in the document root directory.</p>
<h2 id="add-open-graph-meta-tags">3. Add Open Graph meta tags to the page</h2>
<p>This is where the Facebook magic happens.
<p>
<span id="more-745"></span></p>
<p>Facebook will read this Open Graph data when your page is being linked to, and extract the Flash file for embedding. These are the ones you will need:</p>
<h3 id="og-video">og:video</h3>
<p>Full URL to the SWF file, including parameters for this page:</p>
<pre class="brush: html">&lt;meta property="og:video" value="http://example.com/your-player.swf?param=value&amp;otherparam=othervalue"&gt;</pre>
<h3 id="og-video-width-og-video-height">og:video:width, og:video:height</h3>
<p>Specify the dimensions of your Flash movie:</p>
<pre class="brush: html">&lt;meta property="og:video:width" content="504"&gt;
&lt;meta property="og:video:height" content="115"&gt;</pre>
<h3 id="og-video-type">og:video:type</h3>
<p>The mime type of the file:</p>
<pre class="brush: html">&lt;meta property="og:video:type" content="application/x-shockwave-flash"&gt;</pre>
<h3 id="og-url">og:url</h3>
<p>Something that might be optional, but is highly recommended:</p>
<pre class="brush: html">&lt;meta property="og:url" content="Canonical URL to this page"&gt;</pre>
<p>The canonical URL is the best URL to reach this piece of content on your website. (In case there are multiple URLs that get you there.)</p>
<p>I&#8217;d advise you to go read more on <a href="http://ogp.me/" target="_blank">The Open Graph Protocol</a>, as well as having a read through <a href="http://davidwalsh.name/facebook-meta-tags" target="_blank">David Walsh&#8217;s article on Open Graph meta tags</a> for more magic you can implement with these.</p>
<h2>4. Set up SSL (sort of optional)</h2>
<p>The one catch about embedding stuff on Facebook is https. Many users are browsing Facebook with &#8220;secure browsing&#8221; on by default. The result is that your Flash component won&#8217;t get loaded if it doesn&#8217;t live at an <code>https://</code> URL as well.</p>
<p>If you have an SSL certificate installed for your domain, you can make your Flash embed work for https users as well, by simply adding the following meta tag:</p>
<pre class="brush: html">&lt;meta property="og:video:secure_url" property="https://example.com/your-player.swf?param=value&amp;otherparam=othervalue"&gt;</pre>
<p>If you need help setting up SSL, you can consult Linode&#8217;s library, they have a lot of useful documentation.</p>
<ul>
<li><a href="https://library.linode.com/security/ssl-certificates/commercial" target="_blank">Obtaining a Commercial SSL certificate</a> explains how to do the server-side portion of setting up your certificate and key.</li>
<li><a href="https://library.linode.com/web-servers/nginx/configuration/ssl" target="_blank">SSL certificates with Nginx</a> explains that too, as well as how to use it with your Nginx configurations.</li>
<li><a href="https://library.linode.com/web-servers/apache/ssl-guides" target="_blank">Apache SSL Guides</a> lists articles for various operating systems, on how to set SSL up with Apache.</li>
</ul>
<p>I hope that makes it a bit easier for people who want to get this stuff implemented in the future. I definitely had a hard time googling it all together.</p>
]]></content:encoded>
			<wfw:commentRss>http://michd.me/blog/embedding-a-player-on-facebook/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Event-driven JavaScript: a simple event dispatcher</title>
		<link>http://michd.me/blog/event-driven-javascript-a-simple-event-dispatcher/</link>
		<comments>http://michd.me/blog/event-driven-javascript-a-simple-event-dispatcher/#comments</comments>
		<pubDate>Sun, 14 Apr 2013 20:58:26 +0000</pubDate>
		<dc:creator>Mich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[callback]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://michd.me/?p=728</guid>
		<description><![CDATA[Event-driven programming is a powerful way to keep sane in bigger projects. I explain a simple event dispatcher in JavaScript and how to use it in your modules.]]></description>
			<content:encoded><![CDATA[<p>One of the more valuable lessons that I&#8217;ve learned in the years I&#8217;ve been programming is that loose coupling will make your life better. A very good way to achieve loose coupling in your projects is by dividing functionality in self-sufficient modules that communicate merely by subscribing to and triggering events. To work with these events, you need one component that is relatively tightly coupled with all your modules. This little bit of coupling is definitely worth it though.</p>
<p>Before diving into specifics, let&#8217;s talk about just what I mean.</p>
<h2 id="loose-coupling">Loose coupling</h2>
<p>When the code base for a project gets sizeable, one thing that can make it a nightmare to work with is tight coupling. When modules are tightly coupled in a project, it means that changing one method in module A may require you to change the way certain things are implemented in module D, F and G.  In order to make any modifications, you need to be well aware of how other modules rely on the module you wish to modify.</p>
<p>Since having a single module in your head can be taxing enough for the mind, considering basically the whole project when making a local change is awful; oversights are bound to occur. </p>
<p>To ensure you do not need to wrap your head around the entire code base at all time, you&#8217;ll want to make sure your modules are loosely coupled. You can safely change the modules&#8217; internals without having to worry about how other modules have to interact with this module. You need to consciously engineer your modules to be entirely agnostic of the inner workings of others.</p>
<p>You&#8217;ll find that employing this method makes it much less of a daunting task to change some functionality around.</p>
<h2 id="bring-on-event-driven-programming">Bring on event-driven programming</h2>
<p>Event-driven programming is a fairly simple pattern where component subscribe to events and trigger them. A variant of the pattern is the observer pattern; the difference however lies in where the event dispatching happens.</p>
<p>In an observer pattern, you can register observers (subscribers) to event a certain module emits. This way you can subscribe to, for example, an after-save event, which is emitted every time an object&#8217;s data is saved. The observer subscribing to this event will be triggered every time that happens, and a function can then be run.</p>
<p>In this case, we move the subscribing facilities away from the modules to a dedicated event dispatcher module. This provides one central location where modules sign up to be notified when a certain event occurs, as well as where modules go to broadcast an event they want to make the application aware of. </p>
<p>Doing this, all each module is concerned with if it comes to communicating with the rest of the application is 2 uniform things: Emitting events and responding to events emitted elsewhere. The modules do their thing, throw out some information whenever there is something that may concern the rest of the application, and they remain alert for external events pertaining to the module in question.</p>
<h2 id="responsibilities-of-the-event-dispatcher">Responsibilities of the event dispatcher</h2>
<p>The event dispatcher module that drives this whole pattern has only few responsibilities:</p>
<ul>
<li>Keeping track of event subscriptions</li>
<li>Dispatching incoming events to all the subscribers of that event</li>
</ul>
<p><span id="more-728"></span><br />
<h2 id="implementing-an-event-dispatcher-in-javascript">Implementing an event dispatcher in JavaScript</h2>
<p>A really useful feature of JavaScript is that functions are objects, which can be passed around like any other object can. You can therefore pass functions as parameters to other functions, often referred to as callback functions.</p>
<p>Callback functions are functions that will be called after certain execution is finished. In this case, we will be calling back functions when certain events occur.</p>
<p>Our event dispatcher object will need at least two publicly accessible functions: <code>subscribe(eventName, callback)</code> and <code>trigger(eventName, data)</code>.</p>
<p>These subscribe and trigger functions will work with a shared subscribers object, which will be a hash of event names and arrays with callback functions. A subscription list could look like this:</p>
<pre id="subscription-list-example" class="brush: js">{
	"PostSaved": [
		callbackFunction,
		callbackFunction,
		callbackFunction
	],

	"PostDeleted": [
		callbackFunction
	]
}</pre>
<p>The <code>subscribe</code> function takes an event name and a callback function. It will have to first find out whether or not there are any existing subscribers for this event, or if it needs to start a new list to add to. Then the callback function gets added to the array associated with the event name.</p>
<p><code>eventSubscriptions</code> is an object like the example above, declared outside the subscribe function.</p>
<pre id="subscribe-function-example" class="brush: js">function subscribe(eventName, callback) {
  // Retrieve a list of current subscribers for eventName (if any)
  var subscribers = eventSubscriptions[eventName];

  if (typeof subscribers === 'undefined') {
    // If no subscribers for this event were found,
    // initialize a new empty array
    subscribers = eventSubscriptions[eventName] = [];
  }

  // Add the given callback function to the end of the array with
  // eventSubscriptions for this event.
  subscribers.push(callback);

}</pre>
<p>Comparing the type of <code>eventSubscribtions[eventName]</code> (<code>subscribers</code>) with undefined lets us find out whether this event was subscribed to before. If that isn&#8217;t the case, a new array is created at this location, with the <code>[]</code> syntax.</p>
<p>Then we simply push the function <code>callback</code> onto the end of this array.</p>
<p>The <code>trigger</code> function will iterate over this array of callbacks, and call each function with passed data as arguments:</p>
<pre id="trigger-function-example" class="brush: js">function trigger(eventName, data, context) {
  var
    // Retrieve a list of subscribers for the event being triggered
    subscribers = eventSubscriptions[eventName],
    i, iMax;

  if (typeof subscribers === 'undefined') {
    // No list found for this event, return early to abort execution
    return;
  }

  // Ensure data is an array or is wrapped in an array,
  // for Function.prototype.apply use
  data = (data instanceof Array) ? data : [data];

  // Set a default value for `this` in the callback
  context = context || App;

  for (i = 0; iMax = subscribers.length; i += 1) {
    subscribers[i].apply(context, data);
  }
}</pre>
<p>Once again we check whether there are any subscribers for this particular event. If there are none, execution of trigger is halted through an early return.</p>
<p>For the <code><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/apply" title="MDN entry on Function.prototype.apply">Function.prototype.apply</a></code> function, we need our data to be an array. The value is either wrapped in an array, or left as is, if it already was an array.</p>
<p><code>Function.prototype.apply</code> allows passing an object to be bound to <code>this</code> inside the <code>callback</code> function. This is referred to as <code>context</code> in the parameters of <code>trigger</code>. The parameter is made optional by defaulting to <code>App</code>, which is an object declared outside this function&#8217;s scope. I use <code>App</code> as the general namespace for my application, which will be clearer in the full example.</p>
<p>After that preparation is done, we iterate over the <code>subscribers</code> list with a simple <code>for</code> loop, and apply the context (<code>this</code>) and <code>data</code> parameter to every callback function that was subscribed to this event.</p>
<p>The end result could look something like this, as an object in the <code>App</code> namespace:</p>
<pre id="eventdispatcher-example" class="brush: js">(function (App) {
  "use strict";

  var eventSubscriptions = {};

  App.eventDispatcher = {

    subscribe: function (eventName, callback) {
      // Retrieve a list of current subscribers for eventName (if any)
      var subscribers = eventSubscriptions[eventName];

      if (typeof subscribers === 'undefined') {
        // If no subscribers for this event were found,
        // initialize a new empty array
        subscribers = eventSubscriptions[eventName] = [];
      }

      // Add the given callback function to the end of the array with
      // eventSubscriptions for this event.
      subscribers.push(callback);
    },

    trigger: function (eventName, data, context) {

      var
        // Retrieve a list of subscribers for the event being triggered
        subscribers = eventSubscriptions[eventName],
        i, iMax;

      if (typeof subscribers === 'undefined') {
        // No list found for this event, return early to abort execution
        return;
      }

      // Ensure data is an array or is wrapped in an array,
      // for Function.prototype.apply use
      data = (data instanceof Array) ? data : [data];

      // Set a default value for `this` in the callback
      context = context || App;

      for (i = 0; iMax = subscribers.length; i += 1) {
        subscribers[i].apply(context, data);
      }
    }
  };
}(this.AppNamespace));</pre>
<p>Assuming every module in your App has a similar closure wrapped around it, you can then access the event dispatcher from anywhere through <code>App.eventDispatcher</code>.</p>
<h2 id="implementing-the-event-dispatcher-in-your-modules">Implementing the event dispatcher in your modules</h2>
<p>I start the closure of a module with a shorthand reference to the event dispatcher, usually simply <code>events</code>. I make a habit of grouping the subscribe calls together on bottom of the module, after all internal functions have been declared and whatnot. This gives you a single point of control to manage the event subscriptions in the module.</p>
<p>Event triggers, however, will be strewn through the functionality of the module, wherever they&#8217;re appropriate. It helps to add a <code>@triggers eventName</code> to the doc-blocks of your functions to more easily see what events are being triggered in them.</p>
<p>A quick example will make this much clearer:</p>
<pre id="module-example" class="brush: js">// Transport UI module for a music player
(function (App) {
  "use strict";

  // Local reference to the dispatcher
  var events = App.eventDispatcher;

  function playStarted() {
    // Update the UI to indicate the player is playing
  }

  function stopped() {
    // Update UI to indicate player is stopped
  }

  /**
   * Skip the current track and play the next one
   * @triggers UI.Transport.SkipTrack
   */
  function skipTrack() {
    events.trigger('UI.Transport.SkipTrack');
  }

  /**
   * Volume was changed through the interface, trigger event
   * @triggers UI.Transport.SetVolume
   */
  function setVolume(vol) {
    events.trigger('UI.Transport.SetVolume', vol);
  }

  // Subscribe to external events
  events.subscribe('Player.PlayStarted', playStarted);
  events.subscribe('Player.Stopped', stopped);

}(this.AppNamespace));</pre>
<p>As you can see, it&#8217;s rather simple to work with. For passing callback functions, I&#8217;ve simply specified the name of functions declared earlier, however, you can of course write them as anonymous functions right in the subscribe call:</p>
<pre class="brush: js">events.subscribe('UI.Transport.SetVolume', function (newVolume) {
  // Code to set the volume in the core player
});</pre>
<h2 id="stupidly-simple-and-effective-debugging">Stupidly simple and effective debugging</h2>
<p>If an application does all its inter-module communication through this event dispatcher object, it becomes very easy to debug. When I was working on my project, I found that most of the bugs I encountered were related to inter-module communication, as I could properly focus on what happened inside each module. After adding some simple logging facilities to the event dispatcher I could easily trace the majority of bugs back to miss-spelling an event name and forgetting to trigger events some modules were subscribed to.</p>
<p>I added some simple logging to the trigger function; it lets me know whenever an event is triggered, and to how many callback functions it is being dispatched. The clever part here is that it can also let you know if there are no subscribers for the event being triggered. </p>
<p><em>If a tree falls in a forest and no one is around to hear it, does it make a sound?</em> Spoiler: It doesn&#8217;t, since the <a href="http://google.com/search?q=define:sound" title="Google define:sound">definition of sound</a> specifies that it isn&#8217;t considered sound if no-one&#8217;s around to hear it.</p>
<p>I digress. With this logging, an event with no subscribers will still make a sound in your console, and it will let you easily correct the problem.</p>
<p>The new trigger function will look something like this:</p>
<pre id="trigger-function-with-logging-example" class="brush: js">function trigger(eventName, data, context) {
  var
    subscribers = eventSubscriptions[eventName],
    i, iMax;

  if (typeof subscribers === 'undefined') {
    // No list found for this event, return early to abort execution
    console.log('[EventDispatcher] trigger: no subscribers for event "' + eventName + '"');
    return;
  }

  data = (data instanceof Array) ? data : [data];
  context = context || App;

  for (i = 0; iMax = subscribers.length; i += 1) {
    subscribers[i].apply(context, data);
  }
  console.log('[EventDispatcher] trigger: event "' + eventName + '" dispatched to ' + subscribers.length + ' subscribers, with data: ', data);
}</pre>
<p>This is a simplified version of what I actually used, as the real version includes checking whether <code>console.log</code> is available or not. My module also allowed toggling logging on or off, as well as excluding arbitrary events from logging. My application had certain events that were triggered very frequently, so it would be hard to see the events I was interested in through the stream of other events.</p>
<h2 id="conclusion">Conclusion</h2>
<p>If you&#8217;re interested in my final implementation, you can view <a href="https://github.com/michd/step-sequencer/blob/master/assets/js/eventdispatcher.js" title="View eventdispatcher.js on GitHub" target="_blank">the file in my step-sequencer repository</a>. It also makes use of a priority sorting, which has only been briefly mentioned in this post. Another new thing in that version of the dispatcher is the ability to subscribe to any number of events in one subscribe call.</p>
<p>I started employing this pattern as a bit of an experiment at first, but as I progressed through the project, I was time after time just delighted by how easy it made things. I&#8217;m pretty sure the logging has saved me many hours of hunting down bugs. Let me know how you&#8217;re implementing it, and do let me know of any improvements you can think of.</p>
]]></content:encoded>
			<wfw:commentRss>http://michd.me/blog/event-driven-javascript-a-simple-event-dispatcher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Organize your life with Trello</title>
		<link>http://michd.me/blog/organize-your-life-with-trello/</link>
		<comments>http://michd.me/blog/organize-your-life-with-trello/#comments</comments>
		<pubDate>Tue, 22 Jan 2013 00:41:46 +0000</pubDate>
		<dc:creator>Mich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Productivity]]></category>

		<guid isPermaLink="false">http://michd.me/?p=699</guid>
		<description><![CDATA[Trello is an amazing, free tool which makes managing or organizing just about anything a breeze. I discuss how it works, as well as some use cases.]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re all leading very busy lives nowadays. There are people communicating with us from everywhere all the time, and there are always things you need to remember doing or need to get organized. Personally, with the little spare time a full time job and a household leaves me, I have a hard time keeping track of the side projects and creative things I want to be doing, which ultimately causes me to waste more of that spare time than I&#8217;d like.</p>
<p>I intended to do something about this whole problem, in the form of a side project: a todo-list managing web application where you could label todo items for priority, assign people, and so forth. I was pretty far into the website design and initial front-end coding when I first heard about <a href="http://trello.com/">Trello</a>. It took me only a few days to realize that the people behind Trello had done a much better job of it than I ever would. I abandoned my own project shortly after.</p>
<h2 id="what-is-trello">So what is Trello?</h2>
<p>Trello lets you organize &#8220;cards&#8221; in &#8220;lists&#8221;, on &#8220;boards&#8221;; that may sound a little bit abstract, so let&#8217;s expand a bit on that.</p>
<p>A board on Trello consists of one or more named lists. It is an environment where you keep track of a certain thing, collect information on a certain thing, or simply where you manage something. Where you keep something organized.</p>
<p>A &#8220;list&#8221; is no more than a named column where you keep a bunch of cards. Such a list can indicate the progress status of the items within, or it can be treated as a  category. The purpose of a list depends entirely on what you are organizing.</p>
<p>A &#8220;card&#8221; can be anything you want it to be: a feature for a piece of software you&#8217;re working on, a book you want to read, a holiday destination you&#8217;re considering, you can come up with plenty more, I&#8217;m sure.</p>
<p>This screenshot gives a bit of an overview (<a href="/content/trello.png">full size</a>):</p>
<div class="expanded">
<img src="/content/trello.png" alt="Trello screenshot" data-max-width="949">
</div>
<p><span id="more-699"></span>Trello&#8217;s interface lets you easily create new cards and move them around, effectively making organization a painless experience. It is filled with very useful features that just makes management more effective. Examples include checklists on cards, the ability to attach files to cards, custom color-coded labels, due dates, I could go on.</p>
<p>While it is great for personal use, a lot of Trello&#8217;s power is in the way you can have multiple people being part of a board. This lets you assign people to cards to indicate they are involved with a certain thing. More importantly, you can leave comments on cards, allowing for discussion on the exact topic at hand, which is described in the top area of the card. When a card is moved around, all relevant discussion just stays with it wherever it goes.</p>
<h2 id="use-cases">Use cases</h2>
<h3 id="reading-list">Keeping a reading list</h3>
<p>A simple use case is keeping track of books you want to read, are reading, and have read. In my case, I keep a reading list with a friend of mine. We regularly recommend books to each other in the &#8220;To read&#8221; list. For each book we create a new card, and usually include an Amazon link where the book can be purchased. We then assign each other to these books to indicate &#8220;you should read this&#8221;. It works pretty well for me when finishing a book; &#8220;what shall I read next&#8221; is simply answered by having a look at the board.</p>
<h3>Any sort of simple &#8220;to do&#8221;</h3>
<p>The reading list is really just a variation of the to do theme, which is probably the most common use case too. The developers certainly seem to think so, as the default layout for a board is To do, Doing, Done. I keep a board named &#8220;Creative&#8221;, where I line up ideas for blog posts, as well as music to write. I also have a &#8220;Development/Hack ideas&#8221; board, which slightly expands on the to do format: it consists of Ideas, Investigating, Doing, and Done.</p>
<h3 id="howtos">Howtos</h3>
<p>A recent use case I came up with is collecting little howtos. Things you infrequently have to do, and could do with reminded for their procedures go here. (My use case was setting up an email forwarder on my <abbr title="Virtual Private Server">VPS</abbr>). You can create a few categories as lists, name your howtos well in the card title, and add the instructions in the description. That way your set of instructions is just a few clicks away next time.</p>
<h3 id="software-development">Software development</h3>
<p>The biggest use case I can think of is software development. At <a href="http://di.fm/">Digitally Imported</a> we make heavy use of the tool (and that&#8217;s still an understatement). We use a number of boards for our process: Development, user story preparation, defect triage, and roadmap.</p>
<p>Development is the most active one which we discuss in a Skype meeting every day. Every feature, bug to fix, piece of design work or what have you goes through 5 stages: Ready, Building, Accepting, Ready to deploy and Released.</p>
<p>In Ready, items are ready to be picked by a team member when they have space for it, that is, time to work on a new item. That team member then moves the card from Ready to Building, where it stays until all acceptance criteria of the item have been met. It then moves to Accepting, where other team members test and scrutinize the work completed, discussing any further changes required for it to be considered done.</p>
<p>From accepting the item moves, if applicable, to Ready to deploy, where it stays until it gets deployed to the target environment (which is usually one of the websites or a mobile app market). Once it is deployed to its target environment, the card retires to Released. The item is then considered to be done.</p>
<p>In User story preparation, items are prepared and fleshed out (specified if you will). They progress from simple ideas to properly outlined features / changes, before getting moved on to Ready on the Development board.</p>
<p>In Defect triage, any bugs come in, either from users, or from the team. They go from Inbox to Investigating (which speaks for itself), get a proper priority label, and then move on to Accepting/On hold, or in high priority cases, go straight to the Development board.</p>
<p>On the roadmap, the larger scale company projects are organized, and feature sets collected to give a broader overview of progress.</p>
<h2 id="its-free">It&#8217;s free!</h2>
<p>One of the most awesome parts of Trello that almost makes it too good to be true is that the whole thing is completely free for anyone to use. There are no premium features or limitations for free users, you simply get to use this product for free. No begging for donations or plastering everything with adverts either. It&#8217;s simply an un-monetized product by an awesome company. <a href="http://www.fogcreek.com/">Fog Creek Software</a> make their money through other venues, which allows them to invest in this tool they heavily use themselves, while making it available for free for everyone else.</p>
<p>In conclusion: Trello is pretty friggin&#8217; awesome, making organizing just about anything you can think of a breeze. If you&#8217;re trying to get anything done or want to get more structure in your life, I suggest you go give it a try right now. You will not be disappointed, and you will get your stuff done.</p>
]]></content:encoded>
			<wfw:commentRss>http://michd.me/blog/organize-your-life-with-trello/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Music to listen to loudly with eyes closed</title>
		<link>http://michd.me/blog/music-to-listen-to-loudly-with-eyes-closed/</link>
		<comments>http://michd.me/blog/music-to-listen-to-loudly-with-eyes-closed/#comments</comments>
		<pubDate>Tue, 20 Nov 2012 22:18:14 +0000</pubDate>
		<dc:creator>Mich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://michd.me/?p=593</guid>
		<description><![CDATA[This is some music that can take me over as I get into it. It ranges from old hits to obscure stuff, from chill-out to hard rock, in no particular order.]]></description>
			<content:encoded><![CDATA[<p>While I listen to music more or less all day while work and whatnot, I infrequently like to pick out some of my favourite songs, turn up the volume and just sit back and close my eyes, focussing only on the music.</p>
<p>There are some tracks which have the amazing quality to completely take over your awareness as you really get into them. Here are some that do that for me. They range from old hits to obscure stuff, from chill-out to hard rock, and are in no particular order.</p>
<h3>1. The Extreme &#8211; Daydream</h3>
<p><iframe src="http://www.youtube.com/embed/LvtPN2e866Y" width="640" height="480"  frameborder="0" allowfullscreen></iframe><br />
This <a href="http://www.youtube.com/watch?v=LvtPN2e866Y" title="Youtube link" target="_blank">wonderful chill-out tune</a> has a deep bass-line that instantly drew me in the first time I heard it on <a href="http://di.fm/chillout" target="_blank">Digitally Imported&#8217;s Chill-out channel</a> channel. The lush  instrumentation accompanied by a perfectly fitting break beat later on takes you through a dreamland of relaxation. It is all over the place in a big mess of harmony.<br />
<span id="more-593"></span></p>
<h3>2. Phil Collins &#8211; In the Air Tonight</h3>
<p><iframe width="640" height="480" src="http://www.youtube.com/embed/6Mt0ee9FraQ?rel=0" frameborder="0" allowfullscreen></iframe><br />
<a href="http://www.youtube.com/watch?v=6Mt0ee9FraQ" target="_blank">In the Air Tonight</a> [sadly only 240p quality for the studio version I want to showcase] is more of a classic. It carries on slowly and gives the impression that something&#8217;s going to happen, which is the case near the end of the song. It just has this sublime pad and soft drum work going on throughout, along with subtle spacial effects on the vocals. The cool part about this track is that you tend to turn it up because the longest first part is relatively quiet. Since the song isn&#8217;t overly compressed as a lot of more recent music is, when the drums come in, they are rather hard-hitting. Also, after a few listens, you will find yourself air-drumming when that part kicks in.</p>
<h3>3. Drugstore &#8211; Old Shoes</h3>
<p><iframe width="640" height="360" src="http://www.youtube.com/embed/ZjqbdciGUiA?rel=0" frameborder="0" allowfullscreen></iframe><br />
I have not heard the original of <a href="http://www.youtube.com/watch?v=ZjqbdciGUiA" target="_blank">this Tom Waits cover</a>, but this version I found on one of my parents&#8217; CDs years ago is certainly a jewel. It morphs from very calm parts with light re-verb-y guitars into heavy parts with distorted shoegaze-like   guitar work. The kick-off is usually paired with a little drum fill-in, after which all the guitars break loose again. The result is a wall of a sound which leaves no room for any other thoughts if you&#8217;re playing it loud enough.</p>
<h3>4. The Cranberries &#8211; Zombie</h3>
<p><iframe width="640" height="480" src="http://www.youtube.com/embed/6Ejga4kJUts?rel=0" frameborder="0" allowfullscreen></iframe><br />
This <a href="http://www.youtube.com/watch?v=6Ejga4kJUts" target="_blank">classic massive hit</a> still manages to give me goosebumps after all the times I&#8217;ve listened to it. Somewhat similarly to Old Shoes, it has sections with guitar and bass all over the place, blowing you away. This, paired with a powerful voice and equally powerful instrumental parts, just works. The transition to the last part is really smooth and finishes it off beautifully. </p>
<h3>5. Papa Roach &#8211; Between Angels and Insects</h3>
<p><iframe width="640" height="480" src="http://www.youtube.com/embed/1O8FebhnbL4?rel=0" frameborder="0" allowfullscreen></iframe><br />
While this <a href="http://www.youtube.com/watch?v=1O8FebhnbL4" target="_blank">hard rock song by Papa Roach</a> has (explicit) laden lyrics about money and materialism, that&#8217;s not the reason I listed it here. I have difficulty describing the part when it kicks in. It just take you over. It&#8217;s as if the full sound spectrum is being pumped in your ears, in a good way. Definitely the heaviest one of the bunch.</p>
<h3>6. The Me in You &#8211; Low Battery</h3>
<p><iframe width="640" height="360" src="http://www.youtube.com/embed/R1fPu6-Y81E?rel=0" frameborder="0" allowfullscreen></iframe><br />
It&#8217;s a shame that the album version of <a href="http://www.youtube.com/watch?v=R1fPu6-Y81E" target="_blank">Low Battery</a> is not available on Youtube, as that one has a longer outro with more of the light guitar and piano goodness. The Me in You are a very new Belgian band. I got their debut album &#8220;Forgotten Clothes&#8221; as a birthday gift, and I&#8217;ve played through it many, many times since. The whole album is absolutely great, but this one is my favourite of the bunch. It&#8217;s a very mellow sounding track which takse a few listens to really appreciate the attention to detail, and how well everything works together. I suggest you <a href="https://itunes.apple.com/be/album/forgotten-clothes/id498223102">go buy the album</a>, it&#8217;s more than worth it.</p>
<p>There are probably more tracks I can list here, but these are the ones I recently got into again. I will probably write some more posts about music I particularly love in the future. </p>
]]></content:encoded>
			<wfw:commentRss>http://michd.me/blog/music-to-listen-to-loudly-with-eyes-closed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript forEach Object, Array and String</title>
		<link>http://michd.me/blog/javascript-foreach-object-array-and-string/</link>
		<comments>http://michd.me/blog/javascript-foreach-object-array-and-string/#comments</comments>
		<pubDate>Sun, 28 Oct 2012 14:02:28 +0000</pubDate>
		<dc:creator>Mich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[callback]]></category>
		<category><![CDATA[foreach]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Object]]></category>
		<category><![CDATA[String]]></category>

		<guid isPermaLink="false">http://michd.me/?p=566</guid>
		<description><![CDATA[A function that provides a single interface to iterate over the elements of an array, the values in an object, and "even" the characters in a string.]]></description>
			<content:encoded><![CDATA[<p>In many programming languages, you have a simple for each construct available to quickly go over the contents of just about anything iterable. In JavaScript it isn&#8217;t so straightforward. To rectify this, I&#8217;ve written up a function that provides a single interface to iterate over the elements of an array, the values in an object, and &#8220;even&#8221; the characters in a string.</p>
<p>It works with a callback function that takes index/key and value as parameters. This callback function is executed for every item in the collection passed.</p>
<p>The benefit of using this is that you have very readable code; most programmers will intuitively know how it works because of the familiar collection, index and value interface.</p>
<p>To the code!</p>
<p><script type="text/javascript" src="https://gist.github.com/3968505.js">// <![CDATA[</p>
<p>// ]]&gt;</script></p>
<p><noscript>You appear to have JavaScript disabled. To view the code, Please enabled JavaScript or <a href="https://gist.github.com/3968505">view this gist on Github</a>.</p>
<p></noscript><br />
<span id="more-566"></span></p>
<h2>Preparation and parameter checking</h2>
<p>We start, as we should, by declaring the local variables. <code>i</code>, <code>iMax</code> and <code>key</code> are used in the iteration later on, <code>collectionType</code> stores what we&#8217;re dealing with.</p>
<h3>Validating the callBack parameter</h3>
<p>We check whether callBack is an actual function, as this whole function is useless if nothing can be done while iterating.</p>
<h3>Validating the collection</h3>
<p>The first switch construct determines what type of collection we are dealing with. Normally you would use <code>typeof collection</code> here, but JavaScript reports &#8216;object&#8217; when <code>collection</code> is an array (because arrays are objects). As a result, we have no way to differentiate between objects and arrays through <code>typeof</code>.</p>
<p>To get around this, we use toString, from the Object prototype. We use Object&#8217;s toString method specifically, because it&#8217;s only one that actually gives us the information we need; if we were to use <code>collection.toString()</code>, we&#8217;d get &#8220;[object Object]&#8221; for an object, &#8220;a,b,c&#8221; for an array, and &#8220;hello world&#8221; for a string—not very helpful.</p>
<p>Object&#8217;s toString yields &#8220;[object Object]&#8220;, &#8220;[object Array]&#8221; and &#8220;[object String]&#8221; for the aforementioned examples; definitely useful for what we&#8217;re trying to achieve. To call Object&#8217;s toString method on non-Object variables, we use <code>Object.prototype.toString.call(collection)</code></p>
<p>If through all that it turns out <code>collection</code> is neither Object, Array or String, an error is thrown, and the function execution terminated.</p>
<h2>The iteration</h2>
<p>Based on <code>collectionType</code> we just determined, we now iterate over <code>collection</code>. Again we use the readable switch statement.</p>
<h3>Array and String</h3>
<p>Arrays and strings behave much the same as far as iterating them goes. As you access an element at index <code>i</code> in an array using <code>myArray[i]</code>, you access the character at index <code>i</code> in a string through <code>myString[i]</code>. Because of this, we can use the exact same for loop to iterate an array and a string, hence the fall-through in the switch construct.</p>
<p><strong>EDIT: People on IRC and <a href="http://www.reddit.com/r/javascript/comments/12826g/foreach_function_that_iterates_over_objects/">Reddit</a> have pointed out that <code>string[index]</code> is not supported belwo IE7 or IE8, so I&#8217;ve updated the gist to use <code>string.charAt(index)</code> instead, and removed the switch fall-through.</strong></p>
<p>For every item or character in that array or string, <code>callBack</code> is executed with the index and value paramaters.</p>
<h4>A note on for loops</h4>
<p>There is a tiny note-worthy bit in the for loop code. I believe most people would initialise their for loops like this (at least I&#8217;ve done it this way for years):</p>
<pre class="brush: js">var i = 0; 

for (i = 0; i &lt; collection.length; i += 1) {
    // ... code ...
}</pre>
<p>There is something sub-optimal about that approach; every time the condition (<code>i &lt; collection.length</code>) is checked—before every iteration, the <code>length</code> property of <code>collection</code> is accessed. This can be a performance bottleneck, as the length needs to be recounted every time, since it is possible that it has changed since the last iteration.</p>
<p>Instead, store the length is another variable on initialisation, then just compare to the variable in the condition, like this:</p>
<pre class="brush: js">var
    i,
    iMax = 0;

for (i = 0, iMax = collection.length; i &lt; iMax; i += 1) {
    // ... code ...
}</pre>
<h3>Objects</h3>
<p>Iterating over the key/value pairs in an object is another story. The <code>for...in</code> loop is available, but there is a little caveat to it. Objects inherit properties and methods from the prototype chain. Prototypes are a whole other story, but suffice to say that we don&#8217;t want to include those properties and methods in our iteration.</p>
<p>Luckily, there is a function in the <code>Object</code> prototype that lets us figure out whether a property or method is part of that object itself or part of its prototype chain. As you can see, all we have to set up is a <code>for...in</code> loop, then in that loop check whether the object owns the property by name <code>key</code>. If that is the case, <code>callBack</code> is called with key and value parameters.</p>
<h2>Return</h2>
<p>Since the function does all its magic through the callBack function, it does not need to return anything. Hence, we return <code>null</code>.</p>
<h2>Examples</h2>
<p>The code above includes a few examples. I&#8217;ll add some other examples to show what each forEach use is equivalent to using regular loops.</p>
<h3>Array example</h3>
<p>Using <code>forEach</code>:</p>
<pre class="brush: js">var myArray = ["a", "b", "c"]; 

forEach(myArray, function (value, index) {
    console.log(key + ": " + value);
});</pre>
<p>Output:</p>
<pre class="brush: plain">0: a
1: b
2: c</pre>
<p>Using normal <code>for</code> loop:</p>
<pre class="brush: js">var
    myArray = ["a", "b", "c"],
    i = 0,
    iMax = 0;

for (i = 0, iMax = myArray.length; i &lt; iMax; i += 1) {
    console.log(i + ": " + myArray[i]);
}</pre>
<p>Output:</p>
<pre class="brush: plain">0: a
1: b
2: c</pre>
<h3>Object example</h3>
<p>Using <code>forEach</code>:</p>
<pre class="brush: js">var myObject = {
    "Douglas": "Adams",
    "Robert": "Heinlein",
    "Isaac": "Asimov"
}; 

forEach(myObject, function (value, key) {
    console.log(key + ": " + value);
});</pre>
<p>Output:</p>
<pre class="brush: plain">Douglas: Adams
Robert: Heinlein
Isaac: Asimov</pre>
<p>Using <code>for...in</code> and <code>hasOwnProperty</code>:</p>
<pre class="brush: js">var
    myObject = {
        "Douglas": "Adams",
        "Robert": "Heinlein",
        "Isaac": "Asimov"
    },
    key = '';

for (key in myObject) {
    if (myObject.hasOwnProperty(key)) {
        console.log(key + ": " + myObject[key]);
    }
}</pre>
<p>Output:</p>
<pre class="brush: plain">Douglas: Adams
Robert: Heinlein
Isaac: Asimov</pre>
<h3>Beware of HTMLCollections</h3>
<p>I&#8217;ve written this to be environment-agnostic (save for the console.log calls in examples). If you want to use this with results from <code>document.getElementsByTagName()</code>, it won&#8217;t work as it is, reason being that getElements&#8230; returns not an [object Object], array or string, instead it returns [object HTMLCollection], which is not catered for. You can adapt forEach to also work with HTMLCollections, or you can <a href="http://stackoverflow.com/questions/222841/most-efficient-way-to-convert-an-htmlcollection-to-an-array">convert your HTMLCollections to arrays</a>. I hope that saves some people headaches.</p>
<h3>Update (same day)</h3>
<p>People on IRC and <a href="http://www.reddit.com/r/javascript/comments/12826g/foreach_function_that_iterates_over_objects/">Reddit</a> have pointed out the standard value, index array order from the spec, so I&#8217;ve updated the code to use that order instead. They have also pointed out that &lt; IE7/IE8 does not support <code>string[index]</code>, so that&#8217;s been updated to use <code>string.charAt(index)</code> instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://michd.me/blog/javascript-foreach-object-array-and-string/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Selectbox / dropdown replacements</title>
		<link>http://michd.me/blog/selectbox-dropdown-replacements/</link>
		<comments>http://michd.me/blog/selectbox-dropdown-replacements/#comments</comments>
		<pubDate>Tue, 23 Oct 2012 09:40:56 +0000</pubDate>
		<dc:creator>Mich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Dropdown]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Selectbox]]></category>

		<guid isPermaLink="false">http://michd.me/?p=559</guid>
		<description><![CDATA[The select element is hard to style properly and is something that easily ruins sleek designs. Here's a short overview of replacement plugins.]]></description>
			<content:encoded><![CDATA[<p>The <code>&lt;select&gt;</code> element is hard to style properly and is something that easily ruins sleek designs. Many people have already realised this, which is why there are a couple of JavaScript replacements out there.</p>
<p>Here&#8217;s a quick list of those that I&#8217;m aware of—in no particular order.</p>
<ul>
<li><strong><a href="http://gregfranko.com/jquery.selectBoxIt.js/">SelectBoxIt </a></strong>- <a href="https://github.com/gfranko/jquery.selectBoxIt.js">Github</a><br />
Requires jQuery 1.6.1+ and jQueryUI Widget Factory 1.8.19+</li>
<li><strong><a href="http://labs.abeautifulsite.net/jquery-selectBox/">jQuery SelectBox plugin</a></strong> &#8211; <a href="https://github.com/claviska/jquery-selectBox">Github</a><br />
(Obviously) requires jQuery, minimum version not listed.<br />
Has events you can tap into with callback functions</li>
<li><strong><a href="http://harvesthq.github.com/chosen/">Chosen</a></strong> &#8211; <a href="https://github.com/harvesthq/chosen">Github</a><br />
Requires jQuery 1.4+ <em>or</em> Prototype 1.7+<br />
Neat features like search input for long lists</li>
<li><strong><a href="http://jqueryui.com/autocomplete/#combobox">jQuery UI Autocomplete (combobox)</a></strong><br />
Included in jQuery UI<br />
Focussed on searching rather than the dropdown</li>
</ul>
<p>This post is mostly as a reference, so I don&#8217;t need to look up all the options (no pun intended) every time this situation arises. I hope it can help you quickly select (pun definitely intended this time) which one&#8217;s best for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://michd.me/blog/selectbox-dropdown-replacements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New hosting!</title>
		<link>http://michd.me/blog/new-hosting/</link>
		<comments>http://michd.me/blog/new-hosting/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 10:14:50 +0000</pubDate>
		<dc:creator>Mich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Meta]]></category>

		<guid isPermaLink="false">http://michhimself.com/?p=535</guid>
		<description><![CDATA[This site is now hosted elsewhere. I've moved it from one.com's shared hosting to a linode.com VPS.]]></description>
			<content:encoded><![CDATA[<p>Although you may not see any difference, this site is now hosted elsewhere. It&#8217;s taken over a week to get all the administration dealt with, but now it seems to work all okay.</p>
<p>Michhimself.com used to be hosted by <a href="http://one.com">one.com</a>, the first web host I ever paid for, which I registered with in 2009. Back then, the simple PHP/MySQL hosting with FTP access was great, but I&#8217;ve since moved on.  Since it was so-called &#8216;shared hosting&#8217;, it meant that multiple websites would run on the same server; meaning that the performance of my site would depend on the load caused by others.</p>
<p>Now I&#8217;ve moved on to a VPS (Virtual Private Server) at <a href="http://linode.com">linode.com</a>, where I get full root access over the machine. You know what that means: a LOT more freedom to play with. I got to install the web server software myself, as well as PHP, MySQL and a bunch of other things. I&#8217;m even running an IRC bot on the thing. Needless to say, I no longer need to use FTP to access the files on this server; I just use SSH, which is more secure, and seemingly faster as well. Have I mentioned that Linode is fabulous?</p>
]]></content:encoded>
			<wfw:commentRss>http://michd.me/blog/new-hosting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving forward with my photography</title>
		<link>http://michd.me/blog/moving-forward-with-my-photography/</link>
		<comments>http://michd.me/blog/moving-forward-with-my-photography/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 12:32:14 +0000</pubDate>
		<dc:creator>Mich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://michhimself.com/?p=525</guid>
		<description><![CDATA[One of my bigger hobbies is photography. After two years with a decent point-and-shoot, I've finally invested in my first DSLR.]]></description>
			<content:encoded><![CDATA[<p>Something that I may not have mentioned here is that one of my hobbies is photography. I got a little more seriously into it after buying a friend&#8217;s <a href="http://www.steves-digicams.com/camera-reviews/nikon/coolpix-8700/nikon-coolpix-8700-review.html">Nikon Coolpix 8700</a> back in 2010. That camera was a pretty good one, even though it wasn&#8217;t a DSLR or anything fancy, it gave me quite a bit of freedom to play, compared to your regular little compact camera.</p>
<p>Last week however, I purchased my first DSLR after trying and getting outbid on ebay for about a week. I now have a <a href="http://www.kenrockwell.com/nikon/d40.htm">Nikon D40</a> with the kit 18-55mm lens, and I&#8217;m loving it. Compared to the Coolpix 8700, it is orders of magnitude better at guessing settings for correct exposures.  Since it doesn&#8217;t have to move out a lens on start-up, it&#8217;s instantly ready to shoot, and doesn&#8217;t waste energy on motors (other than the auto-focus motor in the lens). I love how it takes your photo the moment you press the shutter button down, rather than half a second after. It makes me feel much more confident to go for certain shots than I normally would be.</p>
<p>The camera automatically goes in stand-by mode if you&#8217;re idle for a while, but is instantly ready to go for it again. This makes it fun to walk through the city with the camera just on all the time, ready to shoot anything you see.</p>
<p>In conclusion, it seems like I&#8217;m going to have a lot of fun experimenting with what this camera will let me do. Eventually I&#8217;ll most likely try some other lenses as well, which is something I&#8217;ve been looking forward to with this kind of cameras.</p>
<p>Here&#8217;s a little set of photos I&#8217;ve taken around Southampton, by day and by night.</p>
<div class="expanded">
<img title="Escape the waves" src="http://michhimself.com/content/DSC_0141.jpg" alt="Escape the waves" data-max-width="800"><img title="West Quay" src="http://michhimself.com/content/DSC_0123.jpg" alt="West Quay" data-max-width="800"><img title="Long exposure with cars, Itchen Bridge" src="http://michhimself.com/content/DSC_0176.jpg" alt="Long exposure with cars, Itchen Bridge" data-max-width="800">
</div>
<p>You can <strong><a href="http://www.flickr.com/photos/michhimself/sets/72157628945088393/" target="_blank">view the full set on Flickr</a></strong>.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://michd.me/blog/moving-forward-with-my-photography/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Form input help on focus without JavaScript</title>
		<link>http://michd.me/blog/form-input-help-on-focus/</link>
		<comments>http://michd.me/blog/form-input-help-on-focus/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 13:41:18 +0000</pubDate>
		<dc:creator>Mich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://michhimself.com/?p=491</guid>
		<description><![CDATA[How to show extra info by your form inputs on focus, in pure HTML and CSS]]></description>
			<content:encoded><![CDATA[<p>Just a simple front-end technique I thought to be worth sharing:</p>
<p>Form fields can usually do with some more information on what you are supposed to fill in. Examples include valid user name rules, desired date/time format.</p>
<h2>The problem</h2>
<p>On one hand, you want your users to know what they&#8217;re supposed to do, as confusing your visitors easily leads to a dramatically decreased conversion rate. On the other hand, you want your forms to look clean and minimal, so your visitors are not bombarded with information. If you show information by every field on your form, it quickly gets cluttered, and that&#8217;s exactly what we want to avoid.</p>
<h2>The solution</h2>
<p>Simply hide the elements containing the help text until they are needed. When a user focuses on a field, the relevant information shows up. This may sound like something you would solve with the <em>onfocus</em> and <em>onblur</em> events, but you can actually accomplish it with CSS.</p>
<p>Assuming you have an element with an <em>info</em> class right after the input element, you just use the <em>:focus</em> pseudo-selector in an <a title="W3C specification on adjacent selectors (CSS2)" href="http://www.w3.org/TR/CSS2/selector.html#adjacent-selectors" target="_blank">adjacent sibling selector</a>.<br />
<span id="more-491"></span></p>
<h2>Example</h2>
<p>For the example, I&#8217;ve come up with a simple sign-up form:</p>
<pre class="brush: html">
&lt;form action=&quot;/user/signup&quot; method=&quot;post&quot;&gt;
    &lt;fieldset&gt;
        &lt;div&gt;
            &lt;label for=&quot;form_username&quot;&gt;Username&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;form_username&quot; name=&quot;username&quot;&gt;
            &lt;div class=&quot;info&quot;&gt;A valid username consists of letters (a-z) and/or numbers (0-9).&lt;/div&gt;
        &lt;/div&gt;
        &lt;div&gt;
            &lt;label for=&quot;form_email&quot;&gt;Email&lt;/label&gt;
            &lt;input type=&quot;text&quot; id =&quot;form_email&quot; name=&quot;email&quot;&gt;
            &lt;div class=&quot;info&quot;&gt;We will send you an email to validate your account.&lt;/div&gt;
        &lt;/div&gt;
        &lt;div&gt;
            &lt;label for=&quot;form_password&quot;&gt;Password&lt;/label&gt;
            &lt;input type=&quot;password&quot; id =&quot;form_password&quot; name=&quot;password&quot;&gt;
            &lt;div class=&quot;info&quot;&gt;Your password should be at least 6 characters long.&lt;/div&gt;
        &lt;/div&gt;
        &lt;div&gt;
            &lt;label for=&quot;form_passwordretype&quot;&gt;Repeat Password&lt;/label&gt;
            &lt;input type=&quot;password&quot; id =&quot;form_passwordretype&quot; name=&quot;passwordretype&quot;&gt;
            &lt;div class=&quot;info&quot;&gt;Please repeat your password to ensure you haven't made any mistakes.&lt;/div&gt;
        &lt;/div&gt;
    &lt;/fieldset&gt;
&lt;/form&gt;
</pre>
<p>To which we add this little bit of CSS that makes it all work:</p>
<pre class="brush: css">
div.info {
    display: none;
    /* Make sure the info element is initially hidden */
    color: #777;
    font-size: 12px;
    margin: 2px 0;
    text-indent: 1em;
}
input:focus + div.info {
    /* This selector selects the div.info that comes right after the focused input */
    display:block;
   /* Make the element visible */
}
</pre>
<p>With some minor CSS additions that gets you this (Try clicking the input fields or tab through them)</p>
<p><iframe style="width: 500px; height: 300px" src="/demos/forminputhelp" allowfullscreen="allowfullscreen" frameborder="0"></iframe><br />
(View on <a href="http://jsfiddle.net/mich/T9Htt/" target="_blank">JsFiddle</a>)</p>
<h2>Now get creative!</h2>
<p>The example shown above is the most basic form of this technique. With some fancy CSS positioning, you could use a sidebar to display the info of the currently focused input, and that&#8217;s just one idea.</p>
<p>I hope this can help some folks create more attractive forms. Be sure to show me your implementations of this technique, and as always, if you have any questions, don&#8217;t hesitate to ask.</p>
]]></content:encoded>
			<wfw:commentRss>http://michd.me/blog/form-input-help-on-focus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MVC &#8211; FuelPHP</title>
		<link>http://michd.me/blog/mvc-fuelphp/</link>
		<comments>http://michd.me/blog/mvc-fuelphp/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 13:56:18 +0000</pubDate>
		<dc:creator>Mich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://michhimself.com/?p=480</guid>
		<description><![CDATA[MVC is an exciting design pattern, and FuelPHP makes utilizing it a smooth, elegant experience.]]></description>
			<content:encoded><![CDATA[<p>Since I started working at <a href="http://carswellgould.co.uk">Carswell Gould</a>, I&#8217;ve learnt a lot more about web development—It&#8217;s amazing how much you learn once you start collaborating with other people—and among those things I learned is how to work with the MVC (Model-View-Controller) design pattern. The way I used to work was just by having the database operations inside classes as much as possible, and use those classes and their methods in the files for the actual pages. For example, A forum thread page (view.php or similar) would have all the code to load the posts and relevant info above the HTML part of the file, using classes like ForumThread and the like.</p>
<p>The MVC way to go for this would be having a <strong><em>controller</em></strong> that gets called when the URL for viewing a thread is requested. The controller would get an instance of a ForumThread <strong><em>Model</em></strong>. The Model describes the properties of a ForumThread and deals with related data (Forum posts, which would be another Model), and database operations, plus any additional behaviours. The data retrieved from the Model instance then gets passed on to a <strong><em>View</em></strong>, which takes care of sticking all the data in HTML. This way interpreting the request, dealing with data and displaying data is nicely separated.</p>
<h2>Frameworks (FuelPHP)</h2>
<p>This whole design pattern is all a very beautiful way to structure your web applications, however, if you have to set that all up from scratch, it would get very tiresome to get right. That&#8217;s where frameworks come in. The first PHP framework I got in touch with is <a href="http://fuelphp.com">FuelPHP</a>, a quite young framework running on PHP 5.3+. According to their front page, it is based on the best ideas of other frameworks, with a fresh start. As this is the first framework I&#8217;ve used, I can&#8217;t really judge that former part, but by googling certain concepts used, I&#8217;ve found out that many of them are quite commonly accepted ones.</p>
<p>In my experience, it&#8217;s very simple to set up some new models and relate them, to quickly get going without all the design hassle you&#8217;d normally have. For the most part, you don&#8217;t get to write the database queries yourself, which is a good thing.</p>
<h3>Validation</h3>
<p>An unrelated part of FuelPHP (as in, it doesn&#8217;t really have anything to do with MVC) is its validation functionality. FuelPHP makes it really smooth to validate input. There are multiple ways to go for it, but my preferred way is to actually specify the validation rules in a Model&#8217;s properties array, then setting up a Validation Observer before save.</p>
<p>If that sounded confusing: An observer is a class that has a number of event-named methods. In a Model you can refer to an observer class and tell it which events to observe. FuelPHP takes care of the rest: When you let your model save its data to the database, any observers with &#8216;before_save&#8217; enabled will be executed first. In the case of a Validation observer this will first run all the validation rules specified in the properties set-up, and throw an error (preventing the actual database save) in the case that some data does not validate.</p>
<p>Having gone through setting up a whole bunch of nested ifs for data validation in the past (Believe me, it&#8217;s tiresome and not elegant at all), I find this way of setting up validation simply beautiful. It&#8217;s all down to adding a few strings to an array, and it&#8217;ll validate. The way the framework is built allows for easy adding of your own validation functions too, so other than elegant, it&#8217;s very flexible.</p>
<h2>Adopt FuelPHP!</h2>
<p>Currently, the community surrounding FuelPHP is still fairly small, which means it&#8217;s often quite hard to google FuelPHP-related things. I would very much like the community for this framework to grow, as I feel it has a lot of potential. Their website (mostly docs section) is still quite incomplete in places, but that should improve as the community grows.</p>
<h2>More information</h2>
<p>I&#8217;ve only briefly touched upon many subjects in this post, so if I sparked your interest, these couple of links should get your started.</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">Wikipedia article on Model-View-Controller</a></li>
<li><a href="http://fuelphp.com/">FuelPHP homepage</a></li>
<li><a href="http://docs.fuelphp.com/">FuelPHP documentation</a></li>
<li><a href="http://docs.fuelphp.com/packages/orm/creating_models.html">Creating a Model in FuelPHP</a></li>
<li><a href="http://docs.fuelphp.com/packages/orm/observers/intro.html">Using Observers in FuelPHP</a></li>
</ul>
<p>Obviously, if you are really interested in trying it out, I suggest downloading it and playing with it! You can get support on <a href="http://fuelphp.com/forums">their forum</a> and in <a href="irc://freenode.net/fuelphp">their IRC channel</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://michd.me/blog/mvc-fuelphp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
