Mozilla Labs Concept Series: Pie Assisted Gestures

A few days ago, Mozilla Labs invited students to answer the question: “What would a browser look like if the Web was all there was? No windows, no unnecessary trappings. Just the Web.” I thought I’d take a crack at it myself, even though I’m clearly going to get my ass kicked by the engineering undergrads 🙂

Here’s a video I knocked together, which shows a very rough mockup of the UI. The basic idea is this – to extend pie menus in such a way that they can help train users into using mouse gestures, and remain as a backup for more complex commands.


Mozconcept: Pie Assisted Gestures from Shahid Hussain on Vimeo.

Restoring your Linux partition in rEFIt

If your lovely Linux icon has, for whatever reason, disappeared from rEFIt to be replaced by the generic icon (or just vanished completely), here’s how to fix it.

rEFIt, a wonderful boot manager for Mac, peers at all of your partitions when it boots, takes a guess at what OS is on there and shows and entry in the larger icon list at the top. To figure out that you have a Linux partition, it will look at the MBR of that partition and go from there.

If your icon has disappeared or been replaced with the generic one, this is where the problem is. So here’s how to fix it.

  • Boot into Linux using a Live CD like the Ubuntu Ibex install CD.
  • Open up a terminal.
  • “sudo grub”
  • Now, find your Linux partition with “find /vmlinuz”
  • It will return (hd0,2) or similar. Use this to install grub like this: “root(hd0,2)” and then “setup(hd0,2)” and finally “quit”.

Once you reboot, your rEFIt icon should be restored, and you should be able to boot back into Linux no problem.

Dual Booting Ubuntu 8.10 with Tiger on a Santa Rosa MacBook Pro

This weekend was taken up by one huge discovery: it is possible to use Gparted on Ubuntu Ibex to resize an HFS+ partition non-destructively. This one fact made it incredibly easy to dual boot my MacBook Pro with Linux. Here’s how:

  • Backup everything you might want to keep from your Mac just in case. Resizing partitions is always risky!
  • Install rEFIt on the Mac.
  • Make enough space on the Mac for your new partition.
  • Create an Ubuntu Ibex installer & live CD.(You can just download the .iso and burn it with Disk Utility.)
  • Boot into the live CD by holding down the “c” key when you reboot. Don’t install right now, but head into GParted.
  • Just resize the HFS+ partition that contains your Mac. Keep your fingers crossed that it works OK. (It did for me).
  • Run the Installer, and go to Manual mode when you get to the partitioner. From here you can do what you want – I created a 20gb partition for root and 4gb for swap partition.
  • Finish the installer and reboot. Here’s a fun bonus – rEFIt will automatically detect the new partition, and just create a spot in the boot menu for you.

And that’s it!

Comcast HSI troubleshooting

I recently solved a problem that’s been bugging with me on Comcast HSI (High Speed Internet), and just in case this helps anyone else, I wanted to document it.

In my case, I’d first plugged in the cable modem, then my Macbook, and gotten zero. The Mac had been issued a DHCP address that looked OK, but no internet access. It got as far as “looking up XXX”. This indicated that DHCP had told the computer where the DNS server was, but my laptop couldn’t actually talk to it.

I gave up after a while, and turned off the modem. I tried again the next day, and it worked.

Later, I wanted to get my Airport Express to work. But after plugging the Airport Express into the network, it couldn’t get a DHCP address.

After poking around online, I discovered that it was possible to log onto the web interface of my cable modem (a Thompson TCM 420). (You can do this by getting onto the same network, setting a static address of 192.168.100.2, and browsing to 192.168.100.1.) Strangely, it reported that only one network device was supported. So, I unplugged my Mac, just plugged in the Airport, and reset everything. Still no dice.

I gave up after a while. But this time, I had a suspicion. I turned off the modem for about 6 hours, then turned it back on with only the Airport Express plugged into the wired network. Bingo!

WTF?

Here’s my stab at what’s happening. I believe that Comcast really is allowing only one DHCP address to be issued to devices on my network, and that it remembers the last device that was issued (like a DHCP reservation). If a new device appears on the network, it only allocates an address to the new device if the old device’s DHCP reservation has expired, which appears to happen after a few hours.

In the first case of the non-working DHCP address, that was bad luck. When the computer’s reservation expired and it was granted a new IP, the new one worked.

The Answer

… appears to be that if you’re messing around with your network, you need to turn off your modem for a fair period of time to allow old leases to expire and new devices to get new IPs.

Outsourcing Trust

UAC
Are you familiar with the UAC prompt in Vista?


Or the “%Application would like to use your current location” prompt on the iPhone?

We – the nerds – can make fairly accurate decisions about the security of a product.

My mum probably can’t. Strangely, she’s being asked all the same questions as I am.

This disconnect is something that Aza, Atul and Jono at Mozilla Labs are trying to solve. Last night, the team discussed some of these issues at an open Labs event held at the Twitter offices. Can your computer just know what the right answer is without pestering you? How can it get that information?

For Instance

Let’s say that you come across a piece of code on the web that you want to use. This could be:

  • A Ubiquity script
  • A Greasemonkey script
  • A Facebook application
  • A regular thick client application for your PC or mobile device

We can extend this idea a little further. Let’s say you come across a piece of information on the web that you want to use. Do you trust it? This could be:

  • A blog entry detailing how to set up X11 for your video card
  • A forum post on how to optimise your website for online advertising
  • A site giving out fashion tips
  • Or whatever

Modelling Trust

There are a few different ways of figuring out whether you trust information.

  • Do you judge it, or do you take someone else’s word?
  • Whose word do you take? Someone you know? Someone you don’t know? An authority?
  • Does that degree of trust change over time?
  • Can you just mitigate the risk of bad information / naughty code?

You Judge It Yourself – a traditional solution

If the user is looking at something they’re familiar with – a regular person looking at fashion tips, or a geek looking at code, this can work well enough. If it’s an area you’re not familiar with, you might be able to use some extra information to guide your way.

Does the information seem sensible?
Is it spelled correctly?
Is someone proposing that you wear A-line flares with pockets in the knees?

As before, the problem here – especially with code – is that not many people have the skills to review the thing accurately.

Mitigate The Risk – also known as sandboxing

In the case of code, allow it to execute in an area where even if it is naughty code, it can’t do too much damage. Or, you test out some advice on your online advertising strategy with 1% of your user population only. Or, you decide to wear your new clothes around the house, and invite some specific people in to check out how you look.

There are two obvious downsides. One, setting up a sandbox can be annoying. Two, you are probably going to have to restrict what sandboxed code can do. If you look fabulous in your new outfit, you probably want to be out on the street rather than inviting just a few people over.

Take Your Friends’ Advice

Women shop for clothing, in general, in a very particular way. They gather together in a group, try on outfits, and ask their friends / gay male friends / husbands how they look.

Frankly, the thought fills me with dread. But it works. It’s another trust model – basing your trust of information or content on people that you trust.

In real life, that trust is weighted. You might trust your friend Alice’s opinion on style, but Bob doesn’t quite have it.

Online, we might think of using a social graph like Facebook to pick up who trusted what. For example, when you consider adding a new Facebook application, FB tells you how many of your friends have added the application. That’s great, but it makes two important assumptions:

  • If someone trusts you, you trust them
  • You trust all of your friends equally

… neither of which is always true in real life. For example, if you want to install a piece of code and you want to know if it’s malicious, you’d probably trust the geeks you know more than your friend in marketing.

Take Everyone’s Advice

When you look up a popular item on Amazon.com, a whole bunch of people have reviewed it and given their opinions. With enough volume, these add up to sensible suggestions of which movies are good, and so on. When browsing the App store, the number of people who have downloaded a top 10 app adds up to a sensible suggestion of which apps are useful and don’t screw too much with your phone.

Also known as the wisdom of crowds.

This works very well at scale. When you’re starting off, the effect of outlier reviewers in the population is large, so it doesn’t work so well. Too many good startups flounder because of this – they’d work great at scale, but getting scale is tough.

The further assumption here is that everyone’s opinion has equal value.

Believe The Popular Kids

If we break that assumption, we can weight the opinions of some people over others. For example, in a web forum, one poster might have a better reputation that others, so you might trust their advice over someone else’s.

The more authority someone has, the more trust you have of their opinions, and the more weight you apply to them.

Don’t read beauty magazines, they will only make you feel ugly

If you don’t take Baz Lurhmann’s excellent advice, and you do read beauty magazines, you might be taking your fashion tips from an authority. SSL works in the same way – you trust that a website is who they say they are, because they registered with a certificate authority. This is having the ultimate trust in someone or something, because they are the ultimate authority.

OK – thanks. What was the question again?

How can your computer understand whether a piece of code it comes across on the web should be trusted?

  • You could trust an authority to tell you.
  • You can take advice from your friends.
  • You can let everyone vote with their feet, and follow the crowd.
  • You can try and figure it out for yourself.
  • Maybe you can sandbox and not have to worry about it.

Capiche?

Office 2007 Picture Transparency

A very small hack. In Office 2003, once you have inserted a picture you can make it transparent. If you love transparency, you’ll have been disappointed to discover that this function has been removed in Office 2007.

However, there is a way around. It’s a little bit ugly.

  • Insert a regular vector object like a rectangle.
  • Right click -> Format Picture -> Fill
  • Select “Picture or texture fill”
  • Insert your picture
  • Now play with the transparency
  • You may have to remove the “line” outlining the shape

Kellogg Directory Search Plugin (Bar Edition)

I have been given a more common use case for my OpenSearch plugin, which is:

  • Go to The Keg / Nevins / Prarie Moon of an evening
  • Meet someone new
  • Introduce yourselves to each other by your first name
  • Wake up the next morning and try to remember who it was you were talking to last night
  • Look them up in the directory

And so, here is a variation on the last OpenSearch plugin that will search by first name rather than last name. As before, click on the “install” link after Kellogg First Name.

Enjoy!

Kellogg Directory Search Plugin

For those of us at Kellogg, we search for people in our online photo directory a LOT. So, I’ve found a way to create a search plugin for those of us using Firefox 2+. Here’s how to do it:

  • Click this link
  • This will generate a plugin on the searchplugins.net site.
  • In the middle of that site, you will see “Kellogg Last Name: Install”. Click on “Install”.
  • Robert is your father’s brother.

This raises an interesting few notes on coopetition. Coopetition is the idea that competing firms may wish to collaborate in some way to create an environment they can both benefit from. The obvious example is industry standard – for example, many competing companies came together to create the DVD format, even though they were in direct competition.

How is this relevant, exactly?

I’ll tell you. Both Internet Explorer 7 and Firefox use OpenSearch for their search plugins. Each plugin is just a little XML file that contains the details of how to kick off that search. OpenSearch is a file format standard for that little XML file. Oddly, it was actually created by Amazon.

So now we have three companies that compete in search (Amazon A9, Google and Microsoft) using a common file format.

Isn’t that nice?

Yes it is – it’s entirely beneficial for the writers of those XML files, and the end users.

So what do the companies get out of it?

It makes it more likely that the format will become widespread.

So why can’t I use the plugin above with IE7?

Well, that illustrates one of the wonderful things about negotiating a common standard across companies. Some of them want to do more than the standard allows, and hence will extend the standard without negotiating the extension.

Doesn’t that defeat the point of a standard?

Yes, it does. There are two possibilities that can follow:

  • The extensions are taken into the body of the standard, and all companies involved use this new, revised standard
  • Everybody uses the new extension and ignores the standard, perhaps because the naughty company involved is the market leader. The extended standard is now proprietary, creating value for the leader through switching costs.

Does that second option really happen?

Well, you can see it above with Mozilla, though I would hope the extension will be rolled into the next version of OpenSearch.

Another good example is Microsoft, with their latest revisions to the Office file format, and the ensuing spat. (The situation isn’t that simple here, but it’s a really interesting example.) Here’s the Rolo Tomasi – as a market leader in many of their markets, they have some strong incentives to follow this second path.

Optimize video for Youtube on Linux with FFMPEG

On observing a colleague at work with a Macintosh, I was impressed with the FFMPEGX tool, and disappointed that there was no equivalent on Linux. Thankfully, I couldn’t have been more wrong – it’s built around the FFMPEG tool, which is originally for the Unix / Linux platform. You will have to prepare yourself for the command line, but you won’t have the nag screen and waves of brushed metal you get on the Mac.

In my case, I needed to optimise some video for uploading to Youtube. Youtube’s own page lists their optimal format. Crunchgear also suggests a video bitrate.

  • Video codec: MPEG4 (DivX or Xvid are specifically mentioned)
  • Video bitrate: between 700 and 1000 kbps
  • Audio codec: MP3
  • Resolution: 320×240

First, let’s install ffmpeg:

sudo apt-get install ffmpeg

Next, run ffmpeg to figure out what format your source video is actually in. In my case, I was manipulating video coming from a Fujifilm F31FD camera. Here’s what I typed:

$ ffmpeg -i DSCF0370.AVI

And here’s the important part of the output:

Input #0, avi, from 'DSCF0370.AVI':
Duration: 00:03:51.0, start: 0.000000, bitrate: 9350 kb/s
Stream #0.0: Video: mjpeg, yuvj422p, 640x480, 30.00 fps(r)
Stream #0.1: Audio: pcm_u8, 16000 Hz, mono, 128 kb/s

So, we can pretty clearly see that it’s 640×480 MJPEG video at 30fps with 16KHz mono audio. In order to optimize for Youtube, I need to change the resolution and video codec, and possibly also encode the audio to MP3 (but it’s such a low bitrate that it’s not going to make much difference).

Here’s the command line to do that:

$ ffmpeg -i DSCF0370.AVI -b 800 -s 320x240 -vcodec mpeg4 -r 30000/1001 out.avi

To break this down quickly:

  • -i denotes the input file
  • -b denotes the output bitrate
  • -s denotes the output size
  • -vcodec sets the output codec to MPEG4. What comes out is actually a kind of DivX5 file. We could have set this FLV and got the Flash video format that Youtube actually uses, but I’m following the instructions!
  • -r 30000/1001 sets the framerate to 30000/1001 = 29.97003 fps, which is the standard frame rate for NTSC video. Oddly, I couldn’t get the encode to work without this.
  • I could have set the output audio to MP3 using the -acodec mp3 option, but the ffmpeg that comes as standard in the Ubuntu repositories doesn’t support it. Ya boo sucks. The default output is MP2 format – I guess I can live with that.

So – while executing that command, the salient part of ffmpeg’s output looks like this:

Output #0, avi, to 'out.avi':
Stream #0.0: Video: mpeg4, yuv420p, 320x240, q=2-31, 800 kb/s, 29.97 fps(c)
Stream #0.1: Audio: mp2, 16000 Hz, mono, 64 kb/s

… and we can check that plays OK like this:

vlc out.avi

Voila! Now you can upload right into Youtube while preserving a modicum of quality.

Restoring GRUB on Ubuntu

Possibly the only useful article on the previous incarnation of this blog was this on, detailing how to pull GRUB back up under Ubuntu. This was written with reference to Ubuntu 4, which I was hooked on like a turbot.

There are many standard ways of reinstalling GRUB – most involve using a Linux rescue floppy (which noone creates) or a Linux Live CD, like Knoppix. Once you have yourself a prompt, you should be able to do this:

# grub
grub> root (hd0,0)
grub> setup (hd0)
grub> quit

… and that’s it. However, you’ll find that you grub will spit back at you “Filesystem type unknown, using whole disk” and you won’t be able to do anything else.

The best way of doing this in a normal distribution is to run:

# grub-install /dev/hda

… but that craps out in Ubuntu, giving you these lines:

/sbin/grub-install: line 429: /dev/null: Permission denied
/sbin/grub-install: line 431: /dev/null: Permission denied

Hungsquirrel puts us on the straight and narrow with this convolved but brilliant solution, slightly modified by me:

  • Boot up your Ubuntu install CD
  • Wait until your install CD has detected your drives – it will be just about to partition your system
  • Switch to console 2 by ctrl+alt+F2
  • Hit enter to activate the console
  • # mkdir mounted
  • # mount /dev/ide/host0/bus0/target0/lun0/part5 mounted
  • # chroot mounted /bin/bash
  • # grub-install /dev/hda

Remember to substitute the /dev/ide/host0/bus0/target0/lun0/part5 for whatever the location of your root drive is. For example, if your booting from hd1,3 (physical drive 1, partition 3) then use /dev/ide/host0/bus0/target1/lun0/part3. Most people will be booting from physical drive 0 somewhere. If you’re not sure where you’re booting from, the quickest way is to note it from the pre-partitioning setup screen in Ubuntu install.

When this reinstalls Grub, since it reads the menu.lst file directly from your root drive, your Grub menu will come back up exactly as you left it.

Credits:
Hungsquirrel post