Wednesday, April 4, 2012

Choosing MV(V)C library for Cowspa

In the initial phase of this open source project cowspa developed by Cowoop, we had chosen knockout.js as important client side component.

However during the implementation team bowed to the delivery pressure and couldn't get a chance to learn, explore and use knockout or any other MVC library. Certainly a mistake! Ultimately we have to paid the price of having to maintain really complex pure jquery based bug-prone codebase. However at this stage, I decided to rectify this and started looking for different client side templating and MVC libraries. Essentially the library that binds the templates to data and can auto-update as the data changes.  I was stunned by choice of libraries/frameworks available.

There are just too many of them. Ones I liked are
Ember is perhaps the best one even according to this post. Angular is very capable and is sheer magic. And well there are many more like excellent backbone.js.

We finally narrowed down two options: Knockout and Agility.

Agility, I liked most, mainly because of it's clear syntax and looked like producing very maintainable code. So it was really tempting to go for it. But for us at this point of time knockout scored better at mainly with it's project maturity (age). Agility is at 0.1.2 at this moment and knockout 2.0.0 and hence knockout enjoys much bigger community. Also this question on stackoverflow http://stackoverflow.com/questions/9758303/how-to-bind-a-data-structure-in-agility-js .


So while we go ahead now with knockout I will certainly keep an eye on agility's development would love to find an excuse to use it.

Thursday, November 25, 2010

Redis patterns | search

Problem

You want to implement search against user objects stored in redis using Python. Something like querying for all user ids whose username begins with "an".

Solution

Here we have user objects stored in as hashes with "user:obj:" as prefix.

For example

user:obj:3955 {id: 3955, username: 'John', ..}

We need some extra data structures to support our search i.e. (search user objects where username begins with given phrase. So search for jo should match John, Joe and so on. We will use sorted sets of all usernames and will assign every element a score. This score is a float and helps us in finding the matching words.

Some scores for eg.

a -> 0.097
ab -> 0.097098
ac -> 0.097099
bc -> 0.098099

So for above four string if we find strings that has score that is => 0.097 and < 0.098, we find all strings that begins with 'a'


Code



Discussion

This to demonstrate simple redis pattern and using it in Python.

See Also

There are already some good writeups on related topics.

Saturday, August 28, 2010

xfce and ubuntuone

I do like Ubuntu Netbook Remix’s UI. However with 10.04 it’s just gone so unstable for me.
  • After login when system prompts for keyring secret, UNR environment crashes and drops to gnome. I have to relogin if I need UNR env.
  • After I removed a few packages it could not just start gnome panel causing a great inconvenience. I guess this is due to Evolution integration with latest Ubuntu. Mail client I like and use is Thunderbird. I cant switch to Evolution.
  • Initially after 10.04 release it was damn slow to respond, so had to do some work around to get it to acceptable speed.

Considering all that I decided to switch to Xfce. It just worked like charm. But now I also use (and like :) ) UbuntuOne service for my backup. UbuntuOne is not integrated for XFCE. Also you cant do everything from UbuntuOne’s cli.

u1sdtool -q; killall ubuntuone-login; u1sdtool -c # configuration
u1sdtool --create-folder ~/my_data # add folders you want to be synced
u1sdtool --list-folders
u1sdtool --current-transfers

For more details you might want to check Ubuntu One wiki .

Wednesday, February 24, 2010

Reliance Netconnect Broadband+ on Linux

  • It works. Make sure while purchasing you inform them that you use Linux
  • It’s fast and reliable in Pashan, Pune area
  • Below config worked for me on Ubuntu 9.10 AND 10.04
  • There are Linux drivers on the CD but I could not get it working on Ubuntu 9.10.
  • For activation, I had to use Windows :(

sudo apt-get install usb-modeswitch wvdial

vi /etc/wvdial

[Dialer Defaults]
Phone = #777
Password =
Username =
Baud = 460800
Stupid Mode = 1
New PPPD = 1
Tonline = 0
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
Baud = 460800
Modem = /dev/ttyUSB0
ISDN = 0

Saturday, January 2, 2010

All izz well?

Surely one of the most over-hyped film. What was good? Aamir, Music and the first half laughs. Post interval it becomes a predictable, boring, idiot bollywood movie.

Munnabhai s were certainly better. I would say watch it on TV or atleast don’t pay 3 times higher than usual for tickets like we did. 4 and half stars by critic hmmmm..

Friday, March 27, 2009

Unicode

Pulling your hairs over some i18n bug or you fix it but are not able to explain what. This is little help in getting fair idea about unicode/codecs/encoding/decoding etc.

Quick tips:

a. It does not make sense to have a string without knowing what encoding it uses.
b. Utf-8 is a way of storing string of Unicode code points.
c. Encoding: Transforming a unicode object into a sequence of bytes
d. Decoding: Recreating the unicode object from the sequence of bytes is known as decoding. There are many different methods for how this transformation can be done (these methods are also called encodings).

Now
Must Read 1. http://www.joelonsoftware.com/articles/Unicode.html
Must Read 2. http://stackoverflow.com/questions/447107/whats-the-difference-between-encode-decode-python-2-x
Continue reading 1: http://farmdev.com/talks/unicode/
Continue reading 2: http://diveintopython.org/xml_processing/unicode.html
Continue reading 3:http://stackoverflow.com/questions/440320/unicode-vs-str-decode-for-a-utf8-encoded-byte-string-python-2-x

Saturday, March 14, 2009

Tata Indicom USB Modem on Linux

cat /etc/wvdial.conf

[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = USB Modem
Baud = 460800
New PPPD = yes
Modem = /dev/ttyACM0
ISDN = 0
Stupid mode = 1
Phone = #777
Password = internet
Username = internet


Don't understand above. Um ok but I am too lazy to explain.