Why I like PythonMonk

•April 13, 2013 • Leave a Comment

For a while I have been thinking about learning a dynamic programming language. These are the best days to be a young fella with time on hand. Computing power has become cheap and you no longer have to target one or two OSes from giant monopolies. Heck even Macs are cheaper. And right out the box these machines (Macs) come with everything installed for creating awesome software solutions. If not, whatever you need is just a repository away on GitHub.

My passion is Healthcare IT. I am always on the lookout for good EMRs and Hospital Management Systems that may be implemented for use in 3rd World countries. Once you bring in the restriction of cost, you are pretty much cornered into looking for systems built using free open source solutions. And, most of these are developed in software ecosystems I have not extensively worked in. When I discovered OpenMRS, I was thrilled by the features it offered and, the fact that it was actively being developed and used in African countries was even more reason to gravitate toward it. But. There’s always a but. OpenMRS is built in Java. Although I am not planning on monkeying with the code daily, it helps to be able to roll up your sleeves and just start debugging. The entire ecosystem did not feel like home. The Java ecosystem has matured so much its just wasn’t inviting. Don’t get me wrong. All of this is based on pure gut. I have nothing against Java. But I don’t like it that Oracle now owns Java. Then I discovered GnuHealth. An open source Hospital Management System developed in Python.

Ruby is very popular. It’s a dynamic language. Has matured enough for CodingHorror to pick it up for his next big thing called Discourse. I have the Ruby pickaxe book. My friend Lucid coder raves about it too. But I still wasn’t sure because there are not EMRs or HIS built on Ruby. 

That brings me back to Python. I have been paying a little attention to Python but never seriously. It was time. Having settled on that, next up was to figure out where to begin. Google search threw up several resources. Mainly pointing to Learn Python the Hard Way. This might be the best way to master Python but it certainly will take a while to complete. Then I signed up for Codeacademy. This is good but a little elementary and slow paced for my needs. 

 I realized that my needs are different from the needs of someone wanting to learn a new programming language. Most tutorials target novices. People who have no programming background. But I want to learn how to develop software solutions with a new programming language. Although getting a good grip on fundamentals is paramount, I don’t need to start at learning what variables are, what for loops are or what ifs are. If you do not have a programming background Codeacademy works great. 

As if on cue, the awesome folks at CodeMonk released PythonMonk. I have been “following” the maturity of RubyMonk, although I had not spent time experiencing it. It was like everything was aligning in the heavens. My discovery of GnuHealth. Deciding Python is what I want to learn and the release of PythonMonk.

I signed up and completed the lessons and problems in 2 days.

If I have to sum up the experience of PythonMonk in one phrase, “Mind Blowing” is what I would use.

And here is why.

The lessons are simple with just enough concepts targeting both novices and experienced programmers. People with no background can comprehend the concepts but there is enough intrigue for experienced programmers to relate to learned concepts. The problems presented at the end of each concept build upon what has been learned but don’t let you blindly bang out code. You have to stop and think, no matter how simple the problem is. This, in my opinion, is the biggest differentiation of PythonMonk compared with other tutorials. Anand has done an extremely awesome (I know I cant stop gushing) job putting together these lessons. Monk suits perfectly. Most tutorials present problems which can be completed using only the concepts presented earlier. You can waltz through them. Not here. Not on PythonMonk. 

The last problem of sorting a list by file name extensions is interesting. This problem is what led to my epiphany. The solution is pretty simple. However, it cannot be completed purely by picking up the concepts presented. You have to venture beyond, on your own, learn a bit more and then solve it. The solution needs an extra concept that is not directly presented in  any of the lessons. But if you are the curious type, then you would have learned it on your own building upon the lessons presented and arrived at the simple solution. This is the power of PythonMonk.

I haven’t become a Python expert after completing the lessons on PythonMonk but, these lessons have filled me with enough intrigue and passion to continue my education and have armed me with enough concepts to dig further.

Hats off to you guys at CodeMonk. Thanks for PythonMonk and keep up the awesomeness. 

How to handle TabHost TabChanged event in Mono Android?

•August 2, 2012 • 1 Comment

Being new to Android development I struggled with this one for some time and hopefully this post will save some poor soul the agony I went through.

After I added a TabHost widget to my Layout I assumed I could attach an event handler to either the TabSpec component or the TabHost itself and listen to these events in the activity. But this does not work. Googling and trolling stackoverflow threw up old references which no longer were valid for 4.0.1 version of the SDK I am targeting.

However the technique is very simple. 

The TabHost has a method named “SetOnTabChangedListener” which takes in an instance of class implementing the IOnTabChangeListener interface. 

So all you got to do is implement IOnTabChangeListener in your Activity and set the listener on the TabHost like so

TabHost.SetOnTabChangedListener(this)

Your activity class needs to implement only the OnTabChanged method and you are golden. This method is called when any tab is clicked and you may do whatever pleases you in the method. The tabId is passed in as a parameter. This is the same string you used when setting yo individual tabs.

spec = TabHost.NewTabSpec(“home”);

There you have it. Enjoy.

My current reading list

•September 21, 2011 • Leave a Comment

After a really long time, I just took a break from constant coding and read The Kingkiller Chronicles Day 1 (The Name of the Wind) and Day 2 (The Wise Man’s Fear) back to back. Enjoyed it although felt both were rushed toward the end as if the author wanted to finish the book under 900 pages. Local library is a great place to borrow books and now with Kindle lending this should be even better.

Here is the list of books in the queue

1. Sencha Touch in Action by Jesus Garcia and Anthony DeMoss

2. Node.js in Action by Mike Cantelon and TJ Holowaychuk

3. HTML5: Up and Running by Mark Pilgrim

4. Programming Razor by Jess Chadwick

5. jQuery Mobile: Up and Running by Maximiliano Firtman

6. Pragmatic guide to Sass by Hampton Catlin and Michael Lintorn Catlin

7. CoffeeScript Accelerated Javascript Development by Tervor Burnham

8. Meaningful Use and Beyond A Guide to IT Staff in Health Care by Fred Trotter and David Uhlman

9. The Way of Shadows (The Night Angel Trilogy) by Brent Weeks

10. Wired by Douglas E. Richards

11. The Frozen Sky by Jeff Carlson

WOW! not sure how I am going to find time to read them all.

2010 in review

•January 2, 2011 • Leave a Comment

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads This blog is doing awesome!.

Crunchy numbers

Featured image

A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed about 2,400 times in 2010. That’s about 6 full 747s.

In 2010, there were 6 new posts, growing the total archive of this blog to 57 posts. There were 9 pictures uploaded, taking up a total of 1mb. That’s about a picture per month.

The busiest day of the year was October 18th with 106 views. The most popular post that day was 5:01 Developer.

Where did they come from?

The top referring sites in 2010 were sterling.codeplex.com, davybrion.com, twitter.com, silverlightshow.net, and reddit.com.

Some visitors came searching, mostly for stylecop vb.net, stylecop for vb.net, stylecop vb, vs2008 trial upgrade, and upgrade vs 2008 trial.

Attractions in 2010

These are the posts and pages that got the most views in 2010.

1

5:01 Developer August 2007
13 comments

2

Using the Sterling database in your Windows Phone 7 App November 2010
2 comments and 1 Like on WordPress.com,

3

Upgrading trial version of VS2008 to licensed version February 2008
2 comments

4

Opening an iPhone 3G – Be Extra Careful January 2010
1 comment

5

It takes guts to do Agile scrum March 2010
3 comments

Introducing HealthCaddy–A Windows Phone 7 App

•January 1, 2011 • Leave a Comment

Do you track your blood glucose, blood pressure, heat rate and, weight readings as part of your health maintenance goals? Then HealthCaddy is your buddy. This Windows Phone 7 App helps you track these important health readings.

The main reading entry screen displays a quick snapshot of four most recent entries. Double-tap the graph to display a full-screen version of the graph which also allows you to view historical readings.

HealthCaddy uses the CTP version of Telerik Windows Phone 7 date and time picker controls. Data is stored to the phone’s isolated storage via the excellent Sterling database engine. And, like discountCalc, HealthCaddy also uses MVVMLight framework to achieve UI and business logic separation.

Here are a few screen shots of the app.

HealthCaddy_ScreenShot1HealthCaddy_ScreenShot2

HealthCaddy_ScreenShot3HealthCaddy_ScreenShot4

HealthCaddy_ScreenShot5HealthCaddy_ScreenShot6

I had to cut out certain features of the app to hit the December 31st 2010 deadline. I intend to implement these ASAP. I am also awaiting the release of version 1 of Telerik controls and the Sterling database engine. These updates will be rolled into the next point release.

I have also setup a UserVoice forum to solicit feature suggestions for future implementations. Post your feature requests here and cast your votes.

discountCalc – My first Windows Phone 7 App

•December 9, 2010 • 2 Comments

discountCalc, my first Windows Phone 7 App has been published and is available in the Windows Phone 7 Marketplace. It is a very simple discount calculator but unlike typical discount calculators, discountCalc allows you to specify two discount amounts and computes the total discount. This is especially useful when shopping at the big box stores where they like to throw in a additional discount for that day. Say, you want to figure out the price of an item discounted at 50% with an additional 15% discount. Most people erroneously assume that they are getting a 65% (50 + 15) discount. Computing 15% of 50%, although not impossible, is not trivial. discountCalc takes any guess work away and makes figuring out the final price very easy. Just plug in the numbers and you get the answer. You can even play with the percentage numbers and discountCalc does on-the-fly computation. Here are  screen shots of the app.

 DiscountCalcScreenShot DiscountCalcScreenShot2

From idea to marketplace, developing for the Windows Phone 7 has been a breeze. Granted it is a very simple app, but I wanted to get the experience of inception to marketplace. Overall, I am extremely happy with the experience. I bought a Mac Mini to develop iPhone apps but never got enough hang of Objective-C to create an app. It’s not that Objective-C is hard but I found it difficult to find time to become knowledgeable enough to create an app. The fact that I use Silverlight in my day job helped me build this app quickly. Creating the art work and getting it just right too some time.

I would like to thank the following people for extending their help during the development of this app. Without these bright folks’ support I could not have published this app.

1. Dele – My cohort at work. Extremely fortunate to be working with such a talented individual. Having successfully published his app (Easy Diary), Dele, helped me get unstuck several times and offered invaluable review comments

2. Joel, Microsoft MVP (Mobile) – Without Joel lending me one of his several Windows Phone 7 devices I could not have tested my app on an actual device. Probably would have had to wing it and risk rejection. Testing on a device is invaluable and for this I am indebted to Joel.

3. Laurent Bugnion, Microsoft MVP (Silverlight) creator if MVVMLight, a Model-View-View-Model framework for WPF, Silverlight and Windows Phone 7 applications. Enjoyed working with MVVMLight. A big thank you to Laurent for trying to help me with what I assumed was a MVVMLight framework but. It actually turned out to be one of the Telerik DLLs.

If you have a Windows Phone 7, please check discountCalc out. All feedback welcome.

del.icio.us Tags: ,

Using the Sterling database in your Windows Phone 7 App

•November 27, 2010 • 3 Comments

I am working on a Windows Phone 7 app (stay tuned. Will reveal soon) and needed a database to manage my data. As you may be aware, the current release of Windows Phone 7 does not have a native embedded database, unlike SQLite for the iPhone platform. A Google search landed me this proof of concept project that makes SQLite available for Windows Phone 7. Coupled with the SQLite Manager Firefox add-on, it looked like I had everything I need for my data storage solution. This blog post, which outlines the creation of a helper class, made using SQLite in my app even easier.

But then I hit a roadblock. No matter what, I could not get my app to talk to my SQLite database. I could not get rid of the “Unable to open database file” exception. So, I gave up and resumed my search. This time, search revealed Sterling, an Isolated Storage database for Windows Phone 7 with LINQ support created by Jeremy Likness. Perfect.

The codeplex home of Sterling has everything you need to start using this excellent storage solution for your Windows Phone 7 app. Source, sample code, documentation (MS Word and PDF formats). You get everything. However, I did run into a few hiccups and hopefully my findings below will help you get past any blocks. This is not a replacement for the excellent documentation for Sterling. I am filling a few gaps that will help those not familiar with Silverlight and/or Windows Phone 7 get Sterling setup quickly.

Here’s how you do it.

1. Download the latest Sterling changeset (69384 as of this writing) from here and extract the zip file to a folder of your choice

2. The following folders will be extracted

Folder Name Description
BuildProcessTemplates Templates used by TFS build process
doc Sterling documentation in Word and PDF formats
src Sterling source code and sample projects

3. The src folder contains the following sub-folders

SetupSln Visual Studio setup solution
SterlingSln Sterling source for Phone and Silverlight projects, samples

4. The SterlingSln folder contains the following

SterlingExample A sample Silverlight project demonstrating the use Sterling
SterlingExample.Web ASP.Net web project that hosts the SterlingExample
WindowsPhoneSterling A sample Windows Phone project demonstrating the use of Sterling
Wintellect.Sterling Sterling engine for use in Silverlight applications
Wintellect.Sterling.Test Visual Studio test project for Wintellect.Sterling
Wintellect.Sterling.WindowsPhone Sterling engine for use in Windows Phone applications

5. The SterlingSln folder also contains the following Visual Studio 2010 solutions

WindowsPhoneSterlingSln.sln VS2010 solution with a Windows Phone sample app (WindowsPhoneSterling) and Windows Phone Sterling engine (Wintellect.Sterling.WindowsPhone)
Wintellect.Sterling.sln VS2010 solution that loads the Sterling engine for Silverlight (Wintellect.Sterling) and a VS2010 test project (Wintellect.Sterling.Test)
Wintellect.Sterling.WindowsPhone.sln VS2010 solution that loads the Sterling engine for Silverlight (Wintellect.Sterling), VS2010 test project (Wintellect.Sterling.Test) and the Sterling engine for Windows Phone (Wintellect.Sterling.WindowsPhone)

The Windows Phone 7 sample app that demonstrates the use of the Sterling engine is WindowsPhoneSterlingSln.sln. In my opinion, this solution file should be renamed as WindowsPhoneSterlingSampleSln.

6. Now that we have an idea of what we get in our download, it’s time to use the engine in your project. You can either build Wintellect.Sterling.WindowsPhone.csproj and reference the generated DLL in your Phone app or add Wintellect.Sterling.WindowsPhone.csproj to your Windows Phone solution and opt for Project reference.

7. Peruse the Quick start sections in the documentation to understand how to use Sterling. The “Using Sterling” section outlines the required steps.

And here is where I stumbled.

The sample code following the “Using Sterling” section shows a service class that can be created in your app to ease the use of Sterling. The caption states that the code is from the Sterling Phone example project. However, if you search WindowsPhoneSterling.csproj or WindowsPhoneSterlingSln.sln, you won’t find the service class. A sample service class (SterlingService.cs) is included in SterlingExample.csproj. But that project is a classic Silverlight project and not a Windows Phone 7 project. I was confused. If you look in the WindowsPhoneSterling.csproj sample project, Sterling engine usage code is in App.xaml.cs file. The code in App.xaml.cs follows the steps outlined in the “Using Sterling” section from the documentation. And yet, the sample code that follows service class, for example, code in “Saving your class” section, references the DatabaseService class.

So, after spending a couple of head-scratching moments this is what I comprehended.

The Sterling engine can be setup in your Windows Phone project in two ways

1. Follow the steps outlined in “Using Sterling” section from the documentation and sprinkle code in the various Application service methods (activating the engine in the Application_Launching event handler, deactivating the engine in the Application_Deactivated and Application_Closing event handlers, etc)

or

2. Create a service class that performs the activation, database registration, deactivation and disposal.

Personally I like option 2. Much cleaner code and I don’t have to monkey with various Application service event handlers. Also, I don’t have to declare a public property in the App class to allow access to the current instance of the database. The service class exposes a static property named “Current” using which you can access the current database instance.

Once you create your service class (complete implementation sample can be found in the documentation for Sterling), you invoke it in your App.xaml. Here is the code that you need to add to your App.xaml

1. Add the namespace declaration

xmlns:yourTag="clr-namespace:ServiceClassNamespace"

Replace “yourTag” above with whatever fancies you and “ServiceClassNamespace” with the namespace of your service class

2. Add the service declaration markup to the <Application.ApplicationLifetimeObjects> node in your App.xaml file like so

<yourTag:YourDatabaseService />

When your Windows Phone app starts up, the methods (StartService, Starting) on your service class will be invoked auto-magically. Likewise, when the app is deactivated or shut down, the appropriate methods (Exiting, Exited) will be invoked again. As long as you follow the conventions,

So, there you have it. Hopefully this has been useful. The Sterling database engine is a fantastic Isolated storage solution for your Windows Phone App. Very few moving parts and dead easy to use. Jeremy Linkess has done a very good job of creating an ingeniously simple solution.

 
Follow

Get every new post delivered to your Inbox.

Join 485 other followers