Megen just finished up her last day of her first year in medical school; she is now officially 1/4 of a doctor! Check out the before and after shots of our dining room table:
Congratulations Megen!
Ask and ye shall receive. Attached is a patch for using friendfeed.py on Google App Engine. You need to also have demjson available. Google App Engine does not allow use of many C modules (like cjson) and both json and simplejson will throw decoding errors from time to time. demjson is slow but won’t throw errors around (I really wish we could use cjson; it’s so much faster).
Basically the differences are:
Enjoy!
Update:
You don’t need to use demjson anymore; simplejson will work just fine. I just got an email from Sanjeev saying that they fixed the issue (’\x’ is not valid JSON). This makes things even easier because simplejson is included in Django (from django.utils import simplejson) which is included in Google App Engine.
Google App Engine gained support for memcached today, a very high performance caching system, and I’m already using it in FF To Go.
I’ll share some code with you so you know how it works. This is the code that renders the public feed:
def public(request):
f = friendfeed.FriendFeed()
try:
start = int(request.GET.get('start', 0))
except:
start = 0
service = request.GET.get('service', None)
num = int(request.session.get('num', NUM))
key = 'public_%i_%i_%s' % (num, start, service)
data = memcache.get(key)
if not data:
try:
data = f.fetch_public_feed(num=num, start=start, service=service)
except Exception, e:
return HttpResponseRedirect('/%s/' % e)
memcache.set(key, data, CACHE_TIME)
extra_context = {
'entries': data['entries'],
'next': start + num,
}
if start > 0:
extra_context['has_previous'] = True
extra_context['previous'] = start - num
return render_to_response('public.html', extra_context, context_instance=RequestContext(request))
And that’s it! The FriendFeed team should be happy; I’m using less of their resources because I don’t need to query them as much as I used to. Now this is really only useful on the FriendFeed public feed because all other feeds are likely to be accessed using your FriendFeed credentials and have user specific differences (ie hiding settings) which we don’t want to cache but the public feed does not respond to your hide settings so it is a good candidate. It’s nice to see that using memcached on Google App Engine is no different from using it on your own server.
Am I the first to use memcached on Google App Engine?
Not much to say other than have at it: http://www.fftogo.com/search/
I’ve made a few modifications to FF To Go this morning (with more in the pipeline):
This was an interesting bug. When FF To Go was hosted on Google App Engine I incorrectly set the project’s time zone to EST. FriendFeed’s API returns UTC timestamps for everything; but all the time deltas (”x hours ago”) were working perfectly fine. When I moved FF To Go to my server all the time deltas were off. Turns out that you cannot set the time zone on Google App Engine which means it defaulted to UTC which explains why everything looked correct. Now I have the project set to UTC on my server as well. Time zone issues are always tricky.
No more cycling on the login screen over and over. If FriendFeed returned a 401 (Unauthorized) then FF To Go will let you know and suggest that your nickname or key might be incorrect. If FriendFeed returns a 403 (Forbidden) it’s likely that we are being rate limited (not sure when/why this happens yet).
Alex Gawley wanted it so I added it. You can now adjust your font size here. Other settings will eventually go there as well.
Bwana (and other intense users of FriendFeed’s “hide” feature) were getting pages full of “Entry Hidden” messages on FF To Go. I haven’t completely solved their problem but for now instead of listing each hidden entry out it will show you a counter at the bottom of the page of how many (if any) entries were hidden. I will be working on this more soon; ideally it would make more requests to the FriendFeed API for more entries until it has 10.
I’ve switched to using a unicode aware urlencode when making requests to the FriendFeed API which means that non-latin languages should be able to share/comment now.
Have any suggestions? Let me know!