Andrew Ferrier’s Blog

Economics; Travel; Film; and Technology.

Archive for the ‘Technical’ tag

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 3 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

Subscribers on Google Reader

without comments

Tip for anyone who blogs and uses Google Reader:  the new ‘Discover’ feature of Google Reader enables you to see how many people are subscribed to your blog. Select ‘Browse’ and search for your blog using keywords. When you’ve found it, it’ll show how many subscribers there are. Take the number with a pinch of salt: it is, of course, only one of many blog readers, albeit a popular one.

Written by andrewferrier

December 25th, 2007 at 1:12 pm

Tagged with ,

Getting WPA Working with a Thinkpad T42 and Knoppix 5.1.1

without comments

Thinkpad problems mean that I’m currently borrowing a T42 from work. It took me a while to get WPA working with Knoppix 5.1.1. Here are the magic incantations required:

wpa_passphrase YOURSSID YourWPAPassPhrase > /etc/wpa_supplicant/wpa_supplicant.conf
wpa_supplicant -ieth1 -c /etc/wpa_supplicant/wpa_supplicant.conf &amp;
ifup eth1
pump -i eth1

Replace eth1 in the list above with whatever network interface name Knoppix has assigned to your wireless card (reading through the output of dmesg should help you with this). Don’t forget to double-check that your router has the MAC address of the card (use ifconfig to find this) if you’re using MAC address filtering.

Written by andrewferrier

November 10th, 2007 at 8:52 am

Tagged with ,

Gallery to Flickr

without comments

Just spent a little while consolidating all my photos: moving the remainder from my Gallery installation on andrewferrier.com to their new and preferred home on Flickr. My Flickr account is now vastly more populated with photos (and more variable in quality). This script basically did all the work. It doesn’t support nested albums, so I had to move all sub-albums to the top level, as well as removing the few ’symlinks’ I had on photos (later versions of Gallery support this). But apart from that, it was plain (if a little slow) sailing. A recommended approach.

Written by andrewferrier

June 20th, 2007 at 8:10 pm

Tagged with ,

From Palm, to Google Calendar

with one comment

As part of my cunning plan to move my data online, I decided to move away from using my Palm for managing my diary - and towards Google Calendar instead. I’ve already stopped using the Palm to-do list; all I really need to do now is find a decent online addressbook; Plaxo being one possibility that Chris suggested.

It took me a while to figure out how to get my data out of the Palm. Palm don’t provide a decent export to anything other than Palm formats for the datebook, so a third-party exporter was called for. The web is seemingly full of dodgy Windows shareware to do the job, but jpilot (which I already, but rarely, use on my Linux machine) turned up trumps. It exports directly to the modern iCalendar standard, fully supported by Google Calendar. Hurrah! Since this solution doesn’t seem to be well-documented, I thought I’d write it down.

Written by andrewferrier

May 10th, 2007 at 7:58 pm

Subscribe to Comments Disabled

without comments

I recently installed the Subscribe to Comments plugin on this blog. However, it seems to have attracted far too much spam. I’ve therefore disabled it again until a version is developed that’s a bit more hardy against spammers. You can always subscribe to an RSS feed for the comments on any post (as you can with any Wordpress-powered blog) by appending /feed to the permalink URL for that post.

Written by andrewferrier

January 19th, 2007 at 5:42 am

Tagged with ,

The Acid Test

without comments

Smoothie Label Fun chemistry fact of the day: Acidity regulators regulate pH in general, not just acidity. Hence (presumably) why this smoothie bottle contains Citric Acid as an acidity regulator (my first thought was: shouldn’t it be an alkali?).

This is when I wish I’d done Chemistry A-Level rather than Further Maths.

Written by andrewferrier

January 16th, 2007 at 9:01 am

Tagged with ,