<?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>Sugar Mountain &#187; Coding</title>
	<atom:link href="http://subelement17.net/blog/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://subelement17.net/blog</link>
	<description></description>
	<lastBuildDate>Tue, 01 Feb 2011 10:28:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Working with Safari Extensions</title>
		<link>http://subelement17.net/blog/2010/08/20/working-with-safari-extensions/</link>
		<comments>http://subelement17.net/blog/2010/08/20/working-with-safari-extensions/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 08:28:26 +0000</pubDate>
		<dc:creator>Olle</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Safari]]></category>

		<guid isPermaLink="false">http://subelement17.net/blog/?p=886</guid>
		<description><![CDATA[So I have had my first go with a Safari Extension and it has not been a smooth ride I tell you! The documentation over at Apple really leaves one wishing for more. Some of the questions that I have manage to fix without documentation are the following &#8220;How the heck do I add icons to [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>So I have had my first go with a <a href="http://subelement17.net/blog/projectplace-login/" target="_blank"><em>Safari Extension</em></a><strong> </strong>and it has not been a smooth ride I tell you! The documentation over at Apple really leaves one wishing for more.</p>
<p>Some of the questions that I have manage to fix without documentation are the following</p>
<blockquote>
<h4><span style="font-weight: normal;">&#8220;How the heck do I add icons to the Safari Settings page?</span></h4>
</blockquote>
<p>Unless you want to have the default Safari Extension icons in Safari Settings(after installation), in the Safari Extension Builder and in the Installation Dialog, make sure you add three icons to your extension folder and call them:<br />
Icon-32.png<br />
Icon-48.png<br />
Icon-68.png</p>
<p>And I guess you can figure out the dimensions of the icons, yes it 32&#215;32, 48&#215;48 and 68&#215;68.<br />
The result will be this:<br />
<a rel="attachment wp-att-893" href="http://subelement17.net/blog/2010/08/20/working-with-safari-extensions/settings-2/"><img class="size-medium wp-image-893 alignnone" style="border: 1px solid black;" title="settings" src="http://subelement17.net/blog/wp-content/uploads/settings1-300x118.png" alt="" width="300" height="118" /></a> <a rel="attachment wp-att-892" href="http://subelement17.net/blog/2010/08/20/working-with-safari-extensions/ex-builder/"><img class="size-medium wp-image-892 alignnone" style="border: 1px solid black;" title="ex-builder" src="http://subelement17.net/blog/wp-content/uploads/ex-builder-300x44.png" alt="" width="300" height="44" /></a></p>
<blockquote>
<h4><span style="font-weight: normal;">Why the heck does not the updates work?</span></h4>
</blockquote>
<p>I made a lot of  misstakes when it comes to the update part of the Extension.<br />
I finally got it to work by leaving the default value when it comes to &#8220;Bundle Identifier &#8220;.</p>
<p>When you create your new Extension you choose a name, for example <em>myex.ver1</em>, and the builder will create the folder(<em>myex.ver1</em><em>.safariextension with the Info.plist)</em> for you and also create the default &#8220;Bundle Indentifier&#8221; in the Extension Builder. In my example the Identifier will be <em>com.yourcompany.myexver1.</em></p>
<p>Now make sure that you only change the &#8220;<em>com.yourcompany&#8221;</em> part of the Identifier. I made the mistake of modifying the last part as well. In my example my Identifier looked like this &#8220;<em>net.subelement.myex.ver1</em>&#8220;.</p>
<p><em> </em></p>
<p><em><span style="font-style: normal;">The problem with this is that the updates will not ever work, when you have a .plist that looks like this:</span> </em></p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
   &lt;key&gt;Extension Updates&lt;/key&gt;
   &lt;array&gt;
     &lt;dict&gt;
       &lt;key&gt;CFBundleIdentifier&lt;/key&gt;
       &lt;string&gt;net.subelement17.myex.ver1&lt;/string&gt;
       &lt;key&gt;Developer Identifier&lt;/key&gt;
       &lt;string&gt;YOUR IDENTIFIER&lt;/string&gt;
       &lt;key&gt;CFBundleVersion&lt;/key&gt;
       &lt;string&gt;1.0&lt;/string&gt;
       &lt;key&gt;CFBundleShortVersionString&lt;/key&gt;
       &lt;string&gt;1.0&lt;/string&gt;
       &lt;key&gt;URL&lt;/key&gt;
       &lt;string&gt;http://subelement17.net/projectplace/projectplace.safariextz&lt;/string&gt;
     &lt;/dict&gt;
   &lt;/array&gt;
&lt;/dict&gt;
&lt;/plist&gt;
</pre>
<p>So the thing is to always user the suggested Identifier, or you might end up in the same problems as I did.</p>
<div class="shr-publisher-886"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='false' data-shr_href='http%3A%2F%2Fsubelement17.net%2Fblog%2F2010%2F08%2F20%2Fworking-with-safari-extensions%2F' data-shr_title='Working+with+Safari+Extensions'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://subelement17.net/blog/2010/08/20/working-with-safari-extensions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Presentation of the core HTML5 features</title>
		<link>http://subelement17.net/blog/2010/05/17/presentation-of-the-core-html5-features/</link>
		<comments>http://subelement17.net/blog/2010/05/17/presentation-of-the-core-html5-features/#comments</comments>
		<pubDate>Mon, 17 May 2010 03:39:23 +0000</pubDate>
		<dc:creator>Olle</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[HTML5]]></category>

		<guid isPermaLink="false">http://subelement17.net/blog/?p=797</guid>
		<description><![CDATA[This must be the coolest way of presenting the new HTML5 features. Marcin Wichary and Ernest Delgado have done a great jobb creating a slideshow presenting the core of HTML5. Do check it out at: http://apirocks.com/html5/html5.html The code can be found at: http://code.google.com/p/html5-slides/]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>This must be the coolest way of presenting the new HTML5 features.<br />
Marcin Wichary and Ernest Delgado have done a great jobb creating a slideshow presenting the core of HTML5.</p>
<p>Do check it out at:<br />
<a title="html5" href="http://apirocks.com/html5/html5.html" target="_blank">http://apirocks.com/html5/html5.html</a></p>
<p>The code can be found at:<br />
<a title="html5 slide code" href="http://code.google.com/p/html5-slides/" target="_blank">http://code.google.com/p/html5-slides/</a></p>
<div class="shr-publisher-797"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='false' data-shr_href='http%3A%2F%2Fsubelement17.net%2Fblog%2F2010%2F05%2F17%2Fpresentation-of-the-core-html5-features%2F' data-shr_title='Presentation+of+the+core+HTML5+features'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://subelement17.net/blog/2010/05/17/presentation-of-the-core-html5-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 and the File API (Firefox 3.6)</title>
		<link>http://subelement17.net/blog/2009/12/10/html5-and-the-file-api/</link>
		<comments>http://subelement17.net/blog/2009/12/10/html5-and-the-file-api/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 21:54:27 +0000</pubDate>
		<dc:creator>Olle</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://subelement17.net/blog/?p=672</guid>
		<description><![CDATA[A blog post about the Firefox 3.6 HTML5 support for the File API and saving files(multiple upload) from you desktop through Drag 'n' Drop.]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>So, I&#8217;m having my first encounter with HTML 5 and the great power of it.<br />
I have mostly been looking into the Firefox 3.6 support for the File API, but also features like <a href="http://dev.w3.org/html5/spec/Overview.html#copy-and-paste" target="_blank">Copy/Paste</a>, <a href="http://dev.w3.org/html5/spec/Overview.html#undo" target="_blank">Undo</a> etc looks really promising?</p>
<h4>Firefox HTML 5 File API support through Drag n&#8217; Drop</h4>
<p>There are a number of blogs out there that has great examples on how to use the Drag n&#8217; Drop  and the File API in HTML5, and more specify, HTML5 in Firefox 3.6. But I have not found any example on the combination of Drag n&#8217; Drop in conjunction with the new File API, most often the File API is &#8220;called&#8221; from a standard &lt;input type=&#8221;file&#8221;..&gt; object.</p>
<p><span style="font-weight: normal;">Uploading files from the Desktop, through Drag n&#8217; Drop is really simple with the use of the HTML5 events ondragenter, ondragover and ondrop. By using the <a href="http://dev.w3.org/2006/webapi/FileAPI/">file API</a> we are able to read the files, get the name and also the size of any standard file formats, like txt, pdf, png or jpg for instance. In the long run, when the browsers out there will start to support HTML5 better, my hope is that we will not see any more browser specific plugins and such.</span></p>
<p><span style="font-weight: normal;">First of all we have the <a title="FileReader object" href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-filereader" target="_blank">FileReader</a> object. In short, it has three interfaces to read files asynchronous; readAsBinaryString, readAsText, and readAsDataURL. The three do the same thing, it reads files into memory(<em>readAsText also has the extra attribute of specifying encoding</em>).<br />
</span><br />
<span style="font-weight: normal;">Since the reading of the filedata into the FileReader object is connected to the &#8220;standard&#8221; event chain, the possibility to keep track of the progress of the loading of the file into memory is as easy as loading of any DOM object. The loaded data can now be saved/uploaded to a server through a Ajax call.</span></p>
<p><span style="font-weight: normal;">The only really sad thing right now, is have not found any browser supplier, except Firefox, that have implemented the FileReader interfaces, and we are left wishing and hoping that more browsers then Firefox 3.6 will have this.<br />
</span></p>
<h4>My somewhat working example(for Firefox 3.6)</h4>
<p>Instead of using the FileReader object like the example below, for reasons I will state later on, I have choosen to use the getAsBinary interface of the File API. getAsBinary is deprecated, and surely will be replaced by the FileReader interface, as below.</p>
<pre class="brush: jscript; title: ; notranslate">
function readFileIntoMem(file){
var reader = new FileReader();
reader.readAsText(files, 'UTF-8');
}
</pre>
<p>But as said, my working example(for Firefox 3.6) uses some functions that are deprecated, but never mind.. Over to the demo app.</p>
<h4>Demo<br />
<span style="font-weight: normal;">[<a href="http://subelement17.net/html5/index.html" target="_blank">Live Demo</a>]</span></h4>
<p>I have a html page that looks like this:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;html&gt;
&lt;head&gt;
&lt;style media=&quot;screen&quot;&gt;
	#file-drop-target{
        font-family: Georgia;
		border:1px solid #000;
		height:30px;
        text-align:center;
        padding:40px;
	}
    h4{
        font-family: Georgia;
        text-align:center;
    }
&lt;/style&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;handleFiles.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h4&gt;Drag 'n' Drop file(Firefox 3.6)&lt;/h4&gt;
&lt;div id=&quot;file-drop-target&quot;&gt;drop files here&lt;/div&gt;
&lt;div id=&quot;status-msg&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Nothing really fancy happens here, the main thing really that I load a javascript file called handleFiles.js and that we have a div with the id of <em>file-drop-target</em>. In handleFiles.js I have added a function call to addOnLoadEvent, that will run onload, that setts the onload handler, the setEventHandlers function, for the window object.</p>
<p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre;"> </span></p>
<pre class="brush: jscript; title: ; notranslate">
function addOnLoadEvent(sFunc)
{
    if(window.addEventListener)
        window.addEventListener('load', sFunc, false);
    else if(window.attachEvent)
        window.attachEvent('onload', sFunc);
}

addOnLoadEvent(setEventHandlers);
</pre>
<p>When the window object loads we will add a call to setEventHandlers that will handle the three events ondragover, ondragenter and ondrop for the html object file-drop-target. The first two events we just cancel. Our main focus is the ondrop event, and by attaching an eventhandler to it we will get access to the objects being dropped. The function doing this is handleDrop function. The first thing I do it terminate the event and hinder any bubbling of the event through out the DOM.</p>
<p>After the preventDef function call we get the new dataTransfer object and get the files that are being draged into the drop target.<br />
And after we have got the list of files being dropped, we need to access and store the files somehow.<br />
You can find a lot of Ajax scripts on the web that will save a file on a server, but they all have one problem. They all have the problem that the filename will not be submitted to the server, a problem as I see it, if one would like to use this technic in a web service. So what I&#8217;m doing is faking a post of a form, and in a form post we have the possibility on the server to get the name of the file being uploaded.<br />
After this has been done, a standard XMLHttpRequest call can be done, just make sure that content-type is multipart/form-data.<br />
The fake-form-posting is very much inspired by a script found on <a href="http://www.captain.at/" target="_blank">http://www.captain.at/</a></p>
<pre class="brush: jscript; title: ; notranslate">

function handleDrop(event)
{
	preventDef(event)

    var dt = event.dataTransfer;
  	var files = dt.files;

	for(var i = 0; i &lt; files.length;i++)
  	{

		http_request = new XMLHttpRequest();
		var boundaryString = 'the_boundery--';
		var boundary = '--' + boundaryString;
		var requestbody = boundary + '\n'

		+ 'Content-Disposition: form-data; name=&quot;thefilename&quot;' + '\n'
		+ '\n'
		+ files[i].fileName + '\n'
		+ '\n'
		+ boundary + '\n'
		+ 'Content-Disposition: form-data; name=&quot;thefile&quot;; filename=&quot;'
			+ files[i].fileName + '&quot;' + '\n'
		+ 'Content-Type: application/octet-stream' + '\n'
		+ '\n'
		+ files[i].getAsBinary()
		+ '\n'
		+ boundary;

		http_request.onreadystatechange = _handleReadyState;
		http_request.open('POST', 's.php', true);
		http_request.setRequestHeader(&quot;Content-type&quot;, &quot;multipart/form-data; \
			boundary=\&quot;&quot; + boundaryString + &quot;\&quot;&quot;);
		http_request.setRequestHeader(&quot;Connection&quot;, &quot;close&quot;);
		http_request.setRequestHeader(&quot;Content-length&quot;, requestbody.length);
		http_request.sendAsBinary(requestbody);
    }
}

function _handleReadyState()
{
    if (this.readyState == 4)
    {
        if(this.status == 200)
        {
            var pathStored = this.responseText
            document.getElementById('status-msg').innerHTML += ' &lt;br /&gt;';

            var linkToUpload = document.createElement('a');
            linkToUpload.href = pathStored;
            linkToUpload.appendChild(document.createTextNode(pathStored));
            document.getElementById('status-msg').appendChild(linkToUpload);
        }
    }
}

/**
* Event handlers
*/

function preventDef(event)
{
	event.preventDefault();
	event.stopPropagation();
}

function setEventHandlers()
{

	var dropTarget = document.getElementById('file-drop-target');
	addEvent(dropTarget,'dragover',preventDef, true);
	addEvent(dropTarget,'dragenter',preventDef, true);
	addEvent(dropTarget,'drop',handleDrop, true);
}

function addEvent(obj, evType, fn, useCapture)
{
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
      var r = obj.attachEvent(&quot;on&quot;+evType, fn);
    return r;
  }
}

function addOnLoadEvent(sFunc)
{
    if(window.addEventListener)
        window.addEventListener('load', sFunc, false);
    else if(window.attachEvent)
        window.attachEvent('onload', sFunc);
}

addOnLoadEvent(setEventHandlers);
</pre>
<p>I hope you like parts of this and share any great changes you might do to the script.. What I&#8217;d really like to see is a more browser none specific script then mine!</p>
<div class="shr-publisher-672"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='false' data-shr_href='http%3A%2F%2Fsubelement17.net%2Fblog%2F2009%2F12%2F10%2Fhtml5-and-the-file-api%2F' data-shr_title='HTML5+and+the+File+API+%28Firefox+3.6%29'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://subelement17.net/blog/2009/12/10/html5-and-the-file-api/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to write good tests. Top 5 considerations to build software without defects. &#124; Making good software</title>
		<link>http://subelement17.net/blog/2009/08/07/how-to-write-good-tests-top-5-considerations-to-build-software-without-defects-making-good-software/</link>
		<comments>http://subelement17.net/blog/2009/08/07/how-to-write-good-tests-top-5-considerations-to-build-software-without-defects-making-good-software/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 05:27:31 +0000</pubDate>
		<dc:creator>Olle</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://subelement17.net/blog/?p=555</guid>
		<description><![CDATA[How to write good tests. Top 5 considerations to build software without defects. via How to write good tests. Top 5 considerations to build software without defects. &#124; Making good software.]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>How to write good tests. Top 5 considerations to build software without defects.</p>
<p>via <a href="http://www.makinggoodsoftware.com/2009/08/05/how-to-write-good-tests/">How to write good tests. Top 5 considerations to build software without defects. | Making good software</a>.</p>
<div class="shr-publisher-555"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='false' data-shr_href='http%3A%2F%2Fsubelement17.net%2Fblog%2F2009%2F08%2F07%2Fhow-to-write-good-tests-top-5-considerations-to-build-software-without-defects-making-good-software%2F' data-shr_title='How+to+write+good+tests.+Top+5+considerations+to+build+software+without+defects.+%7C+Making+good+software'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://subelement17.net/blog/2009/08/07/how-to-write-good-tests-top-5-considerations-to-build-software-without-defects-making-good-software/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Shorten URL in Flex using bit.ly</title>
		<link>http://subelement17.net/blog/2009/08/02/shorten-url-in-flex-using-bit-ly/</link>
		<comments>http://subelement17.net/blog/2009/08/02/shorten-url-in-flex-using-bit-ly/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 23:04:16 +0000</pubDate>
		<dc:creator>Olle</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://subelement17.net/blog/?p=540</guid>
		<description><![CDATA[I have been starting to plan for my next project to come, and felt the need for a function that would use the bit.ly API to shorten URLs for me. I found a nice Python example over at http://tux-log.blogspot.com, but was not possible to find any AS3 examples. So I spent the evening making my own. [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I have been starting to plan for my next project to come, and felt the need for a function that would use the <a title="bit.ly" href="http://bit.ly/" target="_self">bit.ly</a> API to shorten URLs for me.<br />
I found a nice Python example over at <a title="tux-log" href="http://tux-log.blogspot.com" target="_blank">http://tux-log.blogspot.com</a>, but was not possible to find any AS3 examples. So I spent the evening making my own.</p>
<p>Hope you like it, it&#8217;s way from perfect so please feel free to comment!<br />
<code><br />
</code></p>
<p><code> </code></p>
<p><code> </code></p>
<p><code></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">/**</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">* Class ShortenURL</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">* Author: Olle Dahlstrom(olle.dahlstrom@gmail.com)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">* Takes a URL and calls the bit.ly API to shorten it.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">* You need to have a bit.ly username and API Key(get it at http://bit.ly/), I have my stored in a Config class file.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">*</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">* Example Code</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">* import net.subelement17.ShortenURL</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">* var _url:ShortenURL = new ShortenURL();</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">* _url.call('http://subelement17.net/blog', giveMeTheUrl);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">* function giveMeTheUrl(res:String):void)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">* {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">*    //do something with the result....</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">* }</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3f5fbf;">*/</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="color: #9900cc;">package</span> net.subelement17</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;">{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span><span style="color: #0033ff;">import</span> mx.rpc.events.ResultEvent;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span><span style="color: #0033ff;">import</span> mx.rpc.http.HTTPService;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px;"><span style="white-space: pre;"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="color: #0033ff;">public</span> <span style="color: #9900cc;">class</span> ShortenURL</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;">{<span style="white-space: pre;"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"><span style="white-space: normal;"><span style="color: #0033ff;"> private</span> <span style="color: #6699cc;">var</span> apiKey:String = <span style="color: #0033ff;">new</span> Config().bitly_APIKKEY;</span></span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span><span style="color: #0033ff;">private</span> <span style="color: #6699cc;">var</span> userName:String = <span style="color: #0033ff;">new</span> Config().bitly_USERNAME;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span><span style="color: #0033ff;">private</span> <span style="color: #6699cc;">var</span> apiVersion:String = <span style="color: #0033ff;">new</span> Config().bitly_APIVERSION;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span><span style="color: #0033ff;">public</span> <span style="color: #6699cc;">var</span> longURL:String = ''</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="color: #0033ff;"> private</span> <span style="color: #6699cc;">var</span> resultReturn:Function;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span><span style="color: #0033ff;">public</span> <span style="color: #339966;">function</span> ShortenURL(){}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span><span style="color: #0033ff;">public</span> <span style="color: #339966;">function</span> call(URL:String,resultHandler:Function):<span style="color: #0033ff;">void</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;">resultReturn = resultHandler;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>longURL = URL;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span><span style="color: #6699cc;">var</span> htService:HTTPService = <span style="color: #0033ff;">new</span> HTTPService();</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>htService.method = <span style="color: #990000;">'GET'</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>htService.resultFormat = <span style="color: #990000;">'array'</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #990000;"><span style="color: #000000;"><span style="white-space: pre;"> </span>htService.url = </span>'http://api.bit.ly/shorten'<span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px;"><span style="white-space: pre;"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span><span style="color: #6699cc;">var</span> params:Object = <span style="color: #0033ff;">new</span> Object();</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>params.longUrl = URL;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>params.login = userName;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>params.apiKey = apiKey;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>params.version = apiVersion;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>params.format = <span style="color: #990000;">'xml'</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px;"><span style="white-space: pre;"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>htService.addEventListener(ResultEvent.RESULT,resutlHander);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>htService.send(params);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px;"><span style="white-space: pre;"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span><span style="color: #0033ff;">private</span> <span style="color: #339966;">function</span> resutlHander(resultEV:ResultEvent):String</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span><span style="color: #6699cc;">var</span> shortXML:XML = <span style="color: #0033ff;">new</span> XML(resultEV.message.body);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span><span style="color: #0033ff;">if</span>(shortXML.child(<span style="color: #990000;">"errorCode"</span>).toString() == 0)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span><span style="color: #0033ff;">return</span> resultReturn(shortXML.child(<span style="color: #990000;">"results"</span>).child(<span style="color: #990000;">'nodeKeyVal'</span>).child(<span style="color: #990000;">"shortUrl"</span>).toString());</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #0033ff;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span>else</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span><span style="color: #0033ff;">return</span> resultReturn(longURL);<span style="white-space: pre;"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="white-space: pre;"> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;">}</p>
<p></code></p>
<div class="shr-publisher-540"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='false' data-shr_href='http%3A%2F%2Fsubelement17.net%2Fblog%2F2009%2F08%2F02%2Fshorten-url-in-flex-using-bit-ly%2F' data-shr_title='Shorten+URL+in+Flex+using+bit.ly'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://subelement17.net/blog/2009/08/02/shorten-url-in-flex-using-bit-ly/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>So you wanna be a front end developer?</title>
		<link>http://subelement17.net/blog/2009/05/13/so-you-wanna-be-a-front-end-developer/</link>
		<comments>http://subelement17.net/blog/2009/05/13/so-you-wanna-be-a-front-end-developer/#comments</comments>
		<pubDate>Wed, 13 May 2009 06:37:01 +0000</pubDate>
		<dc:creator>Olle</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=398</guid>
		<description><![CDATA[Some tips on how to become a great front end developer. Recipe: will to learn!]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Back in the day when I was a young boy in the big IT-industry I wanted to become the greatest front end developer the web had seen. Due to circumstances, out of my hands of course, I did not reach my goal, but I did get to &#8220;know&#8221; some great ones along the way!</p>
<p>So I guess you possibly have some schooling to bring to the table, or you have been working with back-end stuff stuff for quite some time, you know what object oriented programming is or at least want to learn, and most importantly you have the will to learn!</p>
<p>When I started to become really interested in front end development back in the late 90&#8242;s, front end development was not looked upon as real programming, real programming was C++, Java and the likes. But now, we have job titles like Senior Front End Developer at for instance Yahoo and Google, so I guess that the understanding of the importance of good front end code has really elevated.</p>
<p>So my way of learning the craftsmanship, was to study the masters below, downloaded their code, read it, and then write my own! If it worked for me, I&#8217;m sure it will for you!</p>
<p><strong>Scott Andrew LePera</strong><br />
What really got me started was a guy named Scott Andrew LePera(<a href="http://www.scottandrew.com/">http://www.scottandrew.com/</a>). He got me all warm and fuzzy talking about for instance <a href="http://www.scottandrew.com/weblog/articles/cbs-events">event handlers in javascript</a> and how event bubbles</p>
<p><strong>Aaron Boodman</strong><br />
After that I stumbled over <a href="http://www.aaronboodman.com/">Aaron Boodman,</a> the <a href="http://youngpup.net/">youngpup</a> (and creator of <a href="http://www.youtube.com/watch?hl=sv&amp;v=cQyha30nm6k&amp;gl=SE">Greasemonky</a> among things) showed me all about how to create the menus that we love to have, how to make the Javascripts run smooth in <a href="http://youngpup.net/projects/2027/demo.html">animations</a>, and how <a href="http://youngpup.net/projects/dom-drag/demo.html">drag of elements</a> shall be done. Back in the beginning of the 2000 he had the coolest UI on his blog, and nothing I have seen since has turned me on as much as viewing youngpup.net for the first time(except possibly 13thparallel)!</p>
<p><strong>13thparallel</strong><br />
<a href="http://13thparallel.com/archive/">13thparallel</a> made me think about <a href="http://13thparallel.com/archive/coding-for-portability1/">coding</a> for <a href="http://13thparallel.com/archive/coding-for-portability2/">portability</a>, introduced me to the concept of the <a href="http://13thparallel.com/archive/viewport/">Viewport</a> among other things.</p>
<p><strong>WebFX</strong><br />
Emil A Eklund and Erik Arvidsson at <a href="http://webfx.eae.net/">WebFX</a> showed me that it was possible to create a <a href="http://webfx.eae.net/webboard/">forum</a> on the web with outstanding functionality and speed(unfortunately it only looks good in MS IE), how to work with <a href="http://webfx.eae.net/dhtml/xloadtree/demo.html">XML in advanced Javascript.</a></p>
<p><strong>Peter-Paul Koch @Quirksmode</strong><br />
<a href="http://www.quirksmode.org">Quirksmode</a> helped me really understand the differences between browsers and what do do about it. He also really introduced me to <a href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript">Unobtrusive JavaScript</a>.</p>
<p>Remember that most of the examples above have been written back in 2001-2002, and they still work..What does this tell us, well to use the standards, and no browser specific hack, because browsers change and you will end up chasing your own tail to make things work in new browsers.</p>
<div class="shr-publisher-398"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='false' data-shr_href='http%3A%2F%2Fsubelement17.net%2Fblog%2F2009%2F05%2F13%2Fso-you-wanna-be-a-front-end-developer%2F' data-shr_title='So+you+wanna+be+a+front+end+developer%3F'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://subelement17.net/blog/2009/05/13/so-you-wanna-be-a-front-end-developer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

