Friday, December 28, 2012

Web Design Resources : Color

Coming up with a color palette for you design is one of the harder parts of web design or any graphic design for that matter.

Nowadays we live in a wonderful world of sharing and caring and here are two websites that deserve mention :

Color Lovers This website seems to be the github of color. Definitely keep this bookmarked.

Adobe Kuler A great effort by adobe. Just sweet to browse through. 

Monday, November 26, 2012

Open Command Window at current directory

Common pro-user method:

Hold the shift key when you right click on / inside a folder and you get a menu option : 

Something I just found out today (better): 

I just found this out today. I find having to hold the keydown and press the mouse button a bit too much. You can simply (on windows 7 and up, including windows 8) type in cmd in the address bar as these screenshots demonstrate. Select:


 And after you press enter:
Much better. Enjoy!

Friday, November 23, 2012

.NET 4.5 Authentication and Authorization Trick question

I love the new ClaimsIdentity and ClaimsPrincipal classes added into .NET 4.5 :

Using federated security used to require somewhat configuration in WCF with its SecurityContext handling : and it was not integrated into the IIdentity and IPrincipal classes that come as a part of the .net core framework. Its nice to see these merge up.

That said. Here is a gotcha. Guess the output of this :

If you use GenericIdentity it is Authenticated by default. Whereas with Claims you can have users that are not authenticated! Here is the output:
This is actually more intuitive since we should be able to claim things about anonymous users. The moment you specify an authentication type for Claims Identity the user becomes authenticated.

Enjoy the new features. 

Monday, November 12, 2012

TypeScript is Awesome!

TypeScript has quickly become my current favorite language. If you haven't heard of it yet then go here :

Any self respecting developer that does javascript work should definitely check it out. I really like the ideas in javascript and the ability to modify the language according to my liking but I really really miss the great tooling / typo checking we get with static typing.

I strongly suggest you look at Ander's talk here : (also embedded below) to get an idea of the awesomeness that becomes at your disposal:

Its open source. The tooling will be awesome. Developers, Developers, Developers.

Its better than CoffeeScript
In my opinion typescript is going to be as awesome for Javascript as LESS has proved to be for CSS. And in case you haven't heard of LESS its a superset of CSS that compiles down to CSS (example of popularity, twitter bootstrap uses it : ). Similarly TypeScript is a Superset of Javascript, all your javascript is still valid TypeScript. Super Cool. You are not learning a new language, you are extending your knowledge of a language.

So to learn typescript === learn javascript + more goodness

The community Loves it
The response from the community is what makes me really happy, and raises my faith in human support of all that is righteous and good :) . My measure of community response Stackoverflow : And its not the number of questions they got in one month. Its the the number of votes on the accepted solutions. People are monitoring it a lot, in their own time. Always a good sign.

All your definitions are us
This is quickly becoming the definitive resource for all the typescript definitions your heart can desire : Love the open source 

Monday, October 29, 2012

KnockoutJS tip : when to use brackets?

I simply love the knockout.JS framework. It makes the migration from silverlight to javascript / html so much more comfortable.

One point of confusion in knockout JS you might feel is when do you have to use brackets in front of observable and when can you ignore them? 

e.g. in the knockout intro tutorial : 


will work just as well as: 

Then whats the difference?  is actually a function since ko.observable returns a function : 

My solution:
In code ALWAYS use ().You have to, otherwise you will remove the ko.observable function on assignment which is bad. And on reading you would get the function not the value you wanted. 

In simple data-bind attributes NEVER use (). Because it will not work to two way data binding, i.e If I had bound value: firstName() to the input it would not have worked.  

In calculated data-bind attributes e.g. value: firstName() + lastName() , use brackets since you want one way binding and basically running arbitrary javascript :) 


Sunday, October 7, 2012

Best programming tutorials for JavaScript: With videos!

There is lots you can read about javascript.

But I have always found videos to be a great way to learn real world programming. You get to see people think. You get to see people perform. Great for finding productivity tips that have a HUGE impact.

Here is my playlist for JavaScript (the language) :

Playlist 1:

Some tips: 

Javascript has only one number type
and it is equivalent to double, floating point type
If you are dealing with money, multiply with 100, do arithmetic, divide by 100 :)

And if you cannot get enough, Playlist 2:

You can find all the slides for "Crockford on JavaScript" here :


Thursday, September 20, 2012

My web stack of love, Great MVC / Javascript libraries

Found on nuget : 
  • Elma : described by scott hanselman as tivo for yellow screens of death 
  • dotless : automatically compiles your less files into css files. Does caching of the compiled files as well. 
  • MVCHtml5Templates : modifies your scaffolding to churn out html5. Does this by added EditTemplates into your views folder,  the magic is in MVC. 
  • Glimpse: Firebug for your MVC application. Shows you the routes that were triggered , where the view was searched etc. Really cool 
  • ASP.NET Web API : get the latest version on nuget! 
  • SignalR: Gives persistent web connections (web-sockets or otherwise. You do not need to think about whether web-sockets is supported). 
  • Web API Self Host : changes your webapi project into a desktop application! 

  • jquery : ... 
  • modernizer : get new browser features on old browsers 
  • knockout.js : MVVM for HTML/JS! 
  • upshot.js : seemless data transfer b/w server client. Client / Server data filtering as well against IQueryable. 
  • history.js : for browser window navigation (history). This is used by nav.js wrapper provided by Microsoft. 
  • holder.js : for image placeholders in mockups 

  • Fiddler : For composing HTTP messages. Great for testing your actions.  

Thursday, August 2, 2012

Disable Itunes sync when iPhone is connected on Mac

When developing iPhone applications with monotouch it becomes very annoying that everytime you connect your iPhone to your mac it opens iTunes and starts to sync, followed by opening iPhoto.

You can disable both of these from opening:

Disabling iTunes from opening / syncing when iPhone is connected: 
Simple option in iTunes as shown:

Uncheck "Open iTunes when this iPhone is connected" and click apply.

Disabling iPhoto from opening when iPhone is connected: 
Open iPhoto. Goto Preferences:

And change "Connecting camera opens" to "No application" as shown:


Tuesday, July 31, 2012

Insertion sort in python

This is my implementation with a lot of comments for insertion sort implementation in python. Hopefully the comments can help people understand insertion sort better (like the reason for starting at index 1). You can also view it here :

Monday, July 23, 2012

8 balls problem and solution

Given 8 identical balls, there is a fake ball, which may be either heavier or lighter. Assume that there is a balancing-scale available.
To identify the fake ball,
1.) how many rounds of comparisons are needed?
2.) how many rounds of comparisons are required if the number of balls is n?

A useful definition :
A control ball : A ball that did not cause the scale to tip. Since we know that there is only one ball that is different  select a control ball intuitively form the n-1 possible ones.

1.) 3 weighings.
Number the balls 1-8
  • Weigh 1-2 / 3-4 Three outcomes: 
    • 1-2 is lighter : Weigh 1 / 2 . Three outcomes: 
      • 1 is lighter. Yup then 1 IS lighter 
      • 2 is lighter. Yup then 2 IS lighter
      • Equal. Well weigh 3 / 4 and one is bound to be heavier :) 
    • 3-4 is lighter : proceed same as 1-2 is lighter. 
    • Equal - Weigh 5-6 Three outcomes: 
      • 5 is lighter : Weigh against a control ball (any from 1-4). If same 6 is heavy otherwise 5 is light. 
      • 6 is lighter : same as 5 is lighter 
      • WORST CASE equal: Weigh 7 and a control ball (any from 1-4). Answer should be evident. 
Since in each step you split your sample space in half.  So in general you need log(n,base2) steps. 

Further analysis
If you know whether the ball is heavier OR lighter the weighings reduce to log(n) -1. Also if you need to know whether the fake ball was heavy or light (not just identify the ball). You will need one more weighing, in case 7 was not fake, you would know 8 is fake but not if its heavy or light.

Bad approach
The first intuition is to try and weigh 4 balls / 4 balls instead of 2 balls / 2 balls shown here. The problem with 4/4 approach is that you do not know which particular set of balls have a problem. You only find the direction of the problem for a set of 4 balls. You need to focus on discriminating the balls and that will intuitively lead you to a classification of 2 / 2 balls initially which tells you WHICH 4 balls have the problem.

Friday, July 20, 2012

Manage remote audio in Skype on Mac OSX

Disabling your microphone is a common task that you can do from the Skype call window. This is not what this post is about.

Sometimes you just want to look at the Skype camera and not listen to the audio feed from the other side. This is super easy to do with Skype on Mac OSX. Go to skype -> Preferences -> Audio / Video and adjust the volume as shown:

This volume is independent of your computer volume.

Optionally you can use the quick keyboard shortcuts Command Option Up / Command Option Down. You get a nice indication of the current volume :

Monday, July 16, 2012

Getting the bleeding edge of MonoTouch / MonoForAndroid

If you want to know which version of MonoTouch you have installed you can find that in MonoDevelop using About MonoDevelop:

And click on Version information: 
You can see that my Monotouch version is 5.2.12 which as of this writing is the latest stable version. But in case there is a feature you badly want in the beta / alpha version you can switch over to those quite easily. 

Going Bleeding Edge
Just start MonoDevelop and go to Check for Updates as shown:

Next, now change your Update channel: 
And you will be able to see the Beta / Alpha version available. If you like what you see. Just click on Switch Channel as shown: 

It will start downloading and running the updates. Enjoy!

Sunday, July 15, 2012

Useful bookmarks for MonoTouch

Just in case its useful to have these links handy :

A list of bugs that have been already raised:

A list of bugs that were fixed in each release:

Friday, July 13, 2012

Setting up Git with MonoDevelop on Mac OS X

MonoDevelop on Mac ships with Git integration built in.

As an aside: My preferred source code provider is because they provide unlimited free private repositories. I obviously use the same account for my open source projects as well. So this is the provider I tested.

First of all create a new git repository on BitBucket. Note down the git url as highlighted below:

Now open up MonoDevelop and select Version Control -> Checkout as shown:

Next select Registered Repositories and select Add and then in type Select Git as shown:

Next Copy paste that git url in the url field as shown, This will automatic fill most of the fields for you (cool) :

Just type in the Name (already shown in the previous image MondrianEvolved) and click Ok.

Next specify the newly added repository and select the target directory as a new directory you want created for this repository (make sure you end on /):

Click Ok, And when prompted type in the password as shown:
Your project will download. You are ready to rock and roll :

Most git operations, you can now do from the context menu as shown:

And overall operations from the Menu :

commit messages:

And push changes:

Also if you are doing Git/Hg on Mac OS X I highly recommend you check out SourceTree :
It picks up where MonoDevelop leaves off.


Sunday, July 8, 2012

Uninstalling an application in Mac OS X

The standard way that people uninstall an application in Mac OS X is to simply drag an application from the applications folder into the trash.

This however can leave preference files used by the application behind. These file are generally stored in Library/Preferences  folder (since Mac OS X does not have a concept of a registry).

To ensure that these files are also removed when you delete an application take a look at a neat little free application called AppTrap :

Thursday, July 5, 2012

Disabling reopen closed windows in Mac OS X

By default Mac OS X Lion reopens any windows that an application had open once you quit an application (command Q) unless you close the windows (command W) before quitting the application. 

This is extra annoying with preview since you open an image, Close the application, open another image and now you will suddenly have two images open. 

You can disable this option from system preferences and unchecking "restore windows when quitting and re-opening applications" as shown below. 

Wednesday, July 4, 2012

Notepad / Wordpad on a Mac

There are third party tools but by default Mac comes with TextEdit which is more like wordpad instead of notepad. 

To use TextEdit as notepad you can switch to plaintext by going to preferences and changing to plaintext mode. 

The keyboard shortcut for this is : Shift Command T 

Tip for studying at ANU

I am currently enrolled in the Master of Computing (computer science) program at ANU (Australian National University). It is useful to know what to expect in which course. Here are a couple of links that an help you in determining that:

For finding out how other students have rated each course:

For past exam papers:

Tuesday, June 26, 2012

Monotouch Gotcha : Dispose all outlets

If you have used winforms than you should be familiar with this pattern. Whenever you are done with a window be sure to call Dispose of any other windows that you have a reference to. The reason is that the windows are natively linked to OS windows and in your Dispose you are supposed to release any references to native resources.

In monotouch, even outlets are native objects. So be careful with them. In fact the default monotouch templates point you in the right direction as shown : 

The ReleaseDesignerOutlets automatically adds the code to release any outlets that are created using Interface Builder inside of Xcode:

Of course non-native (managed) resources are not your responsibility : 

Monday, June 25, 2012

Useful Mac OSX shortcuts for a windows developer

Here is a table of ways things are done in macosx vs. how they are done in windows. Mostly the Ctrl key is replaced by command key. And the windows key is also replaced by the command key.

What : windows 7 : Mac OSX Lion
Address bar browser : ctrl  L : command D  
Run (search on windows, spotlight on macosx) : winkey : command + space 
Copy / cut / paste : ctrl c / x / v : command c / x / v
Delete / backspace : delete / backspace : fn + delete / delete 
Close current application : alt F4 : command Q 
change windows :  alt tab : command tab 
scroll through tabs in safari : : control tab 
home and end page : ctrl home / ctrl end : fn left / fn right
home and end line : home / end : command left / command right OR ctrl A (stArt) / ctrl E (End)
Move backward / forward  one word : ctrl left / ctrl right  : option left / option right

Different windows of same application (like safari):
command+backquote (i.e. ` the key under ~) to toggle between different windows of the same application. Alt + tab like windows does not work between windows of same application. 

What : Windows Explorer : Finder 
delete a file : delete : command delete
rename a file: F2 : enter
open a file: enter : command down (actually go down one level)
go up one level : backspace (actually go back) : command up

The Help menu: 
You can select any menu item using the help menu item added to all applications. Press command + ? (i.e. command + shift + /) to open the help menu and get focus on the search menu item. Just type in the menu item content and you will get an option to select the menu item.

Keyboard shortcuts for MonoDevelop: 
Some are inspired by Emacs. Most menu options have their shortcuts mentioned which is great effort by the MonoDevelop team . The commands I used most often :

Build : command B
Debug : command return
Stop debugging : command shift return
Step Into / step Over / step oUt : Shift command I / shift command O / Shift command U
Intellisense : Control Space

Most shortcuts from here work : 
But occasionally you need to change between control and command keys. Also whenever alt is mentioned you are supposed to use the option key.

Creating an outlet : Control click and drag from main view to assistant editor.
Additional shortcuts for Xcode development can be found here : 

Sunday, June 24, 2012

The best version of Macbook Air 2012

 My specs and reason

Why macbook air?

So I decided it was going to be a macbook air. Not a macbook pro because 
a.) If I would play games, I would use a desktop Or better, a gaming console. I only played two games on my dell XPS, max payne 3 (for old times sakes since I played the first two during my undergrad) and prototype. Don't need the heavier graphics card. 
b.) Weight. I envied other people lugging around their laptops while I shied moving my expensive yet awesome laptop. I hope to move more with my macbook.


A cold boot of mac + running chrome alone takes the ram to 2.5GB. The only ram options are 4GB and 8GB. I plan on running cutting edge Windows and .NET runtimes in a VM. So 8GB it is. Not to mention it was only a 100$ more for the ram upgrade. Also operating systems are probably going to demand more ram, Although I hope not since they will be slower if they do no matter how fast the ram gets.


Did not upgrade the processor. That has never been a bottle neck for me. And I feel my current dell with first generation core i7 is super awesome still in processing power. The Air is more powerful than this. Plus the upgrade isn't that much 1.8 to 2.0 still dual core. Hopefully the lower version runs cooler too and uses less battery. I have found no one that would recommend spending on the processor. 


Upgraded the SSD from 128GB to 256GB for 300$. I put a lot of thought into this. Reasons: 
a.) I don't plan on buying another laptop for at least a year. Possibly two. And I hate using two systems. 128GB is not going to last even half a year. And the end of the year I can delete most of the data I have. But most stuff needs to stay with me for a year. 
b.) I want the portability of the macbook air, an external harddisk kills it. 
c.) Windows 7 took 50GB after windows update on my last refresh install of windows. And I haven't even installed visual studio yet. If I want to run both operating systems, 128 is not even an option. 
d.) The upgrade cost from the primary non apple retailer OWC ( is 300$ which is comparable to what apple is charging. Yes I can sell the 128GB SSD when I upgrade but finding a customer is not fun. Not to mention it voids any apple warranty. And you spend a lot of time making sure you transfer the data you need. And securely wipe it. Just a hassle that saves a 100$ in total. Not worth it.

Moving to a Macbook from Windows

My previous rig: I have been using a dell xps studio 16 as my main laptop for the past year. It has been awesome all the way. It cost only 1100$ and came with impressive specs like a quad core CPU and 1GB dedicated GPU. I primarily used Visual Studio 2010 and develop in .NET.

Like many people I feel that it was time I tried the "other" popular platform that users were loving. The Mac/iOS family. I would like to point out I already use iPhone as my main phone. I also have an iPad which resulted in an explosion in the amount of reading I got done in the past 2 years. Simply because of the ease of closing one book when I no longer feel the author or feel overwhelmed with the information and opening the another one instantaneously.

But I have never owned or even used a Mac before. And that just feels not right for a geek. The reason why I never bought one before was two fold: 

I live and breathe C#

No longer an issue thanks to Mono guys.
I am an engineer and appreciate code beauty and code evolution. C# satisfies my urge for programmers lives being made easy by other programmers. If no ones lives are getting easier programmers aren't focusing on the right kinds of problems.

I like the freedom of hardware choice

Still an issue. But unfortunately there are some major discrepancies in my windows hardware :  The webcam on my dell was not the awesomest. But more importantly : There is a delay when I try to record and live listen audio plugged into line in. Even my P2 desktop didn't have this problem. Compare this with what mac gives you : Being a (hobbyist) musician having a system guaranteed to work (like all apple products) as advertised is a safety that I enjoy over mix and match hardware choice. 

I never put the Dell XPS studio 16 on my lap because of known overheating and motherboard frying incidents. And didn't even move around with it much because of weight and because of fear of a harddisk crash.

The macbook air is the best ultrabook you can buy right now. And the 11inch, 128GB SSD, 4GB base version is comparable in price to windows ultrabooks.

In short Macbook Air is the best "laptop" you can buy. You can make yourself a better desktop. But a better ultra-portable laptop is impossible to make on your own. 

Friday, June 15, 2012

Monotouch means business

What is the worlds largest medical technology company? Medtronic (Thats what google says. 
And thats what they say)

Do they have iPad applications used in hundreds of hospitals / medical centers? Why yes ... of course :

They used objective-c for this right? Wrong.

Details :
And here is a nice presentation for people that like videos :

Something to think about the next time someone says "Well you can use C# for iPads as well".
Of course there is nothing stopping someone coming up with saying "Well you can use Java for iPads as well" or is there

Tuesday, June 5, 2012

MonoTouch / Mono for Android (MonoDroid) links

My increasing list of links for learning and using monotouch / mono for android:

Video Tutorials
From xamarin. New videos every week!

Sunday, May 6, 2012

Best Free Media Converter for windows

A quick post. There are a lot of media converters out there. But the one I like the best is Format Factory. Its free and works with all formats I have ever used (including flv). It works in bulk mode as well.

Here's the link :

Friday, March 2, 2012

Quickest way to get make and unix C++ code working on windows

This should come as no surprise:


Now all you need is information about what packages you need to select. Leave everything as default and simply expand Devel and check the following:

  • gcc-g++: C++ Compiler 
  • gdb: The GNU Debugger
  • make: The GNU Version of 'make' utility
And leave the rest to default. Now you will have a working version of CYGWIN readdy to compile and debug C++ code meant for unix running on windows. 

Further information :


Thursday, March 1, 2012

Number of k-combinations for all k

This is an equations that comes up quite commonly in algorithm analysis:

here is an intuitive understanding for this.

Assume we have 10 items.
And we need to find sum of all possible combinations of these
i.e. 0C10 + 1C10 + 2C10 .....

What we are doing is basically we have 10 positions and in that we have 10 elements (since its a combination order does not matter). And in each position we have a choice for the item to be included or Not-included. So its a binary choice for each position and since we have 10 positions its 2x2 10 times i.e. 2^10.

So for n positions we have 2^n possible ways we can select these items.

If you still want a further rephrasing of the same information you can read this :