Weekend Project: Google Data API OAuth2 Token Helper

I have been really into making App Engine sites lately and one of the developer itches I have had for a while was being able to just grab a valid OAuth2 token for Google Data APIs so I can use it in plugins like Rest Client or just on the URL bar in order to preview data. So I wrote a quick site to do it.

https://oauth2helper.appspot.com/

A sample use would be to get an XML feed of all of your Google Docs.

Scopes:


https://docs.google.com/feeds/

https://docs.googleusercontent.com/

https://spreadsheets.google.com/feeds/

 

URL to hit:

https://docs.google.com/feeds/default/private/full?v=3&access_token=[put your token here]

I used a CSS layout template called YAML to give the site a simple yet more elegant design.

http://www.yaml.de/

Updated Layout for Site

Just made some quick updates to the layout of the site. I put a bit of a more geospatial focus to the design since most of my professional work is in the realm geospatial technology. The background map just loads a random location over the continental United States.

My First Publish to the Market: Hospital Plan

After working with mobile application development for a few years I have finally made the time to publish an of my own into the marketplace.

It is a pregnancy support app that I wrote for myself. It is designed to allow you to organize all of the information you need to gather your things and make it to the hospital once labor begins. It includes hospital information, doctor contact information, a checklist of the items to gather and bring and a list of contacts to keep in close touch with.

You can download the application from the Android Market at: Hospital Plan

qrcode

This is the hospital information page. You can put in the name, address and phone number of the hospital and with one click either get directions or call the hospital.

This is the hospital bag checklist page. Gives you a central list of things to remember to grab before you head out the door.

This is the contacts page it lets you centralize all the people you need to keep in touch with, without having to sort through your whole list of contacts.

I used Sencha Touch and PhoneGap in hopes to make it easy to publish the application into multiple markets.

I will soon hopefully have an iOS version too.

Fusion Tables to JSON Open Sourced

Due to a number of requests I have cleaned up and decided to release the code for FT2JSON under the Apache license so others can make use of the software for specific applications.

The code can be found here:

https://github.com/jordoncm/ft2json

The main app engine site will of course always be hosted:

http://ft2json.appspot.com/

Fusion Tables to JSON

I have been messing around with Google Fusion Tables a lot over the past few months and I really like the service. However it really bothered me that the only format that the response data came in was CSV. I also wanted to be able to work with Fusion Tables query data entirely on the browser/client side. So I spent part of the weekend writing an application that proxies Fusion Tables API queries and transforms them from CSV into JSON. I also added a simple Javascript that you can embed on your page and then make Fusion Table queries directly from Javascript.

I posted the application on App Engine and you can find it here: http://ft2json.appspot.com

I wrote it in Python and used Tornado Web Server to help parse requests. Tornado works quite well within App Engine.

Using Relative Paths in link and script Tags Using the CouchDB Server

I am playing with CouchDB a bit this weekend and I am trying to put together a basic application written in HTML and Javascript.

I wanted to use the XMLHttpRequest object to interact with CouchDB; this meant I had to host the code using the web server that is built into CouchDB (to avoid cross domain issues in the browser). However when I first moved the code over from my normal Apache server into the CouchDB server I tried to access the code with my browser at http://localhost:5984/_utils/myapplication and none of my external CSS or Javascript files would load (at least in Firefox).

What I noticed was that since I was using relative paths in the href and src attributes (i.e. <script scr="./file.js" ...) of the link and script tags, the trailing slash on the URL was required for the files to be included properly. I figured this out because when I accessed the same code at http://localhost:5984/_utils/myapplication/, everything worked as expected.

Typically web servers add that slash automatically for you, but for some reason CouchDB does not. To get around this I wrote a quick Javascript that I placed inline, just below the head tag to look for this case and correct it. The script is below.

if(String(window.location).substring((String(window.location).length - 1), String(window.location).length) != '/') {
    window.location = String(window.location) + '/';
}

Seems odd that CouchDB does not account for this.

Barcode Scanning in Android

Been getting into Android a good bit lately. Some for work, some not. Anyway I needed a way to scan a barcode on the phone in order to lookup some information for an application I am designing. However as I found out reading a barcode is not a part of the Android SDK. The SDK does support taking pictures and so forth but no analysis or translation.

After some research I found out how to pull it off on the phone; you can do it by accessing an external barcode scanning application using and SDK concept called Intent. The main barcode scanning application (called "Barcode Scanner" in the market) supports returning scanned codes back to other applications, which makes this relatively straight forward to accomplish. I haven't tried this yet in code but the thing I wonder about is if the Android SDK (or the market) handles application dependences or if that is something you have to handle yourself inside of the application.

Details on getting a scanned code into your application in Android using Intent is detailed in the link below.

http://code.google.com/p/zxing/wiki/ScanningViaIntent

The main project for the Android barcode scanner application is below.

http://code.google.com/p/zxing/

I can't see any reason why this application shouldn't be a default application within the software stack and fully integrated into the SDK. It is a top notch application and open source (not sure if the licenses would be compatible).

Bypassing Cache for Developing Gadgets on Shindig

I have been working some with the Gadget Spec and developing gadgets for use on closed networks. I have been using Shindig to render my gadgets and it is really big on caching gadgets for performance. This is quite annoying when you are developing and tweaking a particular gadget because your changes don't get shown like they should when you refresh the browser.

Anyway, it turns out there is a simple fix for this. Normally you call a URL similar to this to render you gadget in Shindig.


http://your-shindig-server/gadgets/ifr?url=http://url/to/your/gadget.xml

To get Shindig to bypass its cache and pull the latest gadget code all you have to do is add a bpc=1 to the URL query string.


http://your-shindig-server/gadgets/ifr?bpc=1&url=http://url/to/your/gadget.xml

This makes working on a gadget a lot less painful.

Removing .svn Folders from a Codebase

Removing the .svn folders from a codebase effectively removes the codes attachment to the repository. This can be useful for when you are trying to distribute the code to others or if you are trying to bring two different repositories together.

Anyway the proper way to do it is to use svn export. However this requires you to specify an export path and you end up with two copies of the codebase. Also the export method doesn't also export any changes you have made to the codebase that have not been committed. See the following link for more details on svn export.

http://svnbook.red-bean.com/en/1.1/re10.html

The easy way to do this is to use the following command.

find ./ -name ".svn" | xargs rm -rf

This will take the current directory and strip the .svn folder out. Be warned though this will also remove files named .svn, normally this should not be a problem.

I got most of this information from the link below.

http://cephas.net/blog/2007/04/06/command-line-script-to-delete-svn-files-folders/

Using mysqldump to Backup Database Structure and Data Separately

I have have been developing on a MySQL database where a small amount of test data is still over a half a million rows or more. So exporting the schema to pass it along to others takes forever. Fortunately you can export just the structure of the database and nothing else (which is much faster).

mysqldump -h hostname -u user database -RQdp > structure.sql

The option d is the key here. It stands for "no data". The option R will make it include your stored procedures and functions. And the option Q puts backticks (`) around your table names, column names, etc to prevent keyword errors on import.

Alternatively you can also export just the data.

mysqldump -h hostname -u user database -Qtp > data.sql

The option t means "no create info". Which means it wont put any CREATE TABLE statements in your export.

...older