Sunday, December 18, 2011

How I cure my hiccups

I don't get hiccups very often. But I do. And I find them MOST annoying.

I always drank water to cure them and it took some time (about 500 ml of water) to fix them. And now a friend told me the ultimate way that cured it in one gulp :D

Here it is:

  • Stand straight up. Take a mouthful of water but don't swallow it. 
  • Bend down as if to touch your knees.  Breath through nose and feel comfortable.
  • And gulp down the water. 
  • Now comfortably stand straight as before. Breathe. 

No need for a sense of urgency in the entire process. Just do it comfortably. I am amazed I did not know this.

Best time for busking in Melbourne Australia

I've been busking around melbourne for fun while I working on the latest advances in ASP.NET during this holiday.

This pretty much applies for all places but particularly for melbourne.
Time : 7pm to 10 pm (After 10pm amplified busking is no longer allowed which means sound does not carry far and therefore people don't come around with change already in their hand).
Money made : 35 dollars
Fun things: People pay more at night and evening cause they are out to party and have change.
Location: Actually not a good one. There were a lot of buskers out so needed to move farther from the key busking areas.

View Larger Map

Wednesday, December 7, 2011

Busking locations in Melbourne (Australia) and money

Its all about where you stand, at what time, and what you play.  As I go around playing in melbourne for fun here are my experiences:

7th Dec 2011 (weekday)
time, 6:30pm to 7:30pm
Money made : 5 dollars.
Location :

View Larger Map

8th Dec 2011 (weekday)
time 9am to 12am
Money made : 25 dollars
Fun things : A fantastic painter (busking next to me) said that I was very good, a gentleman on a wheelchair threw me a coin, a homeless person gave me a dollar.

View Larger Map

Of course on weekends people make much more (about twice as much).


Monday, December 5, 2011

Busking in Melbourne Australia

I came to Melbourne in November 2011 to enjoy the cultural capital of Australia. It is the most livable city in the world after all. And during this holiday, I decided to busk for the fun of it.

2 Months
Playing the guitar and singing is my hobby. I truly believe that you need to learn at least one musical instrument or singing in order to be happy + successful in life. Eric S Raymond considers it compulsory for a programmer ( Also the best tour of city is from the buskers eye :) 

Getting started equipment
  • An amp. I looked around. Went with Roland Cube Street. Worth every penny.
  • A guitar. Ibanez Montage MSC350BK. One amazing instrument.
  • A capo. Dunlop capos are really good. 
  • A mic + stand. Got a great deal on this JTS Mic + stand combo :
  • Some cables 
  • A cowboy hat made of straw. Really windy in Melbourne. Being straw, its holes lets the wind through plus it has a string to keep it on my head. And really protects against the sun.
  • Shades. So your eyes don't ache. 
  • Sports Gloves. To carry the guitar case + amp around town without injuring my palms. 
Getting a License
Just go to town hall. 

View Larger Map

They will give you a booklet along with dates for a safety and amenity review meeting. You can also just download the booklet + form from here. Also the dates are mentioned here:

But its nice to visit town hall still.

The safety and amenity review 
It takes place inside this building:

View Larger Map

Go in on the review date and time and the receptionist will give you a printed badge + ask you to wait. There is no queue. And considering there were very few people there is no need for a queue.

The meeting is really great. You can read the locations you are not allowed to play in the booklet but having a discussion over it is awesome so you remember where you cannot go and why. e.g. you are not allowed to setup right next to the wall because blind people will not be able to navigate by just touching the wall and will bump into you. Parts of Swanston street that are disallowed for amplification are because Melbourne has horse carriages parked there and horses don't necessarily mix well with amplification.

You are expected to bring all the instruments you are going to use. I took my guitar and my amp. They did not test the amp since pretty much anything that just runs on batteries is allowed. Generators are not allowed.

They asked me to play and I played a bit. As long as you are not just downright terrible they are fine with it. 15 seconds of playing is fine. Although they ask you to have 5 minutes prepared no one had to play that much.

Next they take your picture. And then you go to town hall to submit your cash. A one year general area permit for the first time costs 20 dollars. The actual permit is mailed in a week or you can opt to collect it from town hall. Keep the receipt you get from town hall because that is your interim permit for that duration.

This permit is valid for suburbs under the "City of Melbourne" :

My first day
Did not go as well as I hoped. But to be honest I played at the time when no one else was busking around me (that explains it). I only made 2 dollars in half an hour and since I didn't have my mic with me (the mic case hadn't arrived yet) I decided to retire before a sore throat. I played under the tree here from around 11:00am to 11:30am :

View Larger Map

All in all it was fun. Basically busking is the only way you can play to your hearts content + play for an audience and not have your neighbors annoyed. So even if you don't make money its good to go out and have some fresh air and meet people. About three people admired my amp and asked me where I got it from. I bought it from allans music billy hyde here:

View Larger Map


Saturday, November 5, 2011

RobotLegs Video Tutorials : Beginner to Expert

I wrote about the various frameworks that are available for an Actionscript developer to follow industry accepted best practices a while ago. Since then after a decent amount of time taking community support + feature richness + modern practices into account I have decided that RobotLegs is the best framework for Flex MVC. This post is designed to advance an Actionscript developer to an expert RobotLegs developer.

What is expected of you
This tutorial assumes that the reader is fairly adept in ActionScript and how to use Flash Builder (without using RobotLegs). If you are confident of this, move to next heading. ActionScript is a really simple language. If you are a programmer (in any language) you can get up to speed with Actionscript quite quickly using this tutorial. If you know actionscript then RobotLegs is an extremely easy framework to master.

Really easy to become an expert 
During this presentation there may be points you feel that you do not get the first time. Don't worry by the end of the presentations / video you will be able to understand everything. Also I highly recommend you download the sample applications and go through them yourself after watching the presentation / video.

The presentation
The accompanying files are available online thanks to google docs. In particular the powerpoint presentation (download the pptx it since the google docs online renderer is far from ideal)

The Video:
Here it is :

I suggest you view it in HD on Vimeo here : and if you are logged in on vimeo you can also download the source mp4 for offline viewing.

A significant amount of time and effort went into this (writing / practicing / recording / editing) but I wanted to make it easier for someone who is interested in a modern flex MVC framework and just not getting the feet wet because of lack of a video training.


Sunday, October 30, 2011

Adding SQL Server Compact 4.0 (CE) support to Visual Studio 2010 SP1

I just noticed that SQL Server Compact 4.0 tooling is not installed along with Visual Studio 2010 SP1 by default. 

Ofcource you can still make a SQL Server Compact 4.0 database using the latest build of EntityFramework from Nuget and using Code First development. However if you try to open the generated sdf file from Visual Studio you get the error "The operation could not be completed. Unspecified error" as shown : 

To fix this you can either install "Visual Studio 2010 SP1 Tools for SQL Server Compact 4" from the Web Platforms Installer or use the offline installer available here : 


Sunday, October 16, 2011

Enjoy your typography

If you enjoy typography here are a couple of links to bring a smile to your face.

First of all is the famous "So you need a typeface?" infographic.

(The original author has his website here :

Next up there are the really hilarious shorts by college humour called Font Conference and Font Fight.

And if you have 50 minutes here is a nice talk by Rob Conery and Scott Hanselman with Bill Hill (the creator of cleartype) that you are sure to enjoy.

And if you want to have a deeper understanding of why typography matters here is "Magic of reading" by Bill hill in Microsoft Word format :

Here is a short description of how cleartype works:

For a detailed discussion Wikipedia has an excellent article. Also interestingly WPF renderes all text in cleartype. But so does every windows by default starting from Vista.


Friday, October 14, 2011

CSS Quick Guide

With JQuery which supports CSS selectors in its query part and ASP.NET MVC giving complete control over the HTML, CSS has never been this important for a .NET developer (that works with a designer).

So, here is a short warm up session for CSS that might be useful for you right before you go into a web developer interview.

You can follow this link if you want to download it. 

Monday, October 10, 2011

Installing ASP.NET MVC 3 all in one for Visual Studio 2010

Simply install the mvc 3 tools update :

This contains EVERYTHING you need to get started with ASP.NET MVC 3. This will actually even install NuGet 1.2 for you :)

There is NO need to install the mvc 3 RTM : although if you already have it installed it will not get in the way. The tools update contains the same binaries and the only improvements are in Visual Studio between the two versions. So no need to update projects you have made with the original ASP.NET MVC 3 RTM release.

Compatibility with SP1 / without
It does not matter if you have SP1 installed or not. The special case is when you have Async CTP installed. 

Compatibiliy with Async CTP 
It is not compatible with the original Async CTP. If you want to use async first install the old async CTP. Then you need to upgrade your Visual studio 2010 to SP1 and then install Async CTP SP1 Refresh. Finally you can install ASP.NET MVC 3 tools update and everything will work fine :)


Saturday, October 8, 2011

Comparison of Knockout.js and Backbone.js

Knockout.js is a great micro javascript library that allows you to make MVVM style applications with Javascript. To learn more about knockout.js check out there awesome live (in the browser tutorial) at :

But enough about what is Knockout. Lets move on the how cool is knockout. A sample TODOs was provided by Scott Messinger about how cool Knockout.js is as compared to Backbone.js.

In backbone.js :

And in Knockout.js:


Offline Installer for Visual Studio 2010 SP1

Reinstalling windows is something that I do at least once a year on any machine that I have ever used. Its not a bad omen on the part of windows ... its just that I like my computer system to be clean. So I would really like to have an offline installer for Visual Studio 2010 SP1 that I just run after windows reinstallation rather than waiting to download 500 MB with an online installer. So here is the offline installer for Visual Studio 2010 SP1 core.

Download it here 
Note that the size of the offline installer is 1.5 GB+ because it contains upgrade files for every possible upgrade path (x86 / x64 etc).

Just extract the iso with winrar and run setup.exe.
Note : I recommend that you uninstall AsyncCTP (pre SP1 version) before you being this installation.

Actionscript for C# developers

I've been learning Actionscript for some while now. The reason being the ability to target iOS / Android / Facebook gaming with a single platform.

C# for me is what my brain likes to think in (when it is not thinking in pseudocode or python). Here is a document that I made during the process of learning ActionScript as a language when you know C#.

Note: This document is a constant work in progress thanks to Google docs ability to sync between various computers I own I can chose to start and stop work on it from anywhere :)

You can download the word document file here.

Or view it here:

Friday, October 7, 2011

Razor View Engine Cheat Sheet for C#

C# Razor view engine is the most beautiful templating syntax I have ever seen in the MVC frameworks (rail and django included ... sorry for bringing django up).

Here is a quick cheatsheet that I made when revising if there was anything about the syntax that I didn't get the first time. I am sure there are still syntax related things that I am missing. If you feel that anything needs to be added to this let me know.

Wednesday, September 28, 2011

Server.Transfer vs. Response.Redirect

Server.Transfer and Response.Redirect might seem like duplicates in ASP.NET but both are very different beasts. The fundamental difference between them is quiet easy to understand.

Fundamental Difference
Reponse.Redirect will forward the new url request to the end user browser as a 302 moved http response
Server.Transfer will continue the server side processing with a new aspx page

Intuitive with Respose.Redirect:
  • take longer due to a roundtrip (server - browser - server)
  • The address in the users browser address bar is changed
  • You can redirect to offsite pages
  • You can redirect to standard html pages
Additionally with Server.Transfer you can access properties of the aspx page that transfered the control whereas with Response.Redirect all the server side data objects are released (you can use session variable etc to store / retrieve and share data between pages obviously). 


Wednesday, September 21, 2011

Android / iOS native marketplace / appstore applications with Flash / Flex Captive Runtime and Native Extensions

I am overjoyed to hear this news! The new version of flex SDK has just been released and now you can bundle AIR runtime WITH your android application. This new feature is called Captive Runtime support.

Press release :

This has always been the way with iOS applications. i.e. you just compile your application and it runs straight from app store with no external dependency required. Previously the user needed to install adobe air separately on his android device similiar to how the user needs to install the adobe air runtime on the desktop.

A walkthrough for the Captive Runtime can be found here :

This will be a huge win for flash / flex that are now fully native on iPad / iPhone / Android markets.

Also now on these devices you have the support to call native apis (similar to PInvoke in .NET). This feature is called Native extensions. A detailed description of how to do this can be found here :

This really means that there is no boundary you cannot cross now with flash / flex on these devices.

Enjoy the new possibilities! 

Making game sprites with anime studio

Anime studio is a great software for rapid animation. I am in no way affiliated with the company ... just a fan :

It is great for character poses e.g. "thinking" pose:

And a "no you didn't" pose:

You can also add auto tweens between poses. And this is exactly what makes it great for making sprite sheets. You can export a sequence of pngs for your animation sequence and them combine them into a single sprite sheet png. Additionally it also has a great effects library support (smoke ... and ... blasts!).

I have known this for quite sometime but I just googled for it and a couple of interesting case studies came up.

Here is a video overview how you can use anime studio with GameMaker (tm) :

Here is a great game for apple iOS drawn with anime studio.
(Details :


Thursday, September 1, 2011

The state of Flex Frameworks

As you might know I have been experimenting with Flex for a while. Due to the ability to target andoid/iOS/facebook in one go!

But the way I am wired I need to know just about everything about the technology before I start to get my feet wet. I learnt this with C#. Didn't know about reference types vs. value types after a whole year of coding! (although ... I do miss the careless abandon of my old coding ways)

I feel that now I have the language Actionscript down (I wrote a small book "Actionscript for C# developers" that I will share after its more stable) and have a fair understanding of the flex / flash apis. I now need to dive into the community work that has been done in flex.

Like silverlight / wpf (where I finally settled with MVVMLight ... and I know why I did that ;) ) I am going about searching for the most community accepted solution for flex. Fortunately I know about dependency injection, MVC (thanks to django), a lot about databinding (thanks to mvvm / silverlight / wpf) so its not a voyage of discovery rather a voyage of rediscovery.

Just FYI : With Silverlight / WPF it is clear to me that if I have ICommand delegate based implementation, a servicelocator implementation (and after MEF is officially a part .NET framework why go with any other?) , an INPC implementation and some form of App encompassing Mediator .... I am good to go! Now I need to figure out how these translate to Flex and what are the solutions proposed by the community.

Here are my two cents for flex:

Cairngorm (what was)
One thing is clear. Cairngorm is the official adobe solution : but is a no go for new projects. Its not really the ideal actionscript solution to the types of problems that are faced :
I do feel however that one should view how it was architectured before moving on to the community shiny frameworks.

Community (what is )
So now the question really comes down to which of these is the way to go. I am selecting the most popular solutions (high number of community supporters) here and not going with the completeness / quality. Because I am trying to be a late adapter for now :)

So heres the list I will be evaluating along with first opinions:

I took me about three months of active research and reading to fullly abridge the whole MVVM frameworks story for silverlight / wpf. I hope it will turn out faster for flex.

Till then enjoy!

Update October 2011:  It has become pretty clear to me that RobotLegs is the way to go. Infact it is one of the most watched Actionscript libraries on GitHub! 

Sunday, August 28, 2011

Debugging ItemRenderers

ItemRenderers are to flash/flex what DataTemplates are to Silverlight/WPF. One of the coolest features (and the one I love the most) of Silverlight 5 is the fact that you can debug datatemplates / binding expression. Well in flex you could do this since version 3.

Check it out the breakpoint currently hit in an item renderer:
Also check out the expression view:
In fact in flex/flash you can debug any section of MXML that is inline inside of {} brackets.

Saturday, August 27, 2011

Django + Google App Engine == love

The support for Django in Google app engine is almost completely perfect. The only thing missing is the fact that you cannot query on joins. A build of Django that is up to date and takes this fact into account is available called "django-norel"

To get started on converting Google App Engine Projects to Django you can view this post :

And to get started on converting Pure Django projects on Google App Engine you should read this :

Thursday, August 25, 2011

Most popular Ruby / Ruby On Rails hosting

It really isn't that hard to find the popular opinion regarding this. Its :

You can start free and go up to social scales. You are charged on database storage + hours of work done by the heroku server. At the time of this writing you see that 750 hrs and 5MB worth of storage are for free:
PS: You do not need to give any credit card details to get started.

This is the popular opinion on stackoverflow. Not to mention that the original creator of Ruby (Matz) is also now working for heroku. And heroku was acquired for $212 Million by just to give you an idea that this company isn't going anywhere.


Sunday, August 21, 2011

Prove intuitively that X * Y == Y * X

I needed an intuitive way to show this to my nephew (why is 6* 7 same as 7 * 6). Its really simple.

By definition of multiplication (Y * X) is read as "Y Xs are" which literally means X items stacked Y number of times. i.e. :

But notice that if we view this data horizontally it is Y items stacked X times i.e. X * Y!

therefore X * Y == Y * X


Using pycharm as an HTML/CSS editor

Pycharm is truly a complete IDE.

While going through CSS the missing manual I am using pycharm as my primary editor and it a joy to work with.

Here is one feature I especially like ... I start with a file like this (notice the terrible wordwrap):

I press Ctrl+Alt+L or the menu  Code -- Reformat Code
And pycharm will even fix the wordwrap for me (along with the obvious fixing the tabs in the head section):

Also ... pycharm has a dictionary checker () as well ... which isn't present even in VS2010 without an extension ... and I haven't found a VS extension that is as painless + on the fly.

Look at the colors in the sidebar
Another neat feature is that pycharm shows the color in CSS in the editors sidebar as shown:

Write CSS Faster:
Pycharm comes with snippets for all the css properties you could even want. E.g. to quickly add margin-bottom simply type mb as shown:
Press tab and you get a region where you can type the value you want:
Press Enter and it takes you to the end of that particular declaration so that you can start work on the next one i.e. note the position of the cursor in this picture:

Final words:
With pycharm I see python / django / GoogleAppEngine penetration really skyrocketing.


Friday, August 19, 2011

All about django hosting

Django is by far the most popular web framework for Python. This was validated further when google app engine provided support for django templates.

So now that the python web framework battle is settled the question of hosting your application is the only one that remains (and will remain ... its a good thing).

Community Page
First off ... the official community page is :

A more personalized page
This is a good link just as it is :

In Short (people's vote)
The most recommended shared host is webfaction.

My Personal recomendation
Feature wise is the best. You even get SSH access! Even make remote user accounts with differentiated permissions.
You can try them for free (not time limited) with a 10MB storage account.


Thursday, August 18, 2011

Using the django version that comes with google app engine as your default

I have google app engine installed in my C: drive and the path to django looks like this :
I modified my PYTHONPATH adding "C:\Program Files\Google\google_appengine\lib\django_1_2;" at the end as shown (the ; should not be important but some ide's need it to scan properly):

To run the django tools from the command line (not google app engine specific ... valid for all django installations): 

I then added the django's bin folder "C:\Program Files\Google\google_appengine\lib\django_1_2\django\bin" to my system PATH as shown:

Next you need to fix the file association using the following registry script (save as .reg and merge)

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\py_auto_file\shell\open\command] @="\"C:\\PYTHON\\App\\python.exe\" \"%1\" %*"

This basically adds this key:

Now you can test it from the command pro as follows :
" --version"


Wednesday, August 10, 2011

Fun fact I didn't know about HTML : Headings

Only 6 levels of headings are supported by html! I never ran into such deep nesting (fortunately)
Read more about headings here :

And here is an image to show how h7 / h8 .... are not supported :

Thursday, August 4, 2011

Great books for Beginner to expert flex development

If you want to learn flex I recommend that you start with this book:

Flash Builder 4 and Flex 4 Bible
The great thing about this book is that it starts by thinking that you are a programmer. It teaches you good practices right off the bat.
Next up read:
Enterprise Development with Flex: Best Practices for RIA Developers
The next step in the evolutionary learning of any gui framework is the eco system and third party design patterns etc. This is where this book comes and covers any thing that you would otherwise need to learn by lots of searching or blogs/twitter following :)


Tuesday, August 2, 2011

Programming Interview Question : Prove that a circle will be surrounded by exactly (and maximum) 6 congruent circles if each circle makes contact with this central circle and no circles overlap

I have known since a child that a tennis ball is surrounded by exactly 6 tennis balls. Here I show a glass being surrounded by exactly 6 glasses :

HINT1 : Use the nature of Equilateral triangles.

HINT2 : By Nature I mean angle :)

Solution : 
This image is pretty self explanatory (though not pretty ...... I a paper cup!)

And so if the centers of each surrounding circle are separated by 60 degrees the full 360 is completed by (360/60) = 6 circles.


Saturday, July 30, 2011

Programming Interview Tip : What is the probability that when you open a random page in a phone book the contact you are looking for is in there?

Lets say the phone book pages are numbered from  1 - 1000. And assume that the contact is definitely there in the book.

So when you randomly flip open a book there are 1 of 500 choices that it is one one of the two pages that appear before you.

So the probability is 1/500.

Next Question : How many attempts will it take for me to be certain that the contact is there? 
Well you can NEVER be 100% sure .... for obvious reasons :)

Next Question : So how many attempts will it take for me to be 50% sure that the contact is found in one of the two pages that show up?
The 50% is called percent confidence in statistics lingo.
This is best solved by the difference from 1 for the probability of the contact NOT being on the page.
For each attempt to fail we need to multiply 499/500 . So for n attempts to fail it is (499/500)^n. So the probability of it being successful in n attempts is {1-(499/500)^n}
So you need to solve the equation :
{1-(499/500)^n} = .5
which is obviously :
(499/500)^n = .5
And taking log to the base 499/500 on both sides (using python) :
>>> math.log(.5,499/500.0)

n = 347 attempts

double verify :
>>> math.pow(499/500.0,346.22690104949118)

Thursday, July 21, 2011

An awesome C# template engine

There literally isn't anything (beyond writing your own operating system level stuff .... and I sure someone did that too ;) ) that I do not see being (already) done with .NET

Want to embed a programming language .... been there done that.
Want to write a highly scale-able object / document database .... done.
Additionally there are a large number of projects that were written first in java and ported to C# (e.g. sharpssh).

And the latest case in point and the reason for this post is a template engine. The StringTemplate. (If you want to learn how to write your own engine ... even that information is available!)

For StringTemplate I suggest that you first view the Five Minute Introduction :

And to see it in use take a look at a code project article :

Next you should look at the cheat sheet :

One point to note is that stringtemplate takes an innovative approach to for loops. It does this by using anonymous subtemplates.
Basically :

<attribute:{anonymous-template}>Apply an anonymous template to each element of attribute. The iterated it atribute is set automatically.
<attribute:{argument-name_ | _anonymous-template}>Apply an anonymous template to each element of attribute. Set the argument-name to the iterated value and also set it.

Looping through a hashtables and lists e.g. is covered in an example here :

And if this doesn't suit you (why wouldn't it? ... I'd like to know). Some project from here definitely will :

Monday, July 18, 2011

Programming interview tip : Finding anagrams

Find all the words in a list of words (listA) which are anagrams of a single input word (wordA).

Bad solution (the trap): 
look at all the possible permutations of wordA and find them in listA.

This is a terrible solution and has a complexity of countOfCharactersInWord(wordA)!
where ! is the factorial symbol :)

Good solution:
take all the characters in wordA and sort them. Then compare it with the each item in listA first sorting the characters of that item as well :)

In python :

This yields for my friend "omair" the following interesting (i made them bold) anagrams:

I used the SCOWL wordlist for this. You can get the complete working code (including the wordlist) from here:

Saturday, July 16, 2011

Programming interview tip : Combinations from a list

This question will be discussed in python, since it is uber simple to write functioning yet short programs in :)

Say you have a list of n items e.g.
seq = [1,2,3]

Find products of all items with each other
This is the simplest question.

This gives the following output:
1 * 1 = 1
1 * 2 = 2
1 * 3 = 3
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
3 * 1 = 3
3 * 2 = 6
3 * 3 = 9

Find unique products of the items with each other
This means that you need that you can only have 1*2 or 2*1 etc
Solution: Really simple to do. Each time in the inner loop start at i rather than 0 as shown:

This gives the following output:
1 * 1 = 1
1 * 2 = 2
1 * 3 = 3
2 * 2 = 4
2 * 3 = 6
3 * 3 = 9
Basically notice at each increment of i we do not allow j to go back.

Find unique products and do not multiply a list item with itself
This means that you cannot have 1*1 , 2*2 etc.
Solution: In the inner loop you need to avoid starting at i and rather start at i+1 (since this is the i*i case we need to avoid).

Also if this is all you do at i = n the inner loop will not run so its better to stop the outer loop at n-1

In both cases the output will be:
1 * 2 = 2
1 * 3 = 3
2 * 3 = 6

Thursday, July 14, 2011

Actionscript Tip : The text layout framework

A great podcast by explains in great detail the new features provided by TLF over classic text fields.

Amongst other things I was really blown away by the flow of text between various text fields which you can watch at 5:30.

Monday, July 11, 2011

C# 101

This came up on my :

And I thought I had added c# expert blogs :)

Using advertisements in android with flex

It is really easy to setup admob with a flash / flex android application. The primary objective is to make free applications for the android marketplace and make revenue with advertisements.



Sunday, July 10, 2011

Actionscript Creme 3

Here's what I found really interesting recently regarding actionscript / flash / flex

Deploying to and android device from Flash Professional

Really simple to do :)

Implementing multitouch gestures : zoom / rotate on Android : 

And you can do them simultaneously as well of course!

Converting an Android flex application to iOS
Can be done in just 6 minutes :)


Fastest way to get your web application on chrome web store

Hands down its appmator :

You just give it your url

Fill in some basic Optional information and it gives you a zip file.

Upload that file to chrome web store and you are good to go!
It cannot get any simpler than this :)

Saturday, July 9, 2011

How angry birds for chrome web store was written

GWT (Google Web Toolkit) ! A complete presentation on the subject was given at Google I/O 2011 titled "Kick-Ass game programming with GWT". Google released a library forplay : which makes game programming with GWT easier (includes things like a Box2D physics engine port for GWT).

You can find the presentation below for your offline viewing pleasure :


Tuesday, July 5, 2011

Actionscript Creme 2 : Books!

And all of these books have great reviews. I believe that flash is the best platform for indie games. You can target the key main dream platforms (android, iphone, facebook, chrome web store) will the same code. And that is simply unbeatable.

So here is a list of books that I would like to go through to be an mid level expert in the matter of flash gaming :

This book is a beginners guide and has 4.6 stars as of this writing on amazon!

Going Advanced! 
By the same fellow (rex spuy) that wrote the above title. Again amazing amazon reviews!

Go multiplayer! 
Start here:
And at 400 pages not a heavy read :)


Monday, July 4, 2011

Actionscript Creme :1

There is a lot of great actionscript content being generated by the community. I thought I'd start a series of blog post about these so here goes.

Handling Orientation in Flash CS5.5 for Android

Basically you create two keyframes with different orientations of the stage and toggle them using actionscript on the resize event by comparing the device height with device width.

Flash Typing text effect
This was super neat and easy to do. I wonder why I didn't think of it. You just split the string you want to type on the screen and store it in an array. Then in the ENTER_FRAME event you simply shift the array appending the shifted character to a textfield on the screen making sure you remove the event listener after all characters in the array have been printed to screen.

Creating Paypal buttons in Flash
Really simple to do really :)

A simple lottery application
An easy to follow tutorial that actually makes a somewhat useful application :)

Creating a Picture gallery
A simple tutorial. More about a simple gallery banner rather than a Gallery. Just useful to get the creative juices flowing for a newbie.

Now for a book I would like to read about actionscript :


Sunday, July 3, 2011

Code first development with .NET hits primetime

I remember code first development since the days of django :

This was on of the best database experience I have had.

Now the same thing is possible out of the box with .NET using code first devleopment. The launch blog post is here :

I just came across a really nice Associations tutorial here :


WPF Tip : Dependency Property changed callback not getting called

If you have a dependecy property of type IEnumerable databound to an INPC property simply raising a propertychanged event in the INPC property will not cause the changed callback of the dependency property to get called.

This is because apparently WPF internally uses an optimization where it checks the equality before calling the callback mentioned in the dependency property metadata. 

To force this callback you can assign the a new Enumerable instance to the INPC property. 

WPF Tip : Events Or commands which is called first?

The answer is Event. This is because the event is used to create the command by the control internally. Even click is handled before the command on a button :)

Saturday, June 25, 2011

Best tutorial of C# Async

This is by far the best tutorial of C# Async you can possibly find for the simple reason that the code is all concise and runs in the browser right in front of you!

The examples are also quite nicely / concisely written e.g. here is a sample of a CPU intensive task made async :

public async Task AsyncResponsiveCPU()
    Console.WriteLine("Processing data...  Drag the window around or scroll the tree!");
    int[] data = await ProcessDataAsync(GetData(), 16, 16);
    Console.WriteLine("Processing complete.");

public Task<int[]> ProcessDataAsync(byte[] data, int width, int height)
    return TaskEx.Run(() =>
        var result = new int[width * height];
        for (int y = 0; y < height; y++)
            for (int x = 0; x < width; x++)
                Thread.Sleep(10);   // simulate processing cell [x,y]
            Console.WriteLine("Processed row {0}", y);

        return result;

And heres a sample that uses the CancellationTokenSource (The CancellationToken is polled once per iteration of the y for loop to see if cancellation has been requested, and if so an OperationCanceledException is thrown.)

private CancellationTokenSource cts;

public async Task AsyncCancelSingleCPU()
    cts = new CancellationTokenSource();

        int[] data = await ProcessAsync(GetData(), 16, 16, cts.Token);
    catch (OperationCanceledException)
        Console.WriteLine("Processing canceled.");

public Task<int[]> ProcessAsync(byte[] data, int width, int height, CancellationToken cancellationToken)
    return TaskEx.Run(() =>
        var result = new int[width * height];

        for (int y = 0; y < height; y++)
            for (int x = 0; x < width; x++)
                Thread.Sleep(10);   // simulate processing cell [x,y]
            Console.WriteLine("Processed row {0}", y);

        return result;

And the best of all report progress sample

(Pings several sites, with an EventProgress object passed in to receive progres notifications.

Note that all calls into the ProgressChanged lambda are occurring while AsyncProgressPolling is suspended awaiting GetAllDirsAsync.)

private CancellationTokenSource cts;
public class GetAllPingsPartialResult
    public IList<string> Pings;
    public int Count;
public async Task AsyncProgressPolling() { cts = new CancellationTokenSource(); var progress = new EventProgress<GetAllPingsPartialResult>(); try { progress.ProgressChanged += (source, e) => { ProgressBar.Value = e.Value.Count % 100; //e is of the type GetAllPingsPartialResult }; foreach (var item in await GetAllPingsAsync(@"c:\", cts.Token, progress)) { Console.WriteLine(item); } } catch (OperationCanceledException) { Console.WriteLine("Operation canceled."); } } public async Task<string[]> GetAllPingsAsync(string root, CancellationToken cancel, IProgress progress) { var sites = new List<string>(); for (int i = 0; i < 30; i++) { sites.Add(""); sites.Add(""); sites.Add(""); } var results = new List<string>(sites.Count); foreach (var site in sites) { cancel.ThrowIfCancellationRequested(); var time = DateTime.UtcNow; try {await new WebClient().DownloadStringTaskAsync(site);} catch {} var ms = (DateTime.UtcNow - time).TotalMilliseconds; results.Add(String.Format("[{0}] {1}", ms, site)); if (progress != null) progress.Report(new GetAllPingsPartialResult() { Pings = new ReadOnlyCollection<string>(results), Count = results.Count }); } return results.ToArray(); }

And if you want to read here is an excellent article :


Friday, June 24, 2011

Basic data insertion into a postgis database

I assume you have setup postgis / postgresql using the tutorial here :

The objective is to make a simple table with site + cell + lon + lat and insert a value in it.

First off the SQL to create a the table :

  "LOCATION" geometry,

The geometery type is one of the types that becomes available with postgis. As it is this table is complete. But the real joy of using a GIS based database starts with the ability to add a GIS index. You can do this by : 

  USING gist

Finally lets insert some data into the table : 

    VALUES ('somesite', 'somecell', ST_SetSRID(ST_Point(-71.1043443253471, 42.3150676015829),4326));

Two functions that come with PostGIS are used here : ST_Point and ST_SetSRID
ST_Point is the basic data type for point based geometries. SetSRID is used the set the Spatial reference system ID. 4326 corresponds to the reference system commonly known as WGS 84 and is the most commonly used. In fact this is the system employed by the GPS system. It is important to note that ST_Point and all other similar functions take coordinates in  Longitude ,  Latitude  order.

Till next time.

Tuesday, June 21, 2011

Disabling windows vista UAC + automatic login on a domain in one go :)

I just followed the procedure mentioned here :

  1. Click Start, click Run, type regedit, and then click OK. In Windows Vista/7, simply typeregedit in Start Search and hit Enter.
  2. Navigate to the following registry key:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
  3. Double-click the DefaultUserName entry, type the user name to log on with, and then click OK.
    If DefaultUserName registry value name is not found, create a new String Value (REG_SZ)with value name as DefaultUserName.
  4. Double-click the DefaultPassword entry, type the password for the user account under the value data box, and then click OK.
    If there is no DefaultPassword value, create a new String Value (REG_SZ) withDefaultPassword as the value name.
    Note that if no DefaultPassword string is specified, Windows automatically changes the value of the AutoAdminLogon registry key from 1 (true) to 0 (false) to turn off theAutoAdminLogon feature.
  5. In Windows Vista/7, DefaultDomainName has to be specified as well, else Windows will prompt for invalid user name with the user name displayed as .\username. To do so, double click onDefaultDomainName, and specify the domain name of the user account. If it’s local user, specify local host name.
    If the DefaultDomainName does not exist, create a new String Value (REG_SZ) registry key with value name as DefaultDomainName.
  6. Double-click the AutoAdminLogon entry, type 1 in the Value Data box, and then click OK.
    If there is no AutoAdminLogon entry, create a new String Value (REG_SZ) withAutoAdminLogon as the value name.
  7. If it exists, delete the AutoLogonCount key.
  8. Quit Registry Editor.
  9. Click Start, click Restart, and then click OK.

One thing not mentioned in the post is that if you set AutoAdminLogin to 1 UAC also gets disabled .... which is awesome. This is because local crontab software will be able to access privalaged services (e.g. reporting services) running on the same computer.

PS: the computer is in a safe location such that anyone who has physical access to the machine is a friend.