Saturday, December 04, 2010

Python+Emacs made easy with emacs-for-python

I don't know where this has been all my life but Gabriele Lanaro has put together a really easy to use package for adding lots of Python goodies to Emacs.

Just unzip the archive into ~/.emacs.d/ and add one line to your .emacs and your done (well, also remove all the now unnecessary random cargo-cult prior additions to your .emacs):

(load-file "~/.emacs.d/emacs-for-python/epy-init.el")

I had also previously installed a handful of Python/Emacs packages via Synaptic that may or may not be required to make it all work: python-rope, python-ropemacs, pyflakes.

Friday, July 16, 2010

Increasing podcast tempo (playback speed) with Mplayer and Lame

The following commands will re-encode an mp3 file at a faster speed without increasing the pitch and making it sound like a chipmunk. How this actually works is pretty neat.

mplayer -vo null -vc null \
        -speed 1.33 \
        -af scaletempo,volume=0,resample=44100:0:1 \
        -ao pcm:fast:waveheader:file=temp.wav \
        source.mp3
lame -b 64 --resample 22.05 temp.wav faster.mp3

It will also set the bitrate to 64kbit which was for compatibility with my old player and to reduce the filesize for some podcasts which are unnecessarily big.

There should be a way to use mkfifo instead of temp.wav, and run the mplayer process and lame at the same time, I'll update this when I figure it out.

Update: The above method broke after upgrading to Ubuntu 11.10 (one or both of mplayer or lame changed something I suspect...), so I swapped it out for the simpler and better SoX:

sox --show-progress --norm source.mp3 dest.mp3 \
    tempo -s 1.33 channels 1 rate 22050

This version is easier to understand, faster, doesn't leave need a temp file and also, as a bonus, normalizes the audio to prevent clipping and not hurt my ears.

Using Sansa Clip+ MP3 Player for Podcasts

A mini-review after buying the 2GB model to replace my old mp3 player. I'll only consider it for the purpose of listening to podcasts, other music related features can be found on the SanDisk site or other reviews easily enough.

3 key features for listening to podcasts:

  • No software required, just plug in as a USB drive and copy files across (using a script or manually.)
  • Ability to easily delete files from the player after listening to them.
  • Increase the tempo/speed of playback.

The Sansa Clip+ does all of these, however the fast playback speed is pretty useless as the pitch is increased giving "chipmunk" effects. See the next post for a work-around.

The player remembers the position in each track, which is very nice.

A couple of other issues I've noticed immediately are that it is very small, making one-handed operation difficult, and it has no "hold" button to prevent inadvertent bumping of the buttons. Hopefully being able to clip it outside clothing/bags will alleviate this, time will tell.

It also has a built in battery so you can't carry a spare and must plug it in to charge.

Update: So far, everything is working well. I'm not used to the built in battery, and waiting for it to recharge if I let it go flat is a major pain, but I'll just have to keep it topped up and an hour of charging goes a long way.

One other minor annoyance is that you can't quickly see the duration of a podcast when skipping through them.

Update: One issue that I initially didn't notice, as the ID3 tags were stripped during my reencode process, is that the podcasts are organised by show and there is no "play all" option. This is a pain, I'm used to just listening to them in a more or less random order and not having to stop and select a new show when one finishes.

To quickly fix this, use the id3v2 utility to delete all ID3 tags from the podcast before copying them to the player. This way they are all categorised under a single "Unknown" show menu and the filename is usually sufficient to identify the program.

Wednesday, May 12, 2010

Making use of all the space on a hard drive

If you have a big data drive, there's a good chance that Linux is reserving 5% of it's available space for "emergencies".

This is necessary for your root filesystem as if the disk fills up there may be no way for root to log in and clean things up without this buffer of space for log files etc. to be written into.

However, I have a couple of large drives that store only data and 5% is 100GB I'd rather be able to use.

Fortunately, it's easy to reclaim the space, the following will remove all "reserved blocks":

sudo tune2fs -m 0 /dev/sdXX

This can be reset back to the default 5% (or any percentage) if you need to:

sudo tune2fs -m 5 /dev/sdXX

Friday, January 22, 2010

iPhone woes

My iPhone 3GS died 2 days into our holiday. Something like an IMEI/ICCID not found error, and the only thing it would display was a screen asking to be connected to iTunes to be restored.

Connecting to iTunes wouldn't let me restore as it said my phone was locked with a passcode. Using the forced restore mode, iTunes wouldn't restore without an Internet connection. Once I got a connection, the restore failed with an "Error 23" and the log file contained "radio" errors. Didn't sound good. Tried a DFU mode restore, same "Error 23".

So, it was bricked. My last backup was in October. My bad I guess, but I can only use iTunes via my partner's laptop and usually I don't need to. Thankfully it was still covered by the 1 year warranty.

Calling Apple went smoothly. They acknowledged that I'd done everything I could and booked me an appointment to take the phone into the Apple store.

The Apple store is crazy, there were more staff than customers and the Genius bar was booked out for 2 days. That's where your extra $ go when you buy a Mac, buying blue t-shirts...

The Genius replaced my handset with no troubles, which was great.

Restoring from my backup didn't work very well.

My Apps weren't restored at all, only the links to Web Apps I'd saved to the home screen were restored. This is possibly because I hadn't "authorised" iTunes with my account. Hard to recall if I was warned about that, I didn't know it was necessary in any case.

Restoring Apps manually is a pain, trawling through iTunes receipt emails, figuring out which I hadn't uninstalled and which I wanted to keep using.

Additionally, you have to buy the App again, only once that's done does it confirm that you're not going to have to pay for it again (and gives you a cancel button, God knows why.) If you choose the wrong App then bad luck, the one-click purchase will install it with no cancel button.

One tiny bit of good news: Many App's settings were backed up, and the settings were restored after re-purchasing the App. This wasn't clear initially, but obviously it backs up and restores all the files in the "home" folder, whether the App is present or not.

The music wasn't synced at all as I had iTunes set to manage it manually. Fair enough in that case, but still tedious to get it back.

The lesson to be learnt is that an iPhone backup isn't really a backup at all. It apparently backs up your "home" folder and relies on the Sync to do the rest. This is sort of obvious in hindsight, as it's not like there's going to be room for a 32gb backup, and theoretically that's mostly copies of files (music) that's on the computer anyway.

Just because I don't want everything to be automatically Synced doesn't mean I don't want it backed up.

So, I'll be changing my habits from now on. I won't be switching to using iTunes, that's not an option on Linux, but I'll definitely treat the iPhone as a terminal only and try to keep as much as possible "in the cloud". Using Google Sync for my contacts in addition to my mail and calendars from now on for example.

Sunday, September 27, 2009

Canvas Game on iPhone

I just ported my little canvas game to the iPhone:

Go play!

Thursday, August 13, 2009

GPSLog Labs

GPSLog Labs is a site I've been working on where you can upload logs from your GPS tracking device and map, graph and analyse them.

It will let you track your exercise and training whether your a cyclist or runner, and can also be used to track your mileage and keep a diary of your activity.

It builds on a few of the things I've posted about here before, and there's some more information on the GPSLog Labs blog.

Signing up is trivial as it supports OpenID, I'd appreciate any of your comments and suggestions and hope the site interests some of you.

Tuesday, July 14, 2009

Hopeless Exetel customer service

I got the following message regarding a line fault issue we have with our telephone service:

Please note that the supplier technician who has attended to your service issue has confirmed to us that there is no issue with in the infrastructure/network boundary point and or main distribution frame (MDF). Please re-check your equipment.

That was a surprise to me, as on Saturday the technician had found a fault in the line but had been unable to pull the cable and had said that Optus would have to dig it up and we'd find out more later.

Calling Exetel help was a struggle, after waiting on hold and explaining my issue, the call dropped out when they seemed to put me back on hold. Twice.

Thoroughly pissed off I spent another 20 minutes on hold and listening to complete silence while the help desk person was "just one second" (turns out he was talking to Optus, would have been nice to be told why I was waiting).

So, at this point, 50 wasted minutes later, I find out that Optus is going to fix the line after all, and that the message I received was due to Exetel "closing" the initial fault ticket and was completely wrong.

Idiots.

Saturday, October 11, 2008

Merging GPS logs and mapping them all

Inspired by cabspotting and Open Street Map, I wanted to merge all my GPS logs and create a map showing all the routes I've logged lately.

This is pretty easy using gpsbabel, but I needed to use a little Python to get the list of input log files. (I'm sure there's a way to do it in bash but that's beyond me for now.) My GPS stores files in nmea format, and the directory structure/purpose of my Python script should hopefully be apparent.

>>> import os
>>> from path import path
>>> logs = " ".join([" ".join(["-i nmea -f %s"%log
                               for log in sorted((raw/"raw").files("GPS_*.log"))]) 
                     for raw in path("/home/tom/docs/gpslogs").dirs() 
                     if raw.namebase.isdigit()])
>>> logs
'-i nmea -f /home/tom/docs/gpslogs/200810/raw/GPS_20080930_221152.log -i nmea -f /home/tom/docs/gpslogs/200810/raw/GPS_20081001_071234.log ...'
>>> os.system("gpsbabel %s -o kml,points=0,labels=0,trackdata=0 -F /home/tom/docs/gpslogs/all200810.kml" % logs)

The result of that is a 36.5 MB kml file I could load into Google Earth:

There was one spurious point somewhere in the log file at 0° E, 0° N, and the log has a lot of jitter when I'm walking near home.

Thursday, September 18, 2008

A simple game using JavaScript and the CANVAS element

This should work in Opera and Firefox (though really slowly, why I don't know) and probably Safari. It's not going to work in IE because I can't be bothered getting the iecanvas thingi into the blog code.

Update: There is now an iPhone version.

The only thing to note is less clicks == better score.

Canvas not supported...
Clicks
0
0000