Posts Tagged ‘Software Engineering

Percent encoding for UTF-8

Posted in Technicalon Apr 20, 2010

Warning: This post is not for those who don’t fancy a little bit of computer science.

I was recently looking for some Javascript code that would escape a filename so that a file with international character in the name could be uploaded to Google Docs through my GDocsUploader program.  With some help of some internet searching, this is what I came up with.  This function will take a UTF-8 string and replace non-ascii characters with percent encoded unicode values.

I thought I would share this in case it might help someone else in the future.

function utf8_percent_encode(string) {
    string = string.replace(/\r\n/g,"\n");
    var encstr = "";
    for (var n = 0; n < string.length; n++) {
        var c = string.charCodeAt(n);
        if (c < 128) {
             encstr += String.fromCharCode(c);
        } else if((c > 127) && (c < 2048)) {
             encstr += "%" + ((c >> 6) | 192).toString(16);
             encstr += "%" + ((c & 63) | 128).toString(16);
        } else {
             encstr += "%" + ((c >> 12) | 224).toString(16);
             encstr += "%" + (((c >> 6) & 63) | 128).toString(16);
             encstr += "%" + ((c & 63) | 128).toString(16);
    return encstr;

GDocsUploader 1.4 released

Posted in Technicalon Sep 1, 2009

While still in college, I wrote my first Mac OS X program to upload documents to Google Docs. The program is called GDocsUploader, and it supports drag-and-drop uploading of documents, spreadsheets, presentations, photos, and PDF files.

Today, almost 9 months since my last release, I am happy to release an updated version of the program. The new updated version will allow users to upload PDF documents, a very much requested feature.

You can download the new version from the Google Code project site.
Read the rest of this entry »

GDocsUploader 1.3 released

Posted in Technicalon Dec 17, 2008

About a year ago I started a little programming project to upload documents to Google Docs.  I wrote a little program for Apple OS X called GDocsUploader to support drag-and-drop uploading of documents, spreadsheets, presentations, and photos.

Today I released an updated version of the program.  In addition to bug fixes, this new version supports video uploads to Picasa.  Additionally, this new version makes it much easier to upload multiple files at the same time.

You can download the new version from the Google Code project site.
Read the rest of this entry »

I came across this line of code today, and while I don’t normally hate other people’s coding style, this one has something in it that really bothers me:

i = ((unsigned int)(crcAccum >> 24) ^ *dataBlkPtr++ ) & 0xff;

I’ve written my first semi-major Linux device driver. I won’t say exactly what it does other than write data out to hardware.

Generally, it is well NOT accepted to write to files from the kernel. If you ask how, people will tell you “don’t.” I completely agree with all of the reasons provided, but I decided to do it anyway.

The hardware I’m writing data to isn’t readily available. I wanted to be able to test my code well without having to have the hardware available. So I wrote in some non-release, non-production code that writes data to a file instead of to hardware, but only for testing purposes. When in this simulation mode, the user can interact with the driver and data gets written to the file instead of to hardware, and then the file can be checked for accuracy.

User writes to driver -> kernel driver handles write -> driver writes to file

Easy enough? I thought so until I tried writing to the driver as a regular system user. I chmod’ed the driver so that the user had full privileges to read and write to the file. When root would write to the driver, everything worked, when the regular user would write to the driver, the kernel would crash.

The problem was that the user didn’t have write permissions to the test file that the driver was writing to. I thought the kernel level driver could write to any file it wanted, but apparently, the user’s permissions to the file permeated through the kernel driver. Changing the files permissions fixed things so they didn’t crash any more.

The caps lock and scroll lock lights blink on the keyboard when the kernel crashes. Not quite fireworks, but still kind of cool. Development in a virtual machine is key, so that you really don’t crash your computer, just the virtual machine.

Adobe Error

Posted in Technicalon Feb 25, 2008

Today, Adobe announced a new product: Adobe Air. The basic concept of this is that you can compile a web application that you’ve developed to be a run-time on a users system. Adobe accomplishes this through distribution of the WebKit HTML rendering engine. Basically, your apps run like they would in a web browser, except that they look more like they are a standalone desktop application.

Adobe has done a good job at allowing Air applications integrate well with the desktop.

Adobe isn’t the first to use internet delivery technologies for desktop applications. Mozilla’s XULRunner allows developers to create and package multi-platform programs based off the same technology that powers Firefox. However, Adobe has done a good job at making it simple to publish very traditional AJAX apps as desktop apps.

Adobe’s big problem is they only support Windows and Mac. There is no Linux support, at least not yet. One of Adobe Air’s big selling point is that it makes it easy to create cross-platform applications. However, without Linux support, the most Adobe can advertise is dual-platform apps.

For a great demo Air app, look at this complex YUI example.

SCO goes private

Posted in Businesson Feb 14, 2008

According to a story on Slashdot today, The SCO Group received $100 million of investment to get themselves out of bankruptcy and back in the forward business direction.

SCO has been in loosing in law suits it brought against Novell and IBM.

I couldn’t think of better news. I mean, from the people perspective, any good engineers still left at SCO might not loose their job. From another people perspective, now SCO has money to pay Novell, so they don’t have to lay off people.

All in all, I think all this means is there is a bigger turkey to roast and cut up.