Saturday, May 17, 2014

Output of cal on Linux contains underscore and backspace

I just ran across some strange behavior in the output of the cal command on Linux.

I am running a perl script on Linux. The script retrieves the output of the Linux cal command with

`cal $month $year`

where $month and $year are set in the script.

I have been running this script for years and have not had a problem before.

The output of the calendar for

cal 5 2014

contains some control characters. For day 18, the output of the day is _1_8, where is the backspace key (hex 08). As you can guess, this runs havoc with my script that is formatting the calendar.

I had to filter the output of the command, replacing occurrences of _

s/_\x08//g

After filtering the output, the script ran as expected.

I ran a test script on all calendars from 1800 to 3000. Only May 2014 has the error.

Friday, May 16, 2014

Moving a Firefox extension from Addon-builder to local SDK

A couple of years ago, I developed a Firefox addon using the Addon Builder. The Addon Builder is no longer available. I am developing on a Mac.

I followed the steps at https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Installation to create a new addon using the locally installed SDK.

Open a terminal window and initialize the SDK. Change to the install directory for the SDK and issue the command source bin/activate.

Create a new directory for the root of the extension. Change to the directory and issue cfx init. The name of the extension is the name of the root folder.

Next, I downloaded my old extension from the builder dashboard. (Update: I can no longer find the builder dashboard, so I accessed my profile from the addons listing for me: https://addons.mozilla.org/en-us/firefox/user/username/, replacing username with my user name. Then, instead of clicking Add To Firefox, select Save As from the context menu of the button.) I copied my lib/main.js file and the files in the data folder into the extension I just created with the SDK. I do not know if I could have just edited the unzipped XPI file that I downloaded.

Change to the root directory for the extension. Test the extension with cfx test. A browser window will open and close. No interaction is possible.

Run the application with cfx run. A browser window opens with the extension enabled. Interaction is available. Close the window to end the run.

Create the XPI file for the extension with cfx xpi.

After modifying the extension, are tried to upload it to the builder site. I received the warning that the identifiers did not match.

I modified the id property in the package.json file in the root of the extension. I grabbed the id from the install.rdf from the expanded XPI file for the old extension. The id from the old extension had @jetpack at the end. I removed @jetpack to get the id for the package.json file. I recreated the XPI file and was able to add it as a new version for my extension.

Followers