Friday, January 16, 2009

Tips: Download iPhone SDK with wget

Since its final release, I've been trying to download iPhone's SDK from Apple's website. The whopping 1.6 GB download seems a pretty daunting task in my unstable line, and some of apple's web sites features made it pretty impossible in no time.

My download failed three times after 50-70% completion, each time either I have manually paused the download for some reason or my connection was having some problem. And apples server did not give me any resume feature in any of the download  managers. Downloading 1.6 GB with Firefox's own download manger seemed an option, but what if Firefox crashes?

At last, I thought of giving good ol' wget a try and it didn't fail me. If you are in a similar situation like me, try this.
  1. Downlaod 'Export Cookie' addon for firefox from here
  2. Log into iPhone Developer Site using your apple developer account, if you don't have one, just register, its free.
  3. Export your cookie using the addon to a file named 'cookies.txt'
  4. Run this from the command line

    wget --limit-rate=5k --tries=inf -server-response --continue --load-cookies cookies.txt http://adcdownload.apple.com/iphone/iphone_sdk_for_iphone_os_2.2__9m2621__final/iphone_sdk_for_iphone_os_2.2_9m2621_final.dmg

Now you can pause and resume the download at your will. I have used --limit-rate=5k so that I can also browse without much overhead.

Wednesday, January 14, 2009

Javascript: Getting Current Window Dimension

Javascript function to get current window height and width. Works with most of the browsers.




// function to get the current width of the window
function getWidth(){
var x = 0;
if (self.innerHeight){
x = self.innerWidth;
}else if (document.documentElement && document.documentElement.clientHeight){
x = document.documentElement.clientWidth;
}else if (document.body){
x = document.body.clientWidth;
}
return x;
}

// function to get the current height of the window
function getHeight(){
var y = 0;
if (self.innerHeight){
y = self.innerHeight;
}else if (document.documentElement && document.documentElement.clientHeight){
y = document.documentElement.clientHeight;
}else if (document.body){
y = document.body.clientHeight;
}
return y;
}

Back to Blogging

After a failed attempt last year to get back to blogging, I'm trying it again this year. I really wanted to get back, but got busy will...