Tuesday, August 18, 2009

Hello World - iPhone

I have always been intrigued by iPhone apps and this is a long pending (self-learning) post of a simple 'Hello World' program in iPhone. This blog post serves to let the user get familiar with the iPhone code environment.

Creating a Project
  1. Download XCode along with IPhone's SDK from Apple's website.
  2. Once installed and opened, click File -> New Project
  3. Pick the Application template under iPhone OS category
  4. Select 'View-based application' and click Choose
  5. At this point, it will ask for the Project name -> Save
Once, the Project file is created, it will display all the code files and resources associated with the project. There isn't much now but it is a fully functional application that of course, does nothing. Click on the 'Build & Go' to see the iPhone Simulator open up the application.

XIB files are where the user interface behind the Mac and iPhone application are stored. Double clicking on the MainWindow.xib file will open up the Interface Builder app. This lets the user create the user interfaces. Once the IB loads, it displays a mock iPhone view. The users can select an array of objects (buttons, text boxes and the whole lot of it) from the Tools Library. If the Tools library is not automatically loaded, click Tools -> Libary or (command - shift+command+L)

Interface design
  1. On the TooNumbered Listls Library, make sure Object is selected. And then, in the search box start typing 'text'.
  2. Select TextView and drag it on the mock iPhone area and place it. Double clicking, lets you change the text. Then type the infamous - "Hello World!!"
  3. Close the Interface Builder and select 'Build & Go' on XCode window.

That's the simple 'Hello World!" app on iPhone.

I plan to explore more on iPhone and Objective C and plan to have series of posts. Looking forward to learning more!


Thursday, July 30, 2009

Mono for .Net on Mac

I am a .Net developer and with the new Mac, Mono has been inviting me for a long time now. With my baby's (long!) nap for an hour provided me with the opportunity to try out Mono and blog about it!

Why Mono?
1. A .Net developer since I learn to code - you know how addicted you can get to VS :)
2. A new Mac enthusiast


Steps to start trying out Mono
1. Get the installable from the go-mono site.
2. Run the installer. Mono installs under /Library/Frameworks/Mono.Framework
3. Here comes the famous 'Hello World'!!

using System;
public class Hello
{
static public void Main()
{
Console.WriteLine("Hello World, Here I come");
}
}
Note: For those of us .Net developers that hadn't worked in a shell terminal for a long time now, here are some of the notes to freshen up your memory!
  1. 1. vi filename - opens the vi editor with the filename
  2. 2. to save the file - :w
  3. 3. to quit the editor - :q
  4. 4. obviously, to save and quit - :wq (although, you would have figured it by now!)
4. Compile the code with - 'gmacs hello.cs'
5. Execute the code with - 'mono hello.exe'

There you go! Your first C# program on a Mac! Though simple, doesn't it thrill you?

Bang! Bang!! - The first time I compile the program - I got the error,
"`System.Console' does not contain a definition for `Writeline'". It took a full thirty seconds to spot the reason for the error - It should have been WriteLine!! Darn, VS has us fully spoiled!


Wednesday, July 29, 2009

Is C++ really dead?

Is it?? Read this discussion group thread

Inline Vs. Code Behind

StackOverflow has this discussion on some code being inline in the aspx page versus it getting into the code behind file.

Well, it made me start thinking. Thinking about it, I used to hate code getting into aspx pages with my colleagues. It led into code getting scattered and ended up losing the control of the code. Somehow, code behind makes it look more natural.

However, in case of a gridview - some people get more code into code behind

<asp:Literal ID="litExample" runat="server"

OnDataBinding="litExample_DataBinding" />


protected void litExample_DataBinding(object sender, System.EventArgs e)

{

Literal lit = (Literal)(sender);

lit.Text = string.Format("{1} - {2}",

Eval("ExampleField").ToString(),

Eval("ExampleField2").ToString());

}


There will be no performance difference on either type of the code. It's more to do with the best practices and to improve the readability of the code.


In this case, I like to keep the code in the aspx page as the code here is more declarative and design oriented.


    Text='<%# Eval("ExampleField").ToString() %>' />



Friday, June 19, 2009

Safari Quirks

Have you found that Safari opens all links in a new window a little weird. And you can not force Safari to open it in the same window (in a different tab!) - Read this blog post by Nik Fletcher of TUAW to make Safari use the Uni-Window mode!

Wednesday, May 20, 2009

Wolfram Alpha: Get your answers

After being dubbed the next Google killer - in one line, Wolfram Alpha is: It is certainly not a Google killer but will make Google really think about how it can improve presenting data.

The introduction screencast left all of us waiting for the launch on 7pm CST on last Friday. The screencast had raised the expectations and scores of thousands were eagerly awaiting its launch. To top the expectations, Wolfram had announced that it will video cast the release, which was a first of the kind for a service with such big expectations. Though it started with a small glitch, the computational knowledge-base search engine did quite well.

Wolfram Alpha is certainly impressive and has raised the bar with how the objective data can be computed in real time and facts presented in a neat format. I typed in some of the queries and Wolfram Alpha handled them exceptionally well:
  1. GOOG MSFT
  2. (a+b)^2
  3. Coimbatore India
I did have some no-showers/bloopers:
  1. first president of india
  2. common cold
The Verdict: Wolfram Alpha did amazingly well when given a mathematically corelated input or statistically inclined input. It still has to climb some mountains for Natural Language Processing (NLP).

But given the fact that it is still Alpha, Wolfram Alpha has a long way to go and has shown us all a new dimension. It may not be a immediate threat to Google, but will surely be one to Wikipedia.

Kudos to the team at Wolfram Alpha for a new relevation!

Twitter: I did see the real power of Twitter in action during the Wolfram release. On TweetDesk, I could get a consolidated view on what people were thinking about Wolfram Alpha instantly! Makes me more appreciative of Twitter!

Tuesday, May 19, 2009

Speed up VS 2005

VS2005 is always thirsty for more memory. There are a few tricks that could save up some RAM for you.

Speed up the launch of VS2005
  1. Disable the 'Start Page' - Tools->Options->Environment->Startup section
  2. Disable Splash screeen - Properties->Add parameter /nosplash to the target
  3. Close all unnecessary panels and tabs so that the IDE does not reload them on restart
More Options
  1. Turn off 'Track Changes' - Tools -> Options -> Text Editor
  2. Turn off 'Track Active Item' - Tools -> Options -> Projects & Solutions
  3. Turn off 'Auto Populate Toolbox' - Tools -> Options -> Windows Form Designer
HDD speed matters. 7200 r.p.m is better than a 5400 r.p.m. Read here to see why it's important.

And of course, having more memory helps :)

Wednesday, May 13, 2009

Google Hosted JQuery

Roughly a year back, Google announced that it would host widely used open source JavaScript Libraries on their Content Distribution Network - jQuery, Prototype, Script.aculo.us, MooTools to name a few. Google suggests the use of their Google AJAX API Loader's google.load() method to gain application speed.

How to use in ASP.Net Application?

This is how the JQuery library could be loaded using Google AJAX API Loader's google.load() method.





There are certainly some benefits using Google's CDN
Caching
Decreased Latency
Convenience


Caching - Better speed
The main advantage of using Google's CDN is they manage all the bug fixes, recent updates and provide a high speed access due to better caching, etc. The simple idea behind this is speed - the user's browser does not have to download multiple copies of JS libraries from different public facing websites.

Decreased latency
Certainly, you could make use of Google's distributed servers to download the JS files from a server located physically close to you.

Convenience
Google takes out the pain of staying upto date with the source code, bug fixes, minifying and version changes.

However, there are certain things that a developer needs to be aware of before taking the road of Google CDN.
  1. What if Google goes down? Will your code be prepared to handle something like this. Well, if you will take care of it, you are all set!
  2. There will be a performance speedup only when the user happens to have those libraries loaded from some other site that uses google’s service


A Good Programmer Cartoon


Tuesday, April 28, 2009

DateTime.Now Vs. System.Diagnostics.Stopwatch

Occasionally all of us, as programmers would like to see how fast or how slow a C# function can execute. I am sure, most of us must have used DateTime.Now for the measurements. Roughly on these lines,

DateTime startTime = DateTime.Now;

// Some Execution Process

DateTime endTime = DateTime.Now;
TimeSpan totalTimeTaken = endTime.Subtract(startTime);


Now, does DateTime.Now accurately measure performance? No, it does not. DateTime.Now, according to MSDN has a resolution of ~16ms, which means it is not very precise.

Environment.TickCount
Another approach would to use system tickcount as kept by Environment.TickCount. This keeps the number of milliseconds since the computer was started. Unfortunately it is stored as a signed int, so every 49 days it is actually counting backwards. We can compensate for this by just taking off the most siginificant bit.

Stopwatch
Another better approach is to use Stopwatch. System.Diagnostics offers Stopwatch that automatically checks for high precision timers. You can check if the Stopwatch is using high-precision timers by checking via Stopwatch.IsHighResolution() method.


Stopwatch swTimer = Stopwatch.StartNew();
//Some execution process here
foo()
swTimer.Stop();


Watch for the difference in the code results

protected void Page_Load(object sender, EventArgs e)
{
DateTime sStartTime, sEndTime;
TimeSpan tsTotalTimeTaken;

sStartTime = DateTime.Now;
for (long lCount = 0; lCount < 100; lCount++)
{
Thread.Sleep(1);
}//for(int iCount=0; iCount<100; iCount++)

sEndTime = DateTime.Now;

Stopwatch swTimer = Stopwatch.StartNew();

for (long lCount = 0; lCount < 100; lCount++)
{
Thread.Sleep(1);
}//for(int iCount=0; iCount<100; iCount++)

swTimer.Stop();

tsTotalTimeTaken = sEndTime.Subtract(sStartTime);

Response.Write("Elaspsed Time according to DateTime.Now(): " + tsTotalTimeTaken.Milliseconds + "
");
Response.Write("Elapsed Time according to StopWatch(): " + swTimer.Elapsed.Milliseconds);
}



Output:

Friday, April 3, 2009

Wanna be Macbie

Mac Dream
MacBook has been on my 'Desire List' for sometime now. Everytime I think of indulging myself with the sleek user interface that Apple offers, I push the idea out thinking that its going to be a difficult shift for a ASP.NET developer. Is it really that difficult?

ForeWord: This blog post comes out with no PC vs. Mac argument.This is just research on things needed for a ASP.NET developer treading into Mac waters.

Questions Galore
How can I compile C# code on Mac? Will I have to learn to write code on Objective-C? Should I start using the Cocoa Framework instead of the .NET Framework? Will I still be able to use AJAX.NET on Mac? These are the questions that ring loud and clear in any .NET programmer's mind.

I try to seek answers to these and wish for a Mac soon! :)

BootCamp
BootCamp comes packaged with Mac OS X. This software assists users to install Windows XP and Windows Vista while leaving all the Mac data in place while it creates a separate partition on your drive for Windows. BootCamp even lets you start up the Mac using either of the operating systems.

Parallels and VMWare
Parallels and VMWare are virtualization softwares that help break down the wall between Mac and a PC. Both these products offer a seamless desktop environment between Mac OS X and PC applications.

These virtualization softwares do come with certain performance penalties. See Jeff Atwood ponder problems and discuss solutions.

Decide between Parallels/VMWare and BootCamp

Mono

Mono is a open-source development initiative to develop an open source, UNIX version of Microsoft.NET development platform. Mono includes a CLI (Common Language Infrastructure) virtual machine, a class library that works on CLR and a compiler for C# language.

Everything seems okay, but aren't we still missing something that .NET programmers cannot live without?? Yeah, the Visual Studio has got you hooked onto it - you will not know how much you love this tool until you start missing it! I see the Microsoft guys smiling :)




Here comes MonoDevelop. MonoDevelop is a IDE designed for C# and other .NET languages. Developed code can also be ported on unix machines. Take a look at Screenshots for MonoDevelop, they are really promising.








Mono and AJAX.NET?
Microsoft's ASP.NET AJAX Control Toolkit works on Mono, and is open source (Ms-PL). That doesn't preclude the use of jQuery, though. There are actually several third party AJAX libraries and control toolkits that support Mono, and many are compatible or work in conjunction with ASP.NET AJAX.

You .Net developers, ready for a Mac? :)

Thursday, March 26, 2009

Twitter Buzz


It's been a couple of weeks since I have said - 'I do' to Twitter and I have a couple of interesting observations to make.

Twitter's sweet success
Twitter, with its infamous 140 word limit has carved a niche out for itself in micro-blogging arena. Twitter's growth has been so phenomenal that it has 750,000 user profiles with a whopping 1382% increase in user profiles since last year. Get started in to this world with its own 'Twitter Glossary'.

Who's Tweeting
Adults between the ages of 35 and 49 comprise almost 42 percent of the site's audience - and about 62 percent of them are accessing the site from work. The average user hits Twitter.com about 14 times a month and spends about seven minutes on the site.

Twitter on the move

It could a simple "What are you doing now?". Now, you wonder who would want to know what you do in everyday life? Realistically speaking, will it be just random bragging of an unexceptional life. Rewind to early 2000's and one realizes that the same argument was held when 'Weblogs' were still young in the internet space. Twitter is a platform for social communication. What you do with it depends on 'You'. You could use it for simple 'I did this, I did that sorta stuff' or for something more useful.

You end up following not just people, but their activities and lifestyle in general. Twitter is brevity at its best. It promotes communicating one's thoughts with concise and clear sentences.

Twitter is the latest method of evoking quick answers to your questions. Try posting a question or a musing and you will be surprised to see answers. Twitter is the new age information travel where you follow others without being intrusive.

Twitter creates a sense of virtual world where you have a lifestyle, friends and conversations. It creates the Third World after Home and Work. It is a place where you go to when you are done with family, friends, work and everything else.

Twitter bird feed
The social networking platform is a free for all service right now. There were rumors that Twitter is going to start using advertising platform to start generating revenues. Now, Twitter has confirms that it will soon offer paid premium accounts to businesses.

Time flies with Twitter
Oh! Time does fly fast with Twitter. It leads you onto interesting Tweets, entertaining blog posts, more interesting Tweets and more entertaining stuff - and the world has endless of these. It easily can eat into your productive time. Use it well and it stays your best pal.

Spams Ho!
Where there is a means of communications there are spams and phishers. Watch out for them while you spend your time here.

So the answer to - To Tweet or Not To is - Use it well, or you could end up losing your job in 140 characters or less.

Tuesday, March 10, 2009

ToTweet Or Not to Tweet...

To Tweet or Not To Tweet - That's the question my friend....

I am away from work on a maternity leave - will be quite long, a year actually. Gotta spend some time with the little one, right? Absolutely loving it....

So, I am trying to be a regular at my blogging space exploring new things. This is one such expedition - I have always wanted to try out Twitter and see why everyone (on the blog space) has been using it. Is it one of those fads or is it here to stay? Is it a great networking tool that people claim it to be or is it just a 'time-gobbler' and 'productivity-hinder'? Should you really 'Tweet' or is it just a farce?

Please stay by, while I explore and do check again later to see my views on Twitter :)

Tuesday, February 17, 2009

Frustrating "Local Access Only" Problem - Vista Worries

Being the 'computer handyman' of the family, I was fiddling with my sister's relatively new notebook that has a Vista Home Basic Edition installed on it. After keeping her notebook, up-to-date with all the security patches, service packs and similar things - the weirdest thing (ok! not something totally weird, if you are used to working on a PC :)!) happened. The notebook lost all contact to the outside world. You got it right! - the notebook lost its wireless connection. I was getting a 'Local Access Only'.

The notebook had Vista Home Basic Edition with SP1 installed. Googling, I realized that this was not an isolated issue but a prevalent problem among Vista users. This is a consolidated list of numerous recommended things I tried, before resolving the issue -
  1. Using Windows Diagnostics Mode to resolve the problem automatically. I received the message that the notebook was unable to acquire a new IP address and was asked to reset the router.
  2. Reset the router and modem individially and reset them together.
  3. Disabled DHCP and assigned a static IP to the notebook
  4. Connected the computer using a wired connection to the modem
  5. Uninstalled and reinstalled the wireless adapters numerous times
  6. Checked to see if the wireless adapters (NIC) had any more updates
  7. Was unable to connect in the safe mode with networking turned on
  8. Turned the IPV6 off to see if that was the issue
  9. Removed Symantec and AVG Anti Virus Software running in the system
  10. Turned Windows Firewall off to make sure that was not holding back the connection.
  11. Turned DHCP broadcast flag to ON in the Registry. Read more in this Microsoft KB Article
  12. Gateway 0.0.0.0 problem. Type 'route print' in the Command Window (Start->Run->Cmd->Enter). If you see a 0.0.0.0 entry against the Default Gateway, enter 'route delete 0.0.0.0' and then press Enter.
After all this, I was all set to 'Restore' the system to a prior date when the Wireless Connection was working perfectly fine - and surprisingly, it did the trick! Go to 'Start->Data backup and Recovery' and select the Restore Point when things were working perfectly ok.

Its true that sometimes, the solution can lie just under your nose and you may overlook it :)

Bottomline - The guess is that, Windows has some software updates that might cause this problem to arise. So, once you have the system restored - you should be able to reinstall the Microsoft updates one by one to get hold of the culprit. I will update this blog with the details once I can pinpoint the software update!