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

<channel>
	<title>CodeDefied</title>
	<atom:link href="http://www.codedefied.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codedefied.co.uk</link>
	<description>Code musings &#039;n&#039; stuff</description>
	<lastBuildDate>Mon, 15 Oct 2012 19:17:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>148f:5370 Ralink &#8211; RT5370 Wireless Adapter on the Raspberry Pi</title>
		<link>http://www.codedefied.co.uk/2012/10/15/148f5370-ralink-rt5370-wireless-adapter-on-the-raspberry-pi/</link>
		<comments>http://www.codedefied.co.uk/2012/10/15/148f5370-ralink-rt5370-wireless-adapter-on-the-raspberry-pi/#comments</comments>
		<pubDate>Mon, 15 Oct 2012 19:17:23 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Raspberry Pi]]></category>

		<guid isPermaLink="false">http://www.codedefied.co.uk/?p=359</guid>
		<description><![CDATA[<p>I&#8217;ve had lots of trouble getting the wifi working on my Raspberry Pi &#8211; until &#8211; for some unknown reason I turned off the power management.</p> <p>Now, it works perfectly, and wpa_supplicant no longer renegotiates every five minutes with the router.</p> <p>Just try the following:</p> sudo nano /etc/network/interfaces <p>Then make it look something like this.</p> [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve had lots of trouble getting the wifi working on my Raspberry Pi &#8211; until &#8211; for some unknown reason I turned off the power management.</p>
<p>Now, it works perfectly, and <em>wpa_supplicant</em> no longer renegotiates every five minutes with the router.</p>
<p>Just try the following:</p>
<pre class="brush: bash; gutter: true">sudo nano /etc/network/interfaces</pre>
<p>Then make it look something like this.</p>
<pre class="brush: bash; gutter: true">auto wlan0
iface wlan0 inet static
  address       &lt;someipaddress&gt;
  netmask       255.255.255.0
  gateway       &lt;someipaddress&gt;
  wpa-ssid      SOMEID
  wpa-psk       somepasswork
  wireless-power off
  dns-nameservers 208.67.222.222 208.67.220.220</pre>
<p>And that seemed to sort it, hope this helps someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codedefied.co.uk/2012/10/15/148f5370-ralink-rt5370-wireless-adapter-on-the-raspberry-pi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Debian netinstall on to a USB stick from OSX</title>
		<link>http://www.codedefied.co.uk/2012/09/18/getting-debian-netinstall-on-to-a-usb-stick-from-osx/</link>
		<comments>http://www.codedefied.co.uk/2012/09/18/getting-debian-netinstall-on-to-a-usb-stick-from-osx/#comments</comments>
		<pubDate>Tue, 18 Sep 2012 08:02:25 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Servers 'n stuff]]></category>

		<guid isPermaLink="false">http://www.codedefied.co.uk/?p=347</guid>
		<description><![CDATA[<p>Thought someone might find this useful when trying to get the Debain net install iso (or for that matter, any linux distribution, any install) on to a USB stick for installation but from OSX.</p> <p></p> <p>Download an iso from: <a href="http://www.debian.org/">http://www.debian.org/</a></p> <p>Convert the iso to an img (.dmg) file.</p> hdiutil convert -format UDRW -o debian.img [...]]]></description>
				<content:encoded><![CDATA[<p>Thought someone might find this useful when trying to get the Debain net install iso (or for that matter, any linux distribution, any install) on to a USB stick for installation but from OSX.</p>
<p><span id="more-347"></span></p>
<p>Download an iso from: <a href="http://www.debian.org/">http://www.debian.org/</a></p>
<p>Convert the iso to an img (.dmg) file.</p>
<pre class="brush: bash; gutter: true">hdiutil convert -format UDRW -o debian.img &lt;downloaded file&gt;.iso</pre>
<p>OSX appends .dmg to the file name, so for niceness I guess:</p>
<pre class="brush: bash; gutter: true">mv debian.img.dmg debian.img</pre>
<p>Insert the USB stick, and unmount any partitions that get mounted. Find the drive reference from</p>
<pre class="brush: bash; gutter: true">diskutil list</pre>
<p>…and you should find something like: /dev/disk2 &#8211; which therefor means that the reference we should be looking for is /dev/rdisk2</p>
<p>Now copy the img to the stick using dd:</p>
<pre class="brush: bash; gutter: true">dd if=debian.img of=/dev/rdisk2 bs=1m</pre>
<p>And that should do it.</p>
<p>Note though, you will need to set the boot order in the BIOS of your motherboard to something like USB-FLOPPY as the first item in the boot order. Very simple, but not immediately obvious.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codedefied.co.uk/2012/09/18/getting-debian-netinstall-on-to-a-usb-stick-from-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Social media might be good, but what am I going to do on Saturday night?</title>
		<link>http://www.codedefied.co.uk/2012/04/16/social-media-might-be-good-but-what-am-i-going-to-do-on-saturday-night/</link>
		<comments>http://www.codedefied.co.uk/2012/04/16/social-media-might-be-good-but-what-am-i-going-to-do-on-saturday-night/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 19:37:25 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Social Media]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.codedefied.co.uk/?p=342</guid>
		<description><![CDATA[<p>Perhaps it&#8217;s an age thing, but I&#8217;ve latterly been thinking about what social media means to relationships over time.</p> <p>I&#8217;ve moved around a lot over the course of my life, when I was younger because of my parents, and older with work and circumstance &#8211; and each move has produced a swathe of friends that [...]]]></description>
				<content:encoded><![CDATA[<p>Perhaps it&#8217;s an age thing, but I&#8217;ve latterly been thinking about what social media means to relationships over time.</p>
<p>I&#8217;ve moved around a lot over the course of my life, when I was younger because of my parents, and older with work and circumstance &#8211; and each move has produced a swathe of friends that I rarely see.</p>
<p>Now social media can make the distance and lack of face-to-face meeting up up a little easier, but over time there is an erosion of connection &#8211; that rooting to a particular place that in my mind seems to be the thing that grounds people. Relationships are built over time and the countless deliberate and non-deliberate interactions (i.e. I meet someone I wasn&#8217;t expecting to down the pub etc.).</p>
<p>When you have to be utterly deliberate about meeting up, perhaps a couple of times a year, it&#8217;s inevitable that the connection will become different.</p>
<p>So to the tittle of the post. As the years pass and there is less time for the forming of deep relationships based on shared experience (like time at university, or when friends are having children) what I&#8217;m finding is that I have a long list of Facebook and Twitter contacts, but who&#8217;s actually around to do something on Saturday night?</p>
<p>I expect it&#8217;s in some ways this is a reflection of the the very human trait that leads us all to question the hand we&#8217;ve been dealt. If I&#8217;d lived in the same place all my life, I&#8217;d want to have moved around to collect an armful of interesting experiences. Am I just wishing that I&#8217;d not missed out on the feeling of belonging to a place? After all, if you hate a place, it doesn&#8217;t matter who&#8217;s around on Saturday night if you don&#8217;t like any of them.</p>
<p>Social media brings people together that never would have in the past, but I think it allows for the amplification of our struggles with actually relating with one-another. If your friends all live far away, you will still need someone near by to have a pint with.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codedefied.co.uk/2012/04/16/social-media-might-be-good-but-what-am-i-going-to-do-on-saturday-night/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using dnsmasq with VirtualBox and OS X</title>
		<link>http://www.codedefied.co.uk/2012/02/04/using-dnsmasq-with-virtualbox-and-os-x/</link>
		<comments>http://www.codedefied.co.uk/2012/02/04/using-dnsmasq-with-virtualbox-and-os-x/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 12:59:58 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.codedefied.co.uk/?p=330</guid>
		<description><![CDATA[<p>When working with various virtual machines and browsers, your hosts file can start to look a little over subscribed, and rather difficult to manage.</p> <p>One of my colleagues mentioned <a href="http://thekelleys.org.uk/dnsmasq/doc.html" target="_blank">dnsmasq</a> &#8211; and he implemented it on his host machine to resolve names for various VM&#8217;s.</p> <p>I didn&#8217;t really want to install it on [...]]]></description>
				<content:encoded><![CDATA[<p>When working with various virtual machines and browsers, your hosts file can start to look a little over subscribed, and rather difficult to manage.</p>
<p>One of my colleagues mentioned <a href="http://thekelleys.org.uk/dnsmasq/doc.html" target="_blank">dnsmasq</a> &#8211; and he implemented it on his host machine to resolve names for various VM&#8217;s.</p>
<p>I didn&#8217;t really want to install it on the host, so went for having it on the VM, so that each one could resolve it&#8217;s own list of domains. In the instructions, I&#8217;m making the assumption that the VM has a DHCP provided IP from the host only network within VirtualBox, and it&#8217;s host name (the name I&#8217;m connecting to from the host machine is devbox). Here&#8217;s what I did.</p>
<h4>1. Install dnsmasq on Debian with apt</h4>
<pre class="brush: bash; gutter: true">sudo apt-get install dnsmasq</pre>
<h4>2. Open up /ect/dnsmasq.conf and add:</h4>
<pre class="brush: bash; gutter: true">address=/devbox/192.168.56.101</pre>
<h4>3. Restart dnsmasq</h4>
<pre class="brush: bash; gutter: true">sudo /etc/init.d/dnsmasq restart</pre>
<h4>4. Then in your host machine&#8217;s /etc/hosts file add:</h4>
<pre class="brush: bash; gutter: true">devbox 192.168.56.101</pre>
<h4>5. If you&#8217;re using OS X, create the folder /etc/resolver</h4>
<pre class="brush: bash; gutter: true">sudo mkdir /etc/resolver</pre>
<h4>6. Create a named entry for your box</h4>
<p>Mine&#8217;s called devbox, I&#8217;d do:</p>
<pre class="brush: bash; gutter: true">echo &quot;nameserver 192.168.56.101&quot; &gt; /etc/resolver/devbox</pre>
<p>And that should now work nicely &#8211; <strong>somesubdomain.devbox</strong> for example will  resolve to that VM.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codedefied.co.uk/2012/02/04/using-dnsmasq-with-virtualbox-and-os-x/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Is there anything wrong with the app store model?</title>
		<link>http://www.codedefied.co.uk/2012/01/09/is-there-anything-wrong-with-the-app-store-model/</link>
		<comments>http://www.codedefied.co.uk/2012/01/09/is-there-anything-wrong-with-the-app-store-model/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 20:48:53 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Software Develeopment]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.codedefied.co.uk/?p=261</guid>
		<description><![CDATA[<p>Trust is a massive issue with software today.</p> <p>Imagine&#8230;</p> <p>You want to use some computing device to achieve a task, so you go to google &#8211; after all &#8211; someone must have tried to solve this problem with software somewhere. You search away, deftly clicking through links, finally coming upon Acme software, the answer to [...]]]></description>
				<content:encoded><![CDATA[<p>Trust is a massive issue with software today.</p>
<p>Imagine&#8230;</p>
<p>You want to use some computing device to achieve a task, so you go to google &#8211; after all &#8211; someone must have tried to solve this problem with software somewhere. You search away, deftly clicking through links, finally coming upon <em>Acme</em> software, the answer to all your searching. There before you is an application that will solve you problem perfectly.</p>
<p><span id="more-261"></span></p>
<p>Presuming there&#8217;s nothing stopping you (e.g. cost, incomprehensible download instructions, platform availability), you go on and install, making the assumption that the developer has utterly benign intentions and there isn&#8217;t anything untoward going on.</p>
<p>In that single act of installation, you take your chance; is it legitimate, or is your machine now part of a bot net?</p>
<p>Which is why things like code signing and app stores amongst other things exist. <a href="http://www.zdnet.com/blog/security/after-latest-iphone-hack-charlie-miller-kicked-out-of-ios-dev-program/9773" target="_blank">Whilst not perfect</a> they attempt to mitigate some of the risks.</p>
<p>There is no perfect system and there never will be; all we can do is aim for the situation that is just less riskier. Just think about these two constructs for a moment.</p>
<p>Firstly code signing. When a developer signs code with a certificate from a <a href="http://en.wikipedia.org/wiki/Certificate_authority" target="_blank">Certificate Authority</a>, the CA is confirming that the developer is who they say they are. When your OS asks you to confirm that <a href="http://www.verisign.co.uk">Verisign</a> for example knows who <em>Acme</em> software of <em>42 Wallaby Way, Sydney</em> are, you are trusting that Verisign has checked them out, given them a phone call for example, checked articles of incorporation etc &#8211; i.e. carried out a little bit of background checking. But who are Verisign, do they have a relationship with you (of course not)? Are all CA&#8217;s thorough? And because there are so many of them, who says who you can trust them anyway?</p>
<p>If you write code, you probably think you know the answer to these questions, but to the general user, they&#8217;ll just click &#8220;OK&#8221;, and think nothing of it &#8211; and that says nothing of self-signed code (where the developer generates their own certificate, and signs the code with it).</p>
<p>And then the app store? Some of these (in the case of Apple) provide the certificates, and the gateway to users. Users go to them, hopefully able to trust that they have carried out the due diligence of a CA, perhaps actually checking the code (which is not a requirement of a CA &#8211; so they are taking the duty one step further). Of course this requires that the user has a level of trust in the app stores proprietors, and believes they aren&#8217;t going to do anything evil (same would apply to the CA, but general users will already have that with Google or Apple &#8211; unlikely with Verisign). Of course, the OS manufacturer is actually the one asking you to trust the certificate from the CA, but the question is always posed the other way around &#8211; as a request to the user to trust the CA by clicking ok.</p>
<p>So what is wrong with the app store model?</p>
<p>The first one is that everyone reaches for is that the app store proprietor is given too much control &#8211; ultimate censorship &#8211; but it has proven to be a bit of a moot point in most circumstances. When the Apple app store started, <a href="http://www.macworld.co.uk/ipad-iphone/news/?newsid=23368">there where many cases</a> of software being prevented from approval, and then the accompanying furore. But these are now a much rarer occurance (or perhaps no one cares). If we take the case of Opera, in my opinion, it has such a terrible implementation on iOS that I wonder if there&#8217;s more of a back story than they would care to admit to.</p>
<p>If there&#8217;s anything wrong with this model, it&#8217;s that it isn&#8217;t prefect; so when it goes wrong we think &#8211; hey, what the? I thought they made these things bullet proof. As most users will always click ok &#8211; right here and now, the app store model seems like the best solution.</p>
<p>Which leads us to the disappointment with our human endeavours &#8211; there has never been (or will be) a perfect situation &#8211; just ones that are less bad. Failure leads to improvement, but as we are utterly unable to foresee all circumstances, there will always be <a href="http://www.youtube.com/watch?v=GiPe1OiKQuk">unknown unknowns</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codedefied.co.uk/2012/01/09/is-there-anything-wrong-with-the-app-store-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing BBC Radio streams with MPD</title>
		<link>http://www.codedefied.co.uk/2011/12/24/playing-bbc-radio-streams-with-mpd/</link>
		<comments>http://www.codedefied.co.uk/2011/12/24/playing-bbc-radio-streams-with-mpd/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 15:35:48 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.codedefied.co.uk/?p=280</guid>
		<description><![CDATA[<p>Just a quick something I finally got around to this morning &#8211; getting BBC radio streams (which are often a little opaque) to play on <a href="http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki">MPD</a>.</p> <p>MPD will play external audio streams, but the problem with the BBC streams are that they exist behind tokenised URL&#8217;s. So here&#8217;s a quick PHP script that you [...]]]></description>
				<content:encoded><![CDATA[<p>Just a quick something I finally got around to this morning &#8211; getting BBC radio streams (which are often a little opaque) to play on <a href="http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki">MPD</a>.</p>
<p>MPD will play external audio streams, but the problem with the BBC streams are that they exist behind tokenised URL&#8217;s. So here&#8217;s a quick PHP script that you can set up on a cron (say, run every hour), which will create m3u files with the two tokenised streaming URL&#8217;s contained as entries for MPD to play.</p>
<pre class="brush: php; gutter: true">#!/usr/bin/php5
&lt;?php
$path        						 	 = 	&#039;/path/to/your/mpd/playlists/&#039;;

$stations							 	 =	array(
												  &#039;Radio4&#039;	=&gt;	&#039;http://www.bbc.co.uk/radio/listen/live/r4_aaclca.pls&#039;,
												  &#039;Radio3&#039;	=&gt;	&#039;http://www.bbc.co.uk/radio/listen/live/r3_aaclca.pls&#039;
												  );

foreach ($stations as $key =&gt; $value) {

	$pls           	 					 = 	file_get_contents($value);
	$fileName        					 = 	&#039;{$key}.m3u&#039;;

	preg_match_all(&#039;/File[12]=((.?)+)/i&#039;,$pls,$matches);

	file_put_contents($path . $fileName, join(&#039;\n&#039;,$matches[1]));	

}</pre>
<p>The above examples grabs the <a href="http://www.listenlive.eu/uk.html">.pls files for radio 4 and 3 from the BBC servers</a>, and pushes them into the m3u files.</p>
<p>Hope that helps someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codedefied.co.uk/2011/12/24/playing-bbc-radio-streams-with-mpd/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Large seed data sets in Appcelerator Titanium</title>
		<link>http://www.codedefied.co.uk/2011/12/07/large-seed-data-sets-in-appcelerator-titanium/</link>
		<comments>http://www.codedefied.co.uk/2011/12/07/large-seed-data-sets-in-appcelerator-titanium/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 20:36:08 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Appcelerator]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mobile development]]></category>

		<guid isPermaLink="false">http://www.codedefied.co.uk/?p=246</guid>
		<description><![CDATA[<p>The problem of updating and versioning database tables in Apcelerators&#8217; Titanium API is made a little trixy by the nature of the number of inherent floors with what&#8217;s available, and a lack of comprehensive documentation. I&#8217;d already dealt with versioning within my model classes previously, but had glossed over the seed data.</p> <p></p> <p>My biggest [...]]]></description>
				<content:encoded><![CDATA[<p>The problem of updating and versioning database tables in Apcelerators&#8217; Titanium API is made a little trixy by the nature of the number of inherent floors with what&#8217;s available, and a lack of comprehensive documentation. I&#8217;d already dealt with versioning within my model classes previously, but had glossed over the seed data.</p>
<p><span id="more-246"></span></p>
<p>My biggest problem was that one of the tables had to have just over 9000 rows (and perhaps more once the application is distributed) inserted. The only options <a href="http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Filesystem-module">available according to the documentation</a> were to read the file in, explode on a new line char into an array, then munch through the array keys inserting the data as you go. </p>
<p>Possibly fine if the data is small, but will bomb the device as we&#8217;re talking about 2.2MB of text.</p>
<p>The solution it seemed was to use the new <a href="http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Buffer-object.html">buffers object</a> available I think since version 1.7 of the SDK. The solution is a bit kludgy and rather slow (so needs a some improvement), but it actually works, and most importantly the device survives the process.</p>
<p>So here&#8217;s the code:</p>
<pre class="brush: js; ruler: true; first-line: 1; tab-size: 4">
var seedDataFile			 =	Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory + "data/", model.table + ".sql");

if (seedDataFile.exists()) {
					
	var fileStream			 = 	seedDataFile.open(Ti.Filesystem.MODE_READ);
	var buffer 				 = 	Ti.createBuffer({ length: 1024 });
	var bytesRead			 = 	0;
	
	while ((length = fileStream.read(buffer, bytesRead, 1)) > 0) {
		
		bytesRead 			+= 	length;
		
		var str 			 = 	Ti.Codec.decodeString({
			
			source			 : 	buffer,
			charset			 : 	Ti.Codec.CHARSET_UTF8,
			length			 : 	bytesRead,
			position		 : 	0
		
		});
		 
		var eol 			 = 	str.charAt(str.length - 1);
		 
		if (eol == ";") {
		 	
		 	Model._db.execute(str);
		 	
		 	bytesRead 		 = 	0;
		 	buffer.clear();
		 	
		}
		
		str					 =	null;
		
	}
					
	fileStream.close();
	buffer.clear();
	buffer.release();
	
}
</pre>
<p>Basically it does the following:</p>
<ol>
<li>Open the file into a fileStream object</li>
<li>Read one byte at a time into the buffer (in this case the buffer is 1Kb &#8211; so hopefully I won&#8217;t have an insert query longer than that).</li>
<li>Check to see if we&#8217;ve read in a semi-colon (could expand this to an nl char using regex, but I wanted to save on processing time).</li>
<li>If there&#8217;s a match, take the contents of the buffer, and use that as the query</li>
<li>Reset everything, and clear the buffer.</li>
<li>Continue on, and on etc&#8230;</li>
</ol>
<p>Now, this worked fine in iOS, taking about 7 minutes to do the 9000 odd rows. Android, well that sorry state of affairs took nearly two hours. I&#8217;m thinking that there&#8217;s room for improvement there, but it will work for most cases. Hopefully this will help someone out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codedefied.co.uk/2011/12/07/large-seed-data-sets-in-appcelerator-titanium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Appcelerator Locale, Internationalization and String.format</title>
		<link>http://www.codedefied.co.uk/2011/12/06/appcelerator-locale-internationalization-and-string-format/</link>
		<comments>http://www.codedefied.co.uk/2011/12/06/appcelerator-locale-internationalization-and-string-format/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 19:27:25 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Appcelerator]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mobile development]]></category>

		<guid isPermaLink="false">http://www.codedefied.co.uk/?p=214</guid>
		<description><![CDATA[<p>I came across a rather annoying annoyance in the Appcelerator Locale API today, but only to do with the Android platform. It took a while to figure out what was going on, and had to read through the Google documentation to find an answer.</p> <p></p> <p>When using the internationalised strings.xml, it is possible to do [...]]]></description>
				<content:encoded><![CDATA[<p>I came across a rather annoying annoyance in the Appcelerator Locale API today, but only to do with the Android platform. It took a while to figure out what was going on, and had to read through the Google documentation to find an answer.</p>
<p><span id="more-214"></span></p>
<p>When using the internationalised <em>strings.xml</em>, it is possible to do replacements using <em>String.format</em>. For example:</p>
<pre class="brush: xml; ruler: true; first-line: 1; tab-size: 4">
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;resources&gt;
	&lt;string name="format_string"&gt;%s, exceeds the length of %s&lt;/string&gt;
&lt;/resources&gt;
</pre>
<p>Then:</p>
<pre class="brush: js; ruler: true; first-line: 1; tab-size: 4">
var formattedText = String.format(L("format_string"),12,7);  // 12 exceeds the length of 7
</pre>
<p>The replacements are made according to the <a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html">printf specification</a>, and all is sweetness and light. That is until you try it in Android. </p>
<p>First of all, it refuses to compile with a rather annoying message. It turns out that there is a different formatting required, which is fine, but you can’t specify platform dependent i18n xml files, and the Android formatting doesn’t work with iOS.</p>
<p>So the above needs to become:</p>
<pre class="brush: xml; ruler: true; first-line: 1; tab-size: 4">
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;resources&gt;
	&lt;string name="format_string"&gt;%1$s, exceeds the length of %2$s&lt;/string&gt;
&lt;/resources&gt;
</pre>
<p>The only solution would be to do a find and replace before you compile for a particular platform. Why isn’t this in the documentation – you would need to ask the people at Appcelerator…</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codedefied.co.uk/2011/12/06/appcelerator-locale-internationalization-and-string-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changes to the JavaScript file Object</title>
		<link>http://www.codedefied.co.uk/2011/11/22/change-to-the-javascript-file-object/</link>
		<comments>http://www.codedefied.co.uk/2011/11/22/change-to-the-javascript-file-object/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 12:17:43 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.codedefied.co.uk/2011/11/22/change-to-the-javascript-file-object/</guid>
		<description><![CDATA[<p>With all the changes to Firefox of late, we found that some of the new JavaScript objects have had a little overhaul too.<br /> <br /> Until recently, we were doing the following:</p> var file = form.Image.files[0]; if ( file.fileSize > 15000000) { alert("You're file is too large"); } <p>Now to achieve the same thing, [...]]]></description>
				<content:encoded><![CDATA[<p>With all the changes to Firefox of late, we found that some of the new JavaScript objects have had a little overhaul too.<br />
<span id="more-208"></span><br />
Until recently, we were doing the following:</p>
<pre class="brush: js; ruler: true; first-line: 1; tab-size: 4">
var file = form.Image.files[0];

if ( file.fileSize > 15000000) {
    alert("You're file is too large");
}
</pre>
<p>Now to achieve the same thing, the <em>fileSize</em> is changed to <em>size</em>:</p>
<pre class="brush: js; ruler: true; first-line: 1; tab-size: 4">
var file = form.Image.files[0];

if (file.size > 15000000) {
    alert("You're file is too large");
}
</pre>
<p>This is also true of <em>fileName</em> to <em>name</em>. See here <a href="https://developer.mozilla.org/en/Using_files_from_web_applications">some more info from MDN</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codedefied.co.uk/2011/11/22/change-to-the-javascript-file-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading to MythTV 0.24.1+</title>
		<link>http://www.codedefied.co.uk/2011/11/18/upgrading-to-mythtv-0-24-1/</link>
		<comments>http://www.codedefied.co.uk/2011/11/18/upgrading-to-mythtv-0-24-1/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 08:49:25 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Media Centre]]></category>
		<category><![CDATA[Servers 'n stuff]]></category>

		<guid isPermaLink="false">http://www.codedefied.co.uk/2011/11/18/upgrading-to-mythtv-0-24-1/</guid>
		<description><![CDATA[<p>I&#8217;ve just upgraded my Debian MythTV server install (just a backend), and for some reason it completely broke. Googling around, I found some references to missing dependencies, but it installed just fine; so what the hell was going on &#8211; I just wanted to watch TV&#8230;</p> <p>So looking through log files, I found that MySQL [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve just upgraded my Debian MythTV server install (just a backend), and for some reason it completely broke. Googling around, I found some references to missing dependencies, but it installed just fine; so what the hell was going on &#8211; I just wanted to watch TV&#8230;</p>
<p>So looking through log files, I found that MySQL was denying access for some reason, even though the MythTV user existed, and had permissions to access the mythconverg database.</p>
<p>I had to completely delete the MythTV user, flush privileges, add it again (making sure that it can connect from any host on my LAN), and then re-grant permissions &#8211; how very odd. Hope that helps someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codedefied.co.uk/2011/11/18/upgrading-to-mythtv-0-24-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
