How To Download Documentation with wget January 10, 2010 No Comments

Every now and then I find that what I’m looking for is not available in a convenient Debian / Ubuntu / apt repository. (My favourite applications that I wish would add themselves to Universe, or Multiverse, or Launchpad, or something, are Komodo Edit, and Task Coach. My felicitous find was python-django-doc, which I remember downloading with wget a year or two ago.)

diveintopython is available, but diveintopython3 isn’t (yet?) (although Mark Pilgrim does make it very convenient to download).

And neither is what I would name its package zend-framework-doc.

So here is the quick and easy way to download the Zend Framework Documentation. Make yourself a convenient directory to put the files in. I called mine “zend-framework-doc/html/”. Then open a terminal in your new directory, and type:
wget --recursive \
--level=1 \
--no-parent \
--page-requisites \
--convert-links \
--no-host-directories \
--cut-dirs=2 \
http://framework.zend.com/manual/en/

You can see from the long-format switches what I want it to do. You’ll find the same command useful for loads of other documentation.

Then move the directory to where all the other documentation is on your machine, like so:
cd ../..
sudo mv zend-framework-doc /usr/share/doc/

And then this URL will work:
file:///usr/share/doc/zend-framework-doc/html/index.html

Happy days.

GNOME Shell, GNOME Do, and things to come December 27, 2009 No Comments

Back in the day, when I still believed that Twitter, identi.ca and I could coexist harmoniously all day long (social networking, forums, e-mail, and anything else that can pop up notifications of interesting stuff while I’m busy working cannot make me happy in a long-term, sustainable kind of way (at least not while I have any work to do)) I used to microblog with GNOME Do.

I like GNOME Do. And I like how it dovetails nicely with something relatively new from the GNOME stable; something that appeals to my appreciation of simplicity and effectiveness: the GNOME Shell.

GNOME Shell Activities screenshot

GNOME Shell involves a rethink of your workspaces — Actually, before I start getting too long-winded, check out a video, and maybe browse some of the related videos.

As you can see, applications, places, and recent documents are together, and can be searched together. In the Applications section of Activities, applications are only mentioned once, not per-window as we are accustomed to with a task switcher. I like this. It makes sense to me, in terms of how I go about using my machine.

I also like how the number of workspaces I use is more fluid than before. I used to use four workspaces. Mail would be on the first, work on the second and maybe the third, and music on the last. I find with GNOME Shell I move things around a little more, and I end up using two workspaces most of the time.

What I think will be great for new Linux users, and those who tend to use only one workspace, is that GNOME Shell integrates the benefits of multiple workspaces better with the way one goes about everyday tasks (or at least the way I go about everyday tasks). So when you start to work on a new task, it feels natural to add a new workspace, and open the applications you use to do your new task (say, mail and browser, or browser and word processor) in the new workspace, if only because GNOME Shell lists your applications, places, and recent documents, and lays out your workspaces on the screen at the same time.

You’ll find a great little cheat sheet here, to get you familiar with how to do stuff.

I have to congratulate the developers involved in this project on its stability. Although it might not be complete, GNOME Shell feels rock solid.

It’s also cool to be able to watch it evolving. Here’s a video of a slightly older version. You can spot quite a few changes.

And here are some mockups from the middle of the year.

RainCT has been doing some fantastic work integrating GNOME Shell with Zeitgeist, an event-based search tool.

You can feel part of all this quite easily. You’ll find a “gnome-shell” package in repositories for Debian Squeeze and Sid, Ubuntu Karmic, and Mint Helena. “sudo apt-get install gnome-shell” and then “gnome-shell –replace” will do what you need. For Fedora 12, OpenSUSE 11.2, and how to start GNOME Shell when you log in on Karmic, check out these instructions.

You can follow updates on identi.ca and Twitter. And check out the Getting Involved section on the GNOME Shell page on GNOME Live!

GNOME Shell screenshot

GNOME Do’s “Docky” theme provides a convenient alternative to Alt-Tab or Alt-Left / Alt-Right, or going to Activities to change tasks or workspaces. “sudo apt-get install gnome-do“, and under Preferences and Appearance, choose the Docky theme, if it isn’t already selected. You won’t be able to use Super-Space to summon GNOME Do because Super is repurposed by GNOME Shell to go to Activities. So under Keyboard preferences, change “Summon GNOME Do”. I use Alt-F3.

Scrolling the mouse wheel on the icon of an open application in the GNOME Do dock switches between that application’s windows, across workspaces. I love the Activities screen for organising my windows, but I find that using GNOME Do to switch between applications is quick and convenient, and more natural for me than Alt-Tabbing.

GNOME Shell is potentially the standard interface for GNOME 3.0. But why wait?

December 3, 2009 No Comments

I thought I’d just mention my “Single Most Useful Piece of Software”. I was thinking about how this single little program has done more for me, more reliably than any other program I run. Sure, it only has a couple of settings, and can only be used in certain circumstances, but the sheer usefulness of it is something to be beholden. That piece of software, is Synergy. (Sourceforge page)

What it does, is link the mouse, keyboard and clipboard of multiple PCs together, so you don’t have to keep swapping from one keyboard and mouse to another. You can also copy an paste things from one machine to another. It works on Mac, Linux and Windows.

htmlentities in ASP.NET + MonoRail + NVelocity October 23, 2009 No Comments

Recycle BinLet’s imagine you started an ASP.NET project while Microsoft’s MVC framework (cheekily named “MVC”) was not yet “production-ready”, or if you do not consider it production-ready yet. Let’s say that you eschewed the ridiculously last-century (if ever) WebForms, in favour of something a little more modern. Your choice of framework would be limited to, well, Castle Project’s MonoRail.

MonoRail makes the best of a bad situation. I commend Castle Project on the work that has gone into it. And it seems to embrace the C# idiom.

For a template engine, I chose NVelocity. It seemed a sensible choice. And it has nice “foreach” loops.

Imagine my surprise when it turned out that it has no quick way to escape strings.

Huh? Surely not?

Let’s recap.

PHP:

	<?php print htmlentities($plaintext); ?>

Django pre-1.0:

	{{ plaintext|escape }}

Django post-1.0:

	{{ plaintext }}

C# ASP.NET + MonoRail + NVelocity:

MyProject/Helpers/HttpUtilityHelper.cs:

	using System;
	using System.Web;

	namespace MyProject.Helpers
	{
		public class HttpUtilityHelper
		{
			public string HtmlEncode(string plaintext)
			{
				return HttpUtility.HtmlEncode(plaintext);
			}

			public string UrlEncode(string plaintext)
			{
				return HttpUtility.UrlEncode(plaintext);
			}

		}
	}

MyProject/Controllers/SomeOrOtherController.cs:

	...
	using MyProject.Helpers;
	...
	namespace MyProject.Controllers
	{
		[Helper(typeof(HttpUtilityHelper))]
		public class  SomeOrOtherController : BaseController
		{
			...
		}
	}

MyProject/Views/SomeOrOther/index.vm:

	$HttpUtilityHelper.HtmlEncode($plaintext)

On the other hand, you could save yourself a lot of hassle, and explore other platform options. Don’t be afraid of learning a new language. It might save you a lot of time in the log run.

Linux on the Home Desktop October 13, 2009 No Comments

Just over a decade ago IBM claimed that there were a surprising number of OS/2 desktops out there. I forget how many, and I am too lazy right now to Google it, but they said there were a WHOLE LOT more than I expected.

Then in 1999 I started working in a Big-Blue-blooded company. Their offices around the world sat on IBM token ring networks. In the server room they had three AS/400s. Their desks all held IBM desktops and laptops. And the vast majority of those ran OS/2 Warp. Unless you sat at one of those desks, you probably wouldn’t know about the 800 OS/2 installations in their head office.

Many banks were the same. They knew IBM looks after its customers, and they wanted IBM to take care of their IT infrastructure while they took care of the business of managing money. As a result they often also had AS/400s downstairs, and OS/2 on their desktops.

I expect these are the kinds of businesses that may find Linux on their desktops one day. And if Canonical, Dell, IBM and Novell continue along their current trend, the most likely flavours will be Red Hat, SUSE and Ubuntu.

Interesting as that is to watch, as it gradually takes place, it’s not what this post is about.

This post is about what is required for that rollout to happen, and why those requirements are not met in everyone’s home.

And, to a lesser degree, it’s about why I’m not too bothered.

First, let’s look at hardware compatibility and support. IBM can install OS/2, or Linux, throughout a company, because they manage the hardware, and the support. They train the consultants or the IT department, and the consultants train the staff. All the applications you need are tested before they are installed on your desktop. When a new model of machine becomes available, the IT department installs the OS on it, and all the applications that anyone in the company uses, and runs through their extensive checklist to make sure that everything works, before that new model lands on the marketing director’s desk. (You know the guy — he might not be the marketing director, but he’s the guy with the Car, and he must have the new machine first, because that’s how his ego works. And a company loves people with his kind of ego, because you can get them to do *anything* as long as you play with his obvious, and very sensitive buttons. He might not be cheap, but he’s worth every penny.)

And if you are your own IT department, or if you are your friend’s or your mum’s IT department, then Linux is easy. My mother runs Kubuntu. A friend of mine runs Ubuntu. When they have a question, they call me, but they don’t have questions any more, because all the questions have been answered, and nothing unexpected ever happens. It’s lovely.

One of my daughter’s friends has Hannah Montana Linux. Her dad installed Mint on his own machine at home. (It was on his recommendation that I took a look at it, and it really is nice.) He works for SITA, and they are switching over to Ubuntu (I don’t remember the number of desktops, but it’s a four-digit figure). His girlfriend is rather proud of running Mint too.

These home Linux users all enjoy computers, or have family or friends who enjoy computers.
Rocket Racer

But if you just want to get on with whatever your operating system is supposed to allow you to do, you could be in for some disappointment. Some people don’t want to use forums to find out why their sound doesn’t work. Nor do they want to have to do anything about it. They don’t care about checking for hardware compatibility before buying a webcam, or some deceptively cheap-looking inkjet. And then they get upset when it doesn’t Just Work. They blame Linux …

… or the Free Software community. It must be someone’s fault their new webcam doesn’t work. It works perfectly on Windows, so it’s not the webcam!

I would point a finger at the manufacturer (let’s call them ACME). But then, why should ACME go to the trouble of writing a driver (which isn’t done by the CEO over a weekend — it’s done by one or more programmers, who are salaried for their troubles) when Joe Bloggs accounts for 1% of their market (that’s not Linux users; that’s just new Linux users who would go out and buy an ACME webcam *before* popping over to Linux-drivers.org to see if it’ll work — a mistake seasoned Linux users don’t make often), and the amount of time and effort ACME takes to write the driver might not even be recouped.

(ACME might also say that nobody makes it easy to write a Linux kernel driver. I wouldn’t know. I’ve never written one, yet. But if Christian keeps reminding me about about how Linux handles his sound card, I might try to write a replacement for snd_hda_intel specifically for his sound chip that offers only the facility to change the headphone and microphone volumes.)

This hardware compatibility problem will eventually take care of itself, to a degree. If ACME wants their sound chip to find its way into a corporate desktop, and the corporate desktop is running Linux, then it will be in ACME’s interests to make sure Linux supports their sound chip. But only if they are targeting the corporate desktop. And only if the corporate desktop is running Linux.

So home users may eventually reap the benefits of the gradual corporate migration. But it’s not going to happen next year, I’m sure. Corporates move slowly. Windows 7 promises to be a big hit (despite their awful advertising (and kinda funny remix)). Some IT managers like to explore. Some IT managers like to go with what they know. I can’t tell you where the truce lines will be drawn at the end of the war. But I suspect that nobody will get the whole pie. The size of the Linux pie slice will determine whether home users can expect manufacturer love.

Then there’s the problem with familiarity. Some people go out and buy a nice fast, virus-free netbook with a great boot-up time, with an OS that will happily run as many applications simultaneously as they want. But when they start to play with it, they discover that it doesn’t work quite the way they had in mind.

This will also iron itself out. And it’s also related to the corporate desktop Linux marketshare. People expect Windows. People who think about loving a computer may love Mac OS X, or Linux. Despite how hard Microsoft would like people to love Windows, the problem is that the vast majority of Windows users don’t really think about it in those terms, nor are they likely to. But I tell you, take Windows away from them, and many of them miss it. If you’ve ever seen a constantly-bickering old couple, perhaps you’ll agree that familiarity and love might have more in common than many care to admit.

But for those who sit in front of Linux at work, they may become familiar with how things work; the things that change from release to release, and the things that stay the same. (I myself love it. I have two kids and watching Linux develop is (a tiny bit) like watching kids grow up. Yeah yeah, not exactly the same, but similar, OK. No, I won’t tell you where I live. No, you can’t take my kids off to Child Services. Yes, I am a perfectly fit parent.) And those people will, one day, assume that their netbook should work like their Linux desktop. They will never think about what operating system is hiding inside their cellphone. They will never ask a question on a forum.

That will be the day games publishers ensure there is a Linux version. And ACME webcams Just Work. And nobody wonders why Skype shows an image, but there is no sound coming out their speakers.

I’m sure it will happen.

But frankly, I can wait.

Because that’s the same day there is an incentive to write a prolific Linux virus. (Some say Linux is virus-proof because a virus can only affect files that you have write permission to. But, trust me, if a virus deleted ALL the files you have write permission to, your day would take a serious knock.)

In the meantime, I am perfectly happy look up hardware before I buy. And, actually, I enjoy supporting companies, with my wallet, that support Linux. I still get nasty surprises, like when it turned out that Adobe Air applications do not run on multi-core 64-bit AMD CPUs on Linux. (So I installed it on a virtual machine that uses only one core, and all is hunky dory now.)

And when a large enough chunk of the home desktop market comes round to Ubuntu 12.04 “Proud Panda” I’ll grudgingly go and buy a copy of NOD32 Anti-Virus, Linux Desktop Edition.

DTC’s installation script October 5, 2009 No Comments

Robots
I mentioned in my last post, where we built that metapackage, that I’d post our installation script.

This script is run immediately after a clean install, from CD, of Ubuntu / Kubuntu / Mint. It installs the metapackage, copies our standard settings to /etc, and installs software not available in repositories, like Komodo Edit.

Here it is, with comments.

#!/bin/bash

if [ $# -lt 1 ]
then
    echo "Usage: install "
    echo "  where  is one of 'ubuntu', 'kubuntu' or 'mint'"
    exit 1
fi

DISTRO=$1

# Find the distro architecture
ARCH=`apt-cache -v | cut -d' ' -f4`

# Configure apt to use the proxy
sudo cp ~it/install/etc/apt/apt.conf /etc/apt/

# Update software
sudo apt-get update
sudo apt-get -y dist-upgrade

# Install DTC software requirements
# (Here is the metapackage build in my previous post)
sudo dpkg -i ${DISTRO}-desktop-dtc_1.2_${ARCH}.deb

# Fix unresolved dependencies
sudo apt-get -f -y install

# Install libdvd-css
sudo ~it/install/bin/install-css.sh

# Install Komodo Edit
cd /tmp/
if [ "$ARCH" = "i386" ]
then
    tar -xzf ~it/install/Komodo-Edit-5.1.3-3592-linux-libcpp6-x86.tar.gz
    cd Komodo-Edit-5.1.3-3592-linux-libcpp6-x86/
elif [ "$ARCH" = "amd64" ]
then
    tar -xzf ~it/install/Komodo-Edit-5.1.3-3592-linux-libcpp6-x86_64.tar.gz
    cd Komodo-Edit-5.1.3-3592-linux-libcpp6-x86_64/
fi
sudo ./install.sh -I /usr/lib/komodo-edit-5
sudo ln -s "/usr/lib/komodo-edit-5/bin/komodo" /usr/bin/komodo
cd -

# Put /etc under version control
cd /etc
sudo bzr init
sudo bzr add
sudo bzr commit -m "Original config"

# Copy settings for Kerberos, LDAP, MySQL, etc.
sudo cp -a ~it/install/etc/* .

# Commit changes
sudo bzr add
sudo bzr commit -m "DTC config changes"

cd -

That’s it. Now all that remains is for me to program our team of robots to do installations all by themselves.


[2009-11-04]
The lines
sudo dpkg -i ...
sudo apt-get -f -y install

can be done more easily with
sudo gdebi

What’s more, I’m finding that messing with these meta-packages makes me think that this is a little over-engineered. It’s easier to maintain if you just use a text file (commented, if you want) of package names, and then install with:

cat | egrep -v ‘^#’ | xargs sudo apt-get -y install

(That egrep is to remove the comment lines.)

Building metapackages to make installations easier September 29, 2009 No Comments

At the Digital Tool Company, I have gone through a series of strategies to manage installing new machines, or upgrading old ones.

I’ve been installing Linux since the days of Red Hat 7.2. And the Digital Tool Company (nee O S S Africa) “standard desktop” has moved through Red Hat, Mandrake, Debian, and now sits at Ubuntu and Kubuntu. (There have been forrays into other distros. In fact, I’m typing this on Linux Mint right now (which is very nice, by the way.))

Our first strategy was just to install everything, and copy config files from a machine that was already set up.

Then I made drive images, by installing one machine Just Right, and then copying its drive. Then I’d make a little change, and feel the need to copy the image again. And repeat, until I had wasted vast amounts of time, and annoyed myself.

Then I made a PXE boot image, and created PXE boot disks. Luckily at that stage our machines all used Realtek 8139x network cards, because boot disks can be a bit of a pain.

Now I just use the Ubuntu installation CDs, either the “Desktop” or “Alternative”. After the initial installation, I install a metapackage that has all the extra stuff we use. There’s more to the story, but I’ll cover that in my next post.

What I want to tell you about here is how easy it is to create a metapackage. The benefit is that you can have one metapackage for each distro you want to support, and they are simple to maintain.

First, create a directory for your package. In this example I’ll call mine “dtc-mint-desktop_1.0_i386″. And create a directory called “DEBIAN” inside it.

$ mkdir -p dtc-mint-desktop_1.0_i386/DEBIAN

Next, create a file in the DEBIAN directory called “control”. (If you have done this before, and you want to pull out the control file from a metapackage you’ve already created, use the command “dpkg-deb -e dtc-mint-desktop_1.0_i386.deb dtc-mint-desktop_1.0_i386/DEBIAN”).

$ nano dtc-mint-desktop-1.0_i386/DEBIAN/control

Make it look like this:

Package: dtc-mint-desktop
Priority: optional
Section: metapackages
Maintainer: YOUR NAME <YOUR@E-MAIL.ADDRESS>
Architecture: i386
Version: 1.0
Depends: apache2, auth-client-config, autofs, autofs-ldap, directoryassistant, firebug, firefox-webdeveloper, krb5-user, libapache2-mod-php5, libapache2-mod-python, libnss-ldap, libpam-ccreds, libpam-krb5, libpam-ldap, mailx, msttcorefonts, mysql-client, mysql-server, nfs-common, nscd, ntp, php5, php5-gd, php5-mysql, php5-xsl, php-doc, phpmyadmin, php-pear, postfix, python-django, python-mysqldb, quicksynergy, ssh, ssh-askpass, subversion, sunbird, sun-java6-fonts, synergy, thunderbird-gnome-support, thunderbird-quickfile, vim-gnome, xulrunner-1.9-venkman
Description: Linux Mint desktop system specifically for DTC requirements
It is safe to remove this package if some of the packages are not desired.

Customize the file to suit your requirements. These are just the packages we use, and in this example they exclude the stuff already included in a fresh installation of Linux Mint 7 Gloria Main Edition.

When you’re done, you’re ready to build! The files in packages should be owned by root, so first let’s set the permissions:

$ sudo chown -R root.root dtc-mint-desktop-1.0_i386/

And then we’ll build the package:

$ dpkg-deb -b root.root dtc-mint-desktop-1.0_i386/ dtc-mint-desktop-1.0_i386.deb

That’s it! Next time you want to install your favourite bunch of packages, do a clean install of your distro, and install this package with “dpkg -i”, followed by “apt-get -f install” to satisfy dependencies:

$ sudo dpkg -i dtc-mint-desktop-1.0_i386.deb
$ sudo apt-get -f install

In my next post, we will take a look at our installation script.

AMI Collective Bare Auction September 26, 2009 No Comments

We’re happy to announce that The Digital Tool Company has developed the backend bidding system for the AMI Collective Bare Auction. The AMI Collective is a company doing extraordinary illustration and and design work for major national and international clients.

Up to a hundred vinyl Bare figures, 40 cm tall, were handed to as many artists and painted. They are now on auction for charity at the Bare Auction Website. DTC developed the backend system and integrated it with the frontend, replacing several elements and placing them on the site.

AMI Collective now has up to the second access to every bid with a complete database of bidders and a comprehensive record of all activities.

Linux File Permissions Best Practices August 27, 2009 No Comments

Hey all you Linux users, web site uploaders, and people who occasionally have to touch a Linux box despite your confusion or repulsion,

Here’s an APB on what not to do with file permissions.

-rw-rw-rw- permissions are from Satan. That’s why they are written as 666. -rwxrwxrwx is worse because it’s editable AND executable. And drwxrwxrwx is worse still, because it means that ordinary users may be able to break your machine with “while [ true ] ; do cat bigfile >> biggerfile ; done” (which is why /tmp is in its own partition on a “serious” server).

So, if you are installing a web application and you want the web server to be able to change files, then set the files to be owned by the user that the web server runs as. (I’m going to assume the username is “www-data”, but yours may be “apache” or “httpd”.)

If you want to own the files, and you want “www-data” to be able to change them, then set the group to “www-data”, and make it group-writeable.

And if you want “www-data” and a few special friends to be able to change the files, then create a new group called “www-data-and-friends”, and add them to it.

World-writeable is not OK. Think hard about what you are trying to do, and come up with a smarter way. Or learn how to use ACLs (”man acl”). Or just put the root password in a file called “ROOT_PASSWORD_HERE_EVERYONE” and let someone make the file world-writeable, so that you don’t have to incriminate yourself.

Yours in making the the world a safer place for those who just don’t know, so that it is only the truly stupid who fall prey to accidents,

N.

2 Things about Flex… August 23, 2009 No Comments

We’ve been developing a visually complex Flex app in the last couple of weeks or so. Its not complex from an ‘enterprisy’ type view, but it does have to achieve a few things visually which have been a challenge. I’ve really enjoyed developing in Flex so far, but have found a few issues which I didn’t expect to find in such a well presented set of development tools. It’s almost as if, just as I’m moving forward, someone yanks the carpet out from under me…

Flex comes with a number of pre-built container components… things like ‘Canvas’ and ‘HorizontalList’. These containers are the basic building blocks of your app. Each one is designed to be used in different situations. The HorizontalList is suited to a series of items, presented horizontally. Since it is commonly bound to an Array or ArrayCollection object, it often has more items in it than can be displayed at any one time. So you have a scroll bar… you also have the ability to scroll the list along by creating a handler for the click event and listening out for a click and firing off a ’scrollToIndex’ function, which the name suggests, scrolls you to the relevant item. Thats great, except that the scrolling isn’t your gentle glide to the next item. Its just sort of yanks it over. My application calls for a little more finesse… some gentle scrolling. Impossible. Or so it seems at first. You have to completely re-engineer the HorizontalList to accomodate smooth scrolling. Its a bit of a job, and others have done it before,  but its really one of those things you would expect to have built in. I implemented the HSmoothBox, and then found out that it only accomodates identically wide items if you’re loding them dynamically. Argh! Back to square one. Eventually I modified the HSmoothBox to accept a width parameter, and now I have smooth scrolling! As it turns out, smooth scrolling was left out of Flex 3 because the developers couldn’t put it in, in time… so here’s hoping its gets included soon…

The next frustrating issue I had, was that there appeared to be no discernable way to make a button’s background transparent, short of completely re-skinning it. This is a real annoyance, since every other element in Flex has an ‘alpha’ or ‘backgroundAlpha’ property. Such a simple little thing… and the solution entails jumping through multiple hoops and doing backstroke through a minefield.

I completely understand that there might be complex technical reasons behind why these features were not included, but really, software ought to fulfil the user’s expectations of what can be done. Every component has a property to make it’s background transparent… except the one you want to make transparent…