<?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>ZBlog</title>
	
	<link>http://blog.zarate.tv</link>
	<description>Using the law to keep justice away</description>
	<lastBuildDate>Tue, 24 Aug 2010 11:50:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/zarate/zblog" /><feedburner:info uri="zarate/zblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Dual booting between Snow Leopard and Ubuntu 10.04</title>
		<link>http://feedproxy.google.com/~r/zarate/zblog/~3/7lAlPeG7BLE/</link>
		<comments>http://blog.zarate.tv/2010/08/24/dual-booting-between-snow-leopard-and-ubuntu-10-04/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 11:50:33 +0000</pubDate>
		<dc:creator>Zarate</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://blog.zarate.tv/?p=1641</guid>
		<description><![CDATA[There are a million tutos out there about dual booting, but I just did it today and found it easier than everything I could find and definitely simpler than the last time I had to do it:
* Boot OSX and run the Disk Utility tool. Create a new partition using the free space in your [...]]]></description>
			<content:encoded><![CDATA[<p>There are a million tutos out there about dual booting, but I just did it today and found it easier than everything I could find and definitely simpler than the last time I had to do it:</p>
<p>* Boot OSX and run the Disk Utility tool. Create a new partition using the free space in your HD. Don&#8217;t format it, just leave it as free space.<br />
* Download and install <a href="http://refit.sourceforge.net/">rEFIt</a>. Once you&#8217;ve done that, you can setup Linux as the default OS by editing refit.conf and uncommenting #legacyfirst.<br />
* Insert Ubuntu&#8217;s CD and restart.<br />
* Hold the ALT key while booting up so you are offered all boot options. Select Ubuntu&#8217;s CD and install.<br />
* DONE.</p>
<p>No need for Bootcamp or anything, it&#8217;s as simple as that.</p>
<p>Just a note about how I&#8217;m installing Ubuntu these days. Read sometime ago somewhere (sorry, no link) about being able to reinstall Ubuntu without losing your data. It goes like this. When installing Ubuntu, choose manual partitions. You need to create 3 of them, in this order:</p>
<p>* System partition: pick up the space you want, but 15 &#8211; 20gb should be enough since it&#8217;s going to be for the system only. Select &#8220;/&#8221; as the mounting point.<br />
* SWAP: select it on the combo and pick up at least the size of your RAM.<br />
* Everything else, for the home partition. Select &#8220;/home&#8221; as the mounting point.<br />
* DONE.</p>
<p>Now, next time you want to reinstall Ubuntu, if you follow the same partition scheme, you will boot up to the new system and all your data will be there. And with &#8220;all the data&#8221; I mean <em>all</em> the data: bookmarks, browser history, files, subversion sites and credentials&#8230;. Since in the Linux world all user data is (or should be) stored in your home directory, and you don&#8217;t touch that one when reinstalling, you boot up to a new system with your old data in place. I call that a &#8220;dirty&#8221; installation as opposed to a &#8220;clean&#8221; installation when I back up all the files and completely wipe out the hard disk.</p>
<p>As per Ubuntu on the MacBookPro, it&#8217;s going fairly well. Haven&#8217;t touched the console for the installation. Just used the proprietary hardware drivers manager (System > Administration > Hardware drivers) for the WiFi and the graphic card. Have to say that after trying the NVIDIA closed drivers I&#8217;m sticking with the default ones, seem to do the job for me. Only if you want the F keys to work as normal human beings would expect, you go through <a href="https://help.ubuntu.com/community/AppleKeyboard#Ubuntu%209.04%20and%20Newer">this</a> (using the .conf file method).</p>
<img src="http://feeds.feedburner.com/~r/zarate/zblog/~4/7lAlPeG7BLE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.zarate.tv/2010/08/24/dual-booting-between-snow-leopard-and-ubuntu-10-04/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.zarate.tv/2010/08/24/dual-booting-between-snow-leopard-and-ubuntu-10-04/</feedburner:origLink></item>
		<item>
		<title>Nexus One on Ubuntu: mind your cable!</title>
		<link>http://feedproxy.google.com/~r/zarate/zblog/~3/yDEzk8mMEOc/</link>
		<comments>http://blog.zarate.tv/2010/07/31/nexus-one-on-ubuntu-mind-your-cable/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 09:19:08 +0000</pubDate>
		<dc:creator>Zarate</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[ustwo]]></category>

		<guid isPermaLink="false">http://blog.zarate.tv/?p=1636</guid>
		<description><![CDATA[I&#8217;ve finally started to do some Android development at the studio of dreams™. I&#8217;ve started by fixing some silly bugs and adding minor features on several of our apps and now I&#8217;m facing my first serious task, which is abstracting Facebook and Twitter integration into a simpler to use library. Anyway.
When working at home I&#8217;d [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve finally started to do some Android development at <a href="http://www.ustwo.co.uk/">the studio of dreams™</a>. I&#8217;ve started by fixing some silly bugs and adding minor features on several of our <a href="http://android.ustwo.co.uk/apps">apps</a> and now I&#8217;m facing my first serious task, which is abstracting Facebook and Twitter integration into a simpler to use library. Anyway.</p>
<p>When working at home I&#8217;d rather use Ubuntu instead of OS X but couldn&#8217;t get <a href="http://developer.android.com/sdk/eclipse-adt.html">ADT</a> to find out my Nexus One, so I was stuck on the emulator which was not feasible since one of the apps (<a href="http://android.ustwo.co.uk/tagged/Dot%E2%84%A2">.™</a>) uses the accelerometer. I needed to test on the real device.</p>
<p>First I went to the <a href="http://developer.android.com/guide/developing/device.html">Android documentation</a> and then after Googling quite a bit I finally ended up in this very good tutorial: <a href="http://alan.lamielle.net/2010/01/22/nexus-one-usb-in-ubuntu-9-10">Nexus One USB in Ubuntu 9.10</a>. But still no luck. ADB was still showing <em>???????????</em> instead of my precious. Finally, somewhere, read a comment about the USB cable being involved in the party as well.</p>
<p>Since I don&#8217;t want to carry around the USB cable, 3 weeks ago I went out and bought an extra one so I can keep one home and one in the office. First went to a Carphone Warehouse shop and they told me generic cables will NOT charge the phone. Transferring files would be ok, but no charging. After that I went to a T-Mobile shop and they told me that yes, the generic cable would indeed charge the phone. Are you sure? <em>Yes</em>. Are you <strong>really</strong> sure? <em>Yes</em>. Ok, so be it.</p>
<p>And indeed charges the phone, the guy at T-Mobile was right. However, it prevents USB debugging&#8230; in <em>Ubuntu</em>. Cause the same generic cable with the same Nexus works ok on OS X, but it prevents testing on Ubuntu. God knows what kind of shit there&#8217;s going on in there (why everything works on OS X, but on Ubuntu files and charging do, debugging does not), but just keep it in mind:</p>
<p><strong>Mind your cable!</strong></p>
<p>(at least on Linux)</p>
<img src="http://feeds.feedburner.com/~r/zarate/zblog/~4/yDEzk8mMEOc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.zarate.tv/2010/07/31/nexus-one-on-ubuntu-mind-your-cable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.zarate.tv/2010/07/31/nexus-one-on-ubuntu-mind-your-cable/</feedburner:origLink></item>
		<item>
		<title>No more unfinis</title>
		<link>http://feedproxy.google.com/~r/zarate/zblog/~3/wevXKeIp_qI/</link>
		<comments>http://blog.zarate.tv/2010/06/30/no-more-unfinis/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 10:08:12 +0000</pubDate>
		<dc:creator>Zarate</dc:creator>
				<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://blog.zarate.tv/?p=1618</guid>
		<description><![CDATA[hed emails sent :/
We&#8217;ve all done it, we&#8217;ve all received them:
Sorry, sent the email too fast :/ I was saying&#8230;
The email was sent too fast. Gmail helps out a little bit if you try to send an email without subject:

But to me that&#8217;s not enough because most of the times when I get to write [...]]]></description>
			<content:encoded><![CDATA[<p>hed emails sent :/</p>
<p>We&#8217;ve all done it, we&#8217;ve all received them:</p>
<blockquote><p>Sorry, sent the email too fast :/ I was saying&#8230;</p></blockquote>
<p>The email was sent <em>too fast</em>. Gmail helps out a little bit if you try to send an email without subject:</p>
<p><img src="http://blog.zarate.tv/wp-content/uploads/2010/06/gmail_preventig_email_without_subject.png" alt="" title="Gmail preventing sending an email without subject" width="489" height="257" class="alignnone size-full wp-image-1619" /></p>
<p>But to me that&#8217;s not enough because most of the times when I get to write the Body of the email, the recipients and Subject have been already filled, that&#8217;s what email clients lead you to. First <em>To</em>, then <em>CC</em>, <em>BCC</em>, <em>Subject</em> and finally the <em>Body</em>. So by the time you get to the Body, you&#8217;ve most likely filled both To and Subject and if for some reason you are too quick to fire up, all the mandatory fields are filled and validation looking for empty fields passes.</p>
<p>To prevent this I&#8217;ve taught myself to leave empty To and Subject fields and write the Body first. Only when I&#8217;ve written (and read-proof) the Body I fill To and Subject. This has reduced a lot the number of unfinished emails I send. </p>
<p>So I was thinking about re-arranging email clients like this:</p>
<p><img src="http://blog.zarate.tv/wp-content/uploads/2010/06/mail.png" alt="" title="Re-organized email client, body first, then subject, recipients at the end" width="1204" height="902" class="alignnone size-full wp-image-1623" /></p>
<p>See? First the Body, then Subject and the recipients of the email at the end.</p>
<p>Of course this won&#8217;t help much when replaying to an email, since both Subject and recipients would be automatically filled, but the current layout doesn&#8217;t prevent that either, so that&#8217;s a tie.</p>
<p> You guys think this makes sense? Would this help reduce the number of accidentally emails sent? Or am I just talking non-sense?</p>
<img src="http://feeds.feedburner.com/~r/zarate/zblog/~4/wevXKeIp_qI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.zarate.tv/2010/06/30/no-more-unfinis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.zarate.tv/2010/06/30/no-more-unfinis/</feedburner:origLink></item>
		<item>
		<title>A folder is not a file</title>
		<link>http://feedproxy.google.com/~r/zarate/zblog/~3/l_ujVC80oRI/</link>
		<comments>http://blog.zarate.tv/2010/06/19/a-folder-is-not-a-file/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 16:23:47 +0000</pubDate>
		<dc:creator>Zarate</dc:creator>
				<category><![CDATA[air]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[haxe]]></category>

		<guid isPermaLink="false">http://blog.zarate.tv/?p=1594</guid>
		<description><![CDATA[That seems pretty obvious, right? Well, not for quite a few people. Just check out the opening sentence on the ActionScript reference for the File object:
A File object represents a path to a file or directory.
Uh? Why? When you bring this up some people start banging about old paradigms such as &#8220;system nodes&#8221; and other [...]]]></description>
			<content:encoded><![CDATA[<p>That seems pretty obvious, right? Well, not for quite a few people. Just check out the opening sentence on the ActionScript reference for the <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/filesystem/File.html">File</a> object:</p>
<blockquote><p>A File object represents a path to a file <strong>or directory</strong>.</p></blockquote>
<p>Uh? Why? When you bring this up some people start banging about old paradigms such as &#8220;<em>system nodes</em>&#8221; and other ancient stuff. Well, I think whoever designed the AIR API lost a great opportunity to make a difference and start applying some usability to API design. This is most likely due to the old inferiority complex about ActionScript being a &#8220;serious&#8221; language that Java and C developers cannot look down to.</p>
<p>Well, how do you think Java and C developers explain it to Grandma?</p>
<blockquote><p>Yeah, you have 2 types of files, one is for storing information, the other is a special type of file which can contain other files (of the first type) and other special files like itself.</p></blockquote>
<p>Or</p>
<blockquote><p>Yeah, you have files for your docs, and folders where you can group other files and folders. Y&#8217;know, like real life files and folders.</p></blockquote>
<p>Best part is, since they are forcing the concept so much, they end up with ugly APIs and code. Let&#8217;s see:</p>
<p>Smelly code:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="co1">// WTF? I want a folder but have to create a new File object? </span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">var</span> folder : File = <span class="kw2">new</span> File<span class="br0">&#40;</span>path<span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="co1">// The code below compiles although it doesn&#8217;t make sense</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// cause a file can&#8217;t contain files. Wondering if returns 0 or throws an error</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">var</span> file : File = <span class="kw2">new</span> File<span class="br0">&#40;</span>path<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">var</span> files : <span class="kw3">Array</span> = file.<span class="me1">getDirectoryListing</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
<p>Smelly API:<br />
<a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/filesystem/File.html#isDirectory">File.isDirectory</a> says it pretty much all:</p>
<blockquote><p>Indicates whether <strong>the reference</strong> is to a directory. The value is true if the File object points to a directory; false otherwise.</p></blockquote>
<p>&#8220;<em>The reference</em>&#8220;. Maybe they should&#8217;ve called the class Reference instead of File, then?</p>
<p>Also, if files and folders are the same, why there is <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/filesystem/File.html#deleteDirectory()">File.deleteDirectory(deleteDirectoryContents)</a> vs <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/filesystem/File.html#deleteFile()">File.deleteFile()</a>? Sure there should be a common method called File.delete(), right? Well, turns out that most systems don&#8217;t allow you to remove a non-empty folder without confirmation and thus the <em>deleteDirectoryContents</em> parameter.</p>
<p>So, convinced now? If you are not, then enjoy the official API. If you are, check out <a href="http://github.com/zarate/xapi">XAPI</a> for AIR : )</p>
<p>Benefits (IMHO):</p>
<p>* No instances, all methods are static.<br />
* Different <a href="http://github.com/zarate/xapi/blob/master/src/air/xa/File.as">File</a> and <a href="http://github.com/zarate/xapi/blob/master/src/air/xa/Folder.as">Folder</a> APIs with consistent method names.<br />
* Much simpler API. Compare:</p>
<p>Reading the contents of a text file in plain AIR:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">var</span> file : File = <span class="kw2">new</span> File<span class="br0">&#40;</span>path<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">var</span> stream : FileStream = <span class="kw2">new</span> FileStream<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">stream.<span class="me1">open</span><span class="br0">&#40;</span>file, FileMode.<span class="me1">READ</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">var</span> content : <span class="kw3">String</span> = stream.<span class="me1">readUTFBytes</span><span class="br0">&#40;</span>stream.<span class="me1">bytesAvailable</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">stream.<span class="kw3">close</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
<p>Using XAPI:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">var</span> content : <span class="kw3">String</span> = xa.<span class="me1">File</span>.<span class="me1">read</span><span class="br0">&#40;</span>path<span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
<p>You decide : )</p>
<p>XAPI for AIR hasn&#8217;t been released yet, so if you can&#8217;t wait just go and checkout the code from Github. Once it&#8217;s done it will be released as a SWC, I guess.</p>
<p>Extra ball: XAPI for AIR would be almost 100% identical to XAPI for haXe which was the original implementation (differences due to platform limitations), so if  you are up to developing <a href="http://blog.zarate.tv/2010/02/08/build-tools-with-haxe/">build tools using haXe</a> the jump would be much simpler cause you would be using the same (X)API.</p>
<img src="http://feeds.feedburner.com/~r/zarate/zblog/~4/l_ujVC80oRI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.zarate.tv/2010/06/19/a-folder-is-not-a-file/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://blog.zarate.tv/2010/06/19/a-folder-is-not-a-file/</feedburner:origLink></item>
		<item>
		<title>Running Flash apps 24/7</title>
		<link>http://feedproxy.google.com/~r/zarate/zblog/~3/Db__56SN4m8/</link>
		<comments>http://blog.zarate.tv/2010/05/03/running-flash-apps-247/#comments</comments>
		<pubDate>Mon, 03 May 2010 14:40:03 +0000</pubDate>
		<dc:creator>Zarate</dc:creator>
				<category><![CDATA[air]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[haxe]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://blog.zarate.tv/?p=1546</guid>
		<description><![CDATA[[UPDATE: I presented this alongside with Matt Pollitt at the London Flash Platform User Group, thanks to everyone that came down to the talk.  So sorry that I couldn't stay for longer, but had a train to catch. If you have any doubts or want to say something, just leave a comment and I'll [...]]]></description>
			<content:encoded><![CDATA[<p>[<em>UPDATE: I presented this alongside with <a href="http://www.mattpollitt.co.uk/">Matt Pollitt</a> at the <a href="http://www.lfpug.com/27th-may-2010-27052010/">London Flash Platform User Group</a>, thanks to everyone that came down to the talk.  So sorry that I couldn't stay for longer, but had a train to catch. If you have any doubts or want to say something, just leave a comment and I'll get in touch. <a href="http://www.lfpug.com/developing-flash-apps-to-run-247/">Video is now available</a>, go check it out if you missed it.</em>]</p>
<p>We are developing at <a href="http://ustwo.co.uk/">ustwo</a> a very interesting internal little project that needs to run 24/7. By default developers should always be very careful with memory leaks and hogging resources, but with an AIR/Flash app running non-stop every detail counts.</p>
<p>To top it up, the app must handle images, SWFs (AS2, AS3) and videos <strong>without going through developers</strong>. That means marketing can contact one of the designers, ask s/he to produce someething and put it to display without developer approval. Oh, and all assets are in the network, not in the machine. Scary. </p>
<p>Preliminary tests show we are doing OK, we&#8217;ve been running the app non-stop for 4 days without a crash or needing it to reboot. The player takes and releases memory when it needs to, transitions and animations look as smooth as the first day, etc.</p>
<p>Check out below some of our thoughts.</p>
<p><strong>FAIL, FAIL, FAIL</strong></p>
<p>Shit will happen, so be ready to fail. Assets won&#8217;t load, video will have the wrong codec, image will be 80mb, network will be down&#8230;.</p>
<p>That&#8217;s Google&#8217;s approach to servers. Instead of having a big fat multimillion dollar server, they have a farm of 100 mini-servers and they *know* one or two *will* crash everyday. They&#8217;ve build their systems to cope with failure and fail gracefully.</p>
<p>Also embed some default content for when everything else fails. </p>
<p><strong>RELEASE, RELEASE, RELEASE</strong></p>
<p>You must release resources. Explicitly remove every single listener you add, use FP 10 unloadAndStop and if you are in AIR don&#8217;t hold references to File objects (more about this in another post).</p>
<p>If you are a good dev, the Flash player will behave most of the times&#8230; </p>
<p><strong>MONITOR, MONITOR, MONITOR</strong></p>
<p>&#8230;but sometimes it won&#8217;t. Or something you didn&#8217;t even think was possible will happen in-your-face. You can&#8217;t prevent <strong>all</strong> errors, but you can react when they happen.</p>
<p>At the beginning we were trusting our own app to be its own watchdog, but then we got a nasty crash and obviously the watchdog failed as well. So we&#8217;ve created a <a href="http://blog.zarate.tv/2010/02/08/build-tools-with-haxe/">little haXe/Neko app</a> called &#8220;<em>the helper</em>&#8221; that is automatically called every minute and that checks the state of our app.</p>
<p>At the moment, the helper is being automatically launched using <a href="http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html#//apple_ref/doc/man/5/launchd.plist">launchd</a> (fancy cron job for OS X), but that has very interesting side effects (again, more on another post).</p>
<p>The helper checks if our app is running using something like:</p>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">ps</span> <span class="re5">-x</span> <span class="re5">-o</span> <span class="kw2">comm</span></div>
</li>
</ol>
</div>
</div>
<p>And parsing the result for a relevant match. If the app is not running, it starts it again using:</p>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1">open <span class="sy0">/</span>path<span class="sy0">/</span>to<span class="sy0">/</span>our<span class="sy0">/</span>app</div>
</li>
</ol>
</div>
</div>
<p>Since we are using AIR 2 beta, we could implement a more refined communication system using the new <a href="http://www.adobe.com/devnet/air/flex/quickstart/interacting_with_native_process.html">Native Process API</a>, but for the time being checking if the app is running &#8220;<em>the hard way</em>&#8221; is enough.</p>
<p><strong>UPDATE, UPDATE, UPDATE</strong></p>
<p>Find a good mechanism to auto-update your app. Most 24/7 apps are unattended apps and they might well be in a different room / building / city / country. But even if you are just a few steps away, you still want to be able to remotely deploy a new version.</p>
<p>We decided to implement our own update system based on GIT commits instead of relying on AIR&#8217;s update framework.</p>
<p><strong>LOG, LOG, LOG</strong></p>
<p>Log as much as you can. You&#8217;ll be happy you did when you need to find out why your app crashed. Believe me, in this case more is more, even if you face huge log files. If you are a little bit consistent you can always build automatic parsing tools for your logs or just run a simple grep to find error traces.</p>
<p>BTW, we settled for a log file per day to avoid massive log files.  </p>
<p><strong>WARN, WARN, WARN</strong></p>
<p>As I said before, most of these apps run unattended, so you want to be notified as soon as possible when there&#8217;s an error. You can:</p>
<p>* Use a private Twitter account that people subscribe to.<br />
* Send an email. You can do that from Flash using for example <a href="http://www.bytearray.org/?p=27">SMTP Mailer</a> and a local SMTP server.</p>
<p>Whatever you do, don&#8217;t rely on one method only, specially Twitter, in case is down when the app needs it.</p>
<p><strong>REMOTE, REMOTE, REMOTE</strong></p>
<p>You either enable VNC, SSH or both. If you can&#8217;t, then be prepared for walking / driving / taking the bus a lot.</p>
<p>&#8211;</p>
<p>I&#8217;ll leave the details of running your apps using launchd and the peculiar way in which AIR holds &#8220;hard&#8221; references to files for another posts.</p>
<img src="http://feeds.feedburner.com/~r/zarate/zblog/~4/Db__56SN4m8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.zarate.tv/2010/05/03/running-flash-apps-247/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.zarate.tv/2010/05/03/running-flash-apps-247/</feedburner:origLink></item>
		<item>
		<title>XFL. Finally.</title>
		<link>http://feedproxy.google.com/~r/zarate/zblog/~3/_fsJiBAZpSY/</link>
		<comments>http://blog.zarate.tv/2010/04/18/xfl-finally/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 12:38:11 +0000</pubDate>
		<dc:creator>Zarate</dc:creator>
				<category><![CDATA[adobe]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://blog.zarate.tv/?p=1531</guid>
		<description><![CDATA[Obviously, the Flash to iPhone cross-compiler mayhem has gotten all the attention of the CS5 release, but as Kevin Lynch pointed out, there&#8217;re another 250 reasons to update to CS5. Well, I very much doubt there&#8217;re 250, but there&#8217;s one I&#8217;m very happy about: CS5 not only imports XFL files, it also exports them.
For those [...]]]></description>
			<content:encoded><![CDATA[<p>Obviously, the Flash to iPhone cross-compiler mayhem has gotten all the attention of the CS5 release, but as Kevin Lynch pointed out, there&#8217;re another 250 reasons to update to CS5. Well, I very much doubt there&#8217;re 250, but there&#8217;s one I&#8217;m very happy about: CS5 not only imports XFL files, it also <strong>exports</strong> them.</p>
<p>For those who don&#8217;t know, XFL is an <strong>open</strong> format based on zip+xml+assets used also in other products of the suite such as After Effects. The idea is great, storing the information needed in a simple format makes certain things easier:</p>
<p><strong>File diffs</strong>. Now that source control is much more spread in the Flash world (sadly, not standard yet) how nice would be comparing two XFL files same as you compare two AS files?</p>
<p><strong>Corruption recovery</strong>. How many FLA files have gone down the crapper for no apparent reason? How many FLA files grow in size disproportionally? Well, what do you think is easier, getting meaningful information out of a closed-binary file or out of a zip with xmls and assets? </p>
<p><strong>3rd party tools</strong>. A Flash IDE for Linux!! There&#8217;s probably no business case for Adobe in porting and maintaining a Linux version of the Flash IDE, but with an open format such as XFL is only a matter of time till someone comes up with an IDE-like software for Linux. I&#8217;m almost sure it won&#8217;t be as feature rich as the official IDE (takes time), but doesn&#8217;t need to be. It needs to allow *me* to work in Linux while designers work in Macs.  </p>
<p>It also opens up a new scenario for <a href="http://swfmill.org/">SWFMill</a> or <a href="http://www.mindless-labs.com/trac/samhaxe/">SamHaxe</a>. Wondering if they are thinking already about adding XFL support (being able to compile a XFL in SWFMill, for example).</p>
<p>Since I think XFL is the next best thing after bread, there&#8217;re a couple of things I don&#8217;t fully understand:</p>
<p><strong>Two formats</strong></p>
<p>Why keep the FLA? If you can effectively store in XFL the same information that you can in FLA, why does Adobe maintain the 2 formats? Why don&#8217;t they fully move to XFL and remove complexity from the IDE?</p>
<p><strong>XFL is not the default</strong> </p>
<p>Assuming for some reason that there&#8217;s an actual need to keep the 2 formats, why is XFL not the default? Again, since it offers so many advantages over the FLA, why is not the default format? </p>
<p>&#8211;</p>
<p>One problem at the moment is that <a href="http://www.flashmobileblog.com/2010/04/14/device-central-cs5-multitouch-and-debugger/comment-page-1/#comment-6374">it seems</a> the XFL specs haven&#8217;t been released yet. Kind of sad, to be honest. Reverse engineer a XFL file is not a piece of cake and you can never be sure you are doing it 100% right. Also, it prevents people without CS5 to start investigating, and CS5 launch is still due in mid May.</p>
<p>From the tests I&#8217;ve been doing, it seems fairly clean and well thought through, but difficult to say due to the complexity involved. Sorry for not uploading a sample file, but since CS5 is not out yet, not sure I wouldn&#8217;t get into trouble :/</p>
<p>Anyway, even if not perfect, I&#8217;m very happy about XFL, now need to find out about those other 249 reasons : )</p>
<img src="http://feeds.feedburner.com/~r/zarate/zblog/~4/_fsJiBAZpSY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.zarate.tv/2010/04/18/xfl-finally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.zarate.tv/2010/04/18/xfl-finally/</feedburner:origLink></item>
		<item>
		<title>TedXCam Hackathon</title>
		<link>http://feedproxy.google.com/~r/zarate/zblog/~3/U0rJsq6JqF8/</link>
		<comments>http://blog.zarate.tv/2010/04/11/tedxcam-hackathon/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 17:53:56 +0000</pubDate>
		<dc:creator>Zarate</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[events]]></category>

		<guid isPermaLink="false">http://blog.zarate.tv/?p=1512</guid>
		<description><![CDATA[Is over! The Hackathon is over and boy, did it fly. 
This hackathon was about messing around with a fixed set of open APIs and come up with a good app. We got together into teams and TED + Red Gate put the WiFi, the space, the food and the beer (which I had to [...]]]></description>
			<content:encoded><![CDATA[<p>Is over! The <a href="http://www.tedxcam.com/hackathon/">Hackathon</a> is over and boy, did it fly. </p>
<p>This hackathon was about messing around with a <strong>fixed</strong> set of open APIs and come up with a good app. We got together into teams and TED + <a href="http://www.red-gate.com/">Red Gate</a> put the WiFi, the space, the food and the beer (which I had to miss).</p>
<p>I&#8217;m reasonably happy with our outcome, because for the time given you can&#8217;t really expect much more. Only finding out what was available in those APIs and agree between <strong>7 people</strong> what to do took us 40% of the time. Once we knew what to do, the coding fun began. </p>
<p>What we came up with was a very simple way of putting in perspective what very little it takes to help developing countries. Or what could&#8217;ve been done with the staggering amounts of money companies in developed countries raise. For example, Spinvox&#8217;s first round of funding could&#8217;ve funded over 100,000 health related businesses in Sierra Leone through <a href="http://www.kiva.org/">Kiva</a>. Awesome. </p>
<p>Couple of guys putting together a Ruby backend for the API (including caching requests, as most APIs are limited to a certain amount of request per IP), couple of guys putting together HTML + Ajax to read the data and pass it to Flash and I did a little Flash widget to display the data. Fairly simple, but we got it working.</p>
<p>[UPDATE] We <a href="http://www.tedxcam.com/hackathon-results/">won</a> : ) <a href="http://ventropy.org/">Ventropy</a> is up and running! [/UPDATE]</p>
<p>Interesting to see what other people did. We were very, very pragmatic. Thought about using SVN or GIT, but settled for using Dropbox and worked really well. We got something working as soon as we could and added small improvements till the deadline. Should we take the project to the real life, I very much doubt we would keep anything we coded, though. Other people went for a complete setup (source control, a website, DB abstraction) and I think that time could&#8217;ve been better used in something else, but I&#8217;m not part of the jury : )</p>
<p>The day was totally worth it, but to me it felt like a sprint more than a marathon. 3 years ago, <a href="http://www.dandolachapa.com/2007/06/17/hackday-2007-london/">Yahoo&#8217;s Hackday</a> in London was a full weekend of coding. Much more time to code, learn, develop ideas and network. Sure, the time pressure was a funny incentive, but i like more the <em>&#8220;what can you do in 48hrs?</em>&#8221; thing. Still, thanks to the organizers and the sponsors.</p>
<p>Sadly I had to leave just after the last presentation and to top it up I&#8217;m also going to miss the main <a href="http://www.tedxcam.com/">TEDXCam conference</a> next weekend. Why would I miss such an event, specially when we got free tickets for participating in the Hackathon? </p>
<p>Well, next weekend is the <strong>Xtreme Geek Weekend &#8211; Barcelona Edition</strong>.</p>
<p>Stay tuned!</p>
<img src="http://feeds.feedburner.com/~r/zarate/zblog/~4/U0rJsq6JqF8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.zarate.tv/2010/04/11/tedxcam-hackathon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.zarate.tv/2010/04/11/tedxcam-hackathon/</feedburner:origLink></item>
		<item>
		<title>Giving a go to haxIgniter</title>
		<link>http://feedproxy.google.com/~r/zarate/zblog/~3/jcfM5eOxCmA/</link>
		<comments>http://blog.zarate.tv/2010/04/05/giving-a-go-to-haxigniter/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 10:48:00 +0000</pubDate>
		<dc:creator>Zarate</dc:creator>
				<category><![CDATA[haxe]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.zarate.tv/?p=1486</guid>
		<description><![CDATA[Every time I come back to PHP I miss a compiler to save me from my stupid silly mistakes. Also, I have to say that after years of AS2, AS3 and haXe, PHP&#8217;s syntax feels odd. And basically that&#8217;s the excuse to try haxIginiter, a web framework for haXe targeting PHP and Neko.
[Warning, haxeIgniter is [...]]]></description>
			<content:encoded><![CDATA[<p>Every time I come back to PHP I miss a compiler to save me from my stupid silly mistakes. Also, I have to say that after years of AS2, AS3 and haXe, PHP&#8217;s syntax feels odd. And basically that&#8217;s the excuse to try <a href="http://wiki.github.com/ciscoheat/haxigniter/">haxIginiter</a>, a web framework for haXe targeting PHP and Neko.</p>
<p>[<em>Warning, haxeIgniter is not a port of <a href="http://codeigniter.com/">CodeIgniter</a>, the PHP framework. Sure, ideas are pretty similar, but it's not a direct port</em>]</p>
<p>As a rule of thumb, I like it. Although docs and code need further improvement, it seems easy enough to get your head around. Let alone it brings a compiler and friendly haXe syntax to the server. If you want to try it yourself, read the docs, starting at the <a href="http://wiki.github.com/ciscoheat/haxigniter/">intro</a> and follow links from there.</p>
<p>I&#8217;ll list some things that got me and might save you some time.</p>
<p><strong>By default only works in the root of your server</strong></p>
<p>In theory you should be able to make it work in any folder by tweaking Config.hx, but I got it working in the root and didn&#8217;t try again.</p>
<p><strong>Needs write permission on www/runtime folder</strong></p>
<p>When I started testing on OSX under XAMPP I wasn&#8217;t getting anything on the screen or Apache logs, for some reason. Finally tried in Ubuntu and got to the problem, you need write access folders in www/runtime. </p>
<p><strong>Custom router</strong></p>
<p>The router is the piece of code that decides the &#8220;translation&#8221; between URL and controllers. There&#8217;re 2 by default, Basic and RESTful. Basic translates URLs to classes like this:</p>
<p>site.com/class/method/param1/param2</p>
<p>The RESTful follows the <a href="http://wiki.github.com/ciscoheat/haxigniter/rest-reference">REST approach</a> where:</p>
<p>site.com/controller/id > show(id, ?args)<br />
site.com/controller/new > make(?args)<br />
&#8230;</p>
<p>Ok, but what if you need more control than that? Well, for the time being you just have to roll your own. Create a MyRouter class implementing Router, add it to your Config.hx (about line 259 in 0.9.2) and you have full control over mapping URLs to controllers. See DefaultRouter.hx in haxigniter.server.routing for sample (as any other library, haxIgniter is installed in haxelib&#8217;s path, find it running <em>haxelib path</em> or <em>haxelib setup</em>).</p>
<p><strong>No obvious way of creating common + content views</strong></p>
<p>haxeIgniter offers 3 different template systems. <a href="http://haxe.org/doc/cross/template">haxe.Template</a> (default), <a href="http://haxe.org/com/libs/templo">Templo</a> and good ol&#8217; <a href="http://www.smarty.net/">Smarty</a>. I&#8217;m not so sure that <em>more is more</em> in this case, especially since there&#8217;s a low common denominator interface to deal with all of them, but anyway.</p>
<p>If you want to create a common + content view (common being html header, title, css and js links and content being each page&#8217;s specific markup) you need to render templates inside templates:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="co1">// Create content template and assign some sample value</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">var</span> contentTemplate = <span class="kw2">new</span> haxigniter.<span class="me1">server</span>.<span class="me1">views</span>.<span class="me1">HaxeTemplate</span><span class="br0">&#40;</span><span class="kw3">this</span>.<span class="me1">config</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">contentTemplate.<span class="me1">assign</span><span class="br0">&#40;</span><span class="st0">&#8216;project&#8217;</span>, <span class="st0">&#8216;Wadus&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Render content template and assign output to content var</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// in main template. Main template needs ::content:: variable!</span></div>
</li>
<li class="li1">
<div class="de1">view.<span class="me1">assign</span><span class="br0">&#40;</span><span class="st0">&#8216;content&#8217;</span>, contentTemplate.<span class="me1">render</span><span class="br0">&#40;</span><span class="st0">&#8216;page.mtt&#8217;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Display main template</span></div>
</li>
<li class="li1">
<div class="de1">view.<span class="me1">display</span><span class="br0">&#40;</span><span class="st0">&#8216;common.mtt&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
<p><strong>No helper for linking assets into views</strong></p>
<p>By default there&#8217;s no helper to include assets in your view (js, css, images, etc). Something like:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw3">html</span>.<span class="me1">image</span><span class="br0">&#40;</span><span class="st0">&#8216;foo.png&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
<p>In theory, inside a view, that code would create a img tag with the right path to the foo image, working out what the application path is inside the server, etc. At the moment there&#8217;s nothing like that, but you can set the <a href="http://www.w3schools.com/TAGS/tag_base.asp">base path</a> in your html and then use absolute paths. Something like:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="co1">// In your controller. Needs ::baseUrl:: in the template</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">var</span> <span class="kw3">url</span> = <span class="kw2">new</span> haxigniter.<span class="me1">server</span>.<span class="me1">libraries</span>.<span class="kw3">Url</span><span class="br0">&#40;</span><span class="kw3">this</span>.<span class="me1">config</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">view.<span class="me1">assign</span><span class="br0">&#40;</span><span class="st0">&#8216;baseUrl&#8217;</span>, <span class="kw3">url</span>.<span class="me1">linkUrl</span><span class="br0">&#40;</span><span class="br0">&#41;</span> + <span class="st0">&#8216;/&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
<div class="codesnip-container" >
<div class="html4strict codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="sc-1">&lt;!&#8211; In your view -&gt;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc-1">&lt;img src=&#8217;/foo.png&#8217; /&gt;</span></div>
</li>
</ol>
</div>
</div>
<p>&#8211;</p>
<p>So, there&#8217;re a few gotchas and probably haxeIgniter is not ready for mass consumption yet, but I think it&#8217;s a good start. I&#8217;m using it for building the next version of my website, so you will be able to look at &#8220;real&#8221; code soon. I&#8217;m using quotes here because the next version of my site is going to be <strong>very, very simple</strong>, so probably not the most complete haxeIgniter sample, but sample code nonetheless : )</p>
<img src="http://feeds.feedburner.com/~r/zarate/zblog/~4/jcfM5eOxCmA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.zarate.tv/2010/04/05/giving-a-go-to-haxigniter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.zarate.tv/2010/04/05/giving-a-go-to-haxigniter/</feedburner:origLink></item>
		<item>
		<title>Broken windows</title>
		<link>http://feedproxy.google.com/~r/zarate/zblog/~3/Y_smxgtXdsg/</link>
		<comments>http://blog.zarate.tv/2010/03/22/broken-windows/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 20:12:27 +0000</pubDate>
		<dc:creator>Zarate</dc:creator>
				<category><![CDATA[books]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://blog.zarate.tv/?p=1478</guid>
		<description><![CDATA[Re-reading technical books always makes sense. Usually I don&#8217;t remember anything I read on them once I finish, but while I&#8217;m reading I get all sorts of epiphanies, mostly related to the project I&#8217;m working on at that point in time. Basically, when you read a book, any book, you are a different person so [...]]]></description>
			<content:encoded><![CDATA[<p>Re-reading technical books always makes sense. Usually I don&#8217;t remember anything I read on them once I finish, but while I&#8217;m reading I get all sorts of epiphanies, mostly related to the project I&#8217;m working on at that point in time. Basically, when you read a book, any book, you are a different person so you pay attention and make connections to different things. </p>
<p>I&#8217;m reading now <a href="http://www.pragprog.com/">The Pragmatic Programmer</a>, an all time classic for programmers. For starters, they seem to be the people who coined the term <a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a>, <em>Don&#8217;t Repeat Yourself</em>. Might sound like a minor achievement, but being able to <strong>create</strong> new words and terms that allow people to communicate faster and better is a big deal. See, now when you hear someone talking about making apps more &#8220;web 2.0&#8243; or &#8220;harness the power of social media&#8221; the bullshit alarm in your brain automatically goes off and you get a quick idea of who you are talking to. Very useful.</p>
<p><strong>The building with the broken window</strong></p>
<p>Very early on the book they talk about something that is very true both in programming and real life. Researchers found that in a building, once a window breaks and it&#8217;s not fixed in a reasonable amount of time, the state of said building declines very, very fast. We see this all the time. Whenever something is clean, everyone follows and tries to keep it clean. But as soon as the garbage is left out for too long, people start letting themselves go. Very, very soon, the mindset goes from &#8220;wow, can&#8217;t leave that rubbish there&#8221; to &#8220;fuck it, everything looks shit&#8221;.</p>
<p>In software projects at the beginning everyone is happy and the rainbow is high up in the sky, but soon enough someone <em>breaks a window</em>. It might be using a literal here cause you don&#8217;t have time now to get hold of the config object or making a method public cause it simplifies so much getting the data out of the component, even if that breaks encapsulation. </p>
<p><strong>How to tackle the problem</strong></p>
<p>Fire the developer that breaks the window and doesn&#8217;t fix it in time? Too harsh? Is breaking windows a necessary evil from time to time? It really isn&#8217;t, but, for the sake of the pragmatic people (tight deadline, client wants this, today I was tired, etc), let&#8217;s assume breaking windows in inevitable. I can live with that. But we shouldn&#8217;t live with the broken window for too long or devs will start not caring very fast. What once was a nice and clean system can turn very quickly into a mess nobody wants to touch.</p>
<p>If threatening to fire developers might not go down well, what about threatening them with superstition? </p>
<p><strong>Exodus 23:10</strong></p>
<blockquote><p>And six years thou shalt sow thy land, and shalt gather in the fruits thereof: But the seventh year thou shalt let it rest and lie still</p></blockquote>
<p>This I think I picked up from Chris Heilmann at <a href="http://blog.zarate.tv/2009/10/29/devdays-london/">StackOverflow DevDays</a>. They say it in the sense that every 7th iteration (whatever long that is in your project), stop coding and clean up. I like it cause I think it brings a good balance between fast coding (I can hack this little thing now, code cleaning comes in 2 iterations) and keeping quality reasonable high.  </p>
<p>Also this goes by hand with the idea of the <a href="http://www.codinghorror.com/blog/2009/02/paying-down-your-technical-debt.html">technical debt</a>:</p>
<blockquote><p>Doing things the quick and dirty way sets us up with a technical debt, which is similar to a financial debt. Like the financial debt, the technical debt incurs interest payments, which come in the form of extra effort that we have to do in the future development because the quick and dirty design choice. We can choose to continue paying interest, or we can pay down the principal by refactoring into a better design. Although it costs to pay down the principal, we gain by reduced interest payments in the future.</p></blockquote>
<p>It&#8217;s ok to incur in some &#8220;debt&#8221; when you kick off the project, same as businesses incur in some real debt when they start. But at some point devs need to start paying back some of that debt or the interest (time wasted dealing with crappy code) grows exponentially.</p>
<p>Bottom line: it&#8217;s ok to break a window from time to time, but it&#8217;s not ok letting it broken forever. It will haunt you down : )</p>
<img src="http://feeds.feedburner.com/~r/zarate/zblog/~4/Y_smxgtXdsg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.zarate.tv/2010/03/22/broken-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.zarate.tv/2010/03/22/broken-windows/</feedburner:origLink></item>
		<item>
		<title>XAPI</title>
		<link>http://feedproxy.google.com/~r/zarate/zblog/~3/1dvKbwcvvFk/</link>
		<comments>http://blog.zarate.tv/2010/02/23/xapi/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 13:53:23 +0000</pubDate>
		<dc:creator>Zarate</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[haxe]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.zarate.tv/?p=1467</guid>
		<description><![CDATA[As I said in the last post regarding build tools in haXe, I&#8217;ve been working in XAPI. 
To put it simply, XAPI (Ximple API, the &#8220;x&#8221; is mandatory on haXe projects, you know?!) is a higher level API for haXe backends. Tu put it even simpler, that means doing more with less lines of code.
So, [...]]]></description>
			<content:encoded><![CDATA[<p>As I said in the last post regarding <a href="http://blog.zarate.tv/2010/02/08/build-tools-with-haxe/">build tools in haXe</a>, I&#8217;ve been working in <a href="http://github.com/zarate/xapi">XAPI</a>. </p>
<p>To put it simply, XAPI (Ximple API, the &#8220;<em>x</em>&#8221; is mandatory on haXe projects, you know?!) is a higher level API for haXe backends. Tu put it even simpler, that means doing more with less lines of code.</p>
<p><strong>So, what can it do?</strong></p>
<ul>
<li>Read / write / manage files and folders.</li>
<li>Get information about your system (OS, where&#8217;s the temp or the user folder, etc.).</li>
<li>Interact with other tools in your system (Git, SVN, MTASC, SWfMill, etc.).</li>
<li>Search for files and folders.</li>
<li>And other smaller bits and pieces.</li>
</ul>
<p>You can do all this already with &#8220;plain&#8221; haXe, XAPI only simplifies how you do it. Sometimes it also prevents developers for making mistakes. Two quick samples:</p>
<p>Writing content to a text file using XAPI:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1">xa.<span class="me1">File</span>.<span class="me1">write</span><span class="br0">&#40;</span><span class="st0">&#8216;myFile.txt&#8217;</span>, <span class="st0">&#8216;haXe rocks&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
<p>Using plain haXe:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">var</span> f = neko.<span class="me1">io</span>.<span class="me1">File</span>.<span class="me1">write</span><span class="br0">&#40;</span><span class="st0">&#8216;myFile.txt&#8217;</span>, <span class="kw2">false</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">f.<span class="me1">writeString</span><span class="br0">&#40;</span><span class="st0">&#8216;haXe rocks&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">f.<span class="kw3">close</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
<p>[<em>BTW, the opposite is not true, there's neko.io.File.getContent() which I didn't know about and used to use for this example. And also, turns out the PHP package has php.io.File. putContent()</em>]</p>
<p>Checking if a file exists using XAPI:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">var</span> exists = xa.<span class="me1">File</span>.<span class="me1">isFile</span><span class="br0">&#40;</span><span class="kw2">null</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
<p>Using plain haXe:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">var</span> exists = <span class="sy0">!</span>neko.<span class="me1">FileSystem</span>.<span class="me1">isFolder</span><span class="br0">&#40;</span><span class="kw2">null</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
<p>So, there&#8217;s no &#8220;isFile()&#8221; call in the API, plus using haXe alone you would get an exception because you are passing null (in real world you would never pass null on purpose, but it happens that you pass a variable that is), whereas in XAPI I check for null and, if it is, it just returns false. I think that&#8217;s how it should work and I <a href="http://code.google.com/p/haxe/issues/detail?id=67">reported it as a bug</a>, but it won&#8217;t get fixed :/</p>
<p>Those are the little and not so little additions that XAPI provides to the Std API. To get full details, just install and check out the docs. Simplest option is installing via haxelib (<em>haxelib install xapi</em>), but you can read <a href="http://wiki.github.com/zarate/xapi/installation">installation instructions</a> on the wiki.  </p>
<p>HippoHX&#8217;s API is the mother of XAPI. That&#8217;s when I first decided that I was going to expose a slightly different API that **I** thought it was simpler. See those stars around &#8220;I&#8221;? They are important. You see, this business of building APIs is very, very subjective.  I honestly think it&#8217;s much like designing. You need to know your target audience, one size doesn&#8217;t fit all, and there&#8217;s a great deal of taste involved.</p>
<p>XAPI is an API for developers like me, with the same needs I have, etc., etc. I&#8217;m fine with that, I have no plan to dominate the world (yet), and I&#8217;ve built XAPI to help me on my own projects. I open it to the world so hopefully a) other devs will benefit and b) people will help me fix bugs.</p>
<p><strong>What the future is? </strong></p>
<p>Turns out XAPI is almost feature complete because I want to keep it simple. I want it to be easy to use and I don&#8217;t want to target every single project out there, because that&#8217;s what the Std API is for. When we were discussing on the list about what XAPI could do,<a href="http://jdegoes.squarespace.com/">Jonh de Goes</a> came up with an interesting idea about building some kind of &#8220;general file system wrapper&#8221; API where each &#8220;node&#8221; could be a file on your system, in the cloud or somewhere else (read it <a href="http://lists.motion-twin.com/pipermail/haxe/2010-January/033324.html">here</a>). Well, that sounds like an awesome project, but out of the scope of XAPI. </p>
<p>On what can only be described as sweet irony, he also was the person who convinced me <strong>NOT</strong> to do it when I read his series of posts about writing Good APIs (<a href="http://jdegoes.squarespace.com/journal/2009/5/2/good-api-design-part-1.html">1</a>, <a href="http://jdegoes.squarespace.com/journal/2009/5/6/good-api-design-part-2.html">2</a>, <a href="http://jdegoes.squarespace.com/journal/2009/5/11/good-api-design-part-3.html">3</a>, <a href="http://jdegoes.squarespace.com/journal/2009/9/28/good-api-design-part-4.html">4</a>. Extra Ball, also read his post about <a href="http://jdegoes.squarespace.com/journal/2009/1/3/dispersed-development.html">Dispersed Development</a>).</p>
<p><em>Sweet Spot Saturation Rule</em></p>
<blockquote><p>&#8220;By letting go of the power users, they achieve high usability (this is not always an inevitable tradeoff, but at the very least, simpler applications are easier to make usable than more complex applications&#8221;</p></blockquote>
<p>And that&#8217;s exactly what I&#8217;m planning to do. By not implementing the general file system wrapper he proposes I&#8217;m going to let go power-users like him on behalf of mid-users like myself. I hope it pays off resulting in a very simple to use API. Time will tell.</p>
<p>One thing that I&#8217;m thinking about is custom exceptions, though. At the moment if the Neko VM finds a problem it raises an exception which I&#8217;m not sure we know the type of. So catching them in XAPI and raising new ones to which we know the type I think would help a lot. Ideas welcome, btw. </p>
<p><strong>Is XAPI for you?</strong>  </p>
<p>Well, depends on the type of projects you face and the kind of developer you are. </p>
<p>If you build for backends (php, cpp, neko), it might interest you.<br />
If you are rather new to haXe, it might interest you.<br />
If you develop build tools, it might interest you.<br />
If you are wiling to sacrifice some flexibility to gain simplicity, it might interest you.</p>
<p>And to wrap up, thanks to <a href="http://www.wildwinter.net/">Ian Thomas</a>, he was the first one <a href="http://groups.google.com/group/hippohx/msg/4044af472b8aab4b">suggesting such a project more than a year ago</a>. I might need some time, but I do deliver : )</p>
<img src="http://feeds.feedburner.com/~r/zarate/zblog/~4/1dvKbwcvvFk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.zarate.tv/2010/02/23/xapi/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://blog.zarate.tv/2010/02/23/xapi/</feedburner:origLink></item>
	</channel>
</rss>
