Sun, 11 May 2014

I have participated in this year's competition of  Google Code Jam. Being my first time in an online competition ever, it was pretty interesting, and tough!

The competition was as high as you can imagine, with people from all the different countries in the world, solving problems in minutes, problems that I would need at least an hour to solve. After getting disqualified today, I have realized I'm very slow when it comes to problem solving. I'm not sure if this is a bad thing though, it did serve me quite well when I used to work back in Zain, but it certainly didn't in an online competition.

Q...


Sat, 18 Aug 2012

For this website, I have a model called Category defined as follows:

class Category(models.Model):
    name = models.CharField(max_length=64)
    parent = models.ForeignKey('self', null=True, blank=True)

I wanted at some point to retrieve all the descendats of a certain category, unfortunately Django ORM doesn't have this feature out of the box (yet), so I had to create my own. The idea is create a recursive function that will collect a list of all the siblings at a certain depth and then move on to depth+1 until we get to the leaves.

def get_children(category):
    nodes = Category.objects.filter(par...