Friday, 15 October 2010

Configuring Portable Ubuntu

I have installed Portable Ubuntu under Windows XP and have been configuring it to run some experiments.

Portable Ubuntu is conceptually like running Ubuntu in a virtual machine, except that the Windows all feel like native Windows windows.

Actually getting it working properly involves a bit of tweaking. Here is a summary of what I have done.

First of all, the default install button on SourceForge doesn't actually point to the full install. You can get it from the folder labeled TRES.

To run, just invoke pubuntu.exe. Start up takes a while -- actually as long as a normal boot sequence. To see the boot messages, single click on the Portable Ubuntu icon in the system tray.

The very first thing I would recommend is to disable the Ubuntu screen saver, otherwise your windows will lock up after a period of inactivity and there's no way to unlock them. You can disable the screen saver in System/Preferences/Screen Saver in the GUI.

Portable Ubuntu comes with Open Office. I am running experiments and have no interest in word processing applications. I saved 366MB disk space by removing Open Office:

sudo apt-get remove openoffice*

The default root password is 123456.

To give Ubuntu access to your drive c:, you need to edit a file in your Windows file system. Go the directory where pubuntu.exe lives, and edit the file config\portable_ubuntu.conf. Add the following line:

shared_folder0=c:\

While you're in that file, you might want to increase the amount of RAM allocated to Linux too. You have to restart your Portable Ubuntu session for these changes to take effect.

On start-up your drive C: should be mounted and available as /media/cofs2.

To enable DNS resolution, inside your Portable Ubuntu session, edit the file /etc/dhcp3/dhclient.conf to specify the DNS servers to use. To use the Open DNS servers, add the following line before the request line.

prepend domain-name-servers 208.67.222.222,208.67.220.220;

On start up I often get an error about not being able to mount the Linux partition. There's extensive discussion and some good solutions on this Ubuntu forum. People offer various partial solutions like dropping into an emergency console during boot up and typing:

mount -o remount /
Then Ctrl-D to exit the emergency console

But these mask the underlying issue: one of the start up scripts has inserted a line containing -e into the /etc/fstab file, which causes mounting of volumes to fail.

I finally resolved this. Portable Ubuntu copies aside your /etc/fstab file and makes its own during startup. Inside Portable Ubuntu you can edit the version it copied aside. It's called /etc/fstab.pubuntu.bak. Remove the line that says -e. Shut down Portable Ubuntu. This will copy back fstab.pubuntu.bak to fstab. Restart pubuntu.exe. Problem solved.

Thursday, 30 September 2010

Emoticons: no noses please

I work on text input for mobile devices, e.g. making it easier to type text messages.

Recently we have been reviewing our support for entering emoticons. In one meeting, I observed that it seems to be more common to type emoticons without noses than with them these days. Since we take an empirical approach to these questions, we thought we'd look at our English web corpus. Sure enough, in the period 2007 to early 2010, the nose-less forms are about four times more common than the nose forms i.e. :) beats :-) and ;) beats ;-).

This is of course a perfectly natural linguistic development: words undergo reduction in form over time. It'd be fascinating to take a finer-grained look at the frequencies.

Wednesday, 16 June 2010

ActiveState Komodo IDE 5.2

I have been using ActiveState Komodo on Windows for almost a year now, mostly for Python development, with some legacy Perl maintenance and Bash scripting.

Komodo is a solid but unexciting IDE. It makes a fair stab at providing contextual information in dynamic languages and does a very good job at flagging syntax errors.

One thing it is really not very good at is multi-monitor support. The various panels and sub-windows are all solidly docked in the parent window and cannot be dragged to a second monitor, which severely impacts how much code you can see at once.

The other not-so-great thing is start up time, which can take the better part of a minute if it's reopening a few dozen very small source files. This is a small complaint since I really only start it after a machine restart and that doesn't happen very often.

Friday, 17 April 2009

Cross-site XMLHttpRequest in Javascript

You know how sometimes you put together a simple bit of code and things seem fine but in the back of your mind you think there might be an issue. So you try another scenario/browser and sure enough it doesn't work and you remember why? Well that's what happened a few days ago.

I decided to put together a fairly straightforward site that would let users search for jobs across a range of Craigslist sites. My first impulse was to do this in ASP.Net, doing the scraping on the server side. But Craigslist takes a dim view of people scraping their content and repackaging it.

The next solution I explored was a simple bit of Javascript that would run client-side. The user would fill in a simple form, press go and the Javascript would use XMLHttpRequest to grab search results from Craigslist. It sounds simple enough and worked in IE7.

I had a nagging feeling that I had been reading something recently about cross-site XMLHttpRequests. Sure enough, in the latest incarnation of Firefox, the code didn't work at all, and in VS2008 in the debugger it threw security exceptions.

Cross-site XMLHttpRequest is now severely restricted/forbidden.

I put together a C# WinForms app to do it all for me. It works like a charm. I can now search for telecommuting opportunities across a range of Craigslist sites. The tool is a convenience app that federates user queries. It's a classic case of developers writing the tools that they want for themselves.

I will make the tool available for others shortly. I'll use it for a few days before releasing it. It's always a good idea to let things sit for a day or two.

I spent two hours today bringing the code into conformance with StyleCop. I have mixed feelings about StyleCop. It can be persnickety (Boolean properties with getters and setters have to have XML documentation that starts with the exact words "Gets or sets a value indicating whether...") but a lot of the advice is good. I particularly like the warnings about the correct implementation of IEnumerable<> and IDisposable. By now I have internalized the normative rules concerning casing of variables, methods etc and the ordering of members of a class according to visibility. The added benefit that I derive from using StyleCop is similar to a code-review -- it forces me to reexamine some pieces of code that in hindsight could do with reworking.

Thursday, 5 March 2009

Version Control

Version control is a vitally important part of software development. But really, who wants to get it all set up for small projects?

Well this is the age of free/cheap hosting. I have a wonderful solution going. I am using Unfuddle.com for free SVN hosting and AnkhSVN as the version control provider for Visual Studio 2008. It's a great combination. AnkhSVN integrates seamlessly into Visual Studio. As an added bonus, Unfuddle provides a defect ticket system.

C# interop

C# interop with unmanaged code is not nearly as difficult in practice as it sounds on paper. Most of the interop I have done has been COM (to/from managed code) but for my current freelance gig I need to call from C# into an ANSI C DLL.

I wrote a few simple ANSI C functions to act as the interface to my managed code, just to save some work. I could call them fine. Crucially, I could pass in ANSI strings and get them back.

Then I started getting an AccessViolationException "Attempted to read or write protected memory". I was positive that I had annotated the ANSI C code correctly to export the functions. The C# code had the appropriate DllImport decorations. C# and ANSI C thought the function was CDECL. Everything looked just fine.

The symptoms were downright peculiar. If I declared a local variable in the ANSI C function that I was calling the code threw the exception. If I attempted to call another function from inside the ANSI C function the code threw the exception.

As with so many things, it boiled down to an incorrect setting in the project file, a residual glitch from the fact that I first produced an EXE to exercise the code and then flipped to producing a DLL.

Along the way I learned that I don't need to mess about with IntPtr allocation and freeing. When I have a mutable string (e.g. the result is returned in a char* parameter), I can create a StringBuilder with the appropriate size and pass that from C#. C# marshals it for me.

Sunday, 1 March 2009

Rebuilding machines

This past month has been the month of installing stuff. My wife's hard drive crashed. I managed to resuscitate it enough to pull most data off, then dropped a new drive in. I got a new laptop (an insurance replacement for the laptop that got stolen from our house) and had to set that up. Then serious issues with my primary machine. I am now freelancing. None of this is billable time of course.

My primary machine is a seven (!) year old Dell. It has served me well. Lately I have had difficulty installing software, especially some Windows Updates and Visual Studio 2008. The errors have never been very helpful but in the event logs I could see recurring errors with the Cryptographic Provider Service not being able to start. The error is simply "error: 193".

It seems that people had big issues with the Cryptographic Service in 2003-2004 associated with some service packs, but none of the solutions from that time (deleting corrupt databases so it would rebuild them, checking your "Trusted Root Certification Authorities") made a bit of difference.

In the end I reinstalled the Windows XP Pro, then all my usual applications, then various service packs (SP3 can't be installed without a prior SP; SP1 is not available; SP2 can be installed without anything prior), drivers from Dell etc.

This past month has blown out our data caps several times. New Zealand ISPs charge by data throughput. We have a 5Gb per month allocation. This past month we used 14Gb. Of course, downloading a 1.7Gb IDE for iPhone development didn't help.