<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>Random thoughts on startups, Web Design,  User experience, iOS and Web development tips



  var _gaq = _gaq || [];
  _gaq.push([‘_setAccount’, ‘UA-2417064-25’]);
  _gaq.push([‘_trackPageview’]);

  (function() {
    var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
    ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
  })();</description><title>InitLabs</title><generator>Tumblr (3.0; @initlabs)</generator><link>http://blog.initlabs.com/</link><item><title>Cookies and Javascript</title><description>&lt;p&gt;Below are snippets of code to manage browser cookies using javascript. Cookies can be used to store small amount of data about a website, usually configuration or personalization data about the website so that the web server or webapp can load customized webpage based on cookie data. &lt;/p&gt;
&lt;p&gt;One of my webapp &lt;a href="http://gramfeed.com"&gt;gramfeed&lt;/a&gt; uses these javascript cookie code to manage settings for whether the user wants to show the map visualization by default or not.&lt;/p&gt;
&lt;p&gt;Below are 3 functions to create a cookie and read a cookie:&lt;/p&gt;
&lt;pre&gt;function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}
&lt;/pre&gt;

&lt;pre&gt;function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i &amp;lt; ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
&lt;/pre&gt;

&lt;p&gt;Example of usage:&lt;/p&gt;
&lt;pre&gt;createCookie("color", "red", 10);
readCookie("color");
&lt;/pre&gt;
&lt;p&gt;The code above will create a cookie called &amp;#8220;color&amp;#8221; and will set a value as &amp;#8220;red&amp;#8221; and will expire after 10 days. The value &amp;#8220;red&amp;#8221; can be retrieved next time the webapp loads and set the personalized color of webapp for example. The cookie data can be deleted by setting null value.&lt;/p&gt;
&lt;pre&gt;createCookie("color", "", -1);
&lt;/pre&gt;
&lt;p&gt;Hopefully this helps, comments or questions below :)&lt;/p&gt;</description><link>http://blog.initlabs.com/post/32459126126</link><guid>http://blog.initlabs.com/post/32459126126</guid><pubDate>Fri, 28 Sep 2012 11:21:07 -0400</pubDate><category>javascript</category><category>cookie</category><category>html5</category><category>webapp</category></item><item><title>iOS email sign-in implementation UX</title><description>&lt;p&gt;Just came across this new browser app for iPhone called &lt;a href="http://dolphin-browser.com/"&gt;Dolphin&lt;/a&gt;. I usually don&amp;#8217;t sign up using facebook or twitter for new apps, I use the classic email sign-up. This app makes email signup one set easier by showing the different email service provider as you start typing your email id, little implementation details that makes a big difference for user experience. Most people use either gmail, yahoo or hotmail, this app just gives you those options and many more as you type. Something for every other app developer to consider when implementing email sign-up.&lt;/p&gt;
&lt;p&gt;Checkout the screenshots below showing email sign-in form and options shown as you start typing.&lt;/p&gt;
&lt;p&gt;&lt;img height="460" src="http://farm8.staticflickr.com/7206/6899527546_28ed2a9967.jpg" width="300"/&gt; &lt;img height="460" src="http://farm8.staticflickr.com/7095/7045624803_fef1c013b2.jpg" width="300"/&gt;&lt;/p&gt;
&lt;p&gt;BTW, if you have not tried this app, this browser app is pretty slick for browsing on iPhone.&lt;/p&gt;</description><link>http://blog.initlabs.com/post/20476691350</link><guid>http://blog.initlabs.com/post/20476691350</guid><pubDate>Wed, 04 Apr 2012 14:40:25 -0400</pubDate><category>ux</category><category>ui</category><category>tips</category><category>ios</category></item><item><title>gramfeed: 2 hour side-project to 2 million visitors</title><description>&lt;a href="http://blog.gramfeed.com/post/18460554119/2-hour-side-project-to-2-million-visitors"&gt;gramfeed: 2 hour side-project to 2 million visitors&lt;/a&gt;: &lt;p&gt;Here is a blog post I wrote about how I developed, launched and scaled &lt;a href="http://www.gramfeed.com"&gt;gramfeed.com&lt;/a&gt; to 2 million visitors.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blog.gramfeed.com/post/18460554119/2-hour-side-project-to-2-million-visitors"&gt;Read it here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blog.gramfeed.com/post/18460554119/2-hour-side-project-to-2-million-visitors"&gt;&lt;img height="430" src="http://farm8.staticflickr.com/7181/6792635830_c308b677ef_b_d.jpg" width="1024"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="tumblr_blog" href="http://blog.gramfeed.com/post/18460554119/2-hour-side-project-to-2-million-visitors"&gt;&lt;br/&gt;&lt;br/&gt;gramfeed&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Exactly a year ago was when &lt;a href="http://www.gramfeed.com" target="_blank"&gt;gramfeed.com&lt;/a&gt; launched. Instagram had released developer APIs couple weeks prior and I started playing with the APIs and started creating a web interface for Instagram to pretty much do everything that the Instagram iPhone app did on the web.&lt;/p&gt;
&lt;/blockquote&gt;</description><link>http://blog.initlabs.com/post/18478635490</link><guid>http://blog.initlabs.com/post/18478635490</guid><pubDate>Tue, 28 Feb 2012 22:58:35 -0500</pubDate><category>gramfeed</category><category>instagram</category></item><item><title>How to pin blocked content to Pinterest</title><description>&lt;p&gt;&lt;a href="http://pinterest.com"&gt;Pinterest&lt;/a&gt; just introduced a way for websites to block people from pinning their content to Pinterest by adding a small snippet of meta tag code to HTML:&lt;/p&gt;
&lt;p&gt;&amp;lt;meta name=&amp;#8221;pinterest&amp;#8221; content=&amp;#8221;nopin&amp;#8221; /&amp;gt;&lt;/p&gt;
&lt;p&gt;Sites like Flickr have already implemented this to &lt;a href="http://venturebeat.com/2012/02/24/flickr-pinterest-pin/"&gt;block people from pinning copyrighted&lt;/a&gt; photos to be pinned on Pinterest. You will see a message like this:&lt;/p&gt;
&lt;p&gt;&lt;img height="310" src="http://farm8.staticflickr.com/7051/6781277506_91a5f107a8_b.jpg" width="800"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Here is a simple way to get around this and pin it anyway if you want to do so:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;(You have to use Google Chrome)&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;If you see the blocked message, reload the page by hitting &lt;strong&gt;&lt;em&gt;&amp;#8220;Reload&amp;#8221;&lt;/em&gt;&lt;/strong&gt; button in Chrome.&lt;/li&gt;
&lt;li&gt;Right-click and select &lt;em&gt;&lt;strong&gt;&amp;#8220;Inspect Element&amp;#8221;&lt;/strong&gt;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;In the panel that opens at the bottom, expand the &lt;em&gt;&lt;strong&gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;&lt;/strong&gt;&lt;/em&gt; tag&lt;/li&gt;
&lt;li&gt;You will see a line &lt;em&gt;&lt;strong&gt;&amp;lt;meta name=&amp;#8221;pinterest&amp;#8221; content=&amp;#8221;nopin&amp;#8221; /&amp;gt;&lt;/strong&gt;&lt;/em&gt;, right-click on it and select &lt;em&gt;&lt;strong&gt;&amp;#8220;Delete Node&amp;#8221;&lt;/strong&gt;&lt;/em&gt; (see picture below)&lt;/li&gt;
&lt;li&gt;Now go to bookmarks and click your &lt;strong&gt;&lt;em&gt;&amp;#8220;Pin It&amp;#8221;&lt;/em&gt;&lt;/strong&gt; bookmarklet to pin the image to Pinterest&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;img height="736" src="http://farm8.staticflickr.com/7053/6781277596_25de83bd23_b.jpg" width="800"/&gt;&lt;/p&gt;
&lt;p&gt;Disclaimer: I&amp;#8217;m not really recommending you to do so ;)&lt;/p&gt;</description><link>http://blog.initlabs.com/post/18226946517</link><guid>http://blog.initlabs.com/post/18226946517</guid><pubDate>Fri, 24 Feb 2012 22:06:00 -0500</pubDate><category>pinterest</category></item><item><title>How to get url parameter or hash fragment using javascript</title><description>&lt;p&gt;Below is javascript code snippets that show how to get read url parameters and hash fragment from url. Will be useful when reading url parameters or hash fragments in urls like &lt;a href="http://gramfeed.com/?view=popular"&gt;&lt;a href="http://gramfeed.com/?view=popular"&gt;http://gramfeed.com/?view=popular&lt;/a&gt;&lt;/a&gt; or &lt;a href="http://gramfeed.com/instagram/tags#sunset"&gt;&lt;a href="http://gramfeed.com/instagram/tags#sunset"&gt;http://gramfeed.com/instagram/tags#sunset&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Below is code to get url parameter from url:&lt;/p&gt;
&lt;pre&gt;function getUrlParam( param ){
	param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var exp = "[\\?&amp;amp;]"+param+"=([^&amp;amp;#]*)";
	var regexp = new RegExp( exp );	
	var results = regexp.exec( window.location.href );
	if( results == null ){
		return "";
	} else {
		return results[1];
	}
}&lt;/pre&gt;
&lt;p&gt;Getting hash fragment from url is much easier:&lt;/p&gt;
&lt;pre&gt;hash = window.location.hash;&lt;/pre&gt;</description><link>http://blog.initlabs.com/post/16849127355</link><guid>http://blog.initlabs.com/post/16849127355</guid><pubDate>Tue, 31 Jan 2012 20:27:00 -0500</pubDate><category>javascript</category><category>url</category><category>parameter</category><category>hash</category></item><item><title>How I reduced Google App Engine costs by 75%</title><description>&lt;p&gt;My Instagram project &lt;a href="http://gramfeed.com"&gt;gramfeed.com&lt;/a&gt; was created over a weekend, its a full feature web interface for Instagram. I built it for me to view Instagram feed, comment, like photos and more on the web.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.gramfeed.com/instagram/311748890_11457197"&gt;&lt;img height="612" src="http://distilleryimage2.s3.amazonaws.com/e6995a28063711e1abb01231381b65e3_7.jpg" width="612"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I had decided to use &lt;a href="http://code.google.com/appengine/"&gt;Google App Engine&lt;/a&gt; (GAE) to host the app since it was free to start and it remained free even as the site got over half a million pageviews/month and used only about 20-25% of the free quote under the old App Engine &amp;#8220;CPU hours&amp;#8221; pricing model, after the &lt;a href="http://googleappengine.blogspot.com/2011/11/app-engine-160-out-of-preview-release.html"&gt;pricing model changed&lt;/a&gt; to &amp;#8220;instance based&amp;#8221; usage, my costs sky rocketed by about 30x and had to do something about bringing down the cost or move to a different App hosting solution. I took advantage of the $50 App Engine credit that google gave to continue on App Engine as I started to optimize my app to reduce the cost. Below are things I did to reduce the costs by about 75%, hope it is helpful:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Analyze App Engine usage&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;First thing I did was to setup &lt;a href="http://code.google.com/appengine/docs/python/tools/appstats.html"&gt;Appstats&lt;/a&gt; (event recorder) for the application. It records all Datastore access, memcache and urlfetch calls to the application. This will show performance usage for every call made to application, which is very useful to analyze app usage and make optimizations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use Memcache:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Datastore usage on GAE is one of the biggest factors that can affect the cost. First thing I did was to analyze Appstats, look for any Datastore query calls and optimize by using &lt;a href="http://code.google.com/appengine/docs/python/memcache/overview.html"&gt;memcache&lt;/a&gt;. One way to easily do this is by searching for any datastore put() call and set memcache after it. Next make sure to get data from memcache before attempting a datastore query.&lt;/p&gt;
&lt;p&gt;Set memcache after writing to datastore:&lt;/p&gt;
&lt;pre&gt;data.put()
memcache.set(user_id, data)&lt;/pre&gt;
&lt;p&gt;Try getting data from memcache before doing a datastore query:&lt;/p&gt;
&lt;pre&gt;data = memcache.get(user_id)
if data is None:
    data = Data.get_by_key_name(user_id)
    memcache.set(user_id, data)&lt;/pre&gt;
&lt;p&gt;This reduced the cost significantly since &lt;a href="http://gramfeed.com"&gt;gramfeed.com&lt;/a&gt; was checking for authentication on every page load, it was making a datastore query for every page load, using memcache significantly reduced these datastore queries.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Client side API calls:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Another change that made significant reduction in cost was reducing the number of GAE urlfetch calls made by the application, &lt;a href="http://gramfeed.com"&gt;gramfeed.com&lt;/a&gt; makes well over a million Instagram API calls/month, the application was initially making all Instagram API calls using urlfetch call on the application server side, this not only increased the number of request to the application but also the incoming and outgoing bandwidth for the application, so I changed the design to make all GET API calls from client side using JQuery.&lt;/p&gt;
&lt;pre&gt;$.getJSON(url, function(data) {
...
});&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Reduce requests to application:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A not so popular choice but something that reduced further costs was by serving all javascript and css embedded in the same html using &amp;lt;script&amp;gt; and &amp;lt;style&amp;gt; tags, this prevented additional requests to application for getting javascript and css files for every page load. Also I moved large images bigger than 30kb served in the application to external host like picasa.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Lightbox implementation to reduce unwanted page load:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The initial UI implementation for &lt;a href="http://gramfeed.com"&gt;gramfeed.com&lt;/a&gt; opened a new photo page with full sized image when clicked on any thumbnail. &lt;a href="http://www.gramfeed.com/instagram/472247118_11457197"&gt;Photo page&lt;/a&gt; contributed to about 30% of pageviews, I decided to implement lightbox using javascript to load full sized photos when clicked on thumbnails in the application. This not only reduced the requests to application by 30% but also significantly improved the user experience by loading images faster in lightbox instead of loading a whole new page. This resulted in more engagement by users and photo view has doubled because of this change.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In spite of the ridiculous price hike, GAE is still a very good app hosting service, you don&amp;#8217;t have to worry about scaling your application. You however have to optimize and architect your application to reduce the usage cost. &lt;/p&gt;
&lt;p&gt;Is Google App Engine the right platform for your application? It really depends on the type of application, gramfeed.com did not involve a lot of datastore query and processing, it uses datastore only for performing Oauth connection and performing any HTTP POST to instagram API, most of the HTTP GET to API are done on client side using javascript. So for applications that does not have a lot of backend processing it is definitely best to use GAE, you can host a web application and grow to thousands of users and still stay within the free quota.&lt;/p&gt;
&lt;p&gt;Feel free to post any comments or suggestions&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;</description><link>http://blog.initlabs.com/post/16359268329</link><guid>http://blog.initlabs.com/post/16359268329</guid><pubDate>Mon, 23 Jan 2012 14:19:33 -0500</pubDate><category>gae</category><category>appengine</category><category>instagram</category><category>gramfeed</category><category>memcache</category><category>datastore</category></item><item><title>How to restore phone contacts lost after iOS5 update</title><description>&lt;p&gt;Another major issue people are reporting after updating to IOS5 is missing contacts in the phone, dont freak out its all there, just follow these steps to get the contacts back:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;On iPhone, open Settings -&amp;gt; iCloud&lt;/li&gt;
&lt;li&gt;Turn OFF for &amp;#8220;Contacts&amp;#8221; option&lt;/li&gt;
&lt;li&gt;Select &amp;#8220;Keep on My iPhone&amp;#8221; option&lt;/li&gt;
&lt;li&gt;Close and Open Phone App, all your contacts should be back!&lt;/li&gt;
&lt;li&gt;Now go back to Settings -&amp;gt; iCloud -&amp;gt; turn ON for &amp;#8220;Contacts&amp;#8221; and select &amp;#8220;Merge All&amp;#8221; option.&lt;/li&gt;
&lt;li&gt;You are DONE.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Other issues seen include &amp;#8220;error 3200&amp;#8221; and Apps not restored, there is solution to get these resolved if the &lt;a href="http://blog.initlabs.com/post/11367380879/how-to-upgrade-to-ios5-without-issues"&gt;proper steps are followed&lt;/a&gt;.&lt;/p&gt;</description><link>http://blog.initlabs.com/post/11390316577</link><guid>http://blog.initlabs.com/post/11390316577</guid><pubDate>Thu, 13 Oct 2011 05:07:31 -0400</pubDate><category>ios5</category><category>iphone</category><category>contacts</category></item><item><title>How to upgrade to iOS5 without issues</title><description>&lt;p&gt;Looks like lot of people are having iOS5 update issues, some are complaining about &lt;a href="http://techcrunch.com/2011/10/12/apples-ios-5-error-3200-now-trending-worldwide/"&gt;Error 3200&lt;/a&gt; during update and some are saying Apps/Data is not restored after update, This instructions below I used, if followed should solve both the issues:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Make sure you have iTunes 10.5 installed on your computer&lt;/li&gt;
&lt;li&gt;Connect iOS device via USB&lt;/li&gt;
&lt;li&gt;Sync your device to backup all apps and data.&lt;/li&gt;
&lt;li&gt;In iTunes, select your device and click &amp;#8220;Check for updates&amp;#8221;&lt;/li&gt;
&lt;li&gt;Select, Download and Install&lt;/li&gt;
&lt;li&gt;(If you get Error 3200, &lt;strong&gt;restart&lt;/strong&gt; your computer and update again)&lt;/li&gt;
&lt;li&gt;When device is restarting or after restarting wait patiently and do not try to mess with your iOS device&lt;/li&gt;
&lt;li&gt;iTunes will have a popup &amp;#8220;Restoring Apps&amp;#8230;&amp;#8221;, the device will &lt;strong&gt;NOT&lt;/strong&gt; say syncing in progress, so &lt;strong&gt;DONT&lt;/strong&gt; play with the device until the Apps restore is done, it will probably take over an hour.&lt;/li&gt;
&lt;li&gt;After ITunes popup &amp;#8220;Restoring Apps&amp;#8230;&amp;#8221; is gone, it will start a sync with a sync icon spinning in iOS device top bar, &lt;strong&gt;wait&lt;/strong&gt; until this completes&lt;/li&gt;
&lt;li&gt;Now unlock the iOS device and go through the setup process prompts to complete location, iCloud, Find my Phone,&amp;#8230; setups.&lt;/li&gt;
&lt;li&gt;You are DONE.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Also see &amp;#8220;&lt;a href="http://blog.initlabs.com/post/11390316577/how-to-restore-phone-contacts-lost-after-ios5-update"&gt;How to restore phone contacts lost after iOS5 update&lt;/a&gt;&amp;#8221;&lt;/p&gt;</description><link>http://blog.initlabs.com/post/11367380879</link><guid>http://blog.initlabs.com/post/11367380879</guid><pubDate>Wed, 12 Oct 2011 17:36:00 -0400</pubDate><category>iOS</category><category>iPhone</category><category>iPad</category><category>iOS5</category></item><item><title>Animate sliding subview just like UINavigationView</title><description>&lt;p&gt;Here is another useful tip for iPhone/iPad programming on how to make a subview to slide horizontally just like UINavigationView using QuartzCore animation.&lt;/p&gt;
&lt;p&gt;Assuming you have created a subView called nextView in the xib file, the functions in code snippet below shows how to slide from main view to nextView and back. This requires the QuartzCore framework to be added to the project and QuartzCore.h is imported.&lt;/p&gt;
&lt;pre&gt;- (void) showNextView{
	[self.view addSubview:nextView];
	CATransition *animation = [CATransition animation];
	[animation setDuration:0.5];
	[animation setType:kCATransitionPush];
	[animation setSubtype:kCATransitionFromRight];
	[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
	[[self.view layer] addAnimation:animation forKey:@"SlideView"];
}

- (void) hideNextView{
	[nextView removeFromSuperview];
	CATransition *animation = [CATransition animation];
	[animation setDuration:0.5];
	[animation setType:kCATransitionPush];
	[animation setSubtype:kCATransitionFromLeft];
	[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
	[[self.view layer] addAnimation:animation forKey:@"SlideView"];    
}&lt;/pre&gt;
&lt;p&gt;Be sure to add #import &amp;lt;QuartzCore/QuartzCore.h&amp;gt; in the main view controller header file.&lt;/p&gt;
&lt;p&gt;This type of UIView sliding is implemented in my iPhone app &lt;a href="http://www.instalookapp.com"&gt;Instalook&lt;/a&gt;&lt;/p&gt;</description><link>http://blog.initlabs.com/post/7115389107</link><guid>http://blog.initlabs.com/post/7115389107</guid><pubDate>Sun, 01 May 2011 05:35:00 -0400</pubDate><category>iphone</category><category>ipad</category><category>ios</category><category>uinavigation</category><category>quartzcore</category></item><item><title>How to detect iOS device orientation on load</title><description>&lt;p&gt;If you are designing your iPad or iPhone application to run in both portrait and landscape mode then you may have to make some changes to position/size of UI components on a view based on the orientation.&lt;/p&gt;
&lt;p&gt;Detecting iOS device orientation when device is rotated is easy, there is a method that gets called when device orientation changes:&lt;/p&gt;
&lt;pre&gt;- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
	NSLog(@"Landscape");
    } else {
	NSLog(@"Portrait");
    }
}&lt;/pre&gt;
&lt;p&gt;&lt;span&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;But this method does not apply when the app is first launched, one way to make the changes to UIView based on device orientation on startup is to check the status bar orientation in viewDidLoad method:&lt;/p&gt;
&lt;pre&gt;if (([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft) || ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight)) {
    NSLog(@"Landscape");
} else {
    NSLog(@"Portrait");
}
&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;Hopefully this helps.&lt;/span&gt;&lt;/p&gt;</description><link>http://blog.initlabs.com/post/7115375694</link><guid>http://blog.initlabs.com/post/7115375694</guid><pubDate>Fri, 04 Mar 2011 07:34:00 -0500</pubDate><category>ios</category><category>ipad</category><category>iphone</category><category>orientation</category><category>rotation</category></item><item><title>HTML5 geo location implementation</title><description>&lt;p&gt;Most browsers have started supporting HTML5 location detection. This posts explains a simple way to implement HTML5 location detection. The browsers usually will show a popup bar for user to accept location sharing when the HTML5 geolocation API call is made, this post explains an alternative to get location if the user declines to accept location sharing. The alternative is to use Google ClientLocation API which detects location using IP address. This fallback can also be used if the browser does not support HTML5 geo location API.&lt;/p&gt;
&lt;p&gt;The implementation below is very simple, first it checks whether the browser supports HTML geo location and gets the location, if browser does not support or if it fails to get HTML5 geo location (user declines or other error) then it goes to the fallback method of using Google ClientLocation API to get user location. The implementation is shown on a Google Maps.&lt;/p&gt;
&lt;pre&gt;var map;&lt;br/&gt;var marker;&lt;br/&gt;var defaultLocation = new google.maps.LatLng(40.72, -74.0);&lt;br/&gt;&lt;br/&gt;function init () {&lt;br/&gt;  var options = {&lt;br/&gt;    zoom: 12,&lt;br/&gt;    mapTypeId: google.maps.MapTypeId.ROADMAP&lt;br/&gt;  };&lt;br/&gt;  map = new google.maps.Map(document.getElementById("map"), options);&lt;br/&gt;  map.setCenter(defaultLocation);&lt;br/&gt;  getLocation();&lt;br/&gt;}&lt;br/&gt;&lt;br/&gt;function getLocation () {&lt;br/&gt;  if(navigator.geolocation) {&lt;br/&gt;    navigator.geolocation.getCurrentPosition(success, fallback);&lt;br/&gt;  } else {&lt;br/&gt;    fallback();&lt;br/&gt;  }&lt;br/&gt;}&lt;br/&gt;&lt;br/&gt;function success(position){&lt;br/&gt;   addMarker(new google.maps.LatLng(position.coords.latitude, position.coords.longitude));&lt;br/&gt;}&lt;br/&gt;&lt;br/&gt;function fallback(){&lt;br/&gt;  if (google.loader.ClientLocation) {&lt;br/&gt;    addMarker(new google.maps.LatLng(google.loader.ClientLocation.latitude, google.loader.ClientLocation.longitude));&lt;br/&gt;  } else {&lt;br/&gt;    addMarker(defaultLocation );&lt;br/&gt;  }&lt;br/&gt;}&lt;br/&gt;&lt;br/&gt;function addMarker(latlng) {&lt;br/&gt;  if(marker) marker.setMap(null);&lt;br/&gt;    marker = new google.maps.Marker({&lt;br/&gt;    position: latlng,  &lt;br/&gt;  });&lt;br/&gt;  marker.setMap(map);&lt;br/&gt;  map.panTo(latlng);&lt;br/&gt;}&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="http://initlabs.googlecode.com/svn/trunk/samplecode/html5geo.html"&gt;View Example&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description><link>http://blog.initlabs.com/post/7115350413</link><guid>http://blog.initlabs.com/post/7115350413</guid><pubDate>Mon, 10 Jan 2011 05:32:00 -0500</pubDate><category>html5</category><category>geolocation</category></item></channel></rss>
