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/
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.
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.
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).
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 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/
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.
Here is a Javascript function that I threw together the other day that will take the default format of a MySQL DATETIME or TIMESTAMP field (YYYY-MM-DD HH:MM:SS) and convert it into a Date object in Javascript.
function parse_date(string) {
var date = new Date();
var parts = String(string).split(/[- :]/);
date.setFullYear(parts[0]);
date.setMonth(parts[1] - 1);
date.setDate(parts[2]);
date.setHours(parts[3]);
date.setMinutes(parts[4]);
date.setSeconds(parts[5]);
date.setMilliseconds(0);
return date;
}
I actually don't work with Zope as much as I used to but I was going through some old notes and found this gem to backup a Zope instance's Data.fs file while the server is still running. Between the Data.fs file and the Products and Extensions folders you fundamentally have a full backup of your Zope instance.
/usr/lib/zope2.9/bin/repozo.py -BvzQ -r ./ -f /var/lib/zope2.9/instance/instance_name/var/Data.fs
Depending on where Zope is installed the repozo.py script may be in a different place. The -BvzQ is a basic options set (see the man page for details). The -r is where you are backing up to; in this example it is the current directory. And finally the -f is where the Zope instance's Data.fs is.
This is a php script that I wrote a number of years ago. It allows you to search through schema of MySQL databases by table column name. It can connect to multiple servers and it will search the structure of every table in every database.
It is a great tool to find related columns in a complex server situation. You can get the source code here, feel free to download and use it.
I found this in an old email that I sent to myself. I wrote this utility at my first job out of college. They had a software system that had been through a number of reincarnations over the years and they were left with redundant data across numerous servers and databases. I used this script to locate related fields across systems and would then write translation code that would merge data into a consolidated system.