<?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>The Page Not Found Blog</title>
	<atom:link href="http://www.andygup.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andygup.net</link>
	<description>Living life one line of code at a time - by Andy Gup</description>
	<lastBuildDate>Sat, 11 May 2013 18:44:10 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Hack4Colorado 2013 &#8211; Civic Hackathon</title>
		<link>http://www.andygup.net/hack4colorado-2013-civic-hackathon/</link>
		<comments>http://www.andygup.net/hack4colorado-2013-civic-hackathon/#comments</comments>
		<pubDate>Sat, 11 May 2013 18:44:10 +0000</pubDate>
		<dc:creator>agup</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[ArcGIS]]></category>
		<category><![CDATA[Esri]]></category>
		<category><![CDATA[hackathon]]></category>

		<guid isPermaLink="false">http://www.andygup.net/?p=1253</guid>
		<description><![CDATA[Do you live in Colorado and want to have fun playing with code, learn new APIs and datasets, and generally testing your coding &#8220;skillz&#8221; while under pressure and competing with other hotshot developers for prizes? If you answered &#8220;yes&#8221;, then I strongly recommend you check out the opportunities at the Hack4Colorado event which takes place [...]]]></description>
				<content:encoded><![CDATA[<p>Do you live in Colorado and want to have fun playing with code, learn new APIs and datasets, and generally testing your coding &#8220;skillz&#8221; while under pressure and competing with other hotshot developers for prizes? If you answered &#8220;yes&#8221;, then I strongly recommend you check out the opportunities at the <a href="http://www.hack4colorado.com/">Hack4Colorado</a> event which takes place on the weekend of May 31st. This event is part of a national civic hacking day where other States, Counties and Cities around the country are doing exactly the same thing.</p>
<p>The concept is simple. These events help promote open government data that can be used within applications that you build to solve everyday problems. So, these organizations provide you with cool data sets to choose from and you have fun building an application around it. Ideas include find the nearest rent-a-bike location, explore local hiking trails and so much more.</p>
<p>Full disclosure, <a href="http://developers.arcgis.com/en/">Esri</a> has also graciously offered to provide bountiful cash (yes, cash!) prizes. Other sponsors are offering Rokus, Kinects, and even Big Wheels (yes you also heard that right!). I even have an application in mind that I might try to build when I&#8217;m not helping other folks out.</p>
<p>What do you think? Hopefully I&#8217;ll see you there.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.andygup.net%2Fhack4colorado-2013-civic-hackathon%2F&amp;title=Hack4Colorado%202013%20%E2%80%93%20Civic%20Hackathon" id="wpa2a_2"><img src="http://03259be.netsolhost.com/WordPress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.andygup.net/hack4colorado-2013-civic-hackathon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy enums for custom JavaScript libraries</title>
		<link>http://www.andygup.net/easy-enums-for-custom-javascript-libraries/</link>
		<comments>http://www.andygup.net/easy-enums-for-custom-javascript-libraries/#comments</comments>
		<pubDate>Sat, 11 May 2013 18:16:49 +0000</pubDate>
		<dc:creator>agup</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[enums]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[namespaces]]></category>

		<guid isPermaLink="false">http://www.andygup.net/?p=1240</guid>
		<description><![CDATA[There’s a ton of information on the internet related to the best way to create JavaScript enums. This post is different in that it focuses on using enums that are immutable and cannot be changed within your own custom libraries. The challenge with enum usage in JavaScript is global variable leakage can accidentally cause unexpected [...]]]></description>
				<content:encoded><![CDATA[<p>There’s a ton of information on the internet related to the best way to create JavaScript enums. This post is different in that it focuses on using enums that are immutable and cannot be changed within your own custom libraries.</p>
<p>The challenge with enum usage in JavaScript is global variable leakage can accidentally cause unexpected changes within your application, especially in cases of large, complex applications that may involve your own JavaScript libraries along-side 3rd party libraries. Global variable leakage means two variables can potentially have the same name, and this may not cause an error. Good debuggers help to avoid this problem by using <a href="http://www.jslint.com/">jslint</a>. But, if someone else is using your libraries then you can&#8217;t depend on them using best practices. So, variable leakage can cause unexplainable/unpredictable problems and create hard to track bugs. What we need is a coding pattern to protect enums so that we can guarantee that we always get the value expected.</p>
<p>As of today, JavaScript doesn’t have a <i>universally accepted, </i>built-in cross-browser solution for guaranteeing that specific variables can be made immutable. In other words, if we create a statement <i>var BLUE = “blue”</i> there is no way to enforce that something elsewhere in an application, or code that someone else wrote that is running the same application cannot ever change the value of BLUE.</p>
<p>In comparison, strongly typed languages such as C# and Java let you declare constants. If you accidentally try to change them in your code you get a compiler error that prevents the application from running. The compile-time checking can help prevent bugs in your code later on. Here are several examples from Java and C#:</p>
<pre style="padding-left: 30px;"> final int RADIUS = 1000; //Java</pre>
<pre style="padding-left: 30px;"> const int RADIUS = 1000; //C#</pre>
<p>So here we go. I’ll use six use cases to illustrate a variety of ways to make certain your enums are immutable. This list is not designed to be all inclusive, its intent is to demonstrate patterns that you can use to learn more about JavaScript enums. You can try these out using the following <a href="http://jsfiddle.net/PvRFj/20/">jsfiddle</a>.</p>
<p><b>USE CASE 1</b> – Basic public enum function with no namespace protection. This use cases offers the least amount of protection against global variable leakage. I&#8217;d only expect to see this type of enum in very small, stand-alone applications.</p>
<pre class="brush: java; title: ; notranslate">
function basicEnum() {
    var values = {
         BLACK: '#000000',
         RED: '#FF0000',
         GREEN: '#00FF00'
    }

    return values;
}

console.log(&quot;test0 &quot; + basicEnum().BLACK); //test0 #000000
</pre>
<p><b>USE CASE 2</b> – Basic public enum that uses an internal, privately scoped namespace in which to define the enum object. This use case offers slightly more protection than Use Case 1, but the public function itself is still not protected within the global namespace. It&#8217;s possible there could be two functions with the same name &#8220;colorEnum&#8221;. And, the larger the application gets the higher probability there is of having accidental name duplication.</p>
<pre class="brush: java; title: ; notranslate">
function colorEnum() {
    var values = values || {}
    values.colorEnum = {
         BLACK: '#000000',
         RED: '#FF0000',
         GREEN: '#00FF00'
      };

      return values;
};

console.log(&quot;test1 &quot; + colorEnum().colorEnum.GREEN); //test1 #00FF00
</pre>
<p><b>USE CASE 3</b> – Public enum with no namespace protection using an anonymous function expression to define the enum. This is a variation of Use Case 2 showing you can define multiple categories of enums. And, like Use Case 2 it still offers zero public/global namespace protection. I&#8217;m using the terms public and global to mean the same thing.</p>
<pre class="brush: java; title: ; notranslate">
DoSomething = (function(){

    var constValues = constValues || {}
    constValues.color = {&quot;BLACK&quot; : &quot;#000000&quot; }
    constValues.error = {&quot;ERROR_TIMEOUT&quot; : &quot;Connection Timeout&quot; }
    return constValues;
});

console.log(&quot;test2 &quot; + DoSomething().color.BLACK); //test2 #000000
console.log(&quot;test3 &quot; + DoSomething().error.ERROR_TIMEOUT); //test3 Connection Timeout
</pre>
<p><b>USE CASE 4</b> – Public enum with namespace protection using an anonymous function expression and internal (private) namespaces to differentiate multiple categories of custom enum objects. This use case starts to offer better protection against global variable leakage by wrapping the public function in a namespace.</p>
<pre class="brush: java; title: ; notranslate">
var my_test = my_test || {}
my_test.DoSomething = (function(){

    var constValues = constValues || {}
    constValues.color = {
        &quot;BLACK&quot; : &quot;#000000&quot;,
        &quot;RED&quot; : &quot;#FF0000&quot;
    }
    constValues.error = {
        &quot;ERROR_TIMEOUT&quot; : &quot;Connection Timeout&quot;,
        &quot;ERROR_FAULT&quot; : &quot;Connection problem&quot;
    }
    return constValues;
});

console.log(&quot;test4 &quot; + my_test.DoSomething().color.BLACK); //test4 #000000
console.log(&quot;test5 &quot; + my_test.DoSomething().error.ERROR_TIMEOUT); //test5 Connection Timeout
</pre>
<p><b>USE CASE 5</b> – Namespace protected public anonymous function expression along with an internally (private) scoped function that defines the enum. This is a variation of Use Case 5 showing how to use switch/case statements along with a privately scoped function that are all wrapped inside the anonymous function.</p>
<pre class="brush: java; title: ; notranslate">
var my_second_test = my_second_test || {};
my_second_test.DoSomething = (function(val){

    var color;

    switch(val)
    {
        case 1:
            color = basicEnum().BLACK;
            break;
        case 2:
            color = basicEnum().RED;
            break;
        case 3:
            color = basicEnum().GREEN;
            break;
    }

    function basicEnum() {
        var values = {
             BLACK: '#000000',
             RED: '#FF0000',
             GREEN: '#00FF00'
        }

        return values;
    }

    return color;
});

console.log(&quot;test6 &quot; + my_second_test.DoSomething(2)); //test6 #FF0000
</pre>
<p><b>USE CASE 6</b> – This Use Case shows placing a privately scoped anonymous function expression defining the enum inside a public anonymous function expression, and finally accessed through another prototyped anonymous function expression. Yikes, that was a lot of technical mumbo-jumbo verbiage, right?! It also offers several tests to validate if the enum is immutable or not.</p>
<pre class="brush: java; title: ; notranslate">
var my_third_test = my_third_test || {};
my_third_test.DoSomething = (function(){

    this.basicEnum = (function() {
        var values = {
             BLACK: '#000000',
             RED: '#FF0000',
             GREEN: '#00FF00'
        }

        return values;
    });

});

my_third_test.DoSomething.prototype.findColor = (function(val){
    var color;

    switch(val)
    {
        case 1:
            color = this.basicEnum().BLACK;
            break;
        case 2:
            color = this.basicEnum().RED;
            break;
        case 3:
            color = this.basicEnum().GREEN;
            break;
    }

    return color;
});

var myColor = new my_third_test.DoSomething();

console.log(&quot;test7 &quot; + myColor.findColor(3)); //test7 #00FF00

//The enum properties cannot be changed
myColor.basicEnum().BLACK = &quot;test&quot;;

console.log(&quot;test8 &quot; + myColor.basicEnum().BLACK); //test8 #000000

try{
    //test that basicEnum() is immutable
    myColor.basicEnum() = &quot;test&quot;; //Throws ERROR!
}
catch(err){
    console.log(&quot;test9 &quot; + err);
    //test9 ReferenceError: Invalid left-hand side in assignment
}
</pre>
<p><strong>Conclusion.</strong> So that&#8217;s all there is to it. Hopefully these examples help to not only demonstrate some patterns to protect your data, but also give you ideas for saving time while building larger applications.</p>
<p><strong>Reference.</strong></p>
<p><a href="http://jsfiddle.net/PvRFj/20/">JSFiddle project</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.andygup.net%2Feasy-enums-for-custom-javascript-libraries%2F&amp;title=Easy%20enums%20for%20custom%20JavaScript%20libraries" id="wpa2a_4"><img src="http://03259be.netsolhost.com/WordPress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.andygup.net/easy-enums-for-custom-javascript-libraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Mobile – Setting full content width</title>
		<link>http://www.andygup.net/jquery-mobile-setting-full-content-width/</link>
		<comments>http://www.andygup.net/jquery-mobile-setting-full-content-width/#comments</comments>
		<pubDate>Sun, 21 Apr 2013 21:02:54 +0000</pubDate>
		<dc:creator>agup</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[content width]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery mobile]]></category>
		<category><![CDATA[width]]></category>

		<guid isPermaLink="false">http://www.andygup.net/?p=1228</guid>
		<description><![CDATA[Here are some hints to help get all of your jQuery content stretched to the full width of your mobile browser screen regardless of screen size or orientation. These techniques have been tested on jQuery 1.7.x, jQuery 2.0 and jQuery mobile 1.3.1. Lets start with a look at the minimum required CSS: Problem – Using [...]]]></description>
				<content:encoded><![CDATA[<p>Here are some hints to help get all of your jQuery content stretched to the full width of your mobile browser screen regardless of screen size or orientation. These techniques have been tested on jQuery 1.7.x, jQuery 2.0 and jQuery mobile 1.3.1.</p>
<p>Lets start with a look at the minimum required CSS:</p>
<pre class="brush: java; title: ; notranslate">
html,body,div[data-role =&quot;page&quot;], div[data-role=&quot;content&quot;] {
    height: 100%;
    width: 100%;
    margin: 0px;
    padding: 0px;
}

</pre>
<p><strong>Problem</strong> – Using the minimum CSS above, leaves a spacer on the top and left hand sides of the app, and the right hand border and/or bottom border disappears. I noticed the right hand margin extends approximately 9 to 15 pixels (or greater depending on device) beyond the visible view. I verified this behavior on Android 4.1 native browser and Chrome 26, as well as on iPad 3 using Safari and Chrome 25.</p>
<p><strong>Solution</strong> – set certain CSS width properties as shown below. This solution has been tested on Android 4.1 native and Chome 26, Android 2.3.2 native, and on iPad Safari and Chrome 25. Just a bit of a warning that if displayed on a desktop browser you will see vertical scrollbars. But, you should be detecting the different between mobile and desktop anyway, right!</p>
<p><em>Note:</em> this solution doesn&#8217;t address the problem with content height, it only looks at width. So, yes, you will notice that the height of my sample is off the page.</p>
<pre class="brush: java; title: ; notranslate">

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=7,IE=9&quot;&gt;
    &lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot;&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0, maximum-scale=1.0,user-scalable=no&quot;&gt;
    &lt;meta name=&quot;apple-mobile-web-app-status-bar-style&quot; content=&quot;black-translucent&quot;&gt;

    &lt;title&gt;jQuery Test&lt;/title&gt;

    &lt;link rel=&quot;stylesheet&quot; href=&quot;http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css&quot; /&gt;

    &lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-2.0.0.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.js&quot;&gt;&lt;/script&gt;
&lt;style&gt;
        html,body, div[data-role =&quot;page&quot;] {
            height: 100%;
            width: 100%;
            margin: 0px;
            padding: 0px;
        }

         .ui-content{
            height: 100%;
            width: 100%;
            margin: 0px;
            padding: 0px;
            border-style: solid;
            border-color: chartreuse;
            border-width: 5px;
        }

        #map {
            height: 100%;
            width: 100%;
            padding: 0px;
            border-style: solid;
            border-color: crimson;
            border-width: 10px;
        }
&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;div data-role=&quot;page&quot; id=&quot;page1&quot; &gt;

    &lt;div data-role=&quot;content&quot;&gt;
        &lt;div id=&quot;map&quot;&lt;/div&gt;
    &lt;/div&gt;

&lt;/div&gt;
&lt;/body&gt;

</pre>
<p><b>References</b></p>
<p><a href="https://developer.mozilla.org/en-US/docs/Determining_the_dimensions_of_elements">Determining the dimensions of an [HTML] element</a></p>
<p><a href="http://www.andygup.net/?p=617">Check HTML5 Browser Height and Width using Canvas</a></p>
<p>[Modified April 26, 2013 - fixed code bug]</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.andygup.net%2Fjquery-mobile-setting-full-content-width%2F&amp;title=jQuery%20Mobile%20%E2%80%93%20Setting%20full%20content%20width" id="wpa2a_6"><img src="http://03259be.netsolhost.com/WordPress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.andygup.net/jquery-mobile-setting-full-content-width/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smartphone devs, yes SD card speed matters!</title>
		<link>http://www.andygup.net/smartphone-devs-yes-sd-card-speed-matters/</link>
		<comments>http://www.andygup.net/smartphone-devs-yes-sd-card-speed-matters/#comments</comments>
		<pubDate>Sun, 14 Apr 2013 18:15:28 +0000</pubDate>
		<dc:creator>agup</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[sd card]]></category>
		<category><![CDATA[speed]]></category>

		<guid isPermaLink="false">http://www.andygup.net/?p=1211</guid>
		<description><![CDATA[If you want to get the highest performance out of your SD cards then read on. The purpose of this article is to raise awareness and spark your curiosity about SD card performance considerations. Many developers I talk to aren’t aware that the read/write speeds of SD memory cards can have a significant affect on [...]]]></description>
				<content:encoded><![CDATA[<p>If you want to get the highest performance out of your SD cards then read on. The purpose of this article is to raise awareness and spark your curiosity about SD card performance considerations.</p>
<p><a href="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/04/sdcard_small.png"><img class="size-full wp-image-1214 alignright" alt="Micro SD Class 2" src="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/04/sdcard_small.png" width="115" height="141" /></a></p>
<p>Many developers I talk to aren’t aware that the read/write speeds of SD memory cards can have a significant affect on performance. This is especially true if you are moving around lots of data between a smartphone and the SD card. The good news is there is quite a bit of information out there to help you maximize performance, and a lot of it comes from high-end, camera aficionados believe it or not.</p>
<p>The most common feedback I get is developers typically buy cards with the most capacity at the lowest price. Depending on what you are doing, cheapest and slower isn’t always better. With little bit of research your read/write performance could get significantly better.</p>
<p>To start with there are four common speed classes: 2, 4, 6 and 10 and they represent an approximate minimum performance rating. You can find this number on the front of your card:</p>
<ul>
<li>Class 2 ~ 2 Mbytes/sec</li>
<li>Class 4 ~ 4 Mbytes/sec</li>
<li>Class 6 ~ 6 Mbytes/sec</li>
<li>Class 10 ~ 10 Mbytes/sec</li>
</ul>
<p>Read/write performance to your phones SD card really depends on HOW your application reads and writes data. You may have to do some testing to find out what works best. It depends on the consideration of multiple factors including:</p>
<ul>
<li>Typical file types (e.g. video vs. text vs. image, etc)</li>
<li>Average file or data transaction size</li>
<li>Percentage of reads to writes</li>
<li>Duty cycle (percentage of reads or writes over a fixed time period)</li>
<li>Usage pattern</li>
</ul>
<p>Usage pattern deserves a bit more attention and really starts to tell the story of what your application does behind-the-scenes. I think the best way to describe it is through some common use cases:</p>
<ul>
<li>Many small reads and writes to/from a local database.</li>
<li>Occasional small reads and writes to local database.</li>
<li>Occasional large reads from local database.</li>
<li>Occasional large reads and writes to/from local database.</li>
<li>Large read upon application startup and large write upon application shutdown.</li>
</ul>
<p>Wikipedia has noted that speed can differ significantly depending on what you are writing to the card. The article notes that writing large files versus writing many small files has widely different affects on performance. I’d seen similar observations when I worked on ultra-high performance server systems. So, the concept still remains today and provides excellent hints on how to tweak every extra millisecond of user experience.</p>
<p>If you need maximum performance then consider reformatting or defragging your card on a regular basis. I know Windows disk defragmenter utilities work on most SD cards, not sure about Mac. I have also seen multiple articles talk about bigger capacity is better because of memory fragmentation. With memory fragmentation, the card speed starts to decrease over time as the data becomes more fragmented. It’s the same concept as when you “defrag” the hard drive on your laptop.</p>
<p><strong>References</strong></p>
<p>If you want to learn more here are some helpful links:</p>
<p><a href="https://www.sdcard.org/developers/overview/bus_speed/">SD Association – Bus speed</a></p>
<p><a href="https://www.sdcard.org/developers/overview/speed_class/">SD Association – Speed Class</a></p>
<p><a href="http://en.wikipedia.org/wiki/Secure_Digital">Wikipedia – Secure Digital</a> (See Speed Class Rating section)</p>
<p><a href="http://www.pcpro.co.uk/features/380167/does-your-camera-need-a-fast-sd-card">Does your camera need a fast SD card?</a> (good insight into SD card speed)</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.andygup.net%2Fsmartphone-devs-yes-sd-card-speed-matters%2F&amp;title=Smartphone%20devs%2C%20yes%20SD%20card%20speed%20matters%21" id="wpa2a_8"><img src="http://03259be.netsolhost.com/WordPress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.andygup.net/smartphone-devs-yes-sd-card-speed-matters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Encrypt your OAuth cookies – PHP Example</title>
		<link>http://www.andygup.net/encrypt-your-oauth-cookies-php-example/</link>
		<comments>http://www.andygup.net/encrypt-your-oauth-cookies-php-example/#comments</comments>
		<pubDate>Wed, 10 Apr 2013 01:35:23 +0000</pubDate>
		<dc:creator>agup</dc:creator>
				<category><![CDATA[OAuth]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.andygup.net/?p=1205</guid>
		<description><![CDATA[This post only serves as a reminder that if you decide to use OAuth cookies you should make sure that they are adequately encrypted. I’ve seen a number of web-based OAuth applications recently that left their cookies unencrypted and I wanted to provide a fully working example. Why should you care?  Any crook with a little bit [...]]]></description>
				<content:encoded><![CDATA[<p>This post only serves as a reminder that if you decide to use OAuth cookies you should make sure that they are adequately encrypted. I’ve seen a number of web-based OAuth applications recently that left their cookies unencrypted and I wanted to provide a fully working example.</p>
<p>Why should you care?  Any crook with a little bit of knowledge on how to generate header files can use <em>oauth_token</em> and <em>oauth_token_secret</em> and take control of your customers account.</p>
<p>I don’t know why but several of the most popular PHP OAuth libraries don’t mention this as a best practice. So I’m making an effort to shout out that encrypting your cookies is a very good thing to do and it involves the following:</p>
<ul>
<li>Encrypt <em>oath_token</em> and <em>oauth_token_secret</em></li>
<li>Write encrypted values to cookie</li>
<li>Read encrypted values when required</li>
<li>Provide functionality to delete cookie</li>
</ul>
<p>Another gotcha is if you allow someone to log out of your app without deleting the cookie, then it’s possible someone else could come along and get the cookie then use it to generate requests on behalf of your client application.</p>
<p>So here’s a fully working PHP example of how to encrypt cookies. You can also access this project through a <a href="https://github.com/andygup/php-cookie-encryption-lib" title="php-cookie-encryption-lib">github repository</a>.</p>
<p><strong>Step 1:</strong> generate your key and initialization vector:</p>
<pre class="brush: java; title: ; notranslate">
&lt;?php
  session_start();
  require_once('config.php');
  require_once('Encrypt.php');
  header('Content-Type: application/json');

  $test = new Encrypt(null,null,DEFAULT_TIME_ZONE);
  echo &quot;\n\n---------\n\nGenerate Key (Base64): &quot; . $test-&gt;get_RandomKey();
  echo &quot;\n\n---------\n\nGenerate IV (Base 64): &quot; . $test-&gt;get_IV();

?&gt;
</pre>
<p><strong>Step 2:</strong> setup the config file:</p>
<pre class="brush: java; title: ; notranslate">
&lt;?php

/**
 * @file
 * A single location to store configuration.
 */

//REQUIRED - Encrypt your cookies
//http://si0.twimg.com/images/dev/oauth_diagram.png
//Create your own unique ENCRYPTION_KEY via Encrypt.get_RandomKey()
define('ENCRYPTION_KEY','Q83dBef2tgmHKZ9T1htFA2Y+jZgdler0szN28rjBf8o=');
//Create your own unique initialization vector via Encrypt.get_IV()
define('IV','C2Oez0DLMQ8rCcgYFJwzCw==');
define('DEFAULT_TIME_ZONE','America/Los_Angeles');

?&gt;
</pre>
<p><strong>Step 3:</strong> test ability to set an encrypted cookie and decrypt it.</p>
<pre class="brush: java; title: ; notranslate">
&lt;?php
session_start();
require_once('config.php');
require_once('Encrypt.php');

$key = base64_decode(ENCRYPTION_KEY);
$iv = base64_decode(IV);
echo &quot;Key: &quot; . $key;
echo &quot;\n\nIV: &quot;. $iv;
$test = new Encrypt($key,$iv,DEFAULT_TIME_ZONE);

if(isset($_COOKIE[&quot;twitterapp&quot;]))
{
    header('Content-Type: application/json');

    $retrieved_cookie =  $_COOKIE[&quot;twitterapp&quot;];
    echo &quot;\n\nEncrypted value: &quot; . $retrieved_cookie;
    echo &quot;\n\nActual Value: &quot; . &quot;VodG7slxk+w0INvK66gztp4TOLijNzyiWDzI8Z4IU4PTiBJJkRPdkaEbDtXFYUVkCVU=&quot;;
    echo &quot;\n\nDecrypted Value: &quot; . $test-&gt;decrypt(base64_decode($retrieved_cookie));

}
else
{
    $fake_cookie_string = &quot;VodG7slxk+w0INvK66gztp4TOLijNzyiWDzI8Z4IU4PTiBJJkRPdkaEbDtXFYUVkCVU=&quot;;
    $encrypted_cookie = base64_encode($test-&gt;encrypt($fake_cookie_string));
    setcookie(&quot;twitterapp&quot;, $encrypted_cookie, $cookie_life, '/', OAUTH_COOKIE_DOMAIN);
    header('Location: http://your_domain_name/oauthphp/test.php', true, 302);
    exit;

}
?&gt;
</pre>
<p>And, here is the Encrypt Class:</p>
<pre class="brush: java; title: ; notranslate">
&lt;?php
class Encrypt{
	/*
	* Basic encryption Class
	* Version: 1.0
	* Author: Andy Gup
	*/
    private $key;
    private $iv;

    function __construct($encryption_key,$iv,$time_zone) {
        $this-&gt;key = $encryption_key;
	$this-&gt;iv = $iv;
	date_default_timezone_set($time_zone);
     }

     public function encrypt($value){
          $final = null;
          if($value == null || $this-&gt;key == null || $this-&gt;iv == null)
          {
               header(&quot;HTTP/1.0 400 Error&quot;);
               echo &quot;\n\n\nERROR: Null value detected: check your inputs&quot;;
               exit;
          }
          else
          {
              try
              {
                   $final = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this-&gt;key, $value, MCRYPT_MODE_CFB,$this-&gt;iv);
              }
              catch(Exception $e)
              {
                   header(&quot;HTTP/1.0 400 Error&quot;);
                   echo &quot;\n\n\nERROR: Failed encryption. &quot; .$e-&gt;getMessage();
                   exit;
	      }
          }
          return  $final;
    }

    public function decrypt($value){
        return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $this-&gt;key, $value, MCRYPT_MODE_CFB,$this-&gt;iv);
    }

    public function get_RandomKey(){
        $result = openssl_random_pseudo_bytes(32, $secure);
        return base64_encode($result);
    }

    public function get_IV(){
        $size = mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_CFB);
        return base64_encode(mcrypt_create_iv($size, MCRYPT_RAND));
    }
}
?&gt;
</pre>
<h3>Resources</h3>
<p><a href="https://github.com/andygup/php-cookie-encryption-lib">Github repository</a></p>
<p><a href="http://windows.php.net/">PHP for Windows</a> - the Mcrypt library seems to come with this installation. Mac users may have to install <a href="http://www.mamp.info/en/index.html">MAMP</a>.</p>
<p><a href="http://php.net/manual/en/book.mcrypt.php">PHP Manual for Mcrypt</a></p>
<p><a href="http://oauth.net/">OAuth Community</a></p>
<p>[Modified: April 27, 2013 - added link to github repo.]</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.andygup.net%2Fencrypt-your-oauth-cookies-php-example%2F&amp;title=Encrypt%20your%20OAuth%20cookies%20%E2%80%93%20PHP%20Example" id="wpa2a_10"><img src="http://03259be.netsolhost.com/WordPress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.andygup.net/encrypt-your-oauth-cookies-php-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why does anyone still need a desktop computer?</title>
		<link>http://www.andygup.net/why-does-anyone-still-need-a-desktop-computer/</link>
		<comments>http://www.andygup.net/why-does-anyone-still-need-a-desktop-computer/#comments</comments>
		<pubDate>Sat, 16 Mar 2013 19:51:45 +0000</pubDate>
		<dc:creator>agup</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[desktop]]></category>

		<guid isPermaLink="false">http://www.andygup.net/?p=1200</guid>
		<description><![CDATA[Who are these people that are still buying desktop computers? You would think this is a moot point in the year 2013. The writing has been on the wall for several years now that laptop prices have made them significantly more affordable. Modern laptops are powerful, light-weight and best of all portable. Tablets are running [...]]]></description>
				<content:encoded><![CDATA[<p>Who are these people that are still buying desktop computers? You would think this is a moot point in the year 2013. The writing has been on the wall for several years now that laptop prices have made them significantly more affordable. Modern laptops are powerful, light-weight and best of all portable. Tablets are running a close second to laptops.</p>
<p>But, I do know some folks (who have requested to remain anonymous at risk of being made fun of) who insist that a desktop is the only way to go. Yes you may be shocked and surprised to learn that many non-geeks don’t have the latest, fastest, sleekest, quietest, thinnest, greenest, most powerful, highest resolution, lightest devices. I know that’s crazy, right? Yet, these people do actually exist. So over the last six months I’ve compiled a list of the desktop crowds desires:</p>
<ol>
<li>Need a larger screen</li>
<li>Need the full-size keyboard</li>
<li>Need a larger hard drive</li>
<li>Need more power for processing images and videos</li>
<li>Corporate security reasons where they don’t want laptops leaving the building</li>
<li>Laptops are significantly more fragile and don’t last as long.</li>
</ol>
<p>Now let me briefly present some corresponding counter-<span style="text-decoration: line-through;">arguments</span> suggestions.</p>
<ol>
<li>You can always hook up an external monitor to a laptop or some tablets.</li>
<li>There are also external USB keyboards that rock.</li>
<li>External storage is awesome these days. There are high-performance 128GB thumb drives, for example and even multiple terabyte external drives.</li>
<li>Number 4 above might be the only reason for making a concession towards using a desktop. If you are professional or graphic artist that has video or image processing jobs that take currently many hours on a high-performance quad-core desktop, then you might not want to heat up your laptop to that extreme. For everyone else doing Facebook processing there are definitely some high-powered laptops that can crank on image processing.</li>
<li>You could always use a permanent security cable like I’ve seen at some hotels and airport lounges.</li>
<li>One of the most common causes of laptop death is failure to keep it cool. Make sure it sits on a hard surface like a table and not on top of your puffy down comforter all night. If you have a problem with dropping your laptop get it a protective case.</li>
</ol>
<p>In conclusion, there are very few reasons where a desktop computer is the only solution. The next question you ask me should be &#8220;so, what type of laptop or tablet do you recommend?&#8221;!</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.andygup.net%2Fwhy-does-anyone-still-need-a-desktop-computer%2F&amp;title=Why%20does%20anyone%20still%20need%20a%20desktop%20computer%3F" id="wpa2a_12"><img src="http://03259be.netsolhost.com/WordPress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.andygup.net/why-does-anyone-still-need-a-desktop-computer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Esri DevSummit 2013 – Worlds Largest Geo Developer Conference</title>
		<link>http://www.andygup.net/esri-devsummit-2013-worlds-largest-geo-developer-conference/</link>
		<comments>http://www.andygup.net/esri-devsummit-2013-worlds-largest-geo-developer-conference/#comments</comments>
		<pubDate>Sat, 16 Mar 2013 17:02:35 +0000</pubDate>
		<dc:creator>agup</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[devsummit]]></category>
		<category><![CDATA[Esri]]></category>
		<category><![CDATA[geo]]></category>
		<category><![CDATA[geospatial]]></category>
		<category><![CDATA[Palm Springs]]></category>

		<guid isPermaLink="false">http://www.andygup.net/?p=1194</guid>
		<description><![CDATA[I will be presenting in Palm Springs, California in a few weeks and I hope to chat with some of you there. For those of you who are interesting in Geospatial, the Esri Developer Summit is the largest gathering of geo-spatial developers that I know of. I don’t know the exact numbers, but it’s going [...]]]></description>
				<content:encoded><![CDATA[<p>I will be presenting in Palm Springs, California in a few weeks and I hope to chat with some of you there. For those of you who are interesting in Geospatial, the <a href="http://www.esri.com/events/devsummit">Esri Developer Summit</a> is the largest gathering of geo-spatial developers that I know of. I don’t know the exact numbers, but it’s going to be over 1,500 geo-geeks. If you want to learn about the technical aspects of geo-spatial this is “the” conference.</p>
<p>I’m going to be talking a lot about mobile this year and how to transition from the desktop environment to mobile. Sure there are lots of experts out there building awesome mobile apps, but there are also many, may developers, organizations and companies that are just starting to get their feet wet.</p>
<p>I have four topics this year, so swing on by and say “hi”. Oh, and be sure to bring sun block and hot weather clothes. I hear the temperatures my reach 100F! Here are my sessions:</p>
<ul>
<li><i>Best Practices for HTML5 Geolocation</i> – This will be an A-to-Z overview of the HTML5 Geocation API including the good and the not-so-good. (Tue. 2:30p, Demo Theater 2 and Thur., 1:15pm Mesquite G/H)</li>
<li><i>Getting Started with the ArcGIS Runtime SDK for Android</i> – Great session if you are getting ready to start doing native geo-spatial development on Android (Mon. 1pm, Pasadena Rm.)</li>
<li><i>Building Mobile Applications with the ArcGIS API for Flex</i> – Apache Flex is an incredibly easy-to-use platform where you can take one code base and compile for native iOS and Android. (Tue. 5:30pm Primrose C/D)</li>
<li><i>iOS and Android: Let’s have a hug</i> – this is a fun session where <a href="https://twitter.com/geeknixta">@geeknixta</a> and I get to make fun of each other as well as show off the similarities of our Runtime SDKs on iOS and Android. I&#8217;m the Android fanboy, of course. (Wed. 5:30pm, Catalina/Madera)</li>
</ul>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.andygup.net%2Fesri-devsummit-2013-worlds-largest-geo-developer-conference%2F&amp;title=Esri%20DevSummit%202013%20%E2%80%93%20Worlds%20Largest%20Geo%20Developer%20Conference" id="wpa2a_14"><img src="http://03259be.netsolhost.com/WordPress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.andygup.net/esri-devsummit-2013-worlds-largest-geo-developer-conference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Six Most Common Use Cases for Android GPS</title>
		<link>http://www.andygup.net/six-most-common-use-cases-for-android-gps/</link>
		<comments>http://www.andygup.net/six-most-common-use-cases-for-android-gps/#comments</comments>
		<pubDate>Sun, 03 Mar 2013 20:02:09 +0000</pubDate>
		<dc:creator>agup</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[accuracy]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[GPS]]></category>
		<category><![CDATA[gpstester]]></category>
		<category><![CDATA[location]]></category>

		<guid isPermaLink="false">http://www.andygup.net/?p=1172</guid>
		<description><![CDATA[This post summarizes the six most common use cases associated with using GPS and location services on an Android device. It also continues the series on using the open source GPSTester tool to build better location aware Android apps. So not only can you read about what works and what doesn&#8217;t you can also try various [...]]]></description>
				<content:encoded><![CDATA[<p>This post summarizes the six most common use cases associated with using GPS and location services on an Android device. It also continues the series on using the open source <a href="http://www.andygup.net/?p=1099">GPSTester tool</a> to build better location aware Android apps. So not only can you read about what works and what doesn&#8217;t you can also try various scenarios out yourself using the tool rather than having to build code from scratch.</p>
<p>I’m striving to make this information freely available because adding location to your apps can be fun, and it can also be an important part of the applications that you build. By taking into account these six use cases you will be able to build applications that better meet your requirements and make for a more enjoyable end user experience.</p>
<p><strong>Use Case 1 &#8211; Cold Start.</strong> Application launches from a completely stopped state. Cached GPS  and Network location values may be unreliable. As a developer you don’t really have any control over this but you need to plan for it. The screenshot from the GPSTester tool below shows a typical cold start where the cached network location has better accuracy than the most recent GPS location. You can see from the timestamps that even though the GPS location is more recent than the network location, it&#8217;s the network location that has better accuracy.</p>
<p><a href="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_coldstart2_8bit.png"><img class="alignnone size-full wp-image-1180" title="Android Cold Start" src="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_coldstart2_8bit.png" alt="" width="275" height="203" /></a></p>
<p><strong>Use Case 2 &#8211; Warm Start.</strong> Application launches from a minimized state. Cached GPS values may be reliable depending on how much time has passed since application was last running, and the total distance traveled away from when the app was last used. Like the cold start, the user that decides how and when to start the app and you just have to plan for this use case. The screenshot below represents a typical warm start scenario where the cached GPS result has better accuracy than the cached network provider.</p>
<p><img class="alignnone size-full wp-image-1178" title="Cached Location Providers" src="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_warmstart_8bit.png" alt="" width="275" height="204" /></p>
<p><strong>Use Case 3 &#8211; Minimized.</strong> Requirements may call for location listeners to continue to run in the background, or to be shut off when the application is minimized. There is also the option of using what&#8217;s called passive listeners which rely on other applications to call location services. Note, if you listen for location changes in  a minimized state you typically won&#8217;t benefit from this information until the application is opened again. In my previous posts I&#8217;ve stated that if your target demographic uses retail and social media apps this use case may be of benefit if the person uses the device constantly during the day. Many retail and social media apps access location. However, in many commercial use cases using passive location listeners may provide less than desirable results since there is much less of a chance of another application using a location service.</p>
<p style="padding-left: 30px;"><em>Pros:</em> Running location services while app is minimized can speed up acquisition time when app starts, but only if your requirements call for always-on accuracy at a moment’s notice. If you shut off location then you will save battery life.</p>
<p style="padding-left: 30px;"><em>Cons:</em> If active location services are left on in a minimized state this can sap the battery without the user really knowing it.</p>
<p><strong>Use Case 4 &#8211; Snapshot.</strong> Application only needs to hit a minimum level of accuracy before shutting off location services. The screenshot below shows that it took approximately 2 minutes for the device to reach an accuracy of 12 meters. Yep, you heard that right&#8230;2 minutes! Also note how much the latitude and longitude of the different providers wandered around the map. The blue dot indicates network locations and the red dot indicates GPS locations. This is just a reminder that consumer-grade Android devices may or may not be accurate enough for your unique requirements.</p>
<p style="padding-left: 30px;"><em>Pros:</em> Maximizes battery life.</p>
<p style="padding-left: 30px;"><em>Cons:</em> May cause user interface delays if user needs to refresh the location during a single application session.</p>
<p><a href="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_snapshot_8bit.png"><img class="alignnone size-full wp-image-1181" title="Snapshot" src="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_snapshot_8bit.png" alt="" width="275" height="489" /></a></p>
<p><strong>Use Case 5 &#8211; Continuous duty.</strong> Location services need to be constantly on while application is running. The screenshot below shows a use case of the user being in a downtown area with lots of tall buildings, the apps was run for about 10 minutes, then minimized briefly, then opened again for a warm start. The accuracy didn&#8217;t change much even after 10 more minutes of testing. As you can see, the GPS provider accuracy has suffered significantly at 153 meters, while the network provider is offering 45 meters of accuracy.</p>
<p style="padding-left: 30px;"><em>Pros:</em> Best for constant, up-to-date, always on accuracy. Accuracy available instantly (after the device has &#8216;warmed up&#8217;).</p>
<p style="padding-left: 30px;"><em>Cons:</em> Huge drain on the battery, but you can adjust the minimum distance property needed to trigger a location update.</p>
<p><a href="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_continuous_8bit.png"><img class="alignnone size-full wp-image-1183" title="Continuous Location Watching" src="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_continuous_8bit.png" alt="" width="275" height="489" /></a></p>
<p><strong>Use Case 6 &#8211; Intermittent duty.</strong> GPS is only needed to run at intervals. To test these types of scenarios you can adjust various settings from within the GPSTester Tool&#8217;s preferences. Specifically you can modify the GPS and Network properties for minimum update time and distance. This is very powerful as you can easily toggle these settings to test various settings on-the-fly versus have to write custom code.</p>
<p style="padding-left: 30px;"><em>Pros:</em> Depending on your use cases such as delivery driver tracking application, this can provide a good compromise on battery usage and accuracy.</p>
<p style="padding-left: 30px;"><em>Cons:</em> You will have to write algorithms to constantly adjust the location service settings to meet the users movement patterns. This may also involve cycling the location services on and off to maximize battery life.</p>
<p><a href="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_preferences_8bit1.png"><img class="alignnone size-full wp-image-1186" title="More GPSTester Tool preferences" src="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_preferences_8bit1.png" alt="" width="275" height="489" /></a></p>
<p><strong>A few comments on testing your use cases.</strong> In the GPSTester tool there are a number of settings you can use to adjust how the device will receive location information.</p>
<p>You have full control over which providers are being used whether it’s GPS, Network or Critera.</p>
<p><a href="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_providers2_8bit.png"><img class="wp-image-1174 alignnone" title="Toggling Android Location Proviers" src="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_providers2_8bit.png" alt="" width="275" height="238" /></a></p>
<p>Location provider indicators on the main screen will show which providers are being used. You can also see which provider is providing the best accuracy as determined by comparing available providers.</p>
<p><a href="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_accuracy1_8bit.png"><img class="alignnone size-full wp-image-1175" title="Android Location Providers" src="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_accuracy1_8bit.png" alt="" width="275" height="106" /></a></p>
<p>There is a list of available providers available on the GPSTester tool as well as table row showing what the device considers to be providing the best accuracy.</p>
<p><a href="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_providers_8bit.png"><img class="alignnone size-full wp-image-1176" title="Available Location Providers" src="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/android_providers_8bit.png" alt="" width="275" height="141" /></a></p>
<p><strong>References</strong></p>
<p><a href="http://www.andygup.net/?p=1099">Android GPS Testing Tool</a></p>
<p><a href="https://github.com/Esri/android-gps-test-tool">GPSTest Tool Github Repo</a></p>
<p><a href="http://www.andygup.net/?p=1105">How accurate is Android GPS Part 1 &#8211; Understanding location data</a></p>
<p><a href="http://www.andygup.net/?p=1125">How accurate is Android GPS Part 2 &#8211; Consuming real-time locations</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.andygup.net%2Fsix-most-common-use-cases-for-android-gps%2F&amp;title=Six%20Most%20Common%20Use%20Cases%20for%20Android%20GPS" id="wpa2a_16"><img src="http://03259be.netsolhost.com/WordPress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.andygup.net/six-most-common-use-cases-for-android-gps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How would you rate your smartphones internet connection?</title>
		<link>http://www.andygup.net/how-would-you-rate-your-smartphones-internet-connection/</link>
		<comments>http://www.andygup.net/how-would-you-rate-your-smartphones-internet-connection/#comments</comments>
		<pubDate>Sat, 02 Mar 2013 21:09:23 +0000</pubDate>
		<dc:creator>agup</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[smartphone]]></category>
		<category><![CDATA[speed]]></category>

		<guid isPermaLink="false">http://www.andygup.net/?p=1167</guid>
		<description><![CDATA[Not including WiFi, what I really want to know is over the period of an average day how happy are you with your 3G and/or 4G smartphone or tablet’s internet connection? Do you ever have moments where web pages are slow to download? Has an app ever taken forever to install, or a tweet or [...]]]></description>
				<content:encoded><![CDATA[<p>Not including WiFi, what I really want to know is over the period of an average day how happy are you with your 3G and/or 4G smartphone or tablet’s internet connection? Do you ever have moments where web pages are slow to download? Has an app ever taken forever to install, or a tweet or facebook picture upload failed?</p>
<p>Costs and geography aside, could you turn off your WiFi completely and generally have a decent connection at your home? At work? At the airport? At the supermarket?<a href="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/lightning_sign.png"><img class="alignright size-full wp-image-1168" title="Lightning!" src="http://03259be.netsolhost.com/WordPress/wp-content/uploads/2013/03/lightning_sign.png" alt="" width="120" height="120" /></a></p>
<p>It’s interesting to note that some really big company’s think that internet on mobile devices isn’t as great as it could be. Have you heard of Amazon Silk or Opera Turbo where they incorporate data compression to try and speed things up to overcome limitations of mobile browsers? I’ve even heard that Google is now working on something similar. Are these just attempts to work around current limitations of cellular 3G and 4G? Most likely, yes.</p>
<p>I’d give my general usage internet connection in my home area a 7 rating on a scale from 0 (no internet) to 10 (always incredible). By home area I mean the geographic location where I spend 98% of my time between home, work, shopping and visiting friends. When not developing apps on my phone, it’s primarily used for email, social media and occasional web browsing. Tethering is a different story. For tethering when I travel I’d give it a 4 rating overall. Tethering uses the bandwidth a lot more strenuously than my home area use case. And because of that it exposes any weaknesses in the internet connectivity a lot sooner and makes them much more noticeable. The typical situation I want to avoid when I travel is having to pay for a hotel internet connection. Besides, hotel internet connections in the U.S. are almost always awful in terms of download speeds, especially if you are in a hotel during a large conference.</p>
<p>If you are wondering if there’s anything you can do about bad cellular internet the answer is YES. First, call your provider and explain the situation in as much detail as possible. Simply calling up and saying “my internet connection is terrible” isn’t going to help. But telling them the geographic location, time of day, frequency of the problem, etc. will help immensely. And, you can always follow-up if the problem persists. Sometimes the problems are equipment malfunctions, sometimes cell towers need to be upgraded. Other times it could be the terrain, buildings and heavy foliage. All of these can degrade signals. As you can see there are many reasons why your smartphone internet could be less than desirable.</p>
<p>If you consistently see internet outages and other major problems and you can’t get a solid answer from your provider then you can also contact the FCC or file a public comment.</p>
<p><strong>References:</strong></p>
<p><a href="http://www.fcc.gov/complaints">FCC Online Complaint form</a></p>
<p><a href="http://www.fcc.gov/topic/3g-4g-wireless">FCC 3G and 4G Wireless</a></p>
<p><a href="http://amazonsilk.wordpress.com/2011/09/28/introducing-amazon-silk/">Amazon Silk</a></p>
<p><a href="http://www.opera.com/browser/turbo/">Opera Turbo</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.andygup.net%2Fhow-would-you-rate-your-smartphones-internet-connection%2F&amp;title=How%20would%20you%20rate%20your%20smartphones%20internet%20connection%3F" id="wpa2a_18"><img src="http://03259be.netsolhost.com/WordPress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.andygup.net/how-would-you-rate-your-smartphones-internet-connection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A closer look at Base64 image performance</title>
		<link>http://www.andygup.net/a-closer-look-at-base64-image-performance/</link>
		<comments>http://www.andygup.net/a-closer-look-at-base64-image-performance/#comments</comments>
		<pubDate>Sun, 24 Feb 2013 21:43:50 +0000</pubDate>
		<dc:creator>agup</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.andygup.net/?p=1151</guid>
		<description><![CDATA[This post takes a closer look at Base64 image performance, offers some use cases and raises some questions. I’ve had a number of conversations recently over the benefits of using client-side, Base64 image strings to improve web app performance over making multiple &#60;img&#62; requests. So I ran a few tests of my own, and the [...]]]></description>
				<content:encoded><![CDATA[<p>This post takes a closer look at Base64 image performance, offers some use cases and raises some questions. I’ve had a number of conversations recently over the benefits of using client-side, Base64 image strings to improve web app performance over making multiple &lt;img&gt; requests. So I ran a few tests of my own, and the results are shown at the bottom of the post.</p>
<p>If you aren’t familiar with them, a Base64 image is a picture file, such as a PNG, whose binary content has been translated into an ASCII String. And, once you have that string then copy-and-paste into your JavaScript code. Here’s an example of what that looks like:</p>
<pre class="brush: java; title: ; notranslate">
&lt;html&gt;
&lt;body onload=&quot;onload()&quot;&gt;
	&lt;img id=&quot;test&quot;/&gt;
	&lt;script type=&quot;text/javascript&quot;&gt;
		var html5BadgeBase64 = &quot;iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXH…&quot;;
		function onload(){
			var image = document.getElementById(&quot;test&quot;);
			image.src = &quot;data:image/png;base64,&quot; + html5BadgeBase64;
		}
	&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>There are other ways of doing this that I’m not covering in this post such as using server-side code to convert images on the fly, passing Base64 strings in URLs, etc.</p>
<p>The most commonly cited advantage is that including a Base64 string in your JavaScript code will save you one round-trip HTTP request. There is absolutely no argument on this subject. <span style="font-size: 13px; line-height: 19px;">The real questions in my mind are: <em>what are the optimal number and size for Base64 images? And, is there a way to quantify how much if any they help with performance?</em></span></p>
<p><strong>Size?</strong> Base64 image strings will <em>always</em> be larger than their native counterparts. Take the following example using a copy of the relatively small HTML5 logo and a decent sized screenshot. As you can see the text equivalent is 33% and 31% greater, respectively.</p>
<p style="padding-left: 30px;">Html5.png  = 1.27KB (64&#215;64 pixels)<br />
Html5base64.txt = 1.69KB (1738 characters)<br />
% Difference =  +33%</p>
<p style="padding-left: 30px;">Screenshot.png = 19KB (503&#215;386 pixels 24bit)<br />
ScreenshotBase64.txt = 24.9KB (25584 characters)<br />
% Difference = +31%</p>
<p>In comparison, when working with &lt;img&gt; tags you&#8217;ll be working with an ID that points to the actual image file stored in memory.</p>
<p><strong>Convenience?</strong> As you can see, the length of your base64 strings can get quite long. The simple HTML5 logo in the previous example becomes a 1738 character long string and that’s only 1.69KBs worth of image.</p>
<p>Can you imagine having a dozen of images similar in size to the 19KB Screenshot example? That would create over 300,000 ASCII characters. Let’s put that into the perspective of a Word document. Using 1” margins all the way around, this would create a document approximately seven and a quarter pages long!</p>
<p>I assert that Base64 is best for static images, ones that don’t change much at all over time. The bigger the image the more time consuming it can become convert it, copy-and-paste it into your code and then test it. Any time you make a change to the image you’ll have to repeat the same steps. If you accidentally inject a typo into a Base64 string you have to reconvert the image. That’s simply the best approach from a productivity perspective.</p>
<p>In comparison when using a regular old PNG file, you create the new version, copy it out on the web server, flush your browser cache, run a quick test with no need to change any code and bang you’re ready to go have a cup of coffee.</p>
<p><strong>Caching?</strong> It depends on your header caching settings, browser settings and web server settings. I&#8217;ll just say that typically base64 images will be cached either in your main HTML file or in a separate JavaScript library.</p>
<p><strong>Bandwidth?</strong> Using base64 images will increase the amount of bandwidth used by your website. Compare the size of your HTML file with Base64 images to the size of the same file simply using &lt;img&gt; tags. You can do some basic math if you add up the size of a particular page and multiple it by the number of visits. Better to err on the side of caution, because there really isn’t a good way to tell which images and JavaScript files are getting catched in your visitors browsers and for how often. Here’s an example where you have a 30GB bandwidth limit per month, and simply converted all of your PNG images to Base64 could very easily push you over the limit:</p>
<p style="padding-left: 30px;">100,000 page hits/ month (main.html) x 256KB = 25.6 GB (incls. 75KB of standard PNG images)</p>
<p style="padding-left: 30px;">100,000 page hits/month (main.html) x 293.5KB =  29.4 GB (incls. 97.5KB <strong><span style="color: #0000ff;">Base64</span></strong> images)</p>
<p>Also, some providers give you decent tools that you can use to experiment with Base64 images versus regular images and test that against your bandwidth consumption.</p>
<p><strong>Latency?</strong> This variable doesn’t really apply directly to Base64 images. There are many factors that determine latency that I&#8217;m not going to discuss here. There are some more advanced networking tools that let you figure out average latency on your own web servers. Every request will be unique based on network speed, the number of hops between the client and the web server, how the HTTP request was routed over the internet, TCP traffic over the various hops, load on the web server, etc.</p>
<h3><strong>A few quick performance tests.</strong></h3>
<p>What would a Base64 blog post be without a few tests? I devised four simple tests. One in which I referenced a JavaScript file containing Base64 images. One which contained five &lt;img&gt; tags and then I re-ran the tests again to view the cached performance.</p>
<p>These tests were performed on a Chrome Browser over a CenturyLink DSL with a download speed of 9.23MB/sec and an upload speed of 0.68MB/sec. Several <em>tracert(s)</em> of TCP requests from my machine to the web server showed more than 30 hops with no significant delays or reroutes. The web server is a hosted machine.</p>
<p><strong>Test 1 &#8211; JavaScript file with Base64 images.</strong>This test consists of an uncached basic HTML file that references a 125KB JavaScript library containing five base64 images.</p>
<p style="padding-left: 30px;">Time to load 1.9KB HTML file: 455ms</p>
<p style="padding-left: 30px;">Time to load 125KB JavaScript file: 1.14s</p>
<p style="padding-left: 30px;">Total load time: <strong>1.64s</strong></p>
<p><strong>Test 2 &#8211; Cached JavaScript file with Base64 images.</strong> This test consists of reloading Test 1 in the browser</p>
<p style="padding-left: 30px;">Time to load cached HTML file: 293ms</p>
<p style="padding-left: 30px;">Time to load cached JavaScript file: 132ms</p>
<p style="padding-left: 30px;">Total load time:<strong> 460ms</strong></p>
<p><strong>Test 3 &#8211; using &lt;img&gt; tags to request PNG images.</strong> This test consists of an uncached HTML file that contains five &lt;img&gt; tags pointing to five remotely hosted 20KB PNG files.</p>
<p style="padding-left: 30px;">Time to load 1KB HTML file: 304ms:</p>
<p style="padding-left: 30px;">Time to load five images: 776 ms</p>
<p style="padding-left: 30px;">Total load time: <strong>1.08s</strong></p>
<p><strong>Test 4 &#8211; cached html file using &lt;img&gt; tags to request PNG images.</strong> This consists of reloading Test 3 in the browser</p>
<p style="padding-left: 30px;">Time to load cached HTML file: 281ms</p>
<p style="padding-left: 30px;">Time to load five cached images: 16ms</p>
<p style="padding-left: 30px;">Total load time:<strong> 297ms</strong></p>
<h3>Conclusions</h3>
<p>It&#8217;s not 100.0000% true that multiple HTTP requests results in slower application performance in comparison to embedding Base64 images. In fact, I&#8217;ve seen anecdotal evidence of this before on production apps, so it was fun to do a some quick testing even if my tests were not completely conclusive beyond a doubt.</p>
<p>My goal was to spark conversation and brainstorm on ideas. I know some of you will say that thousands of tests need to be run an statistically analyzed. My argument is that these tests represented actual results that I could see with my own eyes rather than being lumped into some average or medium statistic.</p>
<p>Note that I&#8217;m just posting a snapshot of the tests I ran. I didn&#8217;t have enough time to draw up a significant battery of tests to cover as many contingencies as possible. However, the test numbers I&#8217;ve posted were fairly consistent in the favor of the multiple PNG requests loading faster than a single .js file containing five Base64 images. Obviously more significant testing is needed to sort out other real-world variables, such as image file sizes versus application size and under a variety of conditions and different browsers.</p>
<h3>Resources</h3>
<p><a href="http://andygup.net/samples/base64/images.js">JavaScript library with five Base64 images</a></p>
<p><a href="http://andygup.net/samples/base64/base64jslib.html">HTML file that reference JavaScript library of five Base64 images</a></p>
<p><a href="http://andygup.net/samples/base64/base64img.html">HTML file with five &lt;img&gt; tags</a></p>
<p>[Edited 2/26/13: fixed a few typos]</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.andygup.net%2Fa-closer-look-at-base64-image-performance%2F&amp;title=A%20closer%20look%20at%20Base64%20image%20performance" id="wpa2a_20"><img src="http://03259be.netsolhost.com/WordPress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.andygup.net/a-closer-look-at-base64-image-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using disk: enhanced

 Served from: www.andygup.net @ 2013-05-25 01:59:03 by W3 Total Cache -->