<?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>devbytes</title>
	
	<link>http://devbytes.clintonmontague.co.uk</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Sat, 22 Jan 2011 21:02:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Devbytes" /><feedburner:info uri="devbytes" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Ooops – and the plan!</title>
		<link>http://feedproxy.google.com/~r/Devbytes/~3/Wa2zuhoS4iQ/</link>
		<comments>http://devbytes.clintonmontague.co.uk/more-posts-soon/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 21:02:35 +0000</pubDate>
		<dc:creator>Clinton Montague</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[apology]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[masterclass]]></category>
		<category><![CDATA[training]]></category>

		<guid isPermaLink="false">http://devbytes.clintonmontague.co.uk/?p=120</guid>
		<description><![CDATA[Well, it turns out that I haven&#8217;t kept this site as up-to-date as I was hoping. It&#8217;s been months since I&#8217;ve posted, for which I apologise. If you follow @devbytes on Twitter, hopefully you&#8217;ve been enjoying the links which I&#8217;ve been posting, at least they have been a little more frequent than the posts on [...]]]></description>
			<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://devbytes.clintonmontague.co.uk/more-posts-soon/", "Ooops &#8211; and the plan!", "" );
		//--></script></span><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdevbytes.clintonmontague.co.uk%2Fmore-posts-soon%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Well, it turns out that I haven&#8217;t kept this site as up-to-date as I was hoping. It&#8217;s been months since I&#8217;ve posted, for which I apologise.</p>
<p>If you follow <a href="http://twitter.com/devbytes">@devbytes</a> on Twitter, hopefully you&#8217;ve been enjoying the links which I&#8217;ve been posting, at least they have been a little more frequent than the posts on here! </p>
<p>I will be attending a masterclass on Creative JavaScript and HTML5 in Brighton in February hosted by <a href="http://twitter.com/seb_ly">@seb_ly</a> after which I am hoping to play a lost with the canvas tag and other JavaScriptery, so I suspect that this blog will be turning into a bit of a JS resource with the odd server-side nugget thrown in for good measure; I&#8217;m beginning to see the server side as a means to and end and the front-end as very exciting. </p>
<p>Hope to see you here this year, and hope to post more snippets to keep you coming back.</p>
<p>Fingers crossed!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Devbytes?a=Wa2zuhoS4iQ:FAgcaps6ne0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Devbytes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=Wa2zuhoS4iQ:FAgcaps6ne0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=Wa2zuhoS4iQ:FAgcaps6ne0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=Wa2zuhoS4iQ:FAgcaps6ne0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=Wa2zuhoS4iQ:FAgcaps6ne0:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Devbytes/~4/Wa2zuhoS4iQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://devbytes.clintonmontague.co.uk/more-posts-soon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://devbytes.clintonmontague.co.uk/more-posts-soon/</feedburner:origLink></item>
		<item>
		<title>Fix broken WordPress permalinks for custom post types</title>
		<link>http://feedproxy.google.com/~r/Devbytes/~3/Go8miNF3AY4/</link>
		<comments>http://devbytes.clintonmontague.co.uk/wordpress-flush_rewrite_rules/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 19:07:36 +0000</pubDate>
		<dc:creator>Clinton Montague</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[flush]]></category>
		<category><![CDATA[flush_rewrite_rules]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[rules]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://devbytes.clintonmontague.co.uk/?p=107</guid>
		<description><![CDATA[If you&#8217;ve added some custom post types or taxonomies and you get 404 pages when trying to get to your new pages, you might need to remind WordPress that it needs to update its rules for handling URLs. Luckily, you can do this in one easy step with flush_rewrite_rules(). Just make sure it&#8217;s after your [...]]]></description>
			<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://devbytes.clintonmontague.co.uk/wordpress-flush_rewrite_rules/", "Fix broken WordPress permalinks for custom post types", "" );
		//--></script></span><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdevbytes.clintonmontague.co.uk%2Fwordpress-flush_rewrite_rules%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>If you&#8217;ve added some custom post types or taxonomies and you get 404 pages when trying to get to your new pages, you might need to remind WordPress that it needs to update its rules for handling URLs. Luckily, you can do this in one easy step with <code>flush_rewrite_rules()</code>. </p>
<p>Just make sure it&#8217;s after your custom post type definitions and everything will sort itself out.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Devbytes?a=Go8miNF3AY4:CueLdZFtlWo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Devbytes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=Go8miNF3AY4:CueLdZFtlWo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=Go8miNF3AY4:CueLdZFtlWo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=Go8miNF3AY4:CueLdZFtlWo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=Go8miNF3AY4:CueLdZFtlWo:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Devbytes/~4/Go8miNF3AY4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://devbytes.clintonmontague.co.uk/wordpress-flush_rewrite_rules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://devbytes.clintonmontague.co.uk/wordpress-flush_rewrite_rules/</feedburner:origLink></item>
		<item>
		<title>Javascript setTimeout with anonymous functions</title>
		<link>http://feedproxy.google.com/~r/Devbytes/~3/jsY7CxDCcuA/</link>
		<comments>http://devbytes.clintonmontague.co.uk/settimeout-anonymous-functions/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 19:07:21 +0000</pubDate>
		<dc:creator>Clinton Montague</dc:creator>
				<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[anonymous functions]]></category>
		<category><![CDATA[closures]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[lambda]]></category>
		<category><![CDATA[settimeout]]></category>

		<guid isPermaLink="false">http://devbytes.clintonmontague.co.uk/?p=103</guid>
		<description><![CDATA[Sometimes you don&#8217;t want to create a named function in JavaScript just so that you can call it with setTimeout. And as Doug Crockford is always saying, eval is an evil thing. To get anonymous functions to work with setTimeout or setInterval, you can use an the arguments object to call the anonymous function again. [...]]]></description>
			<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://devbytes.clintonmontague.co.uk/settimeout-anonymous-functions/", "Javascript setTimeout with anonymous functions", "" );
		//--></script></span><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdevbytes.clintonmontague.co.uk%2Fsettimeout-anonymous-functions%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Sometimes you don&#8217;t want to create a named function in JavaScript just so that you can call it with setTimeout. And as Doug Crockford is always saying, <code>eval</code> is an evil thing. </p>
<p>To get anonymous functions to work with setTimeout or setInterval, you can use an the <code>arguments</code> object to call the anonymous function again.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">// if you have a halting condition, add it here, otherwise run forever</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>some_halting_condition <span style="color: #339933;">||</span> run_forever<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// function code to go here as normal</span>
		setTimeout<span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">callee</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>It turns out that this is an amazingly useful pattern. Say you want a function to run every one second, but the function&#8217;s running time is actually two seconds. That&#8217;s not cool &#8211; so by using this pattern, the function will wait for a second after it has finished running, then call itself again. </p>
<p>jQuery uses a very similar pattern for (among other things, I&#8217;m sure) checking to see when the DOM has loaded in Internet Explorer by checking to see if the document body is scrollable.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Devbytes?a=jsY7CxDCcuA:__25U-L37cQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Devbytes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=jsY7CxDCcuA:__25U-L37cQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=jsY7CxDCcuA:__25U-L37cQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=jsY7CxDCcuA:__25U-L37cQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=jsY7CxDCcuA:__25U-L37cQ:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Devbytes/~4/jsY7CxDCcuA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://devbytes.clintonmontague.co.uk/settimeout-anonymous-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://devbytes.clintonmontague.co.uk/settimeout-anonymous-functions/</feedburner:origLink></item>
		<item>
		<title>Example WordPress custom taxonomies and post types</title>
		<link>http://feedproxy.google.com/~r/Devbytes/~3/Zxw8X1muEcM/</link>
		<comments>http://devbytes.clintonmontague.co.uk/wordpress-custom-taxonomies-and-post-types/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 16:55:33 +0000</pubDate>
		<dc:creator>Clinton Montague</dc:creator>
				<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Notes]]></category>
		<category><![CDATA[Time savers]]></category>
		<category><![CDATA[copy-paste]]></category>
		<category><![CDATA[custom post type]]></category>
		<category><![CDATA[custom taxonomy]]></category>
		<category><![CDATA[register_post_type]]></category>
		<category><![CDATA[register_taxonomy]]></category>
		<category><![CDATA[taxonomy]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress3]]></category>

		<guid isPermaLink="false">http://devbytes.clintonmontague.co.uk/?p=98</guid>
		<description><![CDATA[Just a quick copy-paste of a custom taxonomy and post type for my site coasternerd. Currently, the site is built using categories creatively, but I thought it would be a nice exercise to rewrite it using the new features in WordPress 3. It actually turns out that using these is much, much quicker than hacking [...]]]></description>
			<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://devbytes.clintonmontague.co.uk/wordpress-custom-taxonomies-and-post-types/", "Example WordPress custom taxonomies and post types", "" );
		//--></script></span><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdevbytes.clintonmontague.co.uk%2Fwordpress-custom-taxonomies-and-post-types%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Just a quick copy-paste of a custom taxonomy and post type for my site <a href="http://coasternerd.com/">coasternerd</a>. Currently, the site is built using categories creatively, but I thought it would be a nice exercise to rewrite it using the new features in WordPress 3.</p>
<p>It actually turns out that using these is much, much quicker than hacking around how categories are used to build various page types. </p>
<p>Won&#8217;t explain this today, but I wanted to make a note of it so that I can look back for example usage in the future.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/* to go inside functions.php
 *
 * Note: This will only work in WP3+!
 */</span>
add_action <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'register_custom_types'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> register_custom_types <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	register_post_type <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rollercoaster'</span><span style="color: #339933;">,</span>
		<span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Roller coasters'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'singular_label'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Roller coaster'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'labels'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">'not_found'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'No coasters have been built yet!'</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'add_new'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Build a coaster!'</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'add_new_item'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Build a coaster!'</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'edit_item'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Modify a coaster'</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'new_item'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Build a coaster!'</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'search_items'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Find a coaster'</span>
				<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'List of roller coasters'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'public'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'menu_position'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'supports'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thumbnail'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'page-attributes'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'editor'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'taxonomies'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'themepark'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'publicly_queryable'</span><span style="color: #339933;">=&gt;</span>true<span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'rewrite'</span><span style="color: #339933;">=&gt;</span>array<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;slug&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;rollercoaster&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
&nbsp;
	register_taxonomy <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'themepark'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rollercoaster'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Theme parks'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'labels'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'singular_name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Theme park'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'search_items'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Find parks'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'popular_items'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Parks with most coasters'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'add_new_item'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Build a new park!'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'add_new'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Build a new park!'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'all_items'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'All theme parks'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'edit_item'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Edit a park'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'publicly_queryable'</span><span style="color: #339933;">=&gt;</span>true<span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'public'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'themepark'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'rewrite'</span><span style="color: #339933;">=&gt;</span>array<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'slug'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'themepark'</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Devbytes?a=Zxw8X1muEcM:KpxsQXZTH2c:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Devbytes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=Zxw8X1muEcM:KpxsQXZTH2c:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=Zxw8X1muEcM:KpxsQXZTH2c:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=Zxw8X1muEcM:KpxsQXZTH2c:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=Zxw8X1muEcM:KpxsQXZTH2c:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Devbytes/~4/Zxw8X1muEcM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://devbytes.clintonmontague.co.uk/wordpress-custom-taxonomies-and-post-types/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://devbytes.clintonmontague.co.uk/wordpress-custom-taxonomies-and-post-types/</feedburner:origLink></item>
		<item>
		<title>Enable post thumbnails in WordPress</title>
		<link>http://feedproxy.google.com/~r/Devbytes/~3/ToyziVL7Dbc/</link>
		<comments>http://devbytes.clintonmontague.co.uk/wordpress-post-thumbnails/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 18:18:06 +0000</pubDate>
		<dc:creator>Clinton Montague</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[Time savers]]></category>
		<category><![CDATA[add_theme_support]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[post-thumbnails]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[the_post_thumbnail]]></category>
		<category><![CDATA[thumbnails]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://devbytes.clintonmontague.co.uk/?p=83</guid>
		<description><![CDATA[I noticed a very cool feature in WordPress today which lets you add thumbnail images to posts and pages. I used to do this with a custom field, but this makes it much, much easier. Turn it on Add this line to your theme&#8217;s functions.php add_theme_support&#40; 'post-thumbnails' &#41;; Using it When you write/edit a post, [...]]]></description>
			<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://devbytes.clintonmontague.co.uk/wordpress-post-thumbnails/", "Enable post thumbnails in WordPress", "" );
		//--></script></span><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdevbytes.clintonmontague.co.uk%2Fwordpress-post-thumbnails%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I noticed a very cool feature in WordPress today which lets you add thumbnail images to posts and pages. I used to do this with a custom field, but this makes it much, much easier.</p>
<h2>Turn it on</h2>
<p>Add this line to your theme&#8217;s functions.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_theme_support<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post-thumbnails'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>Using it</h2>
<p><a href="http://devbytes.clintonmontague.co.uk/wordpress/wp-content/uploads/Picture-3.png" style="float: right; margin-left: 1em; margin-bottom: 1em;"><img src="http://devbytes.clintonmontague.co.uk/wordpress/wp-content/uploads/Picture-3.png" alt="" title="Native WordPress post thumnails" width="285" height="154" class="alignnone size-full wp-image-84" /></a> When you write/edit a post, you&#8217;ll see a new box alongside Categories, Post Tags etc. From here, you can upload a thumbnail or choose one from the Media Library as you would for adding an image to a post.</p>
<p>Then inside your post templates, add this to display the thumbnail</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Devbytes?a=ToyziVL7Dbc:UYB_NOGRpPE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Devbytes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=ToyziVL7Dbc:UYB_NOGRpPE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=ToyziVL7Dbc:UYB_NOGRpPE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=ToyziVL7Dbc:UYB_NOGRpPE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=ToyziVL7Dbc:UYB_NOGRpPE:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Devbytes/~4/ToyziVL7Dbc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://devbytes.clintonmontague.co.uk/wordpress-post-thumbnails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://devbytes.clintonmontague.co.uk/wordpress-post-thumbnails/</feedburner:origLink></item>
		<item>
		<title>Round != rand</title>
		<link>http://feedproxy.google.com/~r/Devbytes/~3/V-FuwOUMpj0/</link>
		<comments>http://devbytes.clintonmontague.co.uk/round-is-not-random/#comments</comments>
		<pubDate>Fri, 28 May 2010 19:47:30 +0000</pubDate>
		<dc:creator>Clinton Montague</dc:creator>
				<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Notes]]></category>
		<category><![CDATA[ceil]]></category>
		<category><![CDATA[floor]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[math.floor]]></category>
		<category><![CDATA[math.random]]></category>
		<category><![CDATA[maths]]></category>
		<category><![CDATA[numbers]]></category>
		<category><![CDATA[rand]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[round]]></category>

		<guid isPermaLink="false">http://devbytes.clintonmontague.co.uk/?p=78</guid>
		<description><![CDATA[When I wanted a random number (more specifically integer), I used to do something like this (written in JavaScript): 1 2 var highest = 3, random = Math.round &#40; Math.random &#40;&#41; * &#40;highest-1&#41; + 1&#41;; Sounds good, right? Wrong. Let&#8217;s try to make a random number between 1 and 3. It turns out that by [...]]]></description>
			<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://devbytes.clintonmontague.co.uk/round-is-not-random/", "Round != rand", "" );
		//--></script></span><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdevbytes.clintonmontague.co.uk%2Fround-is-not-random%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>When I wanted a random number (more specifically integer), I used to do something like this (written in JavaScript):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> highest <span style="color: #339933;">=</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span>
      random <span style="color: #339933;">=</span> Math.<span style="color: #660066;">round</span> <span style="color: #009900;">&#40;</span> Math.<span style="color: #660066;">random</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>highest<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Sounds good, right? </p>
<p>Wrong. Let&#8217;s try to make a random number between 1 and 3. It turns out that by using <code>round</code>, number 2 has a 50% chance of turning up with 1 and 3 having only a 25% chance. </p>
<p>1 can only be chosen if <code>(Math.random * 2) + 1</code> returns something between 1 and 1.49; 2 will be chosen if the sum returns a number between 1.5 and 2.49; and 3 will be chosen if the returned number is between 2.5 and 3. You can see that the range for 2 is twice as big as 1 and 3. </p>
<p>The solution is to use Math.floor instead. This evens out the bias totally since 1 will be selected for numbers between 1 and 1.99, 2 will be returned for numbers between 2 and 2.99 and 3 will be chosen for values between 3 and 3.99. You can see that the interval between each of these ranges is now the same &#8212; so each number has the same probability of being chosen.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> highest <span style="color: #339933;">=</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span>
      random <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span> <span style="color: #009900;">&#40;</span> Math.<span style="color: #660066;">random</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> highest <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Hint: <code>ceil</code> works just as well <img src='http://devbytes.clintonmontague.co.uk/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Devbytes?a=V-FuwOUMpj0:7WHLk3Qr9Q4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Devbytes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=V-FuwOUMpj0:7WHLk3Qr9Q4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=V-FuwOUMpj0:7WHLk3Qr9Q4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=V-FuwOUMpj0:7WHLk3Qr9Q4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=V-FuwOUMpj0:7WHLk3Qr9Q4:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Devbytes/~4/V-FuwOUMpj0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://devbytes.clintonmontague.co.uk/round-is-not-random/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://devbytes.clintonmontague.co.uk/round-is-not-random/</feedburner:origLink></item>
		<item>
		<title>Change the time zone on Linux</title>
		<link>http://feedproxy.google.com/~r/Devbytes/~3/0KAazhd0dTo/</link>
		<comments>http://devbytes.clintonmontague.co.uk/linux-timezone/#comments</comments>
		<pubDate>Sun, 09 May 2010 12:02:29 +0000</pubDate>
		<dc:creator>Clinton Montague</dc:creator>
				<category><![CDATA[Servers & Sysadmin]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[local time]]></category>
		<category><![CDATA[localtime]]></category>
		<category><![CDATA[time zone]]></category>
		<category><![CDATA[timezone]]></category>

		<guid isPermaLink="false">http://devbytes.clintonmontague.co.uk/?p=74</guid>
		<description><![CDATA[A lot of things on Linux seem pretty complicated, but a lot turn out to be pretty simple. To change the timezone: 1 2 mv /etc/localtime /etc/localtime.default # just in case you need to restore it ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime #obviously replacing Europe/London with your time zone Note: this was written for CentOS 5 &#8211; [...]]]></description>
			<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://devbytes.clintonmontague.co.uk/linux-timezone/", "Change the time zone on Linux", "" );
		//--></script></span><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdevbytes.clintonmontague.co.uk%2Flinux-timezone%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>A lot of things on Linux seem pretty complicated, but a lot turn out to be pretty simple. To change the timezone:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>localtime <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>localtime.default <span style="color: #666666; font-style: italic;"># just in case you need to restore it</span>
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-sf</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>zoneinfo<span style="color: #000000; font-weight: bold;">/</span>Europe<span style="color: #000000; font-weight: bold;">/</span>London <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>localtime <span style="color: #666666; font-style: italic;">#obviously replacing Europe/London with your time zone</span></pre></td></tr></table></div>

<p><em>Note: this was written for CentOS 5 &#8211; your system might vary</em></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Devbytes?a=0KAazhd0dTo:fjUNwZ1wg6U:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Devbytes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=0KAazhd0dTo:fjUNwZ1wg6U:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=0KAazhd0dTo:fjUNwZ1wg6U:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=0KAazhd0dTo:fjUNwZ1wg6U:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=0KAazhd0dTo:fjUNwZ1wg6U:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Devbytes/~4/0KAazhd0dTo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://devbytes.clintonmontague.co.uk/linux-timezone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://devbytes.clintonmontague.co.uk/linux-timezone/</feedburner:origLink></item>
		<item>
		<title>Set up passwordless login with SSH keys</title>
		<link>http://feedproxy.google.com/~r/Devbytes/~3/A3An2VRYtRY/</link>
		<comments>http://devbytes.clintonmontague.co.uk/set-up-ssh-keys/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 19:51:34 +0000</pubDate>
		<dc:creator>Clinton Montague</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[Servers & Sysadmin]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[keys]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[rsa]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ssh-keygen]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://devbytes.clintonmontague.co.uk/?p=67</guid>
		<description><![CDATA[There are two parts to SSH keys &#8211; the public key and the private key. The public key is the one which you put onto the remote server, and the private key is the one you keep on your local machine. When you log in, some clever maths works on both to let you in. [...]]]></description>
			<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://devbytes.clintonmontague.co.uk/set-up-ssh-keys/", "Set up passwordless login with SSH keys", "" );
		//--></script></span><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdevbytes.clintonmontague.co.uk%2Fset-up-ssh-keys%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>There are two parts to SSH keys &#8211; the public key and the private key. The public key is the one which you put onto the remote server, and the private key is the one you keep on your local machine. When you log in, some clever maths works on both to let you in. </p>
<h2>On your local machine</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span></pre></div></div>

<p>It will ask you a couple of questions &#8211; just press enter to each one.</p>
<p>After it&#8217;s finished, it will have created two new files, <code>~/.ssh/id_rsa</code> and <code>~/.ssh/id_rsa.pub</code>. The first is your private key &#8211; this is only for you and should stay on your local machine. The second is your public key &#8211; this is the one which needs to go onto your remote server.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">scp</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.pub username<span style="color: #000000; font-weight: bold;">@</span>hostname.com:~</pre></div></div>

<h2>On the remote machine</h2>
<p>Log into the remote machine then type these commands</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ~
<span style="color: #c20cb9; font-weight: bold;">mv</span> id_rsa.pub .ssh
<span style="color: #7a0874; font-weight: bold;">cd</span> .ssh
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> authorized_keys <span style="color: #000000; font-weight: bold;">&lt;</span> id_rsa.pub
<span style="color: #c20cb9; font-weight: bold;">rm</span> id_rsa.pub</pre></div></div>

<p>Now log out then log in again &#8211; you shouldn&#8217;t need to type the password this time. Magic.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Devbytes?a=A3An2VRYtRY:uGVORadW5XI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Devbytes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=A3An2VRYtRY:uGVORadW5XI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=A3An2VRYtRY:uGVORadW5XI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=A3An2VRYtRY:uGVORadW5XI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=A3An2VRYtRY:uGVORadW5XI:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Devbytes/~4/A3An2VRYtRY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://devbytes.clintonmontague.co.uk/set-up-ssh-keys/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://devbytes.clintonmontague.co.uk/set-up-ssh-keys/</feedburner:origLink></item>
		<item>
		<title>Get embedded YouTube clips to start at a specific time</title>
		<link>http://feedproxy.google.com/~r/Devbytes/~3/Gbup8O7sS8o/</link>
		<comments>http://devbytes.clintonmontague.co.uk/youtube-deep-embedding/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 09:58:32 +0000</pubDate>
		<dc:creator>Clinton Montague</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[deep embedding]]></category>
		<category><![CDATA[deep linking]]></category>
		<category><![CDATA[embedding]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://devbytes.clintonmontague.co.uk/?p=65</guid>
		<description><![CDATA[Did you know that you can get an embedded YouTube clip to start at the time you want it to start? Great for missing the fluff at the beginning of a clip! On another of my sites, coasternerd.com, that was exactly the problem I was trying to solve. At the beginning of a lot of [...]]]></description>
			<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://devbytes.clintonmontague.co.uk/youtube-deep-embedding/", "Get embedded YouTube clips to start at a specific time", "" );
		//--></script></span><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdevbytes.clintonmontague.co.uk%2Fyoutube-deep-embedding%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Did you know that you can get an embedded YouTube clip to start at the time you want it to start? Great for missing the fluff at the beginning of a clip! On another of my sites, <a href="http://coasternerd.com/">coasternerd.com</a>, that was exactly the problem I was trying to solve. At the beginning of a lot of videos, there is a lot of waffle, wouldn’t it be great if you could start the video after that? Well, you can!</p>
<p>Add the code <code>&#038;start=ss</code> (where ss is replaced with the number of seconds you want to skip) to the <code>&lt;embed src="...">&lt;/embed></code>  part of the YouTube code and you’ll cut the crap.</p>
<h2>Code from YouTube</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">object</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;640&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;385&quot;</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;movie&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.youtube.com/v/0WpNSImh6Z8&amp;hl=en_US&amp;fs=1&amp;&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">param</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;allowFullScreen&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">param</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;allowscriptaccess&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;always&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">param</span>&gt;</span>
   <span style="color: #009900;">&lt;embed <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.youtube.com/v/0WpNSImh6Z8&amp;hl=en_US&amp;fs=1&amp;&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;application/x-shockwave-flash&quot;</span> allowscriptaccess<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;always&quot;</span> allowfullscreen<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;640&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;385&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>embed&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">object</span>&gt;</span></pre></td></tr></table></div>

<h2>Modified code</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">object</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;640&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;385&quot;</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;movie&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.youtube.com/v/0WpNSImh6Z8&amp;hl=en_US&amp;fs=1&amp;&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">param</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;allowFullScreen&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">param</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;allowscriptaccess&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;always&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">param</span>&gt;</span>
   <span style="color: #009900;">&lt;embed <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.youtube.com/v/0WpNSImh6Z8&amp;hl=en_US&amp;fs=1&amp;start=27&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;application/x-shockwave-flash&quot;</span> allowscriptaccess<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;always&quot;</span> allowfullscreen<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;640&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;385&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>embed&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">object</span>&gt;</span></pre></td></tr></table></div>

<p>Notice the <code>&#038;start=27</code> on line 5.</p>
<h2>Result</h2>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/0WpNSImh6Z8&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
   <embed src="http://www.youtube.com/v/0WpNSImh6Z8&#038;hl=en_US&#038;fs=1&#038;start=27" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Devbytes?a=Gbup8O7sS8o:gjIR6Ymea1U:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Devbytes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=Gbup8O7sS8o:gjIR6Ymea1U:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=Gbup8O7sS8o:gjIR6Ymea1U:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=Gbup8O7sS8o:gjIR6Ymea1U:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=Gbup8O7sS8o:gjIR6Ymea1U:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Devbytes/~4/Gbup8O7sS8o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://devbytes.clintonmontague.co.uk/youtube-deep-embedding/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://devbytes.clintonmontague.co.uk/youtube-deep-embedding/</feedburner:origLink></item>
		<item>
		<title>Playing with server-side JavaScript</title>
		<link>http://feedproxy.google.com/~r/Devbytes/~3/HuIdlfVM1bo/</link>
		<comments>http://devbytes.clintonmontague.co.uk/playing-with-server-side-javascript/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 16:16:41 +0000</pubDate>
		<dc:creator>Clinton Montague</dc:creator>
				<category><![CDATA[Servers & Sysadmin]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[server side javascript]]></category>
		<category><![CDATA[serverside]]></category>
		<category><![CDATA[ssjs]]></category>

		<guid isPermaLink="false">http://devbytes.clintonmontague.co.uk/?p=60</guid>
		<description><![CDATA[I&#8217;ve wanted to play around with server-side JavaScript for a while now but never really been sure about how to go about it. Today, I took the dive. First, I downloaded and installed node.js 1 2 3 4 5 wget http://nodejs.org/dist/node-v0.1.33.tar.gz tar -xzvf node-v0.1.33.tar.gz &#38;&#38; cd node-v0.1.33 ./configure make make install Next up is creating [...]]]></description>
			<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://devbytes.clintonmontague.co.uk/playing-with-server-side-javascript/", "Playing with server-side JavaScript", "" );
		//--></script></span><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdevbytes.clintonmontague.co.uk%2Fplaying-with-server-side-javascript%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve wanted to play around with server-side JavaScript for a while now but never really been sure about how to go about it. Today, I took the dive.</p>
<p>First, I downloaded and installed <a href="http://nodejs.org/">node.js</a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>nodejs.org<span style="color: #000000; font-weight: bold;">/</span>dist<span style="color: #000000; font-weight: bold;">/</span>node-v0.1.33.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xzvf</span> node-v0.1.33.tar.gz <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">cd</span> node-v0.1.33
.<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></td></tr></table></div>

<p>Next up is creating the classic Hello World first time app.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> sys <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;sys&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    http <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
http.<span style="color: #660066;">createServer</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    response.<span style="color: #660066;">sendHeader</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">200</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;Content-Type&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;text/html&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    response.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Hello World!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    response.<span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">listen</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">8080</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
sys.<span style="color: #660066;">puts</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Server running at http://localhost:8080/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Then start the server:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">node helloworld.js</pre></td></tr></table></div>

<p>Go to http://localhost:8080/ and voila!</p>
<p>As a bonus, I&#8217;ve managed to get apache to route requests through to it (not sure if this is the best way to go about doing it&#8230;) Also remember that you need to start the JavaScript server first!</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
        <span style="color: #00007f;">ServerName</span> js.clintonmontague.co.uk
        <span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span> 
        <span style="color: #00007f;">RewriteRule</span> ^/(.*)$ http://127.0.0.1:<span style="color: #ff0000;">8080</span>%{REQUEST_URI} [P,QSA,L]
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></td></tr></table></div>

<p>Now just to learn and write a decent JavaScript app!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Devbytes?a=HuIdlfVM1bo:hS9OI1wxd7c:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Devbytes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=HuIdlfVM1bo:hS9OI1wxd7c:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=HuIdlfVM1bo:hS9OI1wxd7c:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Devbytes?a=HuIdlfVM1bo:hS9OI1wxd7c:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Devbytes?i=HuIdlfVM1bo:hS9OI1wxd7c:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Devbytes/~4/HuIdlfVM1bo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://devbytes.clintonmontague.co.uk/playing-with-server-side-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://devbytes.clintonmontague.co.uk/playing-with-server-side-javascript/</feedburner:origLink></item>
	</channel>
</rss>

