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.
Enjoy! 

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 : http://code.google.com/appengine/articles/django-nonrel.html

And to get started on converting Pure Django projects on Google App Engine you should read this :
http://www.allbuttonspressed.com/projects/djangoappengine

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 : http://www.heroku.com/

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 Salesforce.com just to give you an idea that this company isn't going anywhere.

Enjoy!

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

Enjoy! 

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.



Enjoy!

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 : http://djangofriendly.com/hosts/

A more personalized page
This is a good link just as it is : http://djangohosting.com/

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

My Personal recomendation
Feature wise https://www.alwaysdata.com/ 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.

Enjoy!

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 :
"django-admin.py --version"



Enjoy!

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 : http://www.w3schools.com/html/html_headings.asp

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 :)

Enjoy!

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.

Enjoy!