Visit my site @ mugunthkumar.com


Author: Mugunth Kumar

Member Since: 2009-07-11 02:57:21
Website: http://mugunthkumar.com

Posts by Mugunth Kumar:

iPhone Tutorial: Elegant way to send formatted In-App email

March 7th, 2010 by Mugunth Kumar

By now, most of you know how to send emails using the Message UI framework without quitting the app. In this tutorial, we will briefly discuss the techniques for sending a HTML formatted email with user generated content. Though sending a HTML formatted email is as easy as setting the option to HTML

[picker setMessageBody:emailBody isHTML:YES];

There are some cases that this method that this method doesn’t take care of. In short, this method works great for sending “Tell a friend about this app” email. But if your app needs much more sophistication, especially, if it needs to email data created by the user, you can follow the approach I suggest. Using this method, you can also adapt your code for International support and send the same email in multiple languages without any “hard-coding

Though the method promises some great features, it is ridiculously simple. :)

Step 1:


Create a HTML File with the contents of your email and add it to your project. You should NOT create any css or link it to any external CSS files. All your styles whether embedded withing the <STYLE> tag or kept as a separate CSS file will mostly be stripped by email clients. The reason could be because email clients don’t want your CSS to mess around with their client CSS. Read this article for more details. A sample is given below.

Step 2:

Insert placeholder markers within your HTML file. Your HTML file should look something like this.

<font size = '1' color= "#222222" style = "font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial;"><i>//TEXT_PLACEHOLDER//</i></font>
<font size = '2' color= "#000000" style = "font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial;"> Have a great day! <br/>//FRIENDNAME_PLACEHOLDER// <br/></font>

The bold markers are the placeholders. You can assume them to be variables in the email. We will be replacing them later.

Step 3:

Do exactly the same steps for sending an in app email explained in one of my previous tutorial, but rather than hardcoding the email body like this,

NSString *emailBody =
[NSString stringWithFormat:@"%@\n\n
Sent from MyGreatApp on iPhone. Download yours from AppStore now!
", content, pageLink, iTunesLink];

Read it from your HTML File you created in Step 2.

NSString *langString = [[userDefaults dictionaryRepresentation] objectForKey:@"NSLocaleCode"];
NSString *emailFileName = [NSString stringWithFormat:@"email_%@.html", langString];
NSString *emailFilePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: emailFileName];
NSString *body = [NSString stringWithContentsOfFile:emailFilePath encoding:NSUTF8StringEncoding error:nil];

Note that, I’m appending the locale code with the email filename. That means you should create your email file by name email_en_US.html and similarly for other language files.

Step 4:

Replace placeholder texts with your contents generated within the app.

body = [body stringByReplacingOccurrencesOfString:@"//TEXT_PLACEHOLDER//" withString:myText];
body = [body stringByReplacingOccurrencesOfString:@"//FRIENDNAME_PLACEHOLDER//" withString:myFriendName];

The values myText and myFriendName should be passed to this email function.

With this architecture in place, you can format your email, change language and do a lot more without much changes to your code. After all, writing cleaner code is more important in the long run.


Mugunth

How to deploy on iPhone OS 3.1.3 without downloading the 2GB SDK

February 3rd, 2010 by Mugunth Kumar

Like most of you, I too downloaded the 3.2 beta and was playing around with some iPad stuff. Today when iPhone OS 3.1.3 is released, without second thought, I immediately updated my iPhone. My iPhone being a development device, I understood that I can no longer use the current XCode installation to run apps on device. When I launched XCode, the Organizer reported,

“The version of iPhone OS on “ABC’s iPhone” does not match any of the versions of iPhone OS supported for development with this installation of the iPhone SDK”

So does that mean, you should re-install the SDK? Just like me, you will probably have confusions like,


Will installing it corrupt or overwrite your 3.2 beta?

Should I re-install 3.2 beta again?

I too had these. Fortunately, I decided to hack things myself and got the 3.1.3 working without downloading the entire SDK. This is how I did. Type the following command into your terminal.


ln -s /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.1.2\ \(7D11\) /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.1.3

Now quit and restart XCode. Voila! you have effectively “fooled” XCode! and you have saved countless hours which you can effectively use on programming another cool app!

Note that this hack will work *any* minor OS updates. However, if you are using a feature specific to the new version you will probably find yourself in trouble. In other words, don’t try to apply the same technique when 3.2 or 4.0 launches.


Mugunth

Save As vs Exporting – Why Apple excels at UI Design?

January 13th, 2010 by Mugunth Kumar

Most users think, Mac UI is all about slick graphics and “cool” icons. Well, that might be true partially, but user interface design isn’t about photoshopping or designing cool looking icons. According to Jakob Nielsen, aesthetics is just one aspect of usability. There is much more to user friendly software than just the “cool factor” or great icons.


Recently, I was using Microsoft’s Excel to edit a dozen large  CSV files. As a matter of fact, in Excel,  whenever you save “anything” you do as a CSV,  you will practically lose out features that aren’t supported natively by the underlying file format. For Example, CSV doesn’t support coloured cells. So when you colour a cell, and try to “save” it as a CSV, Excel pops up this dialog.

Saving as CSV loses of "certain" features

When you click “Yes”, all that Excel does is to “export” whatever content your file has into what the underlying format can support. So since, excel supports coloured cells but CSV doesn’t it ignores your colouring and proceeds saving it to CSV. Excel even goes one step far and doesn’t clear the “dirty flag” because, Excel hasn’t saved *every* change you made into the CSV.

Sounds good so far. But what’s really wrong here? The real problem is, Excel gives you a sense of feel that “everything” have been saved and you are safe. Things become bad when you quit Excel. Because the dirty flag isn’t cleared and the file haven’t been saved completely, Excel prompts you to “save” the file again. Specious, not wanting to take chances, some users like me, save the file again. Again the same thing happens and the end user is still just dumbfounded and asks, But, why the heck should I save it again?

Microsoft UI designers have failed to understand the end users. In this case, it’s because Excel fails to speak the users’ lingo. According to the user, when he “saves” a file, he saves a copy and he is contended that he can always re-open when something bad happens. But excel just “exports” the file into CSV format and tells the user that it “saved” the file (when it in fact didn’t). As a result what happens is data loss. No not just cell colours, in cases, when the users doesn’t know that CSV doesn’t support multiple sheets, excel doesn’t export (or save) the second sheets data and the user just loses the entire content from the second sheet. Disaster! In one of the cases where I work, a co-worker of mine, has got used to these prompts which Excel shows after you “save” your file as CSV

Prompts user to save the "saved" file again

and he just closes Excel assuming that these prompts are nothing but “bugs” in Excel. (Yeah see, he is a half techie and a little knowledge is dangerous.) Things went fine when he didn’t lose data, but just lost some formatting here and there. But the real disaster happened when his second sheet containing over 1000 lines and 3 hour work was lost.

Now, lets’ see how Numbers, the equivalent software from Apple handles this.

Save As panel for Numbers.app

Apple doesn’t even include CSV or other “lossy” formats in the save as sheet. That doesn’t mean, Numbers can’t “save” your data as CSV. But rather Apple calls it as “Export”. Files you export as CSV aren’t yet saved. So, when the user quit Numbers, and get a prompt to save the document, he will not confused.

Because Microsoft does it this way (wrong way), other software makers like Adobe too make the same mistake. Photoshop “saves” a file as PNG and still give you a sense of feel that you have saved the file. Another such example is audacity and paint.net and even those “save as PDF” plugins. They actually don’t “save” your data, but rather export it. Apple gets it right, but the whole world gets it wrong, Unfortunate!.

iPhone Tutorial: Follow Cost API and a open source wrapper

December 22nd, 2009 by Mugunth Kumar

What is Follow Cost?

Follow Cost is a interesting and powerful statistic that helps you check the “cost” you would incur by “following” a person on twitter. This is a very useful statistic that I think every twitter client should adopt.  Tweetie for iPhone was the first to implement follow cost and I use this feature of tweetie to check whether a follower is “worth the pain” (as follow cost puts it).

In short, Follow Cost gives you an approximate count of the number of updates a person tweets in a day. As a thumb rule, I don’t follow anyone with a follow cost of over 40. A celebrity with a high follow cost is @guykawasaki. (80+ at the time of this writing) His tweets are interesting, but is it worth the pain? Depends. To me, definitely not.

The API

Follow Cost has a relatively simple API. But unfortunately, even after 3 months of Tweetie 2 launch, no other twitter client has implemented. You just have to make a GET request to followcost.com server with the twitter username as follows.=

http://followcost.com/<username>.json

The resulting output is a json formatted string which can be parsed using any JSON Framework.

Objective C Code

To make life easier, I wrote a helper class MKFollowCost. To use the class, first download the JSON framework and follow their installation instructions. If you are writing a twitter client, chances are that, you would probably have done this. Download the code from below and drag the two files, MKFollowCost.h and MKFollowCost.m into your project.

You can instantiate a followcost object by

MKFollowCost *followCost = [[MKFollowCost alloc] initWithTwitterName:@”mugunthkumar”];

All of the variables like, milliscobles, tweets per day etc, can be accessed from this object. The object is designed to be embedded without your Twitter Profile object.

Downloads

FollowCost Objective C Wrapper: FollowCost v1.0

Rights

You can use it in your own Twitter client, royalty free. Attributing me is upto you. However, if you modify the source code, please make it open source.

iPhone Tutorial – Enabling reviewers to use your In-App purchases for free

November 15th, 2009 by Mugunth Kumar

In-App purchases is a great way for developers to upsell by giving away their app for free and then allow them to charge for features when users start using it. This freemium model has indeed worked very well for upselling your app in the AppStore. But unfortunately, there isn’t an Apple allowed way to allow reviewers to “download” your in-app purchases for free (like giving away promotional codes for your in-app purchases). So most developers again resort to the same “lite”, “pro” model.

After raising the issue to Apple, I even got a official reply that it’s not possible currently to allow reviewers to use your in-app purchases for free.

noinappurchases

However, developers’ creativity knows no bounds. In this post, I’ll present a method to allow reviewers to use your in-app purchases for free without having multiple versions of the same app on the app store. The source code for the same is also available royalty-free (as always) for using it in your own apps. Before diving in, it’s advised that you read through my previous tutorial on how to do in-app purchases

(more…)

iPhone Tutorial – UISearchDisplayController with NSPredicate

November 15th, 2009 by Mugunth Kumar

Though UISearchDisplayController is seemingly easy (and yes it’s easy), apart from the sample source code, there isn’t much documentation available from Apple. I won’t be posting code for this tutorial, (as most of them come from Apple’s own source code), however, the tutorial will contain code fragments that I wish to highlight and those I changed for improving the search using NSPredicate
(more…)

iPhone Tutorial – In-App Purchases

October 18th, 2009 by Mugunth Kumar

Last week, Apple announced that in-app purchases will be available for free apps as well. This could probably free developers from creating “lite” and “pro” versions of the app and allow developers to “unlock” features inside the app and create business models that the AppStore haven’t seen. This model could be a great boon for developers like us to upsell our apps (provided they are of good quality) and to reduce piracy. In this article, we will look at how to incorporate StoreKit to do In-App purchases for your iPhone Application.

Update: Did it really free you from creating “lite” and “pro” versions? How did you manage to give away free copies of your in-app purchases for reviewers? Read my tutorial on how toenable in-app purchases for free

Apple allows three types of purchases within the app and Apple terms them as consumables, non-consumables and subscriptions.

Consumables are products that are “consumed” immediately. This means, if the purchase is made today, and the user wants to purchase it again tomorrow, he will be charged again when he attempts a purchase.

Non-Consumables are features that are purchased exactly once. Apple automatically takes care of “remembering” those purchases and allows the user to purchase them again for free, just like downloading apps you already purchased.

Subscriptions are the most complicated part, They behave like non-consumables during the subscribed period and like consumables after that. You as a developer have to ensure that anything that is subscribed by the user is available across all of his iTunes synced devices when they are purchased from one device. Hence, do not lock in-app purchases to UDIDs. This might even get your app rejected. The StoreKit, as on date, doesn’t have any built-in mechanism to do it automatically which is why subscriptions are a bit tougher to develop.

One important point to note is that, in-app purchases cannot be used to deliver product updates. Changes to the binary has to be separately submitted. However, if you are a game developer, game data, maps, levels and other “data files” are allowed for in-app purchase.

In this post, we will focus on how to prepare your app for enabling features for the “pro” version from the “lite”. Or technically, we will focus on how to bring in, consumables and non-consumables into your app. We will leave the subscriptions part to another blog post as it’s quite complicated and involves some server side programming as well. (more…)

Custom URL Shortening and Self Hosted “TwitPic”

October 17th, 2009 by Mugunth Kumar

With the outburst of Twitter and microblogging services, many companies who want to make some quick money started services that include, URL shortening like tinyurl, bit.ly, tr.im and others or image sharing services like TwitPic, yFrog and so on. However, due to lack of a proper business model, some of these sites are struggling to meet their bandwidth costs. Because most of these services are just a week long PHP programming work, it’s easy for other companies to enter the URL shortening bandwagon. As such it’s difficult for companies to really make a business model out of this.

Recently, Twitter’s switch from tinyurl to bit.ly as it’s default shortening service infuriated companies like tr.im as they announced that they will probably be shutting down their service, though they reverted their decision later. When such companies go out of business, what will happen to your URLs? Dead and gone for good? So why not host our own URL shortening services? How difficult is it to write our own URL shortening service? Turns out that a few couple of PHP files, and a MySQL database and a mod-rewrite enabled Apache server is all what you need for hosting your own URL shortening service. Writing those PHP code is not for the those who are not conversant with PHP (including me). For people like us, two smart guys, Lester Chan and Ozh Richard at yourls.org have written a custom URL shortener that you can use it for free on your blog. In this post, I will briefly explain how to host your own custom URL shortener using YOURLS. Later we will also look at how to host your own “TwitPic” service.

(more…)

bit.ly wrapper for Objective-C/iPhone

September 26th, 2009 by Mugunth Kumar

Continuing from my part 1, in this section, we will discuss about how to use this helper in your own application.

Source Code

Download the source code here
MKBitlyHelper 1.0.zip

Documentation

With just three lines of code, you can shorten your URL using this wrapper.

Initialize the helper class with your loginname and apikey.

bitlyHelper = [[MKBitlyHelper alloc] initWithLoginName:@"yourlogin" andAPIKey:@"yourapi"];

In your application, you can either provide your application specific API or user provided API. Logging into the bit.ly api helps in tracking the click throughs and referrals. The classes doesn’t provide a login or APIKey by itself.

Now, shortening or expanding URLs is as easy as calling these functions.

NSString *shortURL = [bitlyHelper shortenURL:@"http://mugunthkumar.com"];
NSString *longURL = [bitlyHelper expandURL:shortURL];

Disclaimers and other yada yada…

Be forewarned that it may have errors. As Donald Knuth says,

Beware of bugs in the above code; I have only proved it correct, not tried it.

Feel free you use this code and re-distribute it. The source code must retain the copyrights and my attribution in any derivative works of the source code.

On your application, you might opt to attribute me in your app though it’s not mandatory. I would be happy if you do so ;-)

Introducing MKSync – iPhone App for Syncplicity

September 11th, 2009 by Mugunth Kumar

For the past 2 or 3 months, I’ve been busy developing a product, which I’m announcing now. It’s called as MKSync and it’s a iPhone client for Syncplicity.

The product is in its early release phase and I intend to  submit it to AppStore by this month end. Currently I’m looking for beta testers. I’m looking for around 10-20 beta testers. As and when needs arise, I might increase the limit. I would prefer people who will be interested in testing the app’s second and third versions as well.

As of version 1, the most important features include, sharing files via email and the ability to browse and view downloaded files on iPhone without an active Internet connection. These features are illustrated in the screencast below.

If you prefer a direct download of the screencast, click here
https://my.syncplicity.com/share/kn3xqer1hn/Syncplicity_Screencast.zip — Removed direct download. This screencast is too old.

If you are interested in beta testing, drop me a mail @ feedback@mugunthkumar.com with your UDIDs.

You can send me your UDID using Erica Sadun’s UDID Generator. (iTunes Link)

For more information go to the Syncplicity forum here. (You need a Syncplicity account for accessing the forums)
https://my.syncplicity.com/Forums/default.aspx?g=posts&t=2793

For updates on this product, You can follow us on twitter @mksync.

Update: 21st September 2009: Closed for private beta. Follow us for product release updates.
Update: 19th October 2009: Product submitted to Apple. Follow us for product release updates.
Update: 7th November 2009: Product approved by Apple. No rejections whatsoever! Visit the product page for MKSync here.
Thanks,
Mugunth


For those who don’t know, what is Syncplicity, please read it’s wikipedia entry. It’s a cloud based, online backup and sync service, that works seamlessly behind the scenes to synchronize your data across computers simultaneously backing up to the cloud. Long gone are the days when you carried a USB drive around to keep your data in Sync. Apart from just syncing PCs, it can sync your google docs documents with your PC, keep your facebook albums in sync with your photos and much more…

Ego Searching to the core…!

September 2nd, 2009 by Mugunth Kumar
I know… For ages, I’ve been an egosearcher… But just today, I noticed that Google is suggesting my full name when my first name is typed.
Am I really this popular???
Ego Searching with Safari

Ego Searching with Safari

And now in Google Website itself… :D

Ego Searching in Google

Ego Searching in Google

Am so happy now…!

Mugunth

Formatting Dates relative to Now – Objective C (iPhone)

August 30th, 2009 by Mugunth Kumar

Introduction
Many a times, in an iPhone application, you might need to format the date relative to today. This code snippet will help you do it.

+ (NSString *) formattedDateRelativeToNow:(NSDate *)date
{
NSDateFormatter *mdf = [[NSDateFormatter alloc] init];
[mdf setDateFormat:@"yyyy-MM-dd"];
NSDate *midnight = [mdf dateFromString:[mdf stringFromDate:date]];
[mdf release];

NSInteger dayDiff = (int)[midnight timeIntervalSinceNow] / (60*60*24);
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];

if(dayDiff == 0)
[dateFormatter setDateFormat:@"'Today, 'h':'mm aaa"];
else if(dayDiff == -1)
[dateFormatter setDateFormat:@"'Yesterday, 'h':'mm aaa"];
else if(dayDiff == -2)
[dateFormatter setDateFormat:@"MMMM d', Two days ago'"];
else if(dayDiff > -7 && dayDiff <= -2)
[dateFormatter setDateFormat:@"MMMM d', This week'"];
else if(dayDiff > -14 && dayDiff <= -7)
[dateFormatter setDateFormat:@"MMMM d'; Last week'"];
else if(dayDiff >= -60 && dayDiff <= -30)
[dateFormatter setDateFormat:@"MMMM d'; Last month'"];
else if(dayDiff >= -90 && dayDiff <= -60)
[dateFormatter setDateFormat:@"MMMM d'; Within last three months'"];
else if(dayDiff >= -180 && dayDiff <= -90)
[dateFormatter setDateFormat:@"MMMM d'; Within last six months'"];
else if(dayDiff >= -365 && dayDiff <= -180)
[dateFormatter setDateFormat:@"MMMM d, YYYY'; Within this year'"];
else if(dayDiff < -365)
[dateFormatter setDateFormat:@"MMMM d, YYYY'; A long time ago'"];

return [dateFormatter stringFromDate:date];
}

Link back if you liked it…

–Mugunth

God and Religion

August 22nd, 2009 by Mugunth Kumar

PS: This post has nothing to do with Apple, iPhone, programming, Windows, Microsoft. Sometimes, I do pen down my personal thoughts on my blog. Read it if you are an atheist. Read it if you aren’t either ;-)

This should have been my first blog post. I wrote this on a piece of paper around 7 or 8 years ago, during my college days, when Internet connection was intermittent, I didn’t have a blog let alone a web host.

== God ==

Being in the 21st century, the age of science and technology, computer research, many of us really doesn’t think about God. This Universe, is a very vast area, which “hosts” the Milky Way. Our Solar system is a very small part of that galaxy and the planet we live, Earth (or Mother Earth) is another minuscule part of Solar System. In such a great Universe, only our Earth has the right proportions of Oxygen in Air, has water and the right temperature which makes it the only planet to support life. Isn’t this a miracle? Who could have done this?

For human beings to survive, water and air are indispensable. It’s available for free on this planet. Who gave this to us? Can we all “thank” him for that?

Every engineer knows that a computer’s chip is made from silica, which most commonly found in sand. Can you believe that, that sand is doing miracles on your computer right now when you are reading this? Who designed it? A chorus, “Some Engineer” did it. Nearly every literate person can answer that question.

God is also an Engineer, much like us. The “chip” he designed is called “CELL“. It carries the DNA, which is a “blue print” depicting your Intelligence, your height, your weight, complexion, skin color and the entire “YOU”. It also has the mitochondria that generates the necessary power for the survival of the cell along with a whole lot others. But when we are asked, who made this chip, we blabber this, that and end up saying “evolution”. Evolution, the very word, states that there was something in the beginning and everything evolved from it. Who created that something? (OK, a mild digression, I’m a strong believer of Evolution, which is why I think Veganism is really bad and against evolution.
Analogous to that, we didn’t invent the Core 2 Duo chip out of blue. It “evolved” from it’s predecessor. Tracing back to it’s roots, the very first “CHIP” was created by a Texas Engineer, Jack Kilby. He then invented the calculator and the thermal printer as well.
Similarly, were we able to trace how the first living “CELL” was formed? Do we know what happened before BigBang? Why don’t we just thank Him for what He provided us? Why can’t we worship the nature, He provided us there by thanking him? If everyone believed that God is there and God made the Universe, and God is looking at all of us, there wouldn’t be any unlawful practices, murders, rape or robbery. Don’t think that “Seeing is Believing”. Yes of course, seeing is believing, but it cannot be applied universally. How is your computer working now? What flows through the power cord? Can you see it? Well then don’t believe in Electricity. You can only “feel His presence”

== Religion ==

Now comes the most controversial topic. If I have to believe in God, which religion is the best? Ask me, I’ll never ever say follow religion XXX. Now, who created religion? About 300, 000 years ago, when the Neo Cortex of the brain started growing at a considerably rapid pace (see, I believe in Evolution), we, humans gained “self consciousness”. This self consciousness, lead to the creation of a sophisticated language with which we were able to communicate more information with our peers. Though, animals had the sense of “fear” and morals (some animals like Dolphin, not all), their poorly developed language centers prevented them to form a strict set of rules that constituted a religion. This is again evident from the fact, that animals don’t bother about the carcass of their peers, where as Neanderthals buried their peers after performing some rituals. The “self-awareness”, which humans gained after the growth of “neo cortex”, created the sense of “Afterlife” sometime during the past which seeded the origins of the first religion. However, religion is nothing but a strict set of rules set by the first person(whoever it might be or whatever it might say) who wrote it. Remember the monkey, ladder and the cold water story? Precisely, this is how religion got disseminated. Most of us, who believe in one or the other religion, disseminate their religious thoughts, much like the monkeys in the story, without even “thinking” about it. Read any “holy book”, they always say, the other religion is bad. We live in a secular world and still think these texts are true and we claim we are an intelligent species.

I can hear you murmuring now… So what should you do? Should you believe or not believe? Is there God? Well,

1) God exists. But he didn’t write those holy books which you read. He didn’t build those temples/churches or mosques you visit. You don’t have to go there to worship him. He created this entire Universe for you to live and you think, God lives only in those temples/churches or mosques.

2) God never created religion or never wrote any holy books. It’s we humans who disseminated it. If God really created religion, animals, as well would have built its own temples, much like the way they built their caves or nests.

3) After creating the Universe, the Solar System, the Earth and the laws of Earth, God will never interfere with it/meddle with it.  He created Physics. When you leave (drop) a ball from your hand, it doesn’t stay there. It falls down to Earth, and believe me it’s a miracle. But for most of us, who adhere to “strict religious” principles, miracle is when the same ball moves up rather than being attracted by gravity. God created physics and the Earth and it’s gravity. He is not going to bend the laws of physics just to make you believe his presence. He has given you the sense of “self-consciousness” with which you should understand what’s right and what’s wrong. He’s not going to perform magics or tricks defying the very laws He created. The physics He created itself is a miracle. Here is an article on what Einstein thought about God and Religion.  Some excerpts from that article.

There is a third stage of religious experience which belongs to all of them, even though it is rarely found in a pure form: I shall call it cosmic religious feeling. It is very difficult to elucidate this feeling to anyone who is entirely without it, especially as there is no anthropomorphic conception of God corresponding to it.

The religious geniuses of all ages have been distinguished by this kind of religious feeling, which knows no dogma and no God conceived in man’s image; so that there can be no church whose central teachings are based on it. Hence it is precisely among the heretics of every age that we find men who were filled with this highest kind of religious feeling and were in many cases regarded by their contemporaries as atheists, sometimes also as saints. Looked at in this light, men like Democritus, Francis of Assisi, and Spinoza are closely akin to one another.

How can cosmic religious feeling be communicated from one person to another, if it can give rise to no definite notion of a God and no theology? In my view, it is the most important function of art and science to awaken this feeling and keep it alive in those who are receptive to it.

The “religion” which he explains is close to what modern day “Deism” is all about. A quote from Wikipedia on Deism states that,

Deism is a religious and philosophical belief that a supreme being created the universe, and that this (and religious truth in general) can be determined using reason and observation of the natural world alone, without a need for either faith or organized religion. Deists generally reject the notion of divine interventions in human affairs – such as by miracles and revelations, but not necessarily

The cosmic religious feeling which Einstein had is what we, as Engineers or technologists should follow. It’s closest kin, Deism, says, God never meddles with your day-to-day activities. So tomorrow, when you go to your place of worship, Thank Him for what he has given, rather than asking for some kind of favor.
“Oh God make me filthy rich” will never make you rich. Bill Gates, didn’t pray that way, for he is an atheist, if I’m not wrong.
God created you and the Universe along with every other animal or plant out there. Thank him for that next time when you worship, rather than asking him for some favour which He is not going to give. God gave you the sense of “reasoning”. Question your religion or anyone who preaches any religion. If your religion bans something, ask why? Why shouldn’t I eat Beef (I’m a Hindu, legally, not morally). If God really wanted humans not to eat Beef, he wouldn’t have created cows at the first place. If God really wanted you to circumcise, He would have ensured that your fore-skin falls off once it’s duty of protecting your genitals is over. No, I’m not a creationist. What I believe is, God created “something” initially from which everything else evolved.
What differentiates between the God created chip, “CELL” and human created chip, “Microprocessor” is the ability to reproduce. That ability of the first “CELL” gave way to evolution and Darwinism.
Believing in God doesn’t mean you ought to follow a religion. Einstein never followed one, yet he is not an atheist. You can believe in God without following a religion. If you are following a religion, start questioning it. Ask yourself why?. The moment you really believe in God is the moment when you become truly, self-aware. That God, needn’t be anthropomorphic (nor He is). It’s just a feeling. A cosmic religious feeling which Einstein felt. Start feeling it. When everyone “feels” this, there wouldn’t be war in this World.

Hope you enjoyed the post.
Feel free to pen down your comments. Hope I didn’t hurt anyone’s sentimental feelings. If you felt so, do let me know.

Thanks,
Mugunth

ShahRukh Detention Vs Frisking of Dr. Abdul Kalam

August 17th, 2009 by Mugunth Kumar

The detention of ShahRukh in US has created a lot of furore, not just in India but in the Internet World as well.

I first thought it was the stupid Indian media that created the hype. But the topic started trending in Twitter, and here is a screen cap from Bing, which says ShahRukh is a “Popular” search now (17th Aug 2009).

Bing Says ShahRukh is a popular search now...

Bing Says ShahRukh is a popular search now...

Just about three weeks back, when the man who I revere next to God himself, Dr. Abdul Kalam, was frisked at the Indian Airport by US, no one bothered to make such furore. Dr. Kalam, was asked to remove his shoes (yeah he could be pirating cocaine or meth to US) he accepted and obliged and even Continental reported that

Kalam was very cooperative and underwent the entire process which happened over a month ago

Neither the media, not the Internet savvy people made much noise.

Three weeks later, ShahRukh was detained at the Newark Airport and the whole Indian diaspora made a huge furore.

Hindu reported that, “Shahrukh doesn’t feel like stepping onto US soil again

It was very unprofessional of the airport security staff of not allowing me to use my cell phone to contact my local organisers

We will take up the issue with the United States government strongly. Such incidents involving Indians due to their religion or nationality should not happen… we will not accept it – Civil Aviation Minister Praful Patel

My dear citizens, it’s their country and they have setup their own laws and they have every rights to check who is entering their land and who is not.

Mr Khan said,

I have travelled throughout the world for my shooting and also as brand ambassador for major products, but I have never been treated like this before

StraitTimes reported that, Some (really stupid) cabinet minister wants to retaliate by frisking and detaining Americans travelling to India.

The only Indian Media to report in a neutral stance was Economic Times A quote from their article,

Interestingly, the same day that SRK was detained in Newark, there came news that the great Bob Dylan, wandering around Long Branch, near New York City, was asked for an ID by two cops too young to know who he really was. When he couldn’t furnish one, Dylan was taken back to the resort where he was putting up and staff there vouched for him.

How can ShahRukh expect a “Royal Treatment” in the United States, when Bob Dylan himself was not given one? He may be a super hero in India and he makes a lot of money because some crazy idiots make him God, but the educated upper echelons of India, should at least understand and stop making a furore. In India you might allow any politician/film actor go through your immigration gates without much checks. That has lead us to great problems including the Mumbai Terrorist Attacks. But, after 9/11, every American wants to save him and his country which in my view makes a lot of sense esp if you are patriotic. You can’t expect Americans to follow the herd just like Indians. Moreover, comparing how Abdul Kalam co-operated when he was frisked and what Khan said when he was detained, you should at least understand who is trying to make a fuss.

A kind plea to all those educated Indian diaspora living abroad: Your visa status, your immigration and getting a green card is possible only when America and India has a good relationship with each other. Already, those stupid politicians and film actors and film actor turned politicians have f***ed up our lives. Don’t again allow them to play with your life and make a fool of yourself. They have already made Australia a “bad” place when there wasn’t any racial intentions. Now they have turned to United States. At the end, you have to provide your family with everyday bread. Neither ShahRukh, nor the Indian Politicians will. Save your visas. All these commotions will only make it more difficult for future Indians to secure a H1B or a student visa.
And now don’t ask me why US/Australia and why not stay back in India. Read my other posts Quality of Indian Education and Education System in India

Thanks for reading…


Mugunth

Consuming a RESTful Service (bit.ly) in an iPhone Application

August 14th, 2009 by Mugunth Kumar

Introduction

Of late, many programmers who develop for Windows/Linux have moved to iPhone because of it's runaway success. Among the most successful apps on the Apple AppStore, first comes games (yeah I can hear you, fart apps!!!). Next comes apps like Tweetie and others those consume a web service (REST or otherwise). Games are pretty difficult get started especially if you aren't a game programmer. However, developing iPhone applications that consume a web service is quite easy. In this article, I'll illustrate how to write a iPhone application to consume a web service. I'll take bit.ly's REST service as an example, and at the end, we will be developing a nice "bit.ly" wrapper in Objective-C. For those who are new to REST, it stands for Representational State Transfer. Head on to Wikipedia here for more details. The post itself is split into two parts, one focussing XML and the other JSON.
At the end of the second part, you can download the source code attached.

Bit.ly Documentation

Bit.ly, as you all know is a URL shortening service, that became popular all of a sudden when Twitter started using bit.ly as it's default URL shortening service over tinyurl.com. The REST documentation of bit.ly is available from Google code here.

Some Basics before we dirty our hands with real code

Authentication Types

bit.ly (and many such services) use a kind of HTTP authentication called Basic Authentication. In basic authentication, the username and password that is typed into the client is formatted as
: and the concatenated string is converted to "base64" encoding. This string is passed along with the HTTP Header usually in every API call that does some function which you have to normally log on to see.
There is one more type of authentication, oAuth, which stands from Open Authentication. As of now, bit.ly doesn't use oAuth. Explaining oAuth itself needs a separate article and is outside the scope of this article.

HTTP Request types

When you access a RESTful service, you either request data or post data. In most cases, your HTTP Request type is either a "GET" or a "POST". There are two more types of requests and they are, "PUT" and "DELETE". When to use what, is upto the designer of the RESTful service. You as a consumer, just follow the documentation.
In our case, bit.ly we will be using only "GET" methods.

The real code

You shouldn't be shocked to know that, accessing a RESTful service for data is just a matter of 10 line code.
NSString *longURL = @"http://mugunthkumar.com"
NSString *baseURLString =
@"http://api.bit.ly/shorten?version=2.0.1&longUrl=%@&login=bitlyapidemo&apiKey=";
NSString *urlString = [[NSString alloc] initWithFormat:@"%@%@",
baseURLString, longURL];
NSURL *url = [[NSURL alloc] initWithString:urlString];
NSString *result = [[NSString alloc] initWithContentsOfURL:url];

NSLog(result);
[url release];
[urlString release];
[result release];

Parsing the Result

The result which we "NSLogged" here could be either XML or JSON. In our case, bit.ly by default sends JSON formatted data, which is by far the most commonly used. JSON is lighter than XML for transferring the same amount of data. There are a lot of debate going along on which is good for data transfer. I personally prefer JSON. Of late, JSON is picking up over XML with the advent of JSON parsers. Objective C has a very robust JSON parser called json-framework. We will touch about them later in the next part of this article. The other kind of data format namely XML, is returned by bit.ly, only when you pass

format=xml

along with the URL as an additional parameter. For parsing XML, there are two parsers. One is NSXMLParser and the other is a faster libxml2. Though libxml2 is faster, use it on your iPhone app only when you are going to parse over 10MB of XML data. When your XML data is small (as in our case), the performance gap between NSXMLParser and libxml2 is very meagre. In case of bit.ly, the shorten api returns < 1KB of data. Most RESTful service return very little data (mostly in the order of few hundred kilo bytes) I prefer NSXMLParser for one reason. You code is cleaner than it would be if you use libxml2. In this article, I'll go take you through both ways of handling the data.

Parsing XML

[parser initWithContentsOfURL: url];
[parser setDelegate:self];

[parser setShouldProcessNamespaces:NO];
[parser setShouldReportNamespacePrefixes:NO];
[parser setShouldResolveExternalEntities:NO];

[parser parse];
[parser release];

Parsing XML data using NSXMLParser couldn't be simpler. You just have to create an object (parser) of type NSXMLParser, initialize it and call parse.

Things to note

However, there are a couple of things to note.

1) You can initialize the parser object either with NSURL or with NSData. Both methods work equally well.
2) You OUGHT to set the delegate to self. Otherwise there is no way for the NSXMLParser to notify you of events.
3) The next three lines are optional. You usually set it to YES if you want to get notified of those events as well.
4) The call to [parser parse] is blocking. This means, it will not return until the complete content is parsed. So, you can (and should) release any associated memory at the next line.

Callbacks from NSXMLParser

NSXMLParser has around 14 callback methods. But it's enough if you implement just three of them. They are,

parser:didStartElement:namespaceURI:qualifiedName:attributes:
parser:didEndElement:namespaceURI:qualifiedName:
parser:foundCharacters:

The didStartElement is called when the XMLParser encounters a opening XML element. You usually initialize temporary variables and read attributes if any in this function. In case of bit.ly, you just have to read the "shortUrl" element. Just handling this element alone will do.

ShortURL from bit.ly

ShortURL from bit.ly

Declare the following NSStrings, currentShortURL, actualShortURL and currentElement.
Write the following code into the didStartElement Block.
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
currentElement = [[elementName copy] autorelease];
if ([elementName isEqualToString:@"shortUrl"]) {
currentShortURLString = [[NSString alloc] init];
}

Now, in the foundCharacters block, write the following code.
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
if ([currentElement isEqualToString:@"shortURL"]) {
[currentShortURLString appendString:string];
}

In the didEndElement block write,
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if ([elementName isEqualToString:@"shortURL"]) {

actualURLString = currentURLString;
}

Now when the parsing ends, just after the [parser release] function, actualShortURLString will contain the shortened URL.

End of story. If you couldn't follow the code in this blog post, you can always download the source code attached (in next part). For more detailed information on parsing using NSXMLParser follow this article.

Parsing JSON

Parsing JSON is much simpler than XML. In fact, I hate to call it as "parsing" as you don't even have to write a parser!!! By using the open source json-framework kit for iPhone you can easily "convert" a JSON string into a NSDictionary. Now let's have a look at the code.

JSON Parsing Code

JSON Parsing is far much simpler than XML. Infact, the code attached below uses JSON.

Parsing the bitly information is as simple as writing these three lines of code.
SBJSON *jsonParser = [SBJSON new];
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSDictionary *dict = (NSDictionary*)[jsonParser objectWithString:jsonString];

The return string is a dictionary of key value pairs.To read a value, you can call objectForKey function within NSDictionary.

In most cases, including bit.ly, JSON return strings always contain other dictionaries nested within itself. To read a value within a dictionary, just nest your calls  like this.
NSString *shortURL = [[[dict objectForKey:@"results"]
objectForKey:f_longURL]
objectForKey:@"shortUrl"];

Source Code and Documentation

The source code and documentation on how to use this is explained in post 2.

Help your visitors with a *useful* 404 Error page

August 5th, 2009 by Mugunth Kumar

A 404 Error page usually informs visitors that something they were looking for is not found. I wanted to create a useful 404 error page for my blog and site. If it is only for a blog, I would have done with a multitude of plugins available for Wordpress like smart 404, AskApache’s Google 404. A quick search for “404″ in wordpress extension site will reveal atleast 6 pages of extensions.
But much to my bad luck, they didn’t fit my “requirements” properly. I needed a redirection page that would show related search results straight on the page itself.

[ad#AdBrite-Post]

Google’s creating useful 404 pages didn’t work out either as it offered only to show me a text box with keywords pre-populated. I wanted something similar, but with the results of the search in the 404 error page itself, just like the AskApache’s Google 404 plugin. The smart 404 plugin didn’t work for me and many others as well after 2.7.1 upgrade. The askapache needed some .htaccess tweaking which is handled very poorly by godaddy’s Windows hosting. So I decided to write one myself and the result is what you can see here

The first thing I did was to change godaddy’s default error behaviour to redirect to a custom error page titled 404.html just under my root. After about one hour or so, my site got updated and all the 404 behaviours were directed to my page.

[ad#AdBrite-Post]

There are two ways (atleast that which is handled by my 404) in which one would come to your site. One is by typing the URL wrongly or from a old outdated bookmark. Or from one of your old blog redirection. In my case, my old blog was at blogger.com and I’ve set it up to redirect to my new domain. However, because I changed my permalink settings to avoid showing the classic year/month in the URL, all my redirection from blogspot.com were hitting 404’s… :( If smart 404 worked as promised, i would have been happier. But unfortunately, even after the release of 2.8.3 (at the time of writing this), the plugin didn’t work. So the first thing I did was to extract keywords from the referrer url, document.referrer. In case the document.referrer is empty, it means the user has typed a wrong url in the address bar or followed a old bookmark. In that case I extract keywords from document.location.href, which is the wrongly entered url. I strip of everything except the post name which by far has the most keywords related to the URL and pass it to Google AJAX Search API.

Based on inputs from various other sources including my favourite Jakob Nielsen’s suggestions, I decided that my 404 should look like a real *error* page rather than a blog post. It should possibly have a sitemap if it’s a website or links to popular posts in case of a blog. It should take your users to important places in your website as in my 404 page offers links to my homepage and blog. Above all, it should have a search box where user could search for what he was looking for without hitting the browser back button.

My version of 404 error page looks like this.

404 Error page @ mugunthkumar.com

404 Error page @ mugunthkumar.com

It uses plain html and javascript. It’s not a server scripted file like PHP of ASPX. You can go ahead and copy the file (Cmd click -> View Page Source) from my error page and use it in your own site. I would be glad if you could attribute me by linking to this post or blog, though it’s purely optional and I leave it to you.

Tip: Displaying a banner (or crash IE) when people visit your site using IE6

July 28th, 2009 by Mugunth Kumar

You must be knowing that Youtube, displays a subtle warning when users visit it from IE6 browser. Though everyone knows that IE6 is the most crappy browser on planet Earth, corporates are still hesistant to migrate to other Microsoft browsers or from other Vendors like Mozilla/Google/Apple.

To make more and more people aware of the security risks involved with IE, a whole lot of campaign started on Twitter, including  adding a Twibbon to support a cause, “IE 6 must die

You as a wordpress self-hosted user can also help the cause, by installing this plugin.

http://www.incerteza.org/blog/projetos/shockingly-big-ie6-warning/

Thanks to incerteza.org

PS: I have added it to this blog. Try visiting it from IE6. You will see somthing like this.

IE6 Warning

Warn IE6 users about it's pathetic security holes...

The plugin can also be configured to crash your visitor’s browser if they visit from IE6!!! Super cool!!!

incerteza.org rocks..! Doom to IE6…


Mugunth

How to: How to tweet from Office?

July 27th, 2009 by Mugunth Kumar

Some companies have blocked twitter thinking that it’s another facebook. For people who have an iPhone, this is not a problem. But for those who don’t have a mobile access to twitter, and if company has blocked access to “twitter.com”, you think you are out of luck.

Even plugins like TwitterFox or Twitter Clients like TweetDeck doesn’t work as they also have to cross your company’s firewall. Yet not out of luck.  Fortunately, there is a work around, that your company can never prevent.

Welcome to the world of Web Apps. Though a variety of web apps are out there, my favourite one is Seesmic. Login to Seesmic and authenticate using oAuth. You may have to access a *.twitter.com URL. Note that this has to be done only once. Either do it by tethering or do it when you carry your laptop home.

Once you are authenticated, Seesmic can act like your web based twitter client. But wait…! What if your office blocks access to Seesmic? There is yet another work around. Thanks to bit.ly!

How to Tweet from Bit.ly

How to Tweet from Bit.ly

link your twitter account with bit.ly by clicking the Advanced options. Again this is required only once. After linking, you can tweet directly from bit.ly. There is one catch however. You can only post tweets but cannot view it. If you know any other way, do post them in comments.

Mugunth

Usability Analysis – Office 2010 on Windows 7

July 24th, 2009 by Mugunth Kumar

If you were following my tweets, you might be knowing that I got a invitation from Microsoft to test Microsoft Office 2010.

Invitation to test Microsoft Office 2010

Invitation to test Microsoft Office 2010

Yeah, From the screen shot it should be evident that I’m using a mac now. I testing Office 2010 by installing it on my Windows 7 Virtual Box image. Being a usability guy myself, In this article, I will primarily focus on usability aspects of Word, Excel, PowerPoint and Outlook. I haven’t used OneNote or any other software that comes with Office. Again, feature wise, Microsoft has added a lot new things to Office 2010 (so they say…) If you want to know more about those features, head on to http://www.office2010themovie.com/ Before I wrap up, I will also touch up some minor UI glitches in Windows 7, lack of uniformity in the UI, and what I find interesting.

[ad#AdBrite-Post]

So lets get started.

Word

Splash screen of Word 2010

Splash screen of Word 2010

Whoa… That little splash screen was animated!!! and it lasted only for a second or so. Word 2010 opened up near instantaneously. I was running within a VirtualBox. So I expected it to be slow. Yet to my surprise, the startup was fast. On a real PC, i think one wouldn’t even notice the splash screen. It’s really super fast.

The first thing one would notice is the new “Office Button” The already awesome Office Fluent UI (Codenamed ribbon) has gotten some tweaks especially the Omnipotent Office Button. Clicking that button takes you through a great looking “task centered” page dubbed as Outspace.

Clicking the Office Button reveals this "Omnipotent" UI

Clicking the Office Button reveals this "Omnipotent" UI

The tasks are grouped (highlighted in orange in the screen shot above) elegantly. Clicking a group brings up a separate pane where actions related to that group can be performed. In the above screen shot, what you see is the actions related to the “Info” group. But I’ve a little gripe here. There is no visual cue that a group can be clicked. It appears as if only the buttons are clickable. Moreover, going by classical Windows (or Mac) philosophy, a menu option is usually suffixed with a ellipsis (…) when clicking an item brings up a new dialog or something. However, this guideline was not followed in designing this UI. As such, it’s quite confusing to know what’s going to happen if I click something, before actually clicking it. Small things, but one should really put some effort on the usability aspect of things rather than focusing just on aesthetics.

Second thing I noticed was the support for other open formats. Interestingly (or EU Court pressure?) Office 2010 supports Open Office’s ODT file format natively.

Native Support for OpenOffice Files

Native Support for OpenOffice Files

Nice move from Microsoft which I think many of us will like. Even throughout Windows, I noticed Microsoft’s love (or false love?) for open formats. In fact MS Paint, now saves files in PNG format by default as opposed to Windows Bitmap file!

[ad#AdBrite-Post]

The Office Fluent UI (Ribbon) didn’t have any major UI uplifts. But that should probably because it’s already awesome. Neat and task oriented. However, I still miss the “Search Commands” plugin in Office 2010. Though there is a version of Search Commands plugin that works with this technical preview, In my view, this should be a part of default installation. With over 2000 commands in Office, it’s simply impossible to remember everything. So is the options dialog.
When Microsoft Office 2008 on Mac can include a search button why not Office 2010 on Windows?

You can spotlight for commands in Word 2008 for Mac (but not on Windows)

You can spotlight for commands in Word 2008 for Mac (but not on Windows)

I can’t understand this. If Microsoft can do it for Mac, why can’t they do the same for Windows…? As of Office 2007 the Options pane UI is too clumsy. It still remains clumsy in 2010. Not much changes from 2007 to 2010.

Much of the functionality and features remain the same. However, there was tighter integration with SharePoint Server and Office for Web. If you are going to use it only as a client software, then I would say there is no point in buying 2010 (if you are already using 2007).

Excel

Similar to Word 2010, much of UI part of Excel remained the same. I remember Microsoft shunning Multiple Document Interface long long ago. But still, even in 2010, Excel remains *partly* MDI. People really need to compare two Excel sheets side by side.But even with the excellent Window Management (esp Aero Snap) of Windows 7, because of the MDI nature of Excel, you got to open two instances of Excel to compare them side by side. The screenshot below should illustrate my thoughts.

Excel is still MDI in Office 2010

Excel is still MDI in Office 2010

Moreover, by default, a “New Excel Sheet” opens within the same instance. And, if you have Excel pinned to your Taskbar, clicking on the Excel icon on the taskbar when an instance is already running, just brings that instance to front. If at all you want to open another instance(for comparing two excel sheets), you got to open it from the Programs list. From the above screenshot, you can see how difficult it’s to compare two documents that lie entirely within the application. It defeats the very purpose of all the innovative windowing mechanism brought into the Windows 7.

In the screen shot below, I can easily compare two word documents side by side using this Aero Snap feature.

Comparing Files using Aero Snap is easy because Word is SDI

Comparing Files using Aero Snap is easy because Word is SDI

This is something Excel should have. But atleast for the past ten years (from office 2000), Microsoft has not looked at the usability aspects of Office. I agree, they have been innovating on the SharePoint side, but at the same time, minor usability aspects like this should be addressed. You can’t ignore these issues for over a decade.

The MDI document management model itself is decade old. For example, in the screen shot below, you can’t even close an inactive Window without making it active. Where as elsewhere in Windows, you can.

The inactive sheet has to be made active before you can close it

The inactive sheet has to be made active before you can close it

[ad#AdBrite-Post]

When Windows 7 is superior in Window Management, why not leave the Window Management aspect of the application to it? Simply un-acceptable. This minor glitch has been in Excel for over a decade (from 1997 I suppose). Microsoft itself has moved away from MDI when they moved from Visual Studio 6 to Visual Studio .NET (2001-2002 timeframe). But even in 2010, Excel remains in MDI.

Outlook

When I first started Outlook I was greeted by the Outlook Wizard. It seems like, Outlook 2010 supports SMS, though I didn’t test it out.

Does Outlook 2010 support SMS?

Does Outlook 2010 support SMS?

Thankfully, GMail IMAP configuration was easier than Outlook 2007. If I’m not wrong, Outlook 2007 by default configures POP3 and we as a user have to go through various settings pane to change it to IMAP. But in Outlook 2010, the default mail configuration was IMAP. Happy!!!

However, My first experience was quite bad. Outlook crashed! Restarted it, and it went on fine though. It could even be because I’m running on a VM. But what really frustrated me is the UI. Why doesn’t Microsoft follow their own UI conventions? Why is this Windows 2000 like UI appearing on Outlook 2010?

Outlook Bug UI Issue

Microsoft says it has scrapped off Windows Classic UI in Windows 7. Then from where did such a button come from? With Vista, Microsoft moved the OK button from center to right. Alongside, they should have changed it’s appearance to match the OS it’s running on. But they didn’t. I’m not stressing on the aesthetics here, But the uniformity. If’ I’m running Aero, I should see Aero themed buttons, and not Windows Classic buttons. This kind of uniformity mismatches are spread throughout Vista/Windows 7.

Another such example is the “End Program” dialog.

Again Bad Button

This one is a normal "Not Responding" window.

Why Microsoft, Why? UI Anomalies, can easily frustrate an already frustrated user. Consistency and standards is a very important usability evaluation heuristic.

Microsoft said, Office 2010 will be more “task centric”. Meaning that new workflows, for doing the same thing etc., should be present… But unfortunately, apart from the Office Button UI, not much has changed. The below is a screen shot of the “Mailbox Cleanup”

Old Old Mailbox Cleanup Dialog

Old Old Mailbox Cleanup Dialog

The thing is already complicated. If Office 2010 is “task centric”, there should be some other easier to use dialogs/interfaces for doing the same task. But when you click the “Cleanup options” from the Office Outspace, this same old dialog pops up. I don’t understand how can this be called as “task oriented”. The Office Outspace innovation should have been implemented throughout.

[ad#AdBrite-Post]

Conclusion

To conclude, I didn’t find anything enchanting in Office 2010, apart from the “Outspace” UI. But Office 2010 was a bit faster compared to Office 2007. If you are already running Office 2007, I don’t think there is any compulsion to migrate to 2010, but if you are still using 2003, Office 2010 is a must buy. Infact in the entire era of Microsoft Office, I would support only Office 97 and Office 2007 (and maybe Outlook 2003 for it’s spam protection). Everything else were sort of minor updates. Microsoft should really consider making the “Options” dialog more task oriented. A kind of ribbon innovation and they should incorporate the “Search Commands” plugin into the Fluent UI by default. That would really make Office 201X a great update. Let’s see…

Elements of Usability Design: OK/Cancel vs Cancel/OK – Is it just a matter of taste?

July 19th, 2009 by Mugunth Kumar


OK, many of the programmers would have been confused as how to design a dialog on your website. In what order should the dialog contain the OK and Cancel Buttons? Should it be OK – Cancel like Windows or Cancel – OK like the Mac? Are there any “rule of thumb” why a certain standard should be followed? Or is it just a matter of taste?

Firstly Apple’s Human Interface Guidelines state that, rather than OK or Cancel, use the action verb that determines what the user is going to perform. KDE for Linux and Microsoft’s own Human Interface Guidelines also state the same. For example, the screenshot of Smultron, (a text editor I use extensively on Mac) shows the dialog like this.

Smultron - Shows Save/Don't Save over OK/Cancel

Smultron - Shows Save/Don't Save over OK/Cancel

If you have been using a Mac extensively, you would note that, majority of application use this philosophy. The reason? Minimalist Design. Your UI shouldn’t be cluttered. A traditional Microsoft dialog would be like,

The document has unsaved changes. Quitting this application will really make you lose all your changes. If you really want to lose them click OK, else click Cancel

What’s the problem with this design? – Lack of minimalism.
People prefer minimalistic user interface.
According to Jakob Nielsen’s Heuristics for User Interface Design, one of his heuristics for usablity design states that,
Dialogues should not contain information which is irrelevant or rarely needed. Every extra unit of information in a dialogue competes with the relevant units of information and diminishes their relative visibility.

In the Smultron’s case, the user needn’t even read what the Application is trying to say. The buttons are marked clearly and user can click an option with confidence. It follows minimalism. Mac users appreciate this minimalism. The UI is uncluttered with unwanted options unlike Windows.

Look at this screenshot taken from Office 2010. It has a option to open System Information dialog from the About box. A legacy followed for atleast a decade.

Why do we need a shortcut to system info dialog from Outlook?

Why do we need a shortcut to system info dialog from Outlook?

Users will only be confused with this kind of workflow, wherein I have to open outlook to see my system information. A minimalistic UI shouldn’t be cluttered like this.

OK, if Microsoft is making these kind of silly usability mistakes, why should Windows programmers also follow the same cluttered, “un-minimalistic” UI design? Don’t shout at me, I’m also a Windows Developer. The reason, until Windows Vista, a Windows Programmer cannot (atleast easily) change the OK/CANCEL or ABORT/RETRY/CANCEL text from a dialog. Only with Vista (how many years after Mac???) did Microsoft introduced Task Dialog. Only with a task dialog can the developer change the button face text easily. You might have noticed the changes in Windows Vista’s Notepad or Paint’s dialog. Only with better SDK, can we deliver quality products.

Paint Save dialog

Now coming to the order of buttons, our main topic, after a useful digression, should it be OK-CANCEL or CANCEL-OK? Mac introduced GUI far before Windows (of course Apple copied it unabashedly from Xerox PARC Labs).

I would say if you are a platform developer, follow the platform conventions. For example, iTunes on Windows follows Microsoft’s conventions of OK-CANCEL rather than CANCEL-OK like Mac.

iTunes preferences on Windows Vista

iTunes preferences on Windows Vista

So is Microsoft Office on Mac.

Preferences Pane of Word 2008 for Macintosh

Preferences Pane of Word 2008 for Macintosh

Why is this so? Because you should not confuse users. Cancel – OK might be superior for Apple. But when it comes to Windows development, they follow the platform conventions. So did Microsoft.

Now, with more and more applications moving towards web and cloud computing is taking the norm, which philosophy should your web application follow? Now that’s an interesting question. Apple chose that any “positive action” should be on the right and negative actions should be on the left. Why? Because the real world has been modeled like that. See this link (opens in new window). Long long ago, when people hated left handers, they used the word “gauche” (which actually means left) for anything that’s awkward and now Oxford says the meaning of gauche is awkward.. Slowly, it has been hardwired into our brain that left means something awkward. Another reason, why over 75% of countries drive on the right is because of this. (Though driving on the left has recorded lesser accidents because, when you drive on the left you can react quickly to oncoming vehicles which is to your right).

Apple’s philosophy of choosing positives on the right can be seen throughout the UI. The desktop icons are aligned from the right. Any task panes/toolboxes are placed on your right (unless you are a left handed person, you usually leave your pen on the right side of the writing pad isn’t it?)

The close button is placed on the left top corner as opposed to the right corner. The “Don’t Save” button is to the left of the Save button.

Tasks pane on XP

Tasks pane on XP

Office shows the tasks pane on the right

Office shows the tasks pane on the right

Microsoft never follow any sort of convention. Windows Explorer’s tasks are placed on the left where as Office shows its tasks pane on the right. I’ve literally no idea, why it’s like this by design.

Web applications like Wordpress uses this convention.

Publish button is to the right, Delete is to the left.

Publish button is to the right, Delete is to the left.

Even Microsoft’s Bing uses this convention!!!

Even Bing uses this convention!

Even Bing uses this convention!

The download button is to the right. The normal Microsoft convention is to have it at the center when there is only one button. Any website you visit will have “Actions” to the right and “Navigation” links to the left. For example, your shopping carts are always to the right in a majority of cases.

Though Windows had a huge market share, why did web developers stick with the Mac way of doing things? Because the browser philosophy was like that. To go the the previous page, you click the button to the left, to move forward, you click the button to the right. The philosophy is, to progress forward click the “Right” button. A variety of web forms use this philosophy. Look at the location of “Sign in” boxes on Yahoo and Gmail. They are placed on the right.

Now, critics claim that since English is written from left to right, the icon ordering and the order of buttons should follow the other way round. If I’m not wrong, the world’s first written language, Chinese (not the Mandarin flavour) was written top to bottom, right to left. Why did the chinese wrote that way? Because, intuitively, it was the most comfortable way to read. But when the printing industry took the centre stage, to facilitate easier printing and easier stacking of the character moulds, they followed this left to right norm and it still stays like that till date. Sometimes technological limitations force us to do things the wrong way. We all use QWERTY keyboard over DVORAK keyboard though DVORAK was designed for humans and is ergonomically superior to QWERTY. It happens. Can’t help it. But don’t let something like that happen again. You may end up getting carpal tunnel like syndromes for your eyes!

So in my opinion, ordering of buttons or layouts is not just a matter of taste. Follow platform conventions when targeting a platform. Else follow the “Apple way” or the right way.

Mugunth

Review: iTech Clip Music 801 (Bluetooth Receiver for iPhone 3G)

July 18th, 2009 by Mugunth Kumar

Bluetooth receivers come in various forms and shapes… They “claim” that they support A2DP and AVRCP. So do mobile phones. But not all models of receivers “play nice” with all phones.
In fact, if you read the “fine prints” in the user manual, you might even encounter something like this…

This product *may* work. We don't guarantee anything...!

This product *may* work. We don't guarantee anything...!

[ad#AdBrite-Post]

So,that doesn’t mean this product didn’t work as expected, but before buying any bluetooth device, try it out first. If none of your friends have the device to test it for, buy it from IT Show or Electronics Fair where they usually have a couple of products to test compatibility. Usually the shop from where you bought will NOT give you a refund if your mobile doesn’t work with the receiver…

Now that doesn’t mean that this device doesn’t work with iPhone. It works fine though I have some complaints. Before buying this device I got a Philips SHB7100 as it had previous and next track buttons separate from volume control button.I should have done a basic search on the Internet. The third link was someone complaining that this thing doesn’t work with iPhone 3.0 software update. :( Pretty unfortunate. I sold it out at hardwarezone.sg and got this iTech Clip Music 801.

iTech Clip Music near a 20 cent (SGD) coin

iTech Clip Music near a 20 cent (SGD) coin

Though it looked a bit bulky, the build quality was good unlike the Philips SHB7100 and it was very lightweight. (15 gms) After opening I paired it with my iPhone 3G. Pairing was a breeze, and quick. iPhone recognized the device as a headset and seamlessly switched the music through the device. The iPod screen will look like this if your pairing is successful.

iPod App Paired with Bluetooth Receiver

The volume control will be replaced by “Clip Music 801″ and the blue tooth icon.

Oh No!!! the volume control is gone!! was my first reaction.

I tried increasing the volume through the hardware button. No luck. Seems like the device volume controls are the only way to increase/decrease the volume. With the iPhone 3.0 software, the previous/next controls  also didn’t work though it worked with the Mac.Apple might soon release a bug fix.

Coming to the audio quality, it was good though there was some compression artifacts. The sound had clear mids, deep bass but the trebles and highs was slightly missing, which is noticable even if you are NOT an audiophile. However, it can be easily adjusted by choosing a different eq setting. I usually use “Bass booster” on my iPhone. Changing it to “Classical” did the job. No wonder, Apple chose Wifi for their AirTunes rather than bluetooth. The volume was pretty loud, as if the earphones are directly plugged into the iPhone.

Phone voice quality was awesome. The microphone picked up even the lightest sound (though not the background sound). However, while listening to music, when you get an incoming call, the music doesn’t “fade out”. All of a sudden you will hear the ringing tone. The tone is not your ring tone but a different tone played by the headset. When the call ends, the music doesn’t start automatically. You have to manually press the “Play” button.

Quite cumbersome, but still manageable.

Similarly, when you remove your headphones from the headset, it doesn’t pause the music like how it happens on the iPhone. However, when you insert the headphones into the iPhone, music is automatically routed through the plugged in headphones. When you remove it, music is streamed through the device. Nice little feature.

[ad#AdBrite-Post]

As with many other devices, the music DID skip or “miss a beat” because of bluetooth streaming but it was not very obvious. I had a very nasty problem with my old Philips SHB7100 paired with my mac. Now is it very obvious? It depends. If your iPhone is not “busy” doing other things, the audio is smooth. When you are downloading an email attachment, you might get some stutters. Browsing the Internet on WIFI causes the audio to stutter a LOT. LOT means a LOT! Like, as in twice every 5 seconds. Once the page is rendered fully, it resumes normally. Note that browsing on 3G doesn’t cause issues. I think it’s because the bluetooth and WIFI are actually present within the same chip.

All these artifacts are only when you pair it with the iPhone. When I paired it with my mac, there wasn’t any stutter. I could be in the same room, or nearby rooms so long as the distance is less than 5m. But the compression artifacts, were still obvious. Voice calling were working even at far distances though and was clear without skips. This headset even has a “cool” feature called distance alert that will ring a tone when you move away from your mobile phone. So you won’t miss your phone at the restaurant table :D

However voice calling through Skype or Fring didn’t work via bluetooth. The “call connnect” and “call disconnect” tones are routed through bluetooth but calls aren’t. Pretty bad Apple. Pretty bad. On the Mac also, I could see the same behaviour. Skype calls weren’t routed through bluetooth though the ring tones were. Not sure who is the culprit. Games were however not affected.  Sound is routed through bluetooth in this case. I think it’s because the “headset” profile is not accessible to other applications but the “headphones” profile is.

To wind it up, I should say that this headset is good. A 3.5 star rating. However, The technology still has to mature. Compression artifacts are still noticable and A2DP is definitely not for the audiophiles. But for casual music listeners, and specially gamers, cutting the cord is more important that those slight sound artifacts. Playing a game with your iPhone accelerometer without the earphone cords hanging around is really a boon.

iPhone App Review: Boxcar “Pushes” Twitter notifications

July 16th, 2009 by Mugunth Kumar

Well, you know that there has been a lot of twitter clients like iTwitter that already offer push. So why another push notification app for Twitter? what’s so special about this app? -
In one word, It’s innovation…

In my review here, I’ve splitted it into two parts. What’s great vs What’s missing…

[ad#AdBrite-Post]

What’s great about Boxcar Push Notifications?

- You don’t have to switch to a different twitter client. This is a great boon for me. i just love using both Twitteriffic and Tweetie. Boxcar supports both and they even claim to support Twitterlator Pro in a later release.

- OAuth authorization which means, you don’t have to share your password with yet another third-party guy. finally OAuth done elegantly on a client app. Man of Tweetie, Loren Brichter, Please note this… Enough of cribbing

- Speed of push: Boxcar checks your twitter account every two minutes. Much faster than a majority of twitter clients out there. In my testing it was faster that Tweetie on Mac to recognize a @mention

What is missing from BoxCar Push Notifications?

-Badge icons on BoxCar app is missing when you get  a new @mention. The alert sound you get is loud and is similar to the SMS message tone. So I disabled “Sounds” expecting to see the badges pushed. But, no luck there… :( You can see that from my home screen here. I just love the subtle sound of Mail’s alert tone.

Boxcar Push shows only alerts not badges.

Boxcar Push shows only alerts not badges.

The “B” icon, Boxcar’s app icon doesn’t seem to show the count. This happens even when alerts is turned off.

-Second thing, though not a huge issue for me, *could* be a deal breaker for some. I’ve got just 400 followers and I get atleast 25 @mentions a day. For hard core twitter users, It would be great if Boxcar supports twitter user groups and push notifications only for those users. I don’t think that would be too difficult for those guys…
[ad#AdBrite-Post]
Though these two are not a deal breaker, Boxcar is definitely a great buy for 1.99$. Go get it from AppStore now… or visit their website here…

iPhone Tutorial – In-App Email

July 15th, 2009 by Mugunth Kumar


Sending an email from your iPhone application is something which you normally want to do it asynchronously. But unfortunately, prior to iPhone 3.0, the only way to send email was using mailto:// url format. i.e,

[[UIApplication sharedApplication] openURL: @"mailto:john.appleseed@apple.com"];

The technique was clumsy for one reason.

It quits your app and launches mail. To our rescue, comes in-app email.

In-App email is not something new in iPhone 3.0 software. For the end users, it was available from day 1. Remember the Photos app? It sends your photos attached in the email message without quitting? But third party developers like us, were not given access to those private APIs.

In iPhone 3.0 Apple has exposed this private API with which you can send emails without quitting your application.

Sending an email with this technique might not be as easy as one single function call which we saw earlier, but at the same time it’s not complicated like “Push notification”. With less than say 10 lines of code, you can get the in-app email up and running in your own app. Now, let’s see how to do that.

I’m not going to attach any source code or like. The best source code that anyone can write is already available from Apple. Search for MailComposer or click the link below.

https://developer.apple.com/iphone/library/samplecode/MailComposer/index.html (link opens in new window)

There isn’t however a walkthrough though, which is why I thought I could bridge the gap ;-)

To summarize, there are 4 main steps (and 1 other not-so-important) in this.

1) Add the MessageUI Framework to your project

2) Add #import <MessageUI/MessageUI.h> line to the file where you want to use in-app email

3) The real code to show the UI as a modal dialog.

4) Implement a callback delegate so that you know when the user (and system) has finished sending the email.

Let’s get started.

Importing the MessageUI should be a cakewalk. On your XCode window,right click/cmd+click the “Frameworks” folder and click Add -> Existing Framworks. Choose the MessageUI from the path illustrated below.

Adding MessageUI Framework to XCode

Adding MessageUI Framework to XCode

Step 1 – Done

2) The second step needs no special explanation.

In your view controller, you will be using the classes in this framework. So #import the necessary header file, MessageUI/MessageUI.h

Do this #import on the h file rather than the m file as, you will be adding a delegate later (in step 4) to your ViewController.

Step 2 – Done

3)I’ve written a nifty little function that does the complete email sending logic.

The code is here. Feel free to use it in your apps, (attribution not necessary, though I would be happy if you do so)

-(void) showEmailModalView {

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self; // <- very important step if you want feedbacks on what the user did with your email sheet

[picker setSubject:titleText.text];

// Fill out the email body text
NSString *pageLink = @”http://mugunthkumar.com/mygreatapp”; // replace it with yours
NSString *iTunesLink = @”http://link-to-mygreatapp”; // replate it with yours
NSString *emailBody =
[NSString stringWithFormat:@"%@\n\n<h3>Sent from <a href = '%@'>MyGreatApp</a> on iPhone. <a href = '%@'>Download</a> yours from AppStore now!</h3>", content, pageLink, iTunesLink];

[picker setMessageBody:emailBody isHTML:YES]; // depends. Mostly YES, unless you want to send it as plain text (boring)

picker.navigationBar.barStyle = UIBarStyleBlack; // choose your style, unfortunately, Translucent colors behave quirky.

[self presentModalViewController:picker animated:YES];
[picker release];

}

The first step is to create the view for the email class. For that we use the MFMailComposeViewController.

Subsequent steps are to fill in the subject, (ToAddress, CC etc also can be filled from [picker setBlahblahMethods]) and messagebody. Usually, you leave the addresses to be filled by the user. Until the user fills the “To” field, the “Send” button will not be enabled on the Email sheet.

You can choose a color for the in-app email sheet. Unfortunately translucent sheet behave a bit quirky. For me the To address field was getting hidden beneath the translucent toolbar. :( I may be wrong.

Finally call the presentModalViewController to display the email sheet.

Step 3 – Done!!!

4) Now, you need to implement a delegate that will be called when the user taps the “Send” button on the mail interface. Luckily, it’s again a simple thing… :D

For this delegate to be called, you have to set the picker.mailComposeDelegate to self before calling the presentModalViewController (this line is shown in bold in step 3)

If you compile the app, XCode will complain that your “MyGreatAppViewController doesn’t conform to  MFMailComposeViewControllerDelegate protocol. Though it’s a warning and can be ignored, for the sake of writing “quality” app, add the “MFMailComposeViewControllerDelegate” to your protocol handler list like this in the header file.

@interface MyGreatAppViewController : UIViewController <MFMailComposeViewControllerDelegate> { }

This is the reason why I advised you to add the MessageUI header imports in the .h file in Step 2. Now in your .m file, add the following block of code that handles the delegate.

// Dismisses the email composition interface when users tap Cancel or Send. Proceeds to update the message field with the result of the operation.

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error

// Notifies users about errors associated with the interface
switch (result)
{
case MFMailComposeResultCancelled:
break;
case MFMailComposeResultSaved:
break;
case MFMailComposeResultSent:
break;
case MFMailComposeResultFailed:
break;

default:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@”Email” message:@”Sending Failed – Unknown Error :-(
delegate:self cancelButtonTitle:@”OK” otherButtonTitles: nil];
[alert show];
[alert release];
}

break;
}
[self dismissModalViewControllerAnimated:YES];
}

Relax! Not the whole block is important. just write the last line,

[self dismissModalViewControllerAnimated:YES]

and that will do. The other lines are given here for the sake of completion. You can handle those situations if you want.

As of now, there is no delegate method that would report the percentage of the mail that has been transmitted (so that you can display a progress like the Mail app. But hopefully, with subsequent releases of the SDK, apple could open them up as well.

Step 4 – Done!!!

Now, just call

[self showEmailModalView]

where you want the sheet to be shown. That’s it.

Now…. One more thing… ;-)

iPhone users have migrated to iPhone 3.0 (atleast over 75%). iPod touch users still haven’t (atleast at the time of writing this article). How will you handle a situation where in the user using your app is still running iPhone 2.x software?

Fortunately, Apple has provided a simple one-liner to tackle the situation. Just check it by calling canSendMail method

[MFMailComposeViewController canSendMail]

If canSendMail, then call my showEmailModalView function, otherwise, fall back to the tradional way. This handling is explained elegantly in Apple’s source code MailComposer.

https://developer.apple.com/iphone/library/samplecode/MailComposer/index.html (link opens in new window)

That’s it for this tutorial. Hope you enjoyed it and Thanks for visiting my blog,

Update: (28th August 2009)
Two commenters have asked me for sending email without showing the UI.
I think it’s not that easy. You have to use a SMTP client like http://code.google.com/p/skpsmtpmessage/
This blog explains how to send emails in the background without user intervention. But I’m not sure about Apple approving such apps however… :(

SingTel BBoM iPhone App (SG BBOM)

July 14th, 2009 by Mugunth Kumar

SG BBoM iPhone App is designed specifically for use with SingTel mobile broadband plans. The rationale behind this development is, SingTel doesn’t send you an SMS or alery when your mobile broadband data charges over shoot the free limit. Overshooting the free limit even by a 100MB could cost your dearly.

According to SingTel

Excess usage will be charged at $0.01/2KB. Which means, a megabyte of data, (1024KB) will cost you about 5$.

To give you a analogy, a newyork times webpage will be around 500KB. Browse 10 such pages, you end up paying your soul to $ingTel.

SingTel already provides a web interface to check your data usage

http://home.singtel.com/bbmobile/datausage.asp

But because it’s not a light weight page, many of us don’t bother to check our data usage everyday.

Now here comes a handy little app to check your Broadband Usage on the Go on your iPhone.

Checkout more about this app on it’s page. SG BBOM.

Note: This app is still under review by Apple. Will update this blog once it’s done.

Update: 5th August 2009: Apple has approved this app… Click here for the app. SingTel BBOM (iTunes Link)

Setting up XCode 3.0 with SVN

July 11th, 2009 by Mugunth Kumar


Everyone knows SVN (Subversions) is the best version control tool on the planet. XCode, though, might not be as great as eclipse or Visual Studio, it offers one of the best integration with open platforms than both eclipse and Visual Studio.

Apple scripting and XCode makes XCode even more powerful. In fact you can set up keyboard shortcuts to directly search the selected function name or keyword on Google or Apple Docs. (Visual Studio doesn’t offer this support (or atleast that I’m not aware of) But more on that on another post.

Let’s come to the point.
Myself being a iPhone developer, I didn’t use SVN for a long time as a majority of tutorials out there are either too complicated or not direct to the point. Finally I managed to find out a way to use SVN with XCode. In this post, I attempt to take you through one of the easiest way to configure SVN to work with XCode.

[ad#Google-Post]

Pre-requisites:
I assume that you have already installed XCode. If not, go download your copy from iPhone developer center for free.

First, ensure SVN is installed on your mac.

Your Mac normally comes with SVN installed by default. To check whether its installed, open Terminal.app (I really don’t have any idea where it’s located, Spotlight “Ter” and Boom! there you go…!)

Type, the following

svn  --version

in the prompt.

You should see something like this…

Type SVN --version to check the version of SVN installed on your mac

Type SVN --version to check the version of SVN installed on your mac

If not SVN is not installed on your machine. But this should normally not be the case. If that happens to you, install SVN Server from https://opensvn.csie.org/

SVN Client Configuration

Many other sites advise you to download Versions. Though it’s good and it comes clean client. I don’t see a value @ 39 pounds (100 Singapore $) I’m not aware of any free alternatives. But the good news is XCode comes with a very limited XCode client.

Limited as in, It can connect to an existing repository, but not create one. So committing and checking differences shouldn’t be a problem. However XCode doesn’t have the ability to add your project to a SVN repository. So you have to do two things using the SVN command line.

1) Create  a SVN repo

2) Add your project to the created repo.

After these two steps are done, you can use XCode to checkout the files, commit changes directly from XCode.

Let’s see these two steps with illustrations.

[ad#Google-Post]

*** BEWARE *** these two steps involve command line. But the good point is, its not complicated.

Step 1:

Type the following command into Terminal

svnadmin create /Users/<mugunthkumar>/tempsvn

You should see the folder /tempsvn created under your user directory with the following sub directories.

Sub folders created for a SVN repository

Sub folders created for a SVN repository

You don’t have to touch any of these. This is just to confirm that the svn create command has indeed worked.

Whoa… Step 1 is done!!!

Relax

Step 2: Create a SVN repository and import your project into it.

This step is easy. But not as easy as the first step. In Terminal prompt, ls to the folder where you have your source code files.

[ad#AdBrite-Post]

*** IMPORTANT ***

For importing into SVN repository, you have to copy the files you want to import into an empty folder. This is because, if you want to import a folder /Source which contains some files and some sub folders, the import command will not add the folder /Source to the repo. It will add only the *contents” of the folder /Source. This is not what we normally expect.

So, to import your files into the repo under a folder /MyGreatApp, you have to create a folder called /Temp (or anything) and copy your /MyGreatApp folder into /Temp and import /Temp into your project. Don’t worry, the /Temp doesn’t get created in your repository.

Yeah, i know it’s quite counter-intuitive. But you don’t have a choice. Now let’s get started.

Create a directory (I’ve chosen Temp in the example). Copy your code directory “MyGreatApp” into this Temp. Do all these in Finder. Now open Terminal and ls to the directory about “/Temp”. and type in this command into Terminal

svn import -m "Comment goes here" ./Temp file:///Users/mugunthkumar/tempsvn

the  -m “Comment goes here” is optional

the command takes in the directory you have to import and the URL of the repository as it’s parameters. Remember the first step? The repo creation step? We created the repository in /Users/mugunthkumar/tempsvn? If you pass the directory as such, the command fails. So prefix, “file://” to it. (Note the triple / in the command)

After typing this command, you will see a log of all sub directories and files being added to the repo.

Done!!!

Now we will setup XCode to open the project from the repository. Fire up XCode from your Dock (or Spotlight it)

From the XCode menu, choose SCM and select Configure SCM Repositories as shown

SCM Menu in XCode

SCM Menu in XCode

To the left, click the “+” icon to add a new repository to XCode.

Type in a name for your repo (iPhone Dev). This name can be anything.

Fill in the URL as file:///Users/mugunthkumar/TempSVN and the remaining will be filled in automatically by XCode. This URL is same as the one that your provided to the svn import command in step 2. You can provide a user name and password if you want, but if you are the only user (like me and many other iPhone developers), it’s not required.

[ad#AdBrite-Post]

Click OK

Now you have mapped your repository to XCode. Next, checkout the code which you have imported. To do this, Click SCM from XCode menu and choose repositories. You should see the repo you created (iPhone Dev) on the left and some commands including “Check out” on the Repository Window.

XCode Repositories Window

XCode Repositories Window

Click the “Check out” button (second from the left) and check out the files to any convenient location.

Now open the project you checked out. you can safely delete or archive the copy that you imported previously.

XCode will open it normally. Your project is still not linked to SVN! Relax. Just one more step…! You have to tell XCode to use the (iPhone Dev) repository you just created. This is easy. Don’t worry.

Open your project properties by clicking Project -> Edit Project Properties.

Project Settings

Project Settings Menu

From the project info dialog, select the General tab if it’s not already selected and choose the SVN Repository for your project.

Choose Repo

Select a Repository

Close the info Window.

[ad#AdBrite-Post]

All Done! Your XCode project is now linked to your checked out. On your files menu, you should see something like this.

SVN Connected Project

SVN Connected Project

The “M” denotes modified files. Various other statuses are also displayed here.

Your SCM menu should show the following options.

SCM New Menu

SCM New Menu

You can now compare your changes to the latest version, commit your changes to the repo and do a lot others from this menu.

That’s it. Hope you liked the article.
Do write a comment or link back if you liked this article


Mugunth

Download Wallpapers from Bing

June 19th, 2009 by Mugunth Kumar

Ah… Bing… Wonderful product from Microsoft IMO.

I always wanted to save the wallpapers/images that appears on the front page of Bing.com to my local PC. But visiting the site everytime and saving it was cumbersome.

So I thought of writing my own C# utility that could do that job for me.

The utility is just 10KB (yeah Kilo Byte) is open source, free from any kind of obligations. But if you use it in your app, I would be happy if you could attribute me though attribution is not mandatory.

Here is a link to the codeplex hosted project.

Bing Downloader -http://bing.codeplex.com/

Mugunth

StationAlarm SG is on sale…

June 2nd, 2009 by Mugunth Kumar

Finally…

After two rejections I made it to the App Store.

StationAlarm SG is an app that helps you drift to sleep in Singapore MRTs. Just set your start and end stations and you are good to go…

Click on the above link to go to the product page.

Mugunth

StationAlarm SG

May 10th, 2009 by Mugunth Kumar

StationAlarm is an intelligent alarm system that is designed to let you sleep in the MRT without fearing to wake up at the right stations.

All you have to do is to set your current station and the destination station. Your route is automatically computed and StationAlarm rings an alarm to wake up at the right station(s).

Right station(s) means, if there is a interchange, where you have to change trains, StationAlarm can automatically wake you up at the right time for alighting.

For example, when you travel daily from Woodlands to Pioneer, StationAlarm will automatically wake you up at Jurong East and then at Pioneer. It’s especially helpful when you travel across the length of breadth of the island.

continue at source… StationAlarm SG

Mugunth

C# vs C/C++ Performance.

April 14th, 2008 by Mugunth Kumar


Well, this is my first post in this technology series. In fact, the title of this post, forced me to start of a technology focussed blog. Well said about all these, let’s now jump into the issue.

There has been a lot of heated discussion on different forums, newsgroups, and various other threads about the above topic. Now why should I discuss about the same again here?

Well, though there are many discussion groups that claim C++ to be faster and efficient, a small group of people still claim C# to be more efficient.
How the hell can a language that is not compiled to a native code be faster that a C++ binary?

Though the above statement is perfectly valid from the point of C++ programmers, I would like to highlight a few points that could state why some (not all) C# programs are *really faster* than it’s equivalent C++ programs.

Point 1: C# is compiled twice. Once while the program is written and second when the program is executed at the user’s site. The first compilation is done by your C# builder and the second by the .NET Framework on the user’s machine. The reason why C# compiled applications could be faster is that, during the second compilation, the compiler knows the actual run-time environment and processor type and could generate instructions that targets a specific processor. Classical C++ compilers generate native code that is usually the Lowest Common Denominator of all the available processors which means, a C++ program will not be able to take the advantages of the “Hyper Threading” instruction set of the Pentium 4 HT processor. (Of course HT is outdated now…) It will also not be able to take advantages of the Core 2 duo or Core 2 Quad’s “true multi-threaded” instruction set as the compiler generated native code does not even know about these instruction sets.
In the earlier days, not much changes were introduced to the instruction set with every processor release. The advancement in the processor was only in the speed and very few additional instruction sets with every release. Intel or AMD normally expects game developers to use these additional instruction sets. But with the advent of PIV and then on, with every release, PIV, PIV HT, Core, Core 2, Core 2 Quad, Extreme, and the latest Penryn, there are additional instruction sets that could be utilized if your application needs performance. There are C++ compilers that generate code that targets specific processors. But the disadvantage is the application has to be tagged as “This application’s minimum system requirements are atleast a Core 2 Quad processor” which means a lot of customers will start to run away.
This is precisely where the C#’s framework compiler comes into picture. Because the application is compiled the second time at the user’s site, the Framework knows about the actual running platform and is able to generate code that runs the best on the given platform.

Point 2: So, then why doesn’t *all* C# programs run faster?

C# or for that matter any .NET based application runs in a sand-boxed environment and hence many instructions have to be checked for safety. Because additional safety is not free, C# comes with a performance overhead, which means a program like,

for(int i=0;iPoint 3: So when is C# really faster?
A well designed C# program is more than 90% as fast as an equivalent “well-designed” C++ program. But the catch is “well-designing” a C++ program. How many of us can manage memory efficiently in a C++ application that’s so huge say a million lines of code? It’s extremely difficult to “well-design” a C++ program especially when the program grows larger. The problem with “not-freeing” the memory at the right time is that the working set of the application increases which increases the number of “page faults”. Everyone knows that page fault is one of the most time-consuming operation as it requires a hard disk access. One page fault and you are dead. Any optimization that you did spending your hours of time is wasted in this page fault because you did not “free” memory that you no longer needed. A lot of classical applications including Google Picasa suffers from memory management problems. After about two or three days, you can notice that these applications become slower necessitating a Windows Restart. This problem is completely alleviated in C#. the Framework comes with a broom behind you and sweeps your drop during the course of the execution and as a result your working set never grows (unless you really use it) which means lesser page faults. This means that “well-designing” a C++ program is far complicated than a equivalent C# program which is responsible for its sluggish performance.

So now I can hear you asking me,
So to conclude what should I do?
That’s a nice question. Except for writing time-critical blocks of code, prefer C#. Write all your algorithmic code in C++ (not VC++ .NET), compile it into a dll and call that using a Dll Interop through C#. This should balance the performance. This technique is not new or not invented by me or anyone. It’s similar the old age C programming vs Assembly, where people on one camp fight assembly programming is faster and the other camp stating C is easier to develop and then people started using assembly embedded within a C program for time-critical applications using an asm block.

History repeats…!

Mugunth


10 visitors online now
10 guests, 0 members
Max visitors today: 17 at 12:00 am SGT
This month: 58 at 03-01-2010 02:57 am SGT
This year: 59 at 02-12-2010 06:23 am SGT
All time: 59 at 12-19-2009 09:48 pm SGT