<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Tom Dancer</title>
	
	<link>http://tomdancer.com</link>
	<description>Statistically proven to the be the best blog on the web</description>
	<lastBuildDate>Wed, 23 Dec 2009 23:21:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/tomdancer" /><feedburner:info uri="tomdancer" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Automatic unique IDs for Drupal menu items</title>
		<link>http://feedproxy.google.com/~r/tomdancer/~3/aCl2TjlRW7s/</link>
		<comments>http://tomdancer.com/unique-ids-for-drupal-menu-items/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 22:45:50 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[hooks]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://tomdancer.com/blog/?p=226</guid>
		<description><![CDATA[A man walks along the bank of a frozen river. Snow is falling. There is already a thick carpet of flakes crunching beneath his feet with every step. The fall is heavy and the sky is white. Reaching the bridge he begins to cross the wide, high structure keeping one eye on the usually-flowing, unusually still body sitting motionless tens of feet beneath. 'I wonder,' he thinks 'how I can give unique IDs to my Drupal menu items.']]></description>
			<content:encoded><![CDATA[<p><img class="alignnone image-main" title="Let me see some ID" src="http://tomdancer.com/blog/wp-content/uploads/2009/12/see_some_id.jpg" alt="Let me see some ID" width="614" height="119" /><br />
A man walks along the bank of a frozen river. Snow is falling. There is already a thick carpet of flakes crunching beneath his feet with every step. The fall is heavy and the sky is white. Reaching the bridge he begins to cross the wide, high structure keeping one eye on the usually-flowing, unusually still body sitting motionless tens of feet beneath. &#8216;I wonder,&#8217; he thinks &#8216;how can I give unique IDs to my Drupal menu items.&#8217;<span id="more-226"></span></p>
<p>Well I&#8217;ll tell him, and you. And yes, it is a thinly veiled attempt to inject a hint of interest into what could otherwise have been a stale opening paragraph. More such thrilling fiction in future posts. To the point!</p>
<p>There are doubtless several ways to do this of varying degrees of flexibility or complexity, as there often is with Drupal, but I find the method shown below to a be pretty simple one.</p>
<p>We&#8217;ll be using a theme hook, a function Drupal will call automatically which can affect the markup that is output in the end. The hook in question is <a href="http://api.drupal.org/api/function/theme_menu_item_link/6">theme_menu_item_link()</a> which, as the API docs state, generates the HTML output for a single menu link. What we&#8217;ll be doing is creating our own version of that function in our theme which is identical, except that it checks that this link is part of the menu we want to control.</p>
<p>The code below is what we end up with in our theme&#8217;s <em>template.php</em> file:</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> yourthemename_menu_item_link<span style="color: #009900;">&#40;</span><span style="color: #000088;">$link</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'localized_options'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'localized_options'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #666666; font-style: italic;">// Our custom code starts here. &gt;&gt;&gt;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #666666; font-style: italic;">// Check for the menu we need</span><br />
&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'menu_name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'primary-links'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp;* If this item points to the site front page, remove the &lt; &gt; symbols<br />
&nbsp; &nbsp; &nbsp;* or this keyword will result in the link target path being just '/'<br />
&nbsp; &nbsp; &nbsp;* and so your id will just be 'nav_', as opposed to 'nav_front'. Change<br />
&nbsp; &nbsp; &nbsp;* to suit your preference.<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'link_path'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'&lt;front&gt;'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'link_path'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'front'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp;* Generate URL from the link path, replace slashes with hyphens<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'localized_options'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'nav'</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/strtr"><span style="color: #990000;">strtr</span></a><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'link_path'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #666666; font-style: italic;">// &lt;&lt;&lt; Our custom code ends here.</span><br />
&nbsp; <br />
&nbsp; <span style="color: #b1b100;">return</span> l<span style="color: #009900;">&#40;</span><span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'href'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'localized_options'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>You can see what we have added by comparing this function to the one at the hook&#8217;s link above. Ignoring the stuff we copied from the original function, we start by checking this link is part of the correct menu—I&#8217;ll just use the <em>Primary links</em>. If so then we check that the <em>link_path</em>, what Drupal calls the portion of the URL after the domain, to ensure that it is not &#8220;&lt;front&gt;&#8221;. This is used within Drupal to denote a link to the site&#8217;s front page. Because we will be running this path through <a href="http://api.drupal.org/api/function/url/6">the url() function</a>, &#8220;&lt;front&gt;&#8221; would return a URL path of just &#8220;/&#8221; and so the link&#8217;s ID would end up as simply &#8220;nav-&#8221; which isn&#8217;t very descriptive.</p>
<p>That just leaves us with setting the link&#8217;s <em>id</em>, which we will add to an <em>attributes</em> array, inside the link&#8217;s <em>localized_options</em> array. We pass that <em>link_path</em> to the url() function which returns a URL path. I&#8217;m then using <a href="http://php.net/manual/en/function.strtr.php">string translate</a>, to convert the slashes to hyphens (yes you could use str_replace or whatever your preferred method of replacing is—I like strtr for small, quick replacements, since it&#8217;s both of those things itself). Concatenate that onto the end of &#8220;nav&#8221; or whatever prefix you like and we&#8217;re done. This menu&#8217;s links will have a unique ID based on the path of that link. If a path was for example &#8220;about-us/meet-the-team&#8221;, your link&#8217;s ID will be &#8220;nav-about-us-meet-the-team&#8221;.</p>
<p>Obvious problems are that IDs must be unique in the DOM so you need to be aware of where you are using this, and use it appropriately. Perhaps you&#8217;d rather set a class this way instead of an ID to avoid any validation errors. That&#8217;s fine—change $link['localized_options']['attributes']['id'] to $link['localized_options']['attributes']['class'].</p>
<p>Enjoy&#8230; theme hooking your links this Christmas!</p>
<img src="http://feeds.feedburner.com/~r/tomdancer/~4/aCl2TjlRW7s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tomdancer.com/unique-ids-for-drupal-menu-items/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tomdancer.com/unique-ids-for-drupal-menu-items/</feedburner:origLink></item>
		<item>
		<title>Setting a timeout on file_get_contents for URLs</title>
		<link>http://feedproxy.google.com/~r/tomdancer/~3/nykifdS2Llg/</link>
		<comments>http://tomdancer.com/setting-a-timeout-on-file_get_contents-for-urls/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 11:53:09 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://tomdancer.com/blog/?p=215</guid>
		<description><![CDATA[Just a quick post since this doesn't seem to be very well covered, but could be useful to someone. PHP's <a href="http://php.net/manual/en/function.file-get-contents.php">file_get_contents</a> function is an easy way to load the contents of a file or URL into a variable. But what about timeouts?]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone image-main" title="Stream Context" src="http://tomdancer.com/blog/wp-content/uploads/2009/06/stream_context.jpg" alt="Stream Context" width="614" height="180" /></p>
<p>Just a quick post since this doesn&#8217;t seem to be very well covered, but could be useful to someone. You may be familiar with PHP&#8217;s <a href="http://php.net/manual/en/function.file-get-contents.php">file_get_contents</a> function as a way to load the contents of a file into a variable. But it can also be used to get fetch the content of a site, by passing it a URL instead of a filepath.<span id="more-215"></span></p>
<p>This is fine, but what if the site whose URL you pass is down? <a href="http://uk2.php.net/curl">cURL</a> is probably more commonly used for fetching URL content which is understandable–it offers WAY more options and flexibility. One of the parameters you can specify is timeout. Recently I was writing a simple <a href="http://drupal.org">Drupal</a> module to pull certain tweets from <a href="http://twitter.com">Twitter</a>. Drupal&#8217;s caching would be used to hold retrieve the tweets for display, the cache updated via cron. While in development, we experienced one of Twitter&#8217;s seemingly regular periods of unavailability. With cURL, a preset timeout would solve this as the script wouldn&#8217;t be sitting waiting beyond our preset time limit, but cURL seemed like overkill for a simple fetch task where a quick file_get_contents would do. Could I specify a timeout for this function?</p>
<h3>Well&#8230; yes.</h3>
<p>Googling around, I couldn&#8217;t find anything immediately. It certainly wasn&#8217;t thorough research to be sure, but nothing jumped out (sorry if I missed anyone else doing the same thing I am here). But then I spotted a <a href="http://www.php.net/manual/en/function.file-get-contents.php#82527">short comment</a> in the PHP manual page for file_get_contents. The upshot is that you can specify a timeout by creating a <a href="http://php.net/manual/en/function.stream-context-create.php">stream context</a> for the function like this:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;?php<br />
// Create the stream context<br />
$context = stream_context_create(array(<br />
&nbsp; &nbsp; 'http' =&gt; array(<br />
&nbsp; &nbsp; &nbsp; &nbsp; 'timeout' =&gt; 3&nbsp; &nbsp; &nbsp; // Timeout in seconds<br />
&nbsp; &nbsp; )<br />
));<br />
<br />
// Fetch the URL's contents<br />
$contents = file_get_contents('http://tomdancer.com', 0, $context);<br />
<br />
// Check for empties<br />
if (!empty($contents))<br />
{<br />
&nbsp; &nbsp; // Woohoo<br />
&nbsp; &nbsp; echo $contents;<br />
}<br />
else<br />
{<br />
&nbsp; &nbsp; // A terrible, terrible disaster occurs<br />
}</div></td></tr></tbody></table></div>
<p>It may be worth noting that a Warning level error is generated on timeout but, of course, you won&#8217;t have error reporting enabled on a production site, right? Also, you could suppress it if you want, but that&#8217;s nasty so don&#8217;t.</p>
<p>Hope this is useful to someone else.</p>
<img src="http://feeds.feedburner.com/~r/tomdancer/~4/nykifdS2Llg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tomdancer.com/setting-a-timeout-on-file_get_contents-for-urls/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://tomdancer.com/setting-a-timeout-on-file_get_contents-for-urls/</feedburner:origLink></item>
		<item>
		<title>Kohana get a witness?</title>
		<link>http://feedproxy.google.com/~r/tomdancer/~3/X3vaVgqM824/</link>
		<comments>http://tomdancer.com/kohana-get-a-witness/#comments</comments>
		<pubDate>Thu, 28 May 2009 12:09:10 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[code igniter]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[kohana]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://tomdancer.com/blog/?p=206</guid>
		<description><![CDATA[I've blogged in the past about building my own PHP framework. I've found little time to further this goal in recent months and so I started looking around for a good foundation to work from. I've used Code Igniter before, but it's lesser known, PHP5-only, strict OOP fork, Kohana seems a better fit with my tastes.]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone image-main" title="Framework" src="http://tomdancer.com/blog/wp-content/uploads/2009/05/framework.jpg" alt="Framework" width="614" height="170" /></p>
<p>I&#8217;ve blogged in the past about building my own PHP framework. I&#8217;ve found (or perhaps made) little time to further this goal in recent months and so, with a couple of small projects to work on, I started looking around for a good foundation to work from. I&#8217;ve used <a href="http://codeigniter.com/">Code Igniter</a> in the past (though not for a few years), but it&#8217;s lesser known, PHP5-only, strict OOP fork, <a href="http://kohanaphp.com/">Kohana</a> seems a better fit with my tastes.<span id="more-206"></span></p>
<p>Calling Kohana a Code Igniter fork now is perhaps a little unfair, though there are still similarities in terms on overall structure, and it does &#8220;feel&#8221; a little like CI did to work with.</p>
<p>So far I&#8217;m enjoying it, and it has impressed me. Kohana is an MVC-based system, designed to be simple and fast, loading and using only the resources it needs. Check out this <a href="http://docs.kohanaphp.com/overview">overview of their approach</a>. There is no installation to speak of; an example application folder comes with the package which you copy to wherever you like. Your app folder contains all site-specific configuration files and can be placed anywhere in relation to the Kohana core, making it easy to have a central core running multiple sites. A path setting in the index.php file points in the right direction. The core configuration files, which cover everything from database settings and sessions to locale and URL routing, any of which can be overriden and brought into play in your app by simply copying it into your app&#8217;s config folder and customizing to taste. It&#8217;s modular, allowing plug-ins to be easily included to extend functionality. There are even some useful modules available for download with Kohana, including a not-too-shabby auth module with user models. The documentation isn&#8217;t quite what CI&#8217;s is but it&#8217;s getting there, and it&#8217;s wiki delivery makes it easy to improve if you care to contribute.</p>
<p>I always liked Code Igniter and it&#8217;s only the fact that I tend to work exclusively with PHP 5 these days that made me tip towards Kohana instead. There&#8217;s a lot to explore in more detail and I&#8217;ll be blogging about the specifics as a get further into it so, if you&#8217;re interested, keep an eye out. Not literally, of course.</p>
<img src="http://feeds.feedburner.com/~r/tomdancer/~4/X3vaVgqM824" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tomdancer.com/kohana-get-a-witness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tomdancer.com/kohana-get-a-witness/</feedburner:origLink></item>
		<item>
		<title>Base jumping with PHP</title>
		<link>http://feedproxy.google.com/~r/tomdancer/~3/13vqAntK3CY/</link>
		<comments>http://tomdancer.com/base-jumping-with-php/#comments</comments>
		<pubDate>Mon, 11 May 2009 00:07:37 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[mathematics]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[url shortening]]></category>

		<guid isPermaLink="false">http://tomdancer.com/blog/?p=193</guid>
		<description><![CDATA[Since my last post, and yet another private self-promise to post on a more regular basis, with more interesting or in depth info than my previous rambles, I have managed to think of around 6 different post ideas, then forgotten about them. So in absence of depth or interest, here's some code, instead. Or at least some writing abotu some code.]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone image-main" title="BASE jumping" src="http://tomdancer.com/blog/wp-content/uploads/2009/05/base_jumping.jpg" alt="BASE jumping" width="614" height="180" /></p>
<p>Since my last post, and yet another private self-promise to post on a more regular basis, with more interesting or in depth info than my previous rambles, I have managed to think of around 6 different post ideas, then forgotten about them. So in absence of depth or interest, here&#8217;s some code, instead. Or at least some writing about some code.<span id="more-193"></span></p>
<p>With the rise of Twitter from little known geek project to social media darling in the last few months, that all important 140 character limit has revealed the need for URL shortening services even more efficient than the ubiquitous <a href="http://en.wikipedia.org/wiki/TinyURL">TinyURL</a>. Following on from <a href="http://snook.ca/archives/php/url-shortener">Jonathan Snook&#8217;s post</a> on building your own, I thought I&#8217;d have a little play around. I don&#8217;t write as much code casually as I used to and it&#8217;s good to keep your hand in.</p>
<h3>The basics</h3>
<p>Unless you&#8217;re insane, you&#8217;ve can probably guess that you can&#8217;t actually <em>convert</em> very long URLs themselves to very tiny ones. Well maybe you can but if so, that seems unnecessary. You simply assign a unique numeric ID to the URL and convert that instead. But to what? Aaaah. Let me show you!</p>
<p>*wavey screen transition and swirly music*</p>
<p>The most commonly known, used and understood numeric system is the Decimal system, otherwise known as base 10. It is known as such because it consists of 10 unique symbols, 0 through to 9. This is a nice, easy way for us to cope with accounting for the things which surround us, taking it&#8217;s base from the number of fingers (and toes) on your average human. There are other less commonly used numeral systems using a wider selection of symbols which are better suited to other specific purposes, none of which I&#8217;m familiar enough with to talk about with any authority, but there&#8217;s always <a href="http://en.wikipedia.org/wiki/Main_Page">Wikipedia</a>, should you want to know more.</p>
<p>The point is that we can take our URL&#8217;s unique ID in base 10 and convert it to a higher base equivalent, a number using a wider range of symbols per unit increment, so our shortened URL code can reach high values without taking on the physical length of its decimal value. How do you convert bases? Well you could look up or work out something clever, be better educated than me and just know, or you could use <a href="http://php.net/base_convert">PHP&#8217;s <em>base_convert</em> function</a>. This allows the conversion of numbers from bases between 2 and 36. For this particular purpose I&#8217;m going to the maximum, base 36. This base uses 0-9 and letters a-z as its 36 symbols. So, for example, for a decimal value of 1,000,000:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;?php<br />
echo base_convert(1000000, 10, 36); // Outputs 'lfls'</div></td></tr></tbody></table></div>
<p>When a user visits the URL, http://yourshortenerthingdomain.com/lfls, the the reverse <em>base_convert</em> is done (same function, swap the 36 and the 10) and the ID of 1000000 used to retrieve the corresponding URL from the database. The user is then simply redirected.</p>
<h3>Where is it?</h3>
<p>I own a few different domains, some useful, some speculative for hopefully eventually completed future projects, others fairly useless. In the latter category is tdous.com. The domain represents a username I&#8217;ve used for some times for a lot of websites. It&#8217;s based on my initials, <em>t</em> and <em>d</em>, and the letters <em>ous</em>, as in suspiciOUS, so, pertaining to me, with the added consequence that t.d.ous sounds like tedious, as an HILARIOUS self-deprecating joke. So, after years of no use whatsoever, <a href="http://tdous.com/">http://tdous.com/</a> now hosts an experimental (in the sense of it being a personal experiment, not that it holds some secret magic new technique) URL shortener. Only I will use it as there are many such sites with shorter base URLs, but popularity or general use at all was not its purpose. It is essentially completely unnecessary. Also, it has been barely tested, but seems to work. There is only the most basic spam filtering.</p>
<p>There are issues with this approach. <em>base_convert</em> apparently suffers a few bugs at very high values as a result of how such numbers are handled in PHP (I assume it&#8217;s a PHP specific problem) and there is a theoretical limit of around 2 billion when you reach the maximum signed 32-bit integer. Also, since this base 36 conversion uses a sequential pattern of symbols, from 0-9 then a-z in that order, it&#8217;s URLs are predictable, so this will eventually produce URL codes which could be offensive to some people. Though that&#8217;s not so much of a problem for me!</p>
<p>So admittedly I&#8217;ve shown very little of the code involved, but most of it is the actual form handling, spam filtering, database connecting and so on. The script in total is very small and I thought I&#8217;d have more fun talking about this than literally showing it off. And I did. So I was right. And therefore I win.</p>
<img src="http://feeds.feedburner.com/~r/tomdancer/~4/13vqAntK3CY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tomdancer.com/base-jumping-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tomdancer.com/base-jumping-with-php/</feedburner:origLink></item>
		<item>
		<title>Freelancery</title>
		<link>http://feedproxy.google.com/~r/tomdancer/~3/qMM6K7xzWZU/</link>
		<comments>http://tomdancer.com/freelancery/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 12:03:58 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[freelance]]></category>
		<category><![CDATA[freelancery]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://tomdancer.com/blog/?p=174</guid>
		<description><![CDATA[After the post about the rather unrealistic expectations of freelance jobs board posters, I started occasionally looking for more of the same. This was partly an investigation into the devaluation of the "industry" I work in, but mostly because I find it funny. What I found was a world of ignorance and bad English.]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone image-main" title="Freelancery" src="http://tomdancer.com/blog/wp-content/uploads/2009/04/freelans.jpg" alt="Freelancery" width="614" height="170" /></p>
<p>After the post about <a href="http://tomdancer.com/blog/what-price-my-time/">the rather unrealistic expectations of freelance jobs board posters</a>, I started occasionally looking for more of the same. This was partly an investigation into the devaluation of the &#8220;industry&#8221; I work in, but mostly because I find it funny. What I found was a world of ignorance and bad English.<span id="more-174"></span></p>
<p>I am not one to laugh at someone for butchering a sentence in a language not their native&#8230; well I am, but not publically&#8230; well, I&#8230; anyway. Here&#8217;s another fine example of underpriced work I stumbled across recently, and some choice applications for the job.</p>
<blockquote><p>Hi</p>
<p>I want a social networking site like facebook,orkut,stumble. This site should have database and very eye cachy design with flash. My terget is to attract age 16 to 23. Login page,bolg,photo gallery,community etc are require. I want a fully functional social networking site. And remember I want a seo professional who can lift my site. Only professional bidder please bid. Low cost fast delivery.My budget is $600</p>
<p>Happy bidding!</p></blockquote>
<p>Seems reasonable–my &#8220;terget&#8221; was always to attract 16 to 23 year olds too. Clone one of the most popular sites in the world for $600 (the actual budget listed for the job, regardless of this description here, was $100-300). Aside from the obvious ease and speed with which any decent freelancer could do this, there are a couple of potential pitfalls that reduce my temptation to reply.</p>
<p>Firstly, apparently they want eye caching. Now I&#8217;ve used a few different types of caching, from MySQL query caching, through opcode caching, to object and raw HTML page caching. But storing a site within the user&#8217;s own eyes for later use, while ingenious, is beyond my skills.</p>
<p>Secondly, they require &#8220;Bolg&#8221;. From the small amount of research I have done, it seems they want to hire an <a href="http://www.metal-archives.com/band.php?id=30558">obscure Bulgarian metal band</a>. I don&#8217;t really understand the relevance, but they already stumped me with eye caching so this is probably an issue with my own knowledge.</p>
<h3>And then there are the replies&#8230;</h3>
<p>If there&#8217;s anything better than the post, it&#8217;s the replies posted by prospective freelancers.</p>
<p>Here&#8217;s one that sounds a little more like a reply on a fetish roleplaying forum. So I&#8217;m told.</p>
<blockquote><p>yes. i&#8217;m ready, please chose me, i&#8217;m waiting&#8230; thanks</p></blockquote>
<p>And if you&#8217;re unsure of yourself, you could always just beg:</p>
<blockquote><p>Hi  I have 4+ years experience in php.Please give me one chance. I can work for you on hourly basis.  Thanks</p></blockquote>
<p>Finally, here is my personal favourite. There is nothing more to be said about it.</p>
<blockquote><p>We are provided with wide experience in the development of web sites . Also we count with the experience that needs and we can offer you the necessary solution,we offer you to do it in Joomla an excellent agent of contents who will allow to update the information and it has hundreds of components extra that then will be able to make you grow in forums, virtual shops,Chat, communities, etc. We count with wide experience in development for portals, virtual shops, systems to measurement in diverse countries like Spain (principal destination of our developments), Argentina,Mexico, Peru, Chile, Costa Rica, USA, England and Holland. In particular and since his portal it is of fightersurely you will know the most well-known portal of weapon of Spain, since at present we it are taking charge migrating to Joomla, with everything his 10Gb of content,users, forums, etc., for which we are constructing and modifying special modules for the information that this way needs it, the project this one in his final phase and soon you will see it in the place replacing to the former portal. Also we have done shops, portals of auction inverse, real estate agencies, forums, social networks, quite in Joomla. We offer a guarantee of 03 months on our work, on any evil functioning or problem of construction which will be corrected without any cost. The best team to your disposition. With more than 8 years of experience and works in different countries. Quality guaranteed in advance. Regards.</p></blockquote>
<img src="http://feeds.feedburner.com/~r/tomdancer/~4/qMM6K7xzWZU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tomdancer.com/freelancery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://tomdancer.com/freelancery/</feedburner:origLink></item>
		<item>
		<title>A little resurfacing work</title>
		<link>http://feedproxy.google.com/~r/tomdancer/~3/TaoZ_NOz7AE/</link>
		<comments>http://tomdancer.com/a-little-resurfacing-work/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 20:53:23 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[cufon]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://tomdancer.com/blog/?p=149</guid>
		<description><![CDATA[The theme I started this blog with was one of the many off the shelf ones as I didn't have the time to make one of my own. It was about time I got round to it, so here it is. It's nothing too fancy or exciting but hopefully it's not too offensive!]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone image-main" title="A little resurfacing work" src="http://tomdancer.com/blog/wp-content/uploads/2009/04/a_little_resurfacing.jpg" alt="A little resurfacing work" width="614" height="175" /></p>
<p>The theme I started this blog with was one of the many off the shelf ones available out there as I didn&#8217;t have the time to make one of my own. It was about time I got round to it, so here it is. It&#8217;s nothing too fancy or exciting but hopefully it&#8217;s not too offensive!<span id="more-149"></span></p>
<p>One of the more interesting elements of building the theme was using <a href="http://cufon.shoqolate.com/generate/">Cufón</a> for the heading text. Despite the existence of things such as <a href="http://www.mikeindustries.com/blog/sifr/">sIFR</a> and it&#8217;s variants and alternatives, I never really got into the idea of font embedding, but with Cufón and <a href="http://typeface.neocracy.org/">Typeface.js</a> gaining notoriety of late, I thought it might be worth a try.</p>
<p>The way both of these options work is to display VML paths, representing the glyphs of a font, via a JavaScript renderer which replaces the standard HTML textual elements you choose. These paths are contained in a JavaScript file which include in your page like any other and which is generated by uploading your chosen font to the converters on their respective sites. While Cufón has been garnering a lot more &#8220;big&#8221; name and popular attention lately, I like an underdog so had intended to try typeface.js first, but it seems that it currently only supports TTFs. The font I had chosen for my headings, <a href="http://betatype.com/node/35">Serif Beta</a>, was only available as an OTF,  so Cufón it was.</p>
<h3>Easy enough for an idiot like me</h3>
<p>Usage is fairly simple, and made even simpler through the inclusion of jQuery first—Cufón will use jQuery&#8217;s selector engine to allow to very easily pick out the elements to replace. So, to replace all h2 elements, you can do something like this:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Cufon.replace('h2');</div></td></tr></tbody></table></div>
<p>To replace all h2&#8217;s and all li&#8217;s with a class of &#8216;fancy-text&#8217;:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Cufon.replace('h2')('li.fancy-text');</div></td></tr></tbody></table></div>
<p>The full range of jQuery&#8217;s selectorization is available.</p>
<p>The one problem I&#8217;ve found so far is an occaional slight &#8220;jump&#8221; where the original text will occasionally appear in it&#8217;s CSS defined font before the JS has loaded and pop into it&#8217;s Cufóned form once the loading is complete. This is apparently mitigated by have the Cufón call take place at the very end of the page which is why I&#8217;m called the&#8230;</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Cufon.now();</div></td></tr></tbody></table></div>
<p>&#8230;function right before the closing body tag of the page footer, whereas I&#8217;d normally prefer to had that inside a domready jQuery event, since I&#8217;m using jQuery anyway. And while it does still occasionally happen, it only seems to be occasional so it&#8217;s a small price to pay.</p>
<h3>Hope you like it</h3>
<p>Typography aside, I&#8217;m reasonably happy with the theme. It&#8217;s pretty simple, like it&#8217;s creator, which is what I wanted, so it should afford a bit of flexibility over time if I want to add things to the site. If you have any comments or suggestions, please leave them below. Just in case you&#8217;re new to blogs.</p>
<img src="http://feeds.feedburner.com/~r/tomdancer/~4/TaoZ_NOz7AE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tomdancer.com/a-little-resurfacing-work/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://tomdancer.com/a-little-resurfacing-work/</feedburner:origLink></item>
		<item>
		<title>What price my time?</title>
		<link>http://feedproxy.google.com/~r/tomdancer/~3/Y5ggU7qefQY/</link>
		<comments>http://tomdancer.com/what-price-my-time/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 07:30:53 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[freelance]]></category>
		<category><![CDATA[modules]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://tomdancer.com/blog/?p=39</guid>
		<description><![CDATA[For those outside of the world of web design/development, it can be hard to understand what we do. Why does it take so long? It's only a website, right? But getting things just right, as with anything, takes time. Here's an example of a lack of this appreciation.]]></description>
			<content:encoded><![CDATA[<p><img class="image-main" title="what_price_my_time" src="http://tomdancer.com/blog/wp-content/uploads/2009/03/what_price_my_time.jpg" alt="what_price_my_time" width="614" height="160" /></p>
<p>For those outside of the world of web design/development, it can be hard to understand what we do. Why does it take so long? It&#8217;s only a website, right? But getting things just right, as with anything, takes time. But while some are frightened and confused by the process, others are outright ignorant of it and, I&#8217;d go as far to say, insulting in their payment for the time and skill involved. Here&#8217;s an example.<span id="more-39"></span></p>
<p>Drupal is an <a href="http://en.wikipedia.org/wiki/Open_source_software">open source</a> Content Management System. Well, it&#8217;s more than just a CMS, it&#8217;s a development framework, albeit one wrapped around a back-end interface. It&#8217;s sort of a CMS contruction kit. It&#8217;s modular, so if you want to add a feature or set of features and there&#8217;s a module already written to do so, you can plug it in and away you go. But despite that, it still takes time to develop a Drupal site—to write or customize modules for that functionality specific to this project, to make sure all these component parts work correctly together, to design and build a theme, the code the fancy JavaScripts that the kids love, to get it just right. So when a friend of mine saw this project posted on a website where people can find a freelancer to do some work for them, I had to pass it on.</p>
<p>First, here are the requirements:</p>
<blockquote><p><strong>Summary</strong><br />
We need an experienced Drupal programmer/developer in order to set up a site based on Drupal. Although we don&#8217;t have significant drupal experience it seems that most features can be implemented through core modules and contributed modules without the need for real programming at this stage. On a later stage extensive customization may be needed</p>
<p><strong>Site Description</strong><br />
A fairly simple portal and community site. The site will have articles, divided in categories, forums, chat rooms and users blogs.</p>
<p><strong>Categories</strong><br />
The site must display a page for every category and sub-category. This page must include teasers of the latest articles in this category (main), most popular (side column) and most highly rated articles (side). Also category page must display the latest related forum posts and a link to add a post in this category</p>
<p><strong>Articles</strong><br />
Each article will be admin only posted and must have the following features:<br />
- Visitors will have access to teasers only, registered users to the whole article.<br />
- Standard features (Print, email, pdf, vote, comments, tags etc)<br />
- Related articles / Read also features<br />
- Picture(s) inside article<br />
- A thumb of the article picture must be displayed in the teaser text on other pages.<br />
- Display of author name / username must be an option, in both articles and teasers views.<br />
- Internal gallery with categories (admin only access) of articles images<br />
- Full HTML WYSIWYG editor for the articles</p>
<p><strong>Forums</strong><br />
- All will have access only registered users will post<br />
- Will follow the article categorization plus few categories of their own<br />
- Comments will be directly posted by registered users, or will be checked before go public by the admin, depending on specific user field.<br />
- There must be moderators by forum category and subcategory<br />
- Each post could be voted as useful or useless<br />
- Ability to attach pictures in selected categories<br />
- Simplified WYSIWYG editor for the posts</p>
<p><strong>Blogs</strong><br />
- Central page with the most popular, and new blogs (with teasers)<br />
- Users with a selected flag set, or group access, will have the option to have their own blog page<br />
- Link to each user blog though users&#8217; profile<br />
- Report to admin link for every blog / comment entry</p>
<p><strong>Chat rooms</strong><br />
- Multiple rooms<br />
- Male/female marking<br />
- Ajax or flash based<br />
- Smilies<br />
- Kick/ban options<br />
- Private messages<br />
- Operator status based on user field</p>
<p><strong>Media Galleries</strong><br />
Each registered user will have the option to create Galleries of selected media (photos, movies etc).<br />
- Main page for most popular and new galleries</p>
<p><strong>Messages</strong><br />
- Each registered user will be able to send private messages to other users.<br />
- Message length limitation<br />
- Black list / Unwanted senders for each user</p>
<p><strong>Users / Profiles</strong><br />
- 3 levels of users: Visitors, Registed Users, Premium Members<br />
- External page call with parameters must change the Registered Users to Premium Members, for a specific time period.<br />
- User fields: male/female, age, short bio, main photo, photo<br />
- Admin approval for all user submitted content, from one centralized place.</p>
<p><strong>Social Networking Capabilities (optional)</strong><br />
- Depending of existing user contributed modules / cost of implementation</p>
<p><strong>Theme</strong><br />
An already selected theme will be used.</p>
<p><strong>Other Requirements</strong><br />
- The site must be fast (not hundreds of queries per page), secure and SEO friendly.<br />
- Developer can suggest additional (cost efficient) relative features<br />
- Developer can also suggest removal of specific features if they are too complicated to implement.</p></blockquote>
<p>I&#8217;m going to ask around to get some opinions on how long people think this would take and how much they think it might be worth, so comments welcome. I&#8217;ll post the actual time scale/offered price later.</p>
<p>Stay tuned!</p>
<h3>Update</h3>
<p>Ok, here what they said at first:</p>
<blockquote><p>Budget: $250-750<br />
Project must be delivered within 10 working days.</p></blockquote>
<p>And then later, after some people have placed bids:</p>
<blockquote><p>Some of the initial bids seem to be in the extreme upper price range&#8230;<br />
Come on guys&#8230;<br />
What of the above you can perform for lets say $300-$400?</p></blockquote>
<img src="http://feeds.feedburner.com/~r/tomdancer/~4/Y5ggU7qefQY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tomdancer.com/what-price-my-time/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://tomdancer.com/what-price-my-time/</feedburner:origLink></item>
		<item>
		<title>Hooks and Modules</title>
		<link>http://feedproxy.google.com/~r/tomdancer/~3/7v_vLQxIRe4/</link>
		<comments>http://tomdancer.com/hooks-and-modules/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 14:14:50 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[hooks]]></category>
		<category><![CDATA[modules]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://tomdancer.com/blog/?p=62</guid>
		<description><![CDATA[Following on from the post where <a href="http://tomdancer.com/blog/my-nails-are-too-pretty/">I vaguely mentioned building a framework</a>, I thought I would get started on two crucial elements of it today, namely hooks and modules.]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone image-main" title="hooks_and_modules" src="http://tomdancer.com/blog/wp-content/uploads/2009/03/hooks_and_modules.jpg" alt="hooks_and_modules" width="614" height="210" /></p>
<p>Following on from the post where <a href="http://tomdancer.com/blog/my-nails-are-too-pretty/">I vaguely mentioned building a framework</a>, I thought I would get started on two crucial elements of it today, namely hooks and modules. I&#8217;ll talk about how they will work in a moment but first I wanted to explain the state of the code as I begin this part of the project.<span id="more-62"></span></p>
<p>As I have said, I&#8217;ve building a site in order to build the framework. The site is a gallery, similar, at least in structure, to <a href="http://cssimport.com">http://cssimport.com</a> or <a href="http://bestwebgallery.com">http://bestwebgallery.com</a> and will make use of external services to generate parts of its content. There is currently a URL router, views, templates, basic authentication and very, very basic database connection handling. The core pulls these elements together procedurally depending on what is required to serve the request. This all consists of very little code at the moment. It is embryonic, very basic and very fast. I&#8217;m hoping to use this simple base as a benchmark and to try to avoid straying too far from it&#8217;s simplicity to avoid adding unnecessary overhead to a request. But, getting back to the point, the next step is hooks and modules.</p>
<h3>And they are&#8230;?</h3>
<p>Starting with modules, as they are a more widely understood concept, a module is an add-on, a plug-in, an extension. It adds functionality to the system. For example, the User module (as it will be—this code was initially written into the core for ease) provides the framework with authentication, registration, group permissions, profiles and so on. A module which is not required is flagged as inactive, its code is not imported and it has no bearing on request overhead.</p>
<p><a href="http://en.wikipedia.org/wiki/Hooking">Hooking</a> is &#8220;a technique used to alter or augment the behavior of an operating system or application&#8221;. In the framework, hooks will be used to allow modules control over certain core functionality. For example, one hook will allow a module to add to the URL routing table, another may be used to override output to one template, switching it to another if certain conditions are met. There will be types of hook affecting whether they are run before, during or after the request.</p>
<p>The list of modules, which ones are active, and which ones contain what hooks is all data which will be cached as this processing would add a substantial expense to each request. The cache will only be refreshed when a module is activated or deactivated, or when a manual refresh is called.</p>
<h3>Prior art</h3>
<p>As ever, none of this is new. All the best frameworks and some CMS&#8217;s will offer this or similar functionality. Drupal, for example, use the same terminology of &#8220;modules&#8221; and &#8220;hooks&#8221;, indeed I&#8217;m taking some cues from that implementation.</p>
<p>I&#8217;m looking forward to seeing what I can do with this. I remember my first experiments in building a completely modular CMS way back in about 2003. That was a little more extreme in its modularity and more of a purely academic exercise than a practical reality. There was no core functionality at all, only the absolute minimum required to discover and load other modules in the correct order. From there you would add the building blocks of the system in completely plug and play fashion. Back then I paid little attention to other work going on around me, or to existing systems—I just enjoyed coding this stuff up. working in my spare time, and alone, I wasn&#8217;t aware of the standard of existing systems out there. But I always assumed that people must have already done way more, way better than I was capable of so I never really shared it or showed it, or backed it up, sadly. Makes me wonder, knowing the state of the solutions available today what I might be doing now if some of those early high-minded experiments which are long since lost had become something more, and if my enthusiasm or optimism hadn&#8217;t been severely damaged by my <strong>previous</strong> over-working employment. But, musing and self-importance aside, this should be interesting.</p>
<img src="http://feeds.feedburner.com/~r/tomdancer/~4/7v_vLQxIRe4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tomdancer.com/hooks-and-modules/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://tomdancer.com/hooks-and-modules/</feedburner:origLink></item>
		<item>
		<title>Ok, what the &amp;@*$ happened?!</title>
		<link>http://feedproxy.google.com/~r/tomdancer/~3/4Ykl_34x1tQ/</link>
		<comments>http://tomdancer.com/ok-what-happened/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 00:23:41 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[inspiration]]></category>
		<category><![CDATA[me]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://tomdancer.com/blog/?p=36</guid>
		<description><![CDATA[Once upon a time, I could make pretty things. I mean, I was no Van Gogh, but it wasn't terrible. Certainly not compared the majority of the comedy design work you see strewn across the web. So, given the difficulty I seem to have these days designing even the simplest site, what the &#$% happened?]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone image-main" title="WTF?!" src="http://tomdancer.com/blog/wp-content/uploads/2009/03/what_the_xxxx_happened.jpg" alt="WTF?!" width="614" height="191" /></p>
<p>Once upon a time, I could make pretty things. I mean, I was no Van Gogh, but they weren&#8217;t terrible. Certainly not compared the majority of the comedy design work you see strewn across the web. So, given the difficulty I seem to have these days designing even the simplest site, what the &amp;#$% happened?<span id="more-36"></span></p>
<p>I have no copies of my earliest web design/development work. All of this was produced either when I was working &#8220;freelance&#8221; (not in any official capacity—I was knocking up sites for local bands as learning exercise), or at my previous full time gig, my first real paid web position. Combined, those two periods span about 7 years and that&#8217;s a lot of material to have completely lost to idiotically poor backup regimes and corporate bankruptcy.</p>
<h3>How did I do that?!</h3>
<p>Earlier today, I suddenly recalled one band site I had worked on a long time ago. It&#8217;s long dead but I found a partially working copy of it on <a href="http://www.archive.org/web/web.php">the Wayback Machine</a>. I don&#8217;t want to link to it—the database that fuelled the Flash front end couldn&#8217;t be archived of course, and a bunch of sub-movies are missing, so it really doesn&#8217;t look or work as it should. But visually I thought it was pretty impressive. Now, that sounds a little arrogant. But the point is that I can&#8217;t imagine even conceiving of that design now. I feel so removed from whatever state of mind I was in when I built that site that it doesn&#8217;t feel like I really did it and I can get away with praising my own work.</p>
<p>I&#8217;m not really required to design anything at work, luckily for them. But recently, in the privacy of my own home, I&#8217;ve been mocking up some basic layouts for some old ideas and just for fun… just to see what I could come up with blind. Results have been mixed. Few are outright bad. Most are simply dull. In particular I seem to have a problem with choosing colours. As I mentioned, I&#8217;m not a trained designer. Without reference material, I have no idea which colour works with another in this way or that.</p>
<h3>The value of inspiration</h3>
<p>It seems that the more I&#8217;ve learned about &#8220;the way to build websites&#8221; over the years, the more restricted I have become in imagining how they can be presented. There is certainly no lack of inspiration. The 3,000 CSS galleries out there provide a constant flow of eye candy, and I&#8217;m sure it wouldn&#8217;t be too hard to find a rather smashing article which lists &#8220;500 Ways to Instantly Be Excellent at Whatever&#8221;.</p>
<p>Is that too much inspiration? Is looking at row after row of beautiful and mostly only subtly different work helpful or a hindrance? The content is often repeated from one site to the next and trends are shared. I find myself looking at quite similar sites over and over. There may be some very nice aspects to a design but their impact is dulled somewhat by the sheer number of nice aspects I&#8217;m having to take in one after the other. The whole internet becomes a homogenized mush in my mind and this makes it hard to imagine sets of specific, complimentary features or visual elements as part of something new, or at least different.</p>
<p>The goal, I guess, should be to learn how to absorb inspiration appropriately, analyzing what I&#8217;m seeing and picking out the parts I like, why and for what they could be useful, rather than simply looking at all of these sites, saying &#8220;ooh&#8221;, then moving on to the next. That and practice, obviously. I used to sit and experiment for hours. My day job at the time had nothing to do with this industry so the evening were playtime. Didn&#8217;t do much for what was my relationship at the time, but it was an exciting time in terms of learning and trying new things. In moderation, more of that is required again I think. So I&#8217;ll keep mocking up my crap and hopefully get better over time. I&#8217;ll try to work out what I like about things I see rather than just admiring how shiny they are. And anything else I think of long after posting this that didn&#8217;t occur to me at the time but is in fact painfully obvious.</p>
<img src="http://feeds.feedburner.com/~r/tomdancer/~4/4Ykl_34x1tQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tomdancer.com/ok-what-happened/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://tomdancer.com/ok-what-happened/</feedburner:origLink></item>
		<item>
		<title>But my nails are simply too pretty to get my hands dirty</title>
		<link>http://feedproxy.google.com/~r/tomdancer/~3/elmNqkoKIMo/</link>
		<comments>http://tomdancer.com/my-nails-are-too-pretty/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 21:54:37 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://tomdancer.com/blog/?p=14</guid>
		<description><![CDATA[I like writing code. Writing code, especially good code, takes time. As developers, over time we build up a stash of functions or tricks which we can re-use in future projects and this certainly helps to mitigate the cost in time, but this only goes so far.]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone image-main" title="Urgh..." src="http://tomdancer.com/blog/wp-content/uploads/2009/03/my_nails_are_too_pretty.jpg" alt="Urgh..." width="614" height="176" /></p>
<p>I like writing code. Of the programming sort, that is, not the kind that teenage girls invent to secretly talk about boys, celebrities and experimental lesbianism at sleep-overs (you can&#8217;t fool me—I know what goes on). Just wanted to be clear.<span id="more-14"></span></p>
<p>Writing code, especially good code, takes time. As developers, over time we build up a stash of functions or tricks which we can re-use in future projects and this certainly helps to mitigate the cost in time, but this only goes so far.</p>
<h3>Enter the Framework and the CMS</h3>
<p>Frameworks range in complexity and density of features, but in the end the goal is usually to aid development by providing a codebase from which to begin. This usually takes care of some of the grunt-work—the database connecting, query building and executing, templating, caching, authentication, string processing and so on. Content Management Systems also vary greatly and, while often providing for the same needs as a frameworks, are based around a back-end interface for easy, usually form-based administration of the site and its content. Of the pre-built solutions out there, other than Wordpress (if you count it as a full-blown CMS and I won&#8217;t be starting that argument here) I have only really been exposed to Drupal in any great depth. I&#8217;ve been involved in the making of a couple of bespoke ones, built for specific tasks.</p>
<p>Drupal is an interesting case. A hybrid in my opinion, rather than being merely a CMS, out of the box it&#8217;s more like a full-featured framework which happens to come with a back-end. It is very powerful and flexible. There seems to be a misconception out there that Drupal is both bloated and slow. It is in fact very modular, the actual core being quite small. Its compression and caching features can be used to great effect to keep even the most dynamic content-heavy sites running smoothly and serving pages quickly. Ask Nike, or MTV, or President Barack Obama (assuming he built the campaign sites himself).</p>
<h3>So?</h3>
<p>So, I don&#8217;t like using them. Frameworks or CMS&#8217;s. That&#8217;s not because they are not good tools. Drupal in particular is very powerful. It&#8217;s our primary development platform at <a href="http://orangebus.co.uk/">OrangeBus</a> and I don&#8217;t think there&#8217;s much we couldn&#8217;t do with it. The benefits, as I mentioned above, of such platforms are fairly obvious—and anything which can facilitate faster and more efficient development has to be a good thing.</p>
<p>But I like writing code. We write modules for our frameworks, plug-ins for our CMS&#8217;s, but that&#8217;s just not the same as coding something from the ground up, reloading the page and seeing it spring into life. It&#8217;s a naive attitude from a business perspective, certainly, but in a way that most people wouldn&#8217;t be able or willing to appreciate there is a tangible sense of creativity in the slower more hand on approach.</p>
<p>Before this blog&#8217;s temporary shutdown I had mentioned that I was working on a framework of my own for use in any personal projects I take on outside of the day job. In fact I have barely even looked at that code for months until recently. But after reopening the blog I started on a project I&#8217;ve had in the works for nearly two years. It&#8217;s nothing huge, it&#8217;s not even all that serious, but it&#8217;s fun for me. I&#8217;ll mention more about that in the future as I work out more of the details. It has also given me the opportunity to build the framework I want as I build the site, adding features to it where the site requires them to be present if it seems like they would be of benefit to other sites. This may not be the best way to develop a framework, but hey, this is the way I want to do it, so screw you.</p>
<p>At this point it&#8217;s worth noting that none of this is likely to be news to anyone interested in actually reading this, rendering the whole thing fairly pointless. but this is my blog, so screw you once more.</p>
<p>So yes, building this framework is fairly pointless—there is bound to be suitable, pre-existing solution out there. But it&#8217;s fun. I like getting my hands dirty. And my nails aren&#8217;t actually all that pretty to start with. They&#8217;re worn and manly from all the man-tasks I&#8217;ve been completely with consummate, manly ease.</p>
<img src="http://feeds.feedburner.com/~r/tomdancer/~4/elmNqkoKIMo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tomdancer.com/my-nails-are-too-pretty/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://tomdancer.com/my-nails-are-too-pretty/</feedburner:origLink></item>
	</channel>
</rss>
