Andrew Ferrier

Economics; Travel; Film; and Technology.

Archive for the ‘technical’ tag

Compiling FlightGear 2.4.0 for Ubuntu Linux 10.04 (Lucid)

with 22 comments

Update 2011-08-26: If you are using Ubuntu 11.04 or later, it looks like this is now packaged as a .deb by PlayDeb. This post may still be of interest to those using earlier versions of Ubuntu.

I recently had cause to install FlightGear 2.4.0 on Ubuntu 10.04. It’s not packaged in the form of a deb yet, so I’ve documented the commands I used. No guarantees this’ll work for you, as I haven’t tested them rigorously; and I’m assuming some Linux and command-line knowledge.

  • Install some dependencies (this may not be a complete list; it’s simply the set I was missing). If you get warnings below about missing libraries, hunt around for them in the Ubuntu archives.
    sudo apt-get install libboost-graph-dev libopenal-dev libalut-dev libopenscenegraph-dev libjpeg62-dev libplib-dev
  • Get SimGear 2.4.0, unpack it into a temporary directory, and install it (checkinstall will create a deb for you as a side-effect, and install that so you can uninstall with apt if necessary). I’m using -j10on make as I have many CPU cores; you may want to tune this to match your number, although it will only affect the speed of build.
    ./configure --with-jpeg-factory ; make -j10 ; sudo checkinstall
  • Get the FlightGear 2.4.0 source(at the time of writing, the file with the slightly more recent timestamp) and install it:
    ./configure ; make -j10 ; sudo checkinstall
  • Get the 2.4.0 “Base” package and unpack it to /usr/share/local/flightgear. The tarball contains a data/ directory at the top level; you need to move directories around after unpacking so that the flightgear/directory contains direct subdirectories:
    ls -1 /usr/local/share/flightgear/
    AI
    Aircraft
    Airports
    Astro
    ATC
    AUTHORS
    etc...
  • You’re done! Run fgfs to launch Flightgear (there’s no GUI so you’ll have to become familiar with the command-line switches).

Written by andrewferrier

August 17th, 2011 at 6:30 pm

Turning off Resume from Hibernation in Ubuntu 10.04

without comments

I use dm-crypt on all my machines now, including laptops, to provide full-disk encryption. I also use it to encrypt swap partitions with a randomly-generated key. All of these are features that Ubuntu 10.04 provides out-of-the-box, at least when you use the alternate CD to install.

I also recently installed µswsusp on one of my laptops, a userspace hibernation facility. I didn’t really connect the dots until one day I left the laptop running, coming back to find it hibernated. When I tried to resume, the boot process hung as the kernel complained it couldn’t resume the image. After a facepalm moment (of course this wouldn’t work – the encryption key isn’t constant across boots -  you have to use a constant key if you want to get hibernation working), I eventually figured out how to book the machine: use the noresume parameter when booting the kernel.

The only thing blocking me from using this now was getting the Grub menu to come up so I could change that kernel boot line. It appears that in the switch to Grub 2, the key to do this changed to the Shift key, from the Esc key as it had been in Grub 1. After I managed to bring up the menu, I could boot the kernel without resuming the image. I then deinstalled µswsusp.

Written by andrewferrier

October 3rd, 2010 at 3:02 pm

HTC Desire – Bad Points

with 20 comments

Recently I acquired an HTC Desire, when seems to be the de-facto Android phone of the moment. Generally, I love this phone – I wrote part of this blog post on it, and the quality of the hardware is frankly astonishing. Irritatingly, one can’t help but feel a little smug comparing it to the iPhone. However, I don’t want to become yet another mindless gushing fan. So instead of raving about it, I thought I’d provide some provide some constructive criticism on the aspects of the phone I don’t like so much:

  • The battery and power management needs some work. Like all smartphones, the Desire has plenty of battery-sucking components, such as GPS and WiFi. I spend more time than I should really have to turning these off and on manually to conserve power. For example, Google Maps should be able to turn the GPS on by itself, rather than rely on me to do it. Most software based solutions, such as Locale, JuiceDefender, and so on, simply don’t work reliably enough (for example, mobile data connections frequently won’t turn off or on): it’s obvious that Android isn’t exposing enough APIs and these applications therefore have to rely on hacks. Better built-in power management would be welcome.
  • The volume switch is really annoying. In theory, it’s nice to have a hardware control. But I find myself hitting it accidentally when holding the phone, and reducing the ring volume down to vibrate. Sometimes I don’t even notice. I’d prefer to see a soft volume control, less easy to hit accidentally.
  • The openness of the platform is in question. I can install whatever applications I want. However, I still have firmware on the phone that’s been mangled by both HTC and (in my case) Orange. The HTC modifications are fairly nice, but the pre-installed Orange applications are just irritating, and cannot be removed easily. Orange has a bad habit of mangling phones they ship; presumably they think they need to do this to ‘differentiate’ themselves.  Worse still, it turns out one can’t simply ‘reinstall’ the firmware: the closest process is to root the phone – an awkward and unsupported process I’ve yet to be brave enough to attempt.
  • Many of the pre-installed widgets are far too large (witness the SMS widget, which consumes an entire screen), with a lot of unnecessary chrome.
  • The Music app is a bit flaky and crashes once or twice a day.

Written by andrewferrier

July 8th, 2010 at 11:26 am

Logitech Presenter R800 with USB HID in Windows XP SP3

without comments

I recently acquired a Logitech Presenter R800. It’s a beautiful device – not particularly cheap, but very slick and easy-to-use. Unfortunately, Windows XP (Service Pack 3) on my system refused to recognise it – the device was listed as USB Receiver in Windows Device Manager, but Windows kept claiming it couldn’t find the driver. It is presented to the system as a standard USB HID device, so there is no Logitech-specific driver: it uses the standard Windows HID Driver. It worked perfectly out of the box on Ubuntu 9.10.

After 3-4 hours of research, I found the answer. Running a differencing tool between the C:\Windows\Inf folder on a colleague’s PC and mine showed that mine was missing the usb.inf and usb.PNF files from that folder. It wasn’t clear why they were missing, but having copied them over from his machine, the driver installation then worked perfectly. So that’s worth trying if you encounter a similar problem with this product (or indeed any USB HID device).

Written by andrewferrier

April 26th, 2010 at 1:55 pm

Connecting Google Reader and podget

with 2 comments

For some time, I’ve had a Perl script that runs regularly, backing up my Google Reader subscriptions using the standard OPML format:

#!/usr/bin/perl
#
# Usage:
#  backup-google-reader-opml file-to-write-to.opml google.user.name@domain google-password
 
use strict;
use warnings;
 
use WWW::Mechanize;
 
my $mech = WWW::Mechanize->new();
 
$mech->get("http://reader.google.com")
    or die "Cannot reach Google Reader Homepage";
 
$mech->submit_form(
    form_number => 1,
    fields =>
    {
        Email => $ARGV[1],
        Passwd => $ARGV[2]
    }
)
    or die "Cannot submit form";
 
$mech->get("http://www.google.com/reader/subscriptions/export");
$mech->save_content($ARGV[0]);

However, I recently wrote another script (this time Python) that then takes this OPML, parses out all the URLs that are tagged with ‘podcast’, and outputs a serverlist file for podget (an automated console-based podcast downloader). This enables me to subscribe to a podcast in Google Reader, and have the podcast automatically added to the download list. The script looks like this:

#!/usr/bin/python
#
# Pass in the OPML file as the first command-line parameter. Will output the
# podget serverlist on stdout.
 
import re
import sys
import xml.dom.minidom
 
doc = xml.dom.minidom.parse(sys.argv[1])
 
body = doc.getElementsByTagName("body")[0]
 
p = re.compile('^\W+')
 
for outline in doc.getElementsByTagName("outline"):
    if outline.getAttribute("text") == "podcast":
        for subOutlines in outline.getElementsByTagName("outline"):
            title = subOutlines.getAttribute("title")
            title = p.sub("", title)
            print subOutlines.getAttribute("xmlUrl") + " NoCategory " + title

Feel free to use and adapt to your needs.

Written by andrewferrier

November 23rd, 2008 at 9:08 pm

Reinstalling The Thinkpad

without comments

My work Thinkpad (a T61) was becoming a little crufty, so I decided to reinstall it from scratch. Here are a few lessons I learnt along the way:

  • Making a hot copy of your entire drive onto a USB hard disk with VMWare Converter beforehand is a great idea. This basically means you have your entire previous installation still bootable, so you can rescue any data or settings you forgot about, after you’ve done the reformat and reinstall. VMWare Converter is free.
  • Windows XP won’t install if the BIOS has the SATA controller set to AHCI mode – it won’t find the HD to install to. Read the install instructions for the SATA driver before installing Windows. Doing this without a floppy drive involves installing Service Pack 2 first (see below).
  • Windows, surprisingly, does not contain a driver that can work with the Ethernet controller. Have a copy of it ready on a USB stick.
  • The redistributable version of Service Pack 3 isn’t standalone, despite claims to the contrary; it pre-reqs. at least Service Pack 1. Windows Update won’t take you the whole way there, so it’s easiest to get the SP2 and SP3 standalones.
  • The USB ports will not operate at high speed until you install the Intel Chipset Device Software.

Written by andrewferrier

October 10th, 2008 at 1:02 pm

New Delicious – For Mobile Once Again

with 2 comments

Used to be, I employed a cunning trick I found on the web to create a quick ‘n’ dirty homepage for my browser on my mobile – all the delicious bookmarks I’d tagged with mtag.

Then delicious went and released a new version and this trick broke.

After a bit of fiddling, I’ve found a reasonable alternative. feed.informer will take any RSS feed and turn it into fairly plain HTML. So take your RSS feed, which might look something like this:

http://feeds.delicious.com/v2/rss/andrewferrier/mtag?count=100

(the count increases the maximum number of items in the feed to 100)

Now plug it into feed.informer, and edit the options to make the result look how you want (hint: I modify the template, and set the Per-Item Template to <a href=”%URL%”>%TITLE%</a><br />, leaving the rest of the template blank – this prints one bookmark per line). You’ll also need to sign up and create a feed.informer account whilst you’re doing this (assuming you don’t already have one).

Once done, just view the ‘HTML’ version of the digest you created, and set that as your mobile homepage. Bingo.

Written by andrewferrier

August 7th, 2008 at 12:03 pm

LaTeX Tips

without comments

A general grab-bag of tips for using LaTeX, from the days when I still used it a lot:

  • To add nice headers and footers to each page use the fancyhdr package.
  • Use glosstex for most acronym and glossary needs.
  • Use the hyphenat package if you need monospace text (such as that set by the \texttt command) to wrap correctly, with hyphenation marks.
  • The varioref package provides easy-to-use cross referencing with automatic phrases such as ‘on the following page…’ etc.
  • To include EPS easily in both latex and pdflatex documents, use the following magic incantation in the document preamble:
  • \newif\ifpdf
    \ifx\pdfoutput\undefined
        \pdffalse
    \else
        \pdfoutput=1
        \pdftrue
    \fi
     
    \ifpdf
       \usepackage{hyperref}
       \usepackage[pdftex]{graphicx}
       \DeclareGraphicsExtensions{.pdf,.png,.jpg}
    \else
       \usepackage{graphicx}
       \DeclareGraphicsExtensions{.eps}
    \fi

Then refer to graphics files, when including them, without an extension. Use epstopdf to convert all EPS files to PDF for inclusion in the pdflatex version of the document.

  • Use the custom-bib package to easily create custom BiBTeX style files.
  • The following command produces a new environment which gives a nice way of having an introductory paragraph for each new chapter:
  • \newenvironment{intro}{\sffamily}
    {\vspace*{2ex minus 1.5ex}}

Written by andrewferrier

March 24th, 2008 at 9:50 am

Picasa and RAW Bug

with 2 comments

Note to self and others: never use Picasa to download photos direct from the camera when using RAW+JPEG. It has a nasty habit of downloading the JPEGs, then deleting the RAWs. Ouch. Always use a card reader on the Compact Flash card instead.

Written by andrewferrier

March 2nd, 2008 at 9:48 am

Tagged with ,

More Flexible Firefly Smart Playlists with Perl, sqlite3 and m3u

with 5 comments

I use Firefly (previously called mt-daapd) as a media server for my Roku Soundbridge. It has a feature called ‘Smart Playlists’ that dynamically create playlists based on certain criteria, but they aren’t that powerful – they don’t support sorting or other more advanced query features.

Fortunately, underlying Firefly is a sqlite database, which can be queried using standard SQL syntax. This enables a technique of creating static playlists that are automatically re-generated periodically instead.

The prerequisites for the following technique are:

  • Perl, with the File::Spec module (to convert from absolute paths to relative ones, which is what Firefly expects).
  • The sqlite3 command-line interface.

The three commands that follow will create a standard .m3u playlist with the top 100 most-played songs from Firefly’s database, and another playlist with all the non-Podcasts added in the last month, ordered by the time they were added. Neither of these are possible using Firefly’s query language.

sqlite3 /var/cache/mt-daapd/songs3.db 'select path from songs order by play_count desc limit 100' | perl -nle 'require File::Spec; $_ = File::Spec->abs2rel($_, "$PLAYLIST_DIR"); print;' > "$PLAYLIST_DIR/Most-played songs.m3u"
 
MONTHAGO=$(perl -e 'use Date::Calc::Object qw(:all); $date = Date::Calc>now(); $date += [0,-1,0,0,0,0]; print $date->mktime();')
 
sqlite3 var/cache/mt-daapd/songs3.db "select path from songs where genre!='Podcast' and time_added &gt; $MONTHAGO order by time_added desc" | perl -nle 'require File::Spec; $_ = File::Spec->abs2rel($_, "$PLAYLIST_DIR"); print;' > "$PLAYLIST_DIR/Music added in last month by most recent.m3u"

(obviously, if you use these, you’ll need to alter paths to suit, make sure the correct Perl modules are installed, remove line breaks to make it easier to read, etc.)

Firefly will read these .m3us if configured correctly during its next rescan, and use them as it would any other playlists. You can force a rescan with the following wget command:

wget --delete-after -q --http-user noone --http-password yourpasswd "http://localhost:3689/config-update.html?action=rescan"

Although not fully dynamic (they are not generated on request from the Soundbridge), if these commands are called from cron or similar, the playlist can be kept up-to-date ‘enough’.

Written by andrewferrier

January 5th, 2008 at 3:30 pm

online purchase proscarbuy proscar no prescription buy proscar fed ex fedex proscar without priscription non rx cheap Flomax Tamsulosin cheap mexican buy Flomax on line amex where can i buy Flomax without prescription buy cheap Flomax online free consult canada Flomax buy brand Flomax purchase Tamsulosin pay pal without rx where can i buy finpecia without a rx wholesale finpecia cheap 10 mg Buspar canada prednisone no prescription purchasing accutane 40 mg online without prescription free fedex delivery accutane 40 mg buy Finpecia without rx Flomax bestellen 5 mg Maxalt Lasix u.p.s shipping cod buy cheap generic Lasix online order prescription free Lasix buy cheap generic Lasix online order no online rx finpecia buy Maxalt online no prescription purchase maxalt prescription online what does valtrex look like buy Crestor no prescription low cost Valtrex espana Valtrex purchased online without prescription where to buy generic Amitriptyline online without a rx valtrex canada buy Buspar drugs Buspar no prescription overnight how to purchase valtrex how to get a prednisone prescription buy online Lasix without rx purchasing Antabuse without a script order Orlistat no visa buy Proscar online purchase Proscar online Buspar online without prescription best Buspar online pill valtrex generic cheapest cheapest place to buy Buspar buy Prednisone american express Cytotec online order saturday delivery purchase Cytotec online with overnight delivery purchase cheap online Valtrex buy Valtrex legally how to buy Buspar without a prescription purchase finpecia pay pal online without prescription purchase Flomax without prescription needed buy Proscar now Buspar effects generic Orlistat uk comprare Buspar generico cheap order rx Valtrex buy valtrex where where can i buy herbal finpecia can you buy Cytotec in mexico buy cod Valtrex where can i buy herbal finpecia order finpecia no visa buy Valtrex no prescription low cost Valtrex tabletten how to buy Maxalt online without rx buy Bupropion uk 60 mg Orlistat buy cheap generic Orlistat online finpecia 1mg Valtrex buy fedex Rosuvastatin order online where to buy generic Cytotec online in canada how to buy Proscar online without rx non rx cheap Orlistat order finpecia overnight delivery buspar online consultant buy Orlistat online no rx no prescriptions needed for Prednisone Buy prednisone without a perscription to ship overnight Crestor precio buy valtrex free consultation valtrex for sale Crestor buy buy Crestor without doctor buy Prednisone with no prescription where to buy Zithromax Zithromax buy Zithromax no prescription Prednisone overnight buy Crestor no scams Crestor without rx order generic Crestor purchase Buspar money purchase Zithromax online order saturday delivery order Zithromax for cash on delivery order Valtrex on line Buy Valtrex online no membership U.S. pharmacies for prednisone without rx prednisone no script required express delivery Buspar pharmacy purchase Buspar pay pal without rx buy online Valtrex where can i buy Valtrex buy discount Valtrex on line Valtrex bestellen Valtrex online purchase overnight xenical without a rx free xenical Arimidex purchase buy 1 g mg Arimidex Orlistat without rx buy Valtrex no visa online without rx purchase Valtrex without a prescription overnight shipping cheap Buspar by money order