Saturday, March 08, 2014


Been a long time since I posted anything over here. No better day than today to write an update. I am not really sure why I don't feel like writing these days (or reading for that matter) - I guess am just a bit dazed and don't even know what I want to write about. Feeling tired and run down right now, don't know if it cause I've been sick or it's just a state of a the mind!

Friday, March 08, 2013

Lone traveller

The calmness at the railway station was disturbed by the loud siren of the train approaching. All of a sudden, everything sprung to life as if they have found their purpose; as if that’s the moment they all had been waiting for. I looked at the clock hanging at the platform, it was close to 2 AM, train was just late by about 4 hours, nothing special if you are used to how things operate in India, being late and laid-back is the way of life here. Everyone expects it, in fact, I guess quite a few people in India will miss their trains (or bus or whatever) if those things started being on time. The train made a stop and there was a mad rush everywhere, people who had reached their destination were in a hurry to get down but they were being pushed back to the compartment by the crowd which was in a rush to get inside! I don’t know why everyone over here is in such a rush, as-if you get a prize for being the first to climb up or get down, maybe you feel a sense of pride if you are the first. I didn’t have to put in any effort in boarding the train, I was pushed into the compartment by the crowd behind me trying to get in.

I settled myself besides the window and started looking at the lights from lamp posts outside. As the train slowly pulled away from the station, the lights went dimmer and dimmer and by the time the train had picked up speed, I was staring outside at the dark emptiness. I closed my eyes and the same set of questions cropped up again in my mind – Where am I headed? Why did I even board this train? Almost everyone who cared about me had called me out of my mind when I had said that I want to leave everything behind and start afresh, and for that I needed a little time off to do some soul searching, to find out what my higher purpose in this life was – the mountains seemed to be the best place for that. There is some sense of calm about the mountains, the sound of the river streams as they come down the mountains, that you just want to lose yourself in them. By the way, I didn’t understand when people said why I want to leave everything behind, heck I had nothing unless living an aimless life and going through the motions day-in day-out just to keep you afloat is considered everything. Yes, I had a well paying job; a plush house loaded with amenities but is that all that you need? Isn’t there more to life than things that money can buy?

It wasn’t an easy decision to just let go of a life that you are used to even if it is not worthwhile, we humans have the tendency to not come out of our comfort zone, we just hate changes even if they it is good for us. I took a long hard look at my life as it had panned out over last 5-8 years and didn’t find even a single moment that I cherished, a moment which made me smile – yes, there were good times and there were bad times and really really bad times but there was not even a single moment which brought a sense of satisfaction or inner peace. I think I had become like someone who is terminally ill, you don’t have any dreams, anything to look forward to, and you just live everyday as it comes, just trying to survive one more day. I knew I had to break out of that life as I don’t think I could have sustained that lifestyle any longer. And now that I have left my old life behind, I can only hope that the soul searching would lead me somewhere. Perhaps, I will love the mountains & the new life so much that I wouldn’t even want to return back (anyway you need to have something to return back to). Sometimes I do wonder though, if this soul searching is even needed? I already know what I need, it’s just that I am not lucky enough to have what I need. There is a saying – “you don’t always get what you want”, I guess in my case  “I don’t ever get what I really want” would be fitting. Perhaps, I am indeed terminally ill.

Tuesday, May 22, 2012

MongoDB Tidbits - PHP, Mongo Collections and ODM

So I jumped onto the NoSql (Not-Only Sql) bandwagon and off-late have been dabbling with MongoDB and PHP. Coming from a RDBMS background, NoSql is for sure a different paradigm and requires thinking differently. These series of posts are on my experience with MongoDB, the problems that I’ve faced and the solutions/workarounds that I’ve found so far. All the code samples in these posts are on 64-bit Linux version of MongoDB 2.0.3 and PECL Mongo driver 1.2.9. These posts assume basic familiarity with MongoDB.
The reason why I started even looking outside of RDBMS was due to loosely defined schema that I had to support. Basically, on our website a user can submit activities, now these activities can be on different types and the activity attributes change based on the activity type. We started off with MySql DB and soon started realizing that supporting different schemas in a RDBMS was a bit painful. The most popular approach for modeling such kind of schema seems to be EAV (as used by Magento) but I just found it to be a bit too complex. We actually started serializing our entities into xml and dumping them into a My Sql column but I realized that by doing so, I am not getting any benefits of using a RDBMS (no referential integrity etc).
Why Mongo?
Once I decided that RDBMS was a no-go, I started looking out for alternatives in the NoSql world. I had tried playing with Cassandra and Hadoop/HDFS earlier but felt they had a steep learning curve. Also, I feel Cassandra and Hadoop/HDFS are more suitable for applications dealing with huge amount of data, given their distributed nature and complex processing (great support for Map-Reduce). I finally evaluated MongoDB, CouchDB and Redis – found Redis to be a glorified Key-Value store and MongoDB to be closest to a RDBMS (you can have indexes, dbrefs) without being a RDBMS, making it a little easier for people with RDBMS background to learn it.
Mongo Schema Design
After picking on Mongo and installing it, the first choice that you have to make is on the schema design and how to define relationshipts between entities . There are two ways in which you can define relationships –

  1. Embedding: A document becomes a subdocument of another document. You can embed as many levels deep as you wish. Warning – Embedding generally works great if you are embedding only up to one level as Mongo currently does not have good support for querying/updating attributes which are nested multiple levels deep – more on it in a subsequent post where-in I ran into the issue with $ operator.
2.       Linking: Documents are different entities (part of different collections) and are linked by their MongoIds (_Id). Enforcing the relational integrity is primarily the responsibility of the client application.
Based on the docs, I also followed the same principle: if a relationship between two entities is “Composition” , I embed sub- entitiy subdocument else I add it to a different collection and link them using MongoId. Below is one example of composition and linking –
>  db.activities.find({}).pretty();
activityTitle:”This is example”,
Here tag is a subdocument (1:n relationship), whereas submittedBy has the reference to the Id of the user stored in db.users. Tag by itself can be a complex object (i.e. it can have its own attributes like tag:[{tagId:1,name:”tag1”,submittedBy:23},…].

That’s pretty much on the schema design; currently our schema design is pretty straightforward with collections for “top-level” entities like activities, users, keywords (more on this later) and subdocuments for sub-entities like tags.
One caveat: Mongo column names are case sensitive, which is different from MySql. Quite a few times in the beginning, I have had the col name in wrong case and wasted bunch of time trying to figure out what’s wrong with my query.
ODM (Object Document Mapper) Strategy
 Once the Mongo collections are finalized and the PHP DTO/Models (Data Transfer Object) classes defined, the next step is to figure out how are we going to map our models to Mongo collections and retrieve/persist the same? The PECL driver is pretty flexible but only support retrieving/persist PHP associative arrays, so there has to be an adapter in between which converts our PHP class into an associative array. There are few mappers available already like Doctrine and Php-ODM but somehow I wasn’t very comfortable with them – doctrine: seemed to be a bit too heavy, whereas Php-ODM relies on storing property in an internal array; what we wanted was a way to store protected variables and have getters and setters so that we can validate the values and typecast them. Also, we had the need for being able to return only a subset of properties (in case of partial update). Our implementation is pretty simple: every model inherits from BaseModel which has a method toArray(). The toArray() just calls get_object_vars() and takes two optional arrays as parameter: includeItems and excludeItems. Below is the implementation of our toArray() method –

Our Models have protected variables for properties which need to be serialized and override the toArray() method if needed.

That's pretty much it for our ODM

Thursday, March 08, 2012

Still searching...

Another year, same day when I think about where I am, what am I doing and what do I want to achieve. Another year, same day and I still haven't found answers to any of these rhetorical questions. Sometimes, i do wonder if I'm being even reasonable but then "what's rhyme or reason to a fool or a dreamer?" Who am I being these years, a fool, a dreamer, maybe both?  Anyway, reasoning is a relative term, I know, I could convince others based on my reasoning if they are at least willing to listen.
I'll keep waiting for answers...there's nothing else for me to do, anyway.

Monday, December 05, 2011


Seven years went under the bridge like time standing still...

Funny how, at times, life moves backwards and takes you to places you've been trying to run away from all this while. Perhaps, it's just life's way of reminding you of things that you've been missing and yearning for deep inside.

Tuesday, November 01, 2011


Guess, woke up on the wrong side of the bed today - feeling little down and out. Don't know why but I have these phases where I just feel run down - times when I look back at my life and don't feel really great about where I'm headed. I know that it's just a passing phase and soon I'll be back to normal - living life day by day. The thing about living your life in a way which doesn't excite you or keep you involved everyday is that it's just not sustainable, one day, you'll break out of it for sure. There's no point in continuing with something which has long been broken long ago. The issue is with finding out the thing that moves you, that makes you feel good but as I've always quoted - "I can't tell you what I want from life but I do know for sure what I don't want!". Maybe, I do know what I want but you can't always have what you want, can you?

Monday, September 19, 2011

Windows Phone 7–A Review

OriginalPngIt’s been more than 3 months now that I’ve been using a WP7 and I guess now I have enough idea about what I like about WP7 and what I don’t. This post is a mini-review on the review and I would not touch upon the hardware much. Also, I haven’t upgraded to Mango (WP 7.5) so I won’t talk about Mango much, though most of the stuff that I’ll be writing about would be applicable even for Mango.

Preamble – I’ve been a Windows Mobile user since quite a while and have had Windows Mobile powered devices since Windows Mobile 2003 SE. I still own quite a few Windows Mobile powered devices from Windows Mobile 5 to Windows Mobile 6.5. I have also played with iOS 4 and Android (2.3) powered devices.

The Likes -

Firstly the good things about WP7 – the OS is actually quite snappy and live tiles is a pretty cool and refreshingly different idea than almost all the other mobile devices out in the market. The lock screen on WP7 is the best with all the important stuff right there on the lock screen itself including missed calls, email/text notifications and calendar stuff. Native integration with the cloud and social networks (facebook, twitter, linkedIn) is pretty slick too.

The Dislikes or things that need to be better -

This is going be a much bigger list than the “likes” list – not because there are more things to dislike about this OS but because some of the things are simply annoying and make you feel like pulling out your hair Smile

  1. No Outlook Backup - I have been used to syncing my older WM phones with Outlook – everything on my phone was backed up including Contacts, Tasks/Calendar using Outlook. I did try backing up on the cloud using Live Mesh but somehow was more comfortable with backing up to a local computer which I use daily. The first thing that I did when I got my new WP7 phone was to connect it to the computer and heck, figured out there is no Outlook sync – so there was no way for me to get my contacts back on the phone. Quite stupid given that Outlook is still the best personal manager (email, tasks, contacts and calendar) available and I use it almost daily. I don’t think it can get any more stupid that getting your contacts synced from Facebook/Google/Hotmail takes a matter of minutes but syncing with your own personal computer is impossible. So, I had to figure out a way to sync my Outlook contacts/calendar with the cloud – in the end I had to use GO Contact Sync to sync my contacts with my Google a/c so that I can get them on my phone.
  2. No Text Message Backup - The text messages on my WM 6.5 were backed up using MS MyPhone. In WP7 there is no way to backup text messages so one hard-reset and all your messages are lost forever!
  3. Look ma no paste – I know there is copy-paste support since NoDo but what I am talking about is the paste support in the dialer app. I don’t know what the devs who disabled this support were smoking but there have been numerous instances where the phone number on a website is not recognized by the OS and the only way to currently dial such number is to write it down somewhere (or use speech) and then dial it manually. Yes, there are 3rd party apps which let you paste a number, but seriously, why can’t the native dialer app have this?
  4. No Tasks Support – Guess fixed in Mango but really silly that there is no way to sync your tasks and there is no native task app (with reminders) in WP 7.0.
  5. Text Contact Details – If you want to share a contact’s details with somebody else on WP7 then you are quite out of luck – guess sharing contacts via text messages is not considered very social any longer – you should just share them on the cloud somewhere!
  6. International Assist – Perhaps I should have RTFMed before making a phone call but this feature gave me headaches when I tried reaching a local 1-800 number and the dialler kept on adding a + before the 1 (i.e. making it an international call). A frantic Google search made me realize that it’s a feature! I hate it when some apps try to outsmart the user. Ideally, the International Assist should be turned off by default and not turned on.
  7. Mail an attachment – The only attachment that you can send from the Pocket Outlook (or whatever it’s called) is of type pictures! I know I can send Office documents using the Office hub but seriously why I can only attach pictures from the mail client is beyond me.
  8. Half Baked Call History – The call history on WP7 is like one endless list of calls without any support for fitlers like Incoming, Outgoing and Missed. I can perhaps live without the filters but there is no way in the Call history to tap on a number and view the call history log just for that number. The call history by number is important when you do get a missed call from an unknown number and you want to check if you have received any other calls from that number or not.
  9. Lack of Customization/ General UI observation – Let’s face it, users love customizing their phones – customization is what makes a phone truly yours. Unfortunately, the only changes to the appearance that you can make is altering the accent color (from a list of predefined ones) and choosing a light v/s dark theme.

    The live tiles home screen wastes a bit of real estate by showing the right arrow always. I have never clicked on the arrow ever and have always swiped to get to the app list – so not sure if that arrow is needed. Perhaps, the navigation arrow can be removed all together giving more horizontal space to the tiles. Maybe it’s just me but I somehow preferred the honeycomb UI of the 6.5 for the app list instead of an endless list (with jumplist in Mango) of WP7.

  10. Capacitive Hardware Buttons – Maybe I am nit-picking but there should be some way of at least disabling these buttons while you are playing a game like Fruit Ninja – so many times I’ve had the Bing Search open because I moved my finger accidently on the Search Icon while playing.
  11. Zune Now Playing Artist Info – The Zune Now playing integration thingie (where it pulls up artist information from the marketplace) has never worked for me even though I have an US Zune a/c with US mailing & billing address. Funnily, Zune has no issues in pulling artist information from marketplace on my computer.

That’s pretty much it – looking at the “dislikes list” it might look like that I have more to bitch about WP7 than what I like but the fact is I actually find WP7 to be quite slick and if the above inconveniences are fixed than it’s going to be quite a force to reckon with in the Mobile space.

* Image courtesy – Dell.