Obvious Ideas

From the desk of a Software Developer

Archive for the ‘Code’ tag

App Engine: Mapping Entities Using Deferred Tasks

View Comments

I recently started using deferred tasks in my App Engine application. I’m using them mainly for two things:

  1. splitting user requests into two pieces – one that being done immediately and one that being done in the background, to speed up the response time.
  2. mapping (iterating over) all my entities to calculate various statistics.

I won’t provide here details on how to use deferred tasks, because this is described in detail in a great article by Nick Johnson, which I highly recommend reading. One thing I do want to share from my experience, is my implementation of the Mapper base class:

This implementation is taken from Nick’s article mentioned above, but I made some changes to it. The first change is giving subclasses the ability to set the property to order the entities by. I needed this, because I found out that when your entities have custom key names ordering by key breaks for some reason.

The other change is re-factoring the way the next batch starts. It seems to me that in the sample provided in the article there’s an error in the indentation, resulting in the code not doing batching properly and can even break in some situations. In my version every task run maps only one batch (or less). This is sub optimal in terms of # of tasks it takes to map all your entities, but as long as you don’t have really a lot of entities this is not such an issue.

I really would love to hear others’ comments no my changes and about how you use deferred tasks or map your entities.

Arik

Written by Arik

December 7th, 2009 at 8:57 pm

EXCLUSIVE: The Code Change That Was Needed To Increase Facebook Friends Limit

View Comments

Today Michael Arrington announced that Facebook lifted their 5000 friends limit. As a tech blogger, I bring you the “behind the scenes” view: the code change that was needed to be done to increase this limit:

fb_friends_limit

For the non techies:

  • line 3: commented out – the previous friends limit defined
  • line 4 – the new friends limit

Shocking. :-)

Arik

Written by Arik

May 9th, 2008 at 7:25 pm

Handling RSS Feeds with PHP using Zend_Feed

View Comments

Zend Framework is becoming a very comprehensive set of widely needed components for PHP development. As other frameworks offer similar components, one of Zend’s Framework greatest strengthens is the fact that you can use its components as stand alone components and not only as part of the MVC structure. In this post I will show how you can easily use it’s Zend_Feed component to merge feeds.

Recently I though of making one combines RSS feed of both of my blogs and my twitter updates. There are some RSS merging services out there, and there’s also Yahoo pipes which seems that it’s most useful ability is to do various RSS tweaking tasks. As part of my playing around with the Zend Framework, I’ve decided to make this merged RSS feed using the Zend_Feed component. Actually at the end I’ve realized that this merged feed idea is quite useless, but at least this post came out of it :-)

Most of the basic actions, like importing an RSS feed, creating an RSS feed and more are covered in the Zend Framework manual. In this post I will elaborate more on the more advanced topics, like sorting and merging RSS feeds but I will also go briefly over the more basic stuff as well.

So let’s begin.

Read the rest of this entry »

Written by Arik

February 25th, 2008 at 9:58 pm