Development

Morse Code Widget – Submitted Accepted to Ovi Store

April 13th, 2009  |  Published in Development, Mobile, Nokia, Nseries, Releases, S60, hackathon, morsecode

UPDATE: That was fast, just got an email that the widget has been accepted!


I’ve officially submitted the Morse Code widget to the Ovi Store where hopefully it will downloaded onto millions of devices worldwide. And guess what? It’s FREE.

In case you’ve forgotten about it, here’s a brief video showing how it works.

Legislators’ web pages containing earmarks

April 11th, 2009  |  Published in Development, Politics, Thoughts

Over on Taxpayers for Common Sense, they’ve been doing a good job of keeping up with how well House members are complying with new rules about posting earmarks and appropriations to their websites.

The webpage on taxpayer.net gives some insight into their process, but unfortunately, their Excel spreadsheet only uses legislator’s names. This is fine for most individual projects, but if you want to mashup the data across multiple data sources, then ideally you need a common identifier like a GovTrack ID or a BioGuide ID.

Anyway, I took a quick stab at writing an Excel macro which attempted to figure out people’s bioguide IDs. Here’s the results:

Database of FY2010 Earmark Requests (with BioGuide IDs, version 8)

Note that this work was done with version 8 of the Taxpayer.net database, so if they continue to release new versions of their spreadsheet, this representation might be a bit behind.

Are digitally transparent legislators less likely to include earmarks?

March 17th, 2009  |  Published in Development, Errata, Thoughts

For the past two months, I’ve been developing RepresentedBy, a Facebook application created for the Sunlight Labs Apps For America competition. During the two months of development, I’ve immersed myself in the online government world and while I’ve been exposed to quite a lot of great work by passionate individuals, I’ve also realized how little of Congress is digitally transparent.

Digitally transparent can mean a lot of things to different people, so in an attempt to quantify that, I’ve developed what I’m calling the DTI, or Digital Transparency Index. This is a number between 0 and 115 that gives you a rough idea of how engaged a legislator is in the digital world. Legislators are scored on the following criteria:

  • 25 points if they have a public facing email address
  • 20 points if their website has a valid RSS feed
  • 10 bonus points if they’ve posted a news item to their RSS feed in the past week, 5 bonus points if they’ve posted a news item to their RSS feed in the past month
  • 20 points if they have an active Twitter account
  • 10 bonus points if all of the tweets on their home page are from the past week, 5 bonus points if all of the tweets on their home page are from the past month
  • 20 points if they have an active YouTube account
  • 10 bonus points if they’ve posted a YouTube video in the past week, 5 bonus points if they’ve posted a YouTube video in the past month

The sad truth is that Congress isn’t as digitally immersed as a lot of us. Out of 115 possible points, the highest score anyone received was an 85. Worst of all, out of 451 active legislators, 209 of them scored a big fat zero, 161 legislators scored low (meaning an index of 35 or less), and only 81 legislators scored 40 or higher.

digital immersion # of legislators
none 209
low 161
medium to high 81

My first assumption was that this gap was an age related issue. The average age of Congress is around 60 years old which isn’t exactly the average age of of your cutting edge Internet user. However, I compared the results of the Digital Transparency Index with the number of years that someone has been in Congress and didn’t notice any obvious trends implying a difference based on age. Here’s a graph showing the results.

The far right of this graph indicates highly engaged digital legislators, and the far left of the graph indicates poorly engaged digital legislators. Aside from the large number of legislators who are not digitally engaged, when you start looking closely at highly engaged digital legislators, there’s not a huge disparity between the number of new, younger legislators engaging digitally and older, veteran legislators engaging digitally.

Next, I wondered if there was a connection between digital transparency and earmarks. Taxpayer.net recently released information about active legislators and the earmarks they have included in the 2009 stimulus package so I compared the amount of solo earmarks included by each legislator with their Digital Transparency Index, and graphed the results:

While there is a disproportionately large number of legislators who are not digitally engaged and who have not sponsored large earmarks, you’ll notice that as digital engagement increases, there becomes fewer and fewer legislators who are sponsoring extremely large earmarks. The only exception to this rule is Nancy Pelosi who has a very large Digital Transparency Index (80), but has also sponsored a large number of solo earmarks ($15,667,000).

Is this a trend? Does being digitally engaged and having real-time communication with your constituents discourage legislators from sponsoring earmarks? Or is it the opposite and legislators who don’t support earmarks on principle are more likely to take that message directly to the people and engage with them digitally?

Here’s a table summarizing my findings.

digital immersion # of
legislators
avg solo
earmarks 2009
avg years
in Congress
none 209 $5,226,898 15.8
low 161 $6,366,649 16.1
medium to high 81 $4,069,291 15.1

If you want to see where your legislator falls on either of these graphs, then check out RepresentedBy, a Facebook application I’m creating which includes this information and personalizes it to your specific district.

Finally, I hope to develop the Digital Transparency Index some more, so if you have any comments or suggestions on how to improve it, then please include them in the comments.

RepresentedBy Facebook app launches public beta

March 5th, 2009  |  Published in Development, Errata, Releases, Thoughts

My last entry about Google AppEngine and Facebook Applications was written during the development of RepresentedBy, a Facebook application which is still in a rough beta state, but has finally been opened up to the general public.

The goal of RepresentedBy is to:

  • To increase civic engagement.
  • To increase personal awareness of the legislators representing you in Congress and how they are voting on important issues.
  • To share information about your representatives with your friends, and to encourage civic engagement among your peers.
  • To provide an open source learning template for Facebook applications developed with Google App Engine.

The app is still in beta, but once it’s ready for release sometime in late March, then the source code will be made available. In the meantime, please check out the application and let me know what bugs you find, and any problems that you encounter.

Google AppEngine and Facebook Applications – 10 Things I wish I had known

March 1st, 2009  |  Published in Development, Errata, Thoughts

For the past six weeks, I’ve spent some of my spare time learning about Python, Google AppEngine and how to create Facebook applications with them. In a few weeks, I’ve learned a thing or two the hard way and thought I would share some lessons learned to save other developers from beginner’s frustration.

1. Never exceed 1000

When working with AppEngine, it’s good practice never to exceed 1000 in anything you’re doing. You name it, this rule applies. For example:

  • Your application can’t have more than 1000 files.
  • Each file can’t exceed 1000K (this includes third party libraries).
  • Each page needs to render in under 10000ms.
  • Database queries might not return more than 1000 results.
  • Each data structure in memory shouldn’t exceed 1000K
  • Each object stored in memcache can’t exceed 1000K
  • and so on….

Before you choose to build an app with AppEngine, make sure you can accomplish what you want to do within these limitations. It might make sense to only use AppEngine for part of the whole project (e.g. AppEngine for processing and Amazon S3 for storage).

(**UPDATE** Google recently upped some of these AppEngine limits, but not for everything)

2. AppEngine forces your code to scale out, not up

When I first heard about cloud computing and scalable infrastructures, I thought it meant giant supercomputing clusters which can handle massive amounts of processing and calculations.

AppEngine isn’t like this at all. It’s designed from the ground up to be scalable, but it achieves this by doing hundreds of thousands of small tasks instead of tens of really big tasks. And your source code needs to embrace this philosophy. If your script needs to spend time processing thousands of records, you should re-think why it has to be one script instead of ten smaller ones.

Switching my brain to architect for AppEngine was the hardest part of AppEngine development, but once I got into the groove, it makes total sense. I’ve really enjoyed building my applications from the ground up with scalability in mind. I might not be as open minded if I had to port and existing application to AppEngine, but luckily, I haven’t had to do that yet. ;)

3. Use DynDNS to develop AppEngine/Facebook apps locally

AppEngine imposes a daily quota of 250 deployments to their server. This limit seems reasonable, but often you’ll need to test your Facebook applications in Facebook itself. And if you’re tweaking CSS or troubleshooting bugs, then you can use up your quota quickly if you have to deploy a new app each time you want to test a change in Facebook. If you use up all your deployments for the day, then you can’t upload anymore and have to stop development until the quota resets in 24 hours.

This has happened to me twice now, and after the second time, I found a great thread in the Developing for Facebook + Google App Engine group describing a solution for using DynDNS or similar service to give a domain name to your local PC, then pointing your Facebook app at your local computer. That way you can test the application on Facebook.com using your local AppEngine devserver. Trust me, this is worth the setup time.

4. Be prepared to dig in, tweak and modify Python libraries

There’s a lot of great Python code libraries out there, but much of it doesn’t work with AppEngine because of AppEngine’s unique webapp framework. You can get most libraries to work with AppEngine by adding a line or two of custom code, but you have to be willing to dig into the code and fix it.

For instance, I’m using the Google YouTube API, and in order for it work with AppEngine, you need to override the http_request_handler like this:

import gdata.service
import gdata.urlfetch
gdata.service.http_request_handler = gdata.urlfetch

Another example is custom template tags. You need to register your custom tags with AppEngine’s framework:

register = webapp.template.create_template_register()

And then in each of your individual scripts you need to register the library. So for a library named ‘customtags’ it would be:

webapp.template.register_template_library('customfilters')

w00kie has a good blog entry talking about this in more detail, but don’t expect a lot of existing Python libraries to be completely plug-n-play with AppEngine.

5. There is never too much error detection

When a user visits your URL on Facebook, Facebook will call the URL on AppEngine, AppEngine will use its framework to get data from the Internet, from its DataStore, and from Memcache, then return the result to Facebook which processes the FBML and displays the content to the user.

Unfortunately, just about anything can go wrong. I’ve had Facebook authentication fail even though you’re logged in, I’ve had Facebook give up on waiting for AppEngine to render its page, I’ve had AppEngine throw errors when doing a simple urlfetch, and I’ve had third party APIs suddenly stop responding. These errors are rare and normally not reproducible, but you still don’t want your user trying to figure out what an "ApplicationError 5" means. , So write your code to handle lots of exceptions.

6. FBJS is your friend and is key to achieving scalability in Facebook apps on AppEngine

The home page of my Facebook app is a beast. The content you see on the home page comes from more than 30 URLs on 10 different domains and third party APIs. Waiting for AppEngine to download and render this content takes forever, but I was able to pull it off by breaking up the page into five separate pieces. There’s a shell page, and then within that shell page there are four modules which each use FBJS to make a separate AJAX call to AppEngine to retrieve and display their own content.

I’ve learned the hard way that putting all your code in one page can take forever to render and consume lots of CPU, and FBJS helps reduce spread the page load out across multiple scripts.

7. Debugging FBJS is a real pain

While FBJS helps you scale out, debugging FBJS is a real pain. First, it only warns you of syntax errors, so if you have a logical error your script fails without warning. Facebook doesn’t report errors to the browser or allow you to use alerts, so the only solution I’ve found so far is to comment out your JS code one line at a time until you find the trouble spots. I would only advise doing this if you’re developing locally, otherwise you’ll quickly run into your quota limit for daily uploads to AppEngine.

8. If you’re retrieving external content, memcache is your best friend

As I mentioned earlier, the home page of my Facebook app gets most of its content from external URLs. For each URL, you fetch its content, process it into a native Python object (list or dict), and then render the content out via a template. This can eat up your CPU hours, reduce your response time, and make users give up on you.

Using memcache fixes all this. Memcache can store native Python objects, so once you’ve parsed a URL’s content in a native format, store the native object directly in memcache and retrieve it next time a user needs content from that URL

9. Use cron jobs to keep memcache current

Using memcache speeds up response time for all users except your first user. Since you shouldn’t be treating your first user any differently than the others, it’s worth setting up a script that keeps memcache refreshed with external content. This way all users will benefit from the speedup of memcache.

In my Facebook application, I’m retrieving content from a pool of around 3,000 different URLs, so I have set up a script that randomly picks 3-5 of these URLs, retrieves their content, and stores the result in memcache. I’ve also setup a cron job to call this caching script every minute or so and it’s sped up the average response time of the page, because the server never has to go out and retrieve 30 URLs of content at once. Also, if you are using third party APIs that put a limit on your usage, this is a great way to ensure you stay under those limits.

Right now, I’m executing the cron job from my own webserver, but AppEngine has said that cron support is on their roadmap, so hopefully in the future you’ll be able to support this entirely from within your AppEngine setup.

10. Once you’ve built an app or two with AppEngine, you’ll either love it or hate it.

I’ve really enjoyed developing apps with AppEngine, but I will admit it’s not for everyone. Anyone needing to do a lot of heavy data processing, or handle incredibly large data sets will experience nothing but frustration with AppEngine. However, for the majority of online projects, it’s a great way to build something scalable quickly, making it ideal for Facebook applications.

My first major Facebook application should be ready for public beta in the next week or two, so I’ll keep you posted about its progress.

The Wubbahed.com Google Friend Connect Challenge

December 15th, 2008  |  Published in Development, Thoughts

UPDATE: The contest is now over! The results were that only six people joined, and that included both me and my mother. Not exactly a resounding call for social interaction, so Friend Connect has been removed. On to the next project….


Every now and then, someone random starts following me on Twitter. I’m never really sure if they’re finding my Twitter page because of this blog or not, but I’m curious what kind of loyal readers are out there, and more importantly, if they’re actually interested in engaging in a community on this site, or if they’re just here to get information and leave.

I recently got an invitation to add Google Friend Connect to my site, however, I was hesitant to do so because I don’t think I do the community thing really well on this blog. But I’m not one to stamp out the voice of the people, so I’m now going to introduce the Google Friend Connect Challenge!

Below is the widget for Google Friend Connect. I’m going to leave it up here on the home page until the end of 2008. If at that time, at least 10 people have joined the site, then it will be permanently moved into the sidebar. Otherwise, I’ll let it be just another thing I tried out in 2008.

MobileCampNYC3

October 8th, 2008  |  Published in Development, Errata, hackathon, mobilecampnyc

MobileCampNYC3 is happening on November 15th here in NYC. It’s going to be a good time, but space is limited, so if you’re interested in attending, check out the signup page for more information:

http://barcamp.org/MobileCampNYC3

If you’ve never been to a BarCamp before, they’re lots of fun — check out some pics from MobileCampNYC and MobileCampNYC2.

DSC_0242

Running OpenTape on my Nokia N95

August 29th, 2008  |  Published in Development, Mobile, Nokia, Nseries, S60, hackathon

I always liked the website Muxtape, and right around the time that the site went offline, a group launched an open source web application that allows you to run and share a mix tape on your own server. It’s called OpenTape, and while the idea is similar, they are NOT related to Muxtape.

OpenTape is amazingly easy to use. Just download the files, unzip, and upload them to your own webserver. From there you can use the web interface to set up and configure the mix tape you want to share.

But what I want to know is can I run OpenTape on my mobile phone? Specifically, my N95? If you want to try this yourself, here are the steps.

  1. Register and install the Mobile Web Server to your S60 compatible device.
  2. Download and install the PAMP package for S60 and install it on your compatible device.
  3. Download OpenTape and copy it to the htdocs folder of your Mobile Web Server installation.

Once that’s done, just go to the directory on your webserver, and voila, it works!

Notice that the URL is actually from my Mobile web site…

Once I set up the password, then it was still working just fine.

And after I added songs, i thought it was looking so good.

But then it never displayed any of my songs. Hmmm…

Not to give in so quickly, I started digging through the source code, and it turns out that the problem might be with the PHP package on my mobile. First, the /code/xspf.php XML file wasn’t returning any tracks even though they were uploaded in the folder and the permissions were set correctly. Digging further, it looks like the code is using an ID3 library to read all of the metadata about the Mp3 files, so maybe that’s not included in the PAMP package?

Anyway, I’m so close, but I’ll keep looking into this and see what kind of fix I can come up with.

Sauna Talk

August 22nd, 2008  |  Published in Development, Errata, Mobile, Nokia, Nseries, S60

I read a lot of blogs many of which are heavily devoted to technology, mobile, and the developers who love them.

This week I came across a new video series for N-Gage targeting developers and it’s strangely brilliant in a Finnish way. It’s called Sauna Talk because all the interviews, well, take place in a sauna. Beware though, clicking this link will force you to watch a lot of video content starring this guy.

The only thing that’s really lame about it is that there’s no RSS feed and there’s no way to easily share/embed the video. If there were RSS, I’d probably go back to the site more. And this totally needs to be on YouTube.

Children’s PressLine – RSS and widget for S60

August 10th, 2008  |  Published in Development, Mobile, Nokia, Releases, S60, Thoughts, hackathon

I’ve been doing some pro bono web work recently for Children’s Pressline, a youth news service that trains kids to be reporters and editors who write articles for mainstream media partners. It’s a non-profit open to any child in NYC, and currently their news stories are being run in the NY Daily News, Metro, and the Amsterdam News.

The work I’ve done involves some basic tweaks to their website, setting up a Children’s PressLine Facebook page and creating a Children’s PressLine RSS feed that shows you their latest stories and links to the major media outlet running the story.

There’s not a mobile website, but just by having an RSS feed, that’s all you really need to get started reading the content on your mobile. If you’re reading this on your S60 device, you can just click on the RSS feed, and automatically subscribe to the latest news articles.

If you’ve got one of the newer S60 devices, though, then you can get a richer experience using this widget I made which pulls in the RSS feed and displays the latest news stories directly on your phone.

S60 widget (WRT)

You can download the Children’s PressLine widget directly, or scan in this QR code to get it straight to your mobile:

Get the widget

Total development time for this widget was less than an hour, and most of that time was just deciding which colors to use in the CSS. If you haven’t seen the Nokia Web Run Time, then I’d recommend checking it out as it’s going to be a great way to build quick applications for S60 devices. Right now, it’s only drawback is that it has almost no access to the device itself (e.g. GPS, Contacts), but Nokia has already announced these features will be included in the next major release.

If you want to see the source code of the widget, then just download the file to your PC and change the file extension from .wgz to .zip. Then open the zip file and all of the source code is there. It’s a very simple setup with one HTML page, and one XMLHttpRequest call to retrieve the RSS feed.

Let me know if you have any questions about how the widget was built, and I’m also interested to see how other people are using widgets not just for their personal use, but also to help promote causes they believe in.