Thursday, 17 December 2009

Linux Tips: Vim autoconfigure for different filetypes

Thanks to Ajay Somani, over at for this post that finally helped me solve a long term gripe with vim.

When I'm in 'programmer' mode, I use vim with syntax highlight turned on.
When I'm in 'wannabe fiction writer' mode, I use it with spell check turned on.

And these two personas keep fighting like Jekyll and Hyde. Because I have both of these turned on, vim insists on syntax highlighting my fiction, interpreting apostrophes as quotes and then coloring everything after them. Worse still, it spell-checks my C-code. It'll highlight some text in red, and then spell-check it, and decide it's mis-spelt, and thus surround it in a background colored.... red. This results in large blocks of red-on-red text that cannot be... uh... read.

The solution, it turns out, is to add this magic line to my vimrc:

autocmd BufEnter *.txt set spell

Wednesday, 16 December 2009

HTTPS: No one uses it

I spent a whole night battling to get secure http working in 'Movgrab', only to discover that no-one uses it. I couldn't find a single proxyserver that supported 'straight' https (some of them might support use of the 'upgrade' header, but as of right now, I don't understand that). So then I switched to using https to connect directly to video-sharing websites. Any google website (youtube, bounces me straight to if I try to use https. Many other sites let you use it for the initial connection, but insist on redirecting you to http: when you try to get video. The rest don't support https at all.

I don't know, I would have thought that in these days of 'Web 2.0' secure browsing would have been the norm by now.

Tuesday, 15 December 2009

Hey, movgrab people!

So, I posted movgrab to on Sunday. Since then, I've not heard anything, but through my advanced psychic superpowers I happen to know that visits to my new technical blog have jumped dramatically. The only explanation for this, I believe, is that people are downloading movgrab, and seeing the mention of my blogs on the help-page (or the website they download it from).

So, if you're coming here having used movgrab, leave a comment. Did it compile on your system? Does it work as advertised? Will it change your life? Did using it open a portal to the dungeon dimensions (if it did, and you're thinking of suing, you're out of luck, I included a disclaimer covering exactly this eventuality).

Come on people, I needs to know!

Sunday, 13 December 2009

My first code release up on freshmeat!

Big day for me today. I've been writing software projects for simply years, maybe even decades, and every one of them has grown and grown, but it's never finished, it's never ready for release. Finally I've gotten my first project completed!

Okay, it's a fairly trival app. Movgrab is a command-line app for downloading flash/mp4/mp3 movies and audio from websites that offer that kind of thing. This is useful to we linux luddites who are still using machines that most people wouldn't even use for email these days (for instance, I've got a bunch of pentium-1 laptops that I use as 'holiday' or 'travel' laptops, because no one is likely to bother stealing them, and if they get smashed or something, then I've not lost very much). On weedy machines like the one I'm typing this blog-post on, web-browsers like firefox don't run well. Unfortunately light-weight webbrowsers don't support flash. The solution? Download the movies and watch them with a command line player, rather than in a web-browser.

There are other downloader applications out there of course, but few of them are command-line 'C' programs like movgrab. Most of them require you to install scripting languages and libraries, which can be a headache, I find. Also, few of them support as many download types as movgrab does (including BBC iplayer, youtube, metacafe, dailymotion, crazymotion, uchannel, various university webcasts etc, etc).

More important than the app is the underlying library ('libUseful') that allowed it to be written. Writing movgrab meant adding a lot of code to the library to support HTTP transfers, and this is being used in a lot of other projets too.

So, there is a new website over at, where one can download this first of my masterpieces.

Sunday, 29 November 2009

Linux tips: Recovering lost text data from disk, or EVEN MEMORY

Okay, first new post for the new 'technical' blog. The topic is "Holy ****!!! I just had my browser/text editor crash, and I've lost all that work! What do I do now?"

Well, so long as the editor you were using stores it's data in some form of plain text, and so long as you are using linux, freebsd, or some other unix, (or possibly Mac OSX), I may be able to help.

WARNING: These techniques, like any secret powers, come with a degree of risk. I take no responsibility for any accidents where you wipe your hard-disk, explode your computer, or accidentally sell your soul to the devil. In fact I take no responsiblity for anything at all. You have been warned.

I christen this blog...

So, I'm starting up a second blog. Why? Well, my first blog was about my efforts to be a writer, my sundry opinions on the state of Science Fiction and the political issues within it, and technical linux hackery. These things did not play well together. People who knew me from my 'writerly' efforts were completely bamboozled by posts full of 'grep | cut -c 1-10 | sed "s/apple/pear/" | tr ':' ' ''

And can you blame them?

But, on the other hand, my rare 'technical' posts got the most satisfying feedback, when people said "Hey! This really helped me to do something!", so I'm starting up this 'Linux techy' blog to turn alongside my main blog over at

First I'll be transfering over my old 'linux' posts, and then I'll come up with something new to say.

Saturday, 20 June 2009

By-Voice: Free online text-to-speech synthesis

I stumbled across a cool little service at Basically, this is a simple web-service by which you can get text converted to computer-generated speech. The service works by making a HTTP request to by-voice, which means its a little awkward for everyday users, but it's wonderful for programmers, because you could, if you were to sign up to the service fully, write programs that would on-the-fly download speech and play it.

Sunday, 7 June 2009

Linux Tips: SSH

It's been a while since I posted, having gotten most of my rants off my chest in the early days of the blog. Rather than just spout my opinions again, I thought I'd do some posts about Unix/Linux tricks that I find myself using time and again.

First up, uses of secure shell 'SSH'. These tricks should work with any unix that has an ssh command, so they should also work with MacOSX, I think. Obviously, you need two machines for them to communicate between, or it's all pointless.

Monday, 4 May 2009

The Hacker Will Always Get Through

The BBC currently has a program up on the explosion in cybercrime.

Initially this program had me shouting "No! No! No! You just don't get it!", but eventually it did a twist-in-the-tail and hit the real reason that cybercrime is so rife:

Computer users are stupid.

I'm sorry, I know it's not a pleasant truth, we would far rather believe that there are these fiendishly clever, evil people out there who are doing super-clever things, and that's why people get hacked. But the truth is never pleasant, is it?

Saturday, 18 April 2009

Why Open Source needs another decent Webbrowser

The Open Source world needs another decent web-browser.


Well this ties up with a lot of issues related to how open source, and particularly linux, has been changing over the years, and how, in many ways, I believe that open source is becoming increasingly irrelevant and less open.

Way back when I started using linux the arguments in its favour were hard for the windows using crowd to understand, but there were some that they could get their head around.

1) Linux was fast. I'd start up applications, and they'd pop into existence on the desktop. They might be primitive looking compared to what you'd get under windows, but they did the job well enough, and people's eyebrows would raise when my PC booted in ten seconds flat once it had got through the bios stage.

2) Linux was small and undemanding. You could fit it on almost any piece of hardware more powerful than a 486. Old kit that windows users were unable to use any more worked fine for linux, and to this day I use a bunch of circa 1995 AST laptops running linux, so that I can take them anywhere and if they get stolen, what have I really lost?

3) Linux was reliable. It didn't lock up or crash like windows. There was no 'Blue screen of death', or if there was, it normally meant you had hardware problems, like your processor fan had stopped turning, and the CPU had thus overheated.

4) Linux didn't get viruses/trojans/hacked. This had a lot to do with it being simple and primitive, meaning fewer openings for exploits, and also that it didn't try to do everything for the user (and hence be too ready to open files and run programs that really it shouldn't be messing with). If you did 'ps ax', you could look through a short list of processes, and know what each of them did, and spot any that shouldn't be there (and I once detected some naughtiness going on with just this method).

There were other features that they didn't understand, but which were very important to me. I could get the code for programs, and compile it myself. If they didn't do some little thing that I wanted, or if they blew up unexpectedly, I could go in there and try to fix them, or add the thing that was lacking, or sometimes even take features out that, for one reason or another, I particularly didn't want. I could, and did, learn lots from looking at other people's code, and how they did things.
What's more, there were generally many programs available for linux to do a given task, each with its own advantages and failings. I could pick the one that was most right for me. When once, I heard another linux user saying "You should just use program X, and no other", I looked at him aghast and said "In that case, I should just use windows and be done with it. Linux is about choice. If it's not about choice, it's not about anything."

This was what open source meant for me. Oh yes, and it was free too, which was the main thing that the windows users REALLY understood. But for me the ability to choose, modify, understand and take ownership of the programs I ran, that was what was really important.

And it's all gone to hell since then.

Sunday, 22 February 2009

Blogger API: I'm impressed

Well, I'm impressed.

I've managed to figure out the blogger A.P.I. sufficiently to write a little command-line app that lets me type up my posts in an editor (vi) and then post them to blogger. Why would I want this? Well, my laptops are weedy things that I got for free, and which date from the 1990's. Full-featured modern browsers run painfully slowly on them. I normally use 'links' as my preferred web-browser. Now, you look at links, and yes it's clunky, and yes, the pages don't render as they 'should', but it *mostly* works. It's small and fast. Then you look at firefox, opera, konqueror and co. They work on many more sites, and have more features, but to get this extra 10% of functionality, they are utterly huge and slow with masses of dependancies. Something isn't quite right with this picture, I feel. But this is a rant for another day.

For me, writing my posts in 'vi', and then sending them later, is the ideal solution. It's quick and easy, and 'vi' recovers it's data effectively after a power-cut or what-have-you. However, most things these days, are hideously overengineered, and if a company decides to let others 'hook into' their systems, it usually involves downloading and using libraries, and before long your system is littered with libraries that you use for one app.

So, finding documentation that tells you 'connect to this address, send this HTTP transaction, you have now posted to your blog', is damn impressive. This is the way it should be, open, and fairly simple. Took me about an hour to get it working. All hail google.


Thursday, 19 February 2009

Cory doctorow on the history of copyright

Here (you tube) is a must-see public speech by Cory Doctorow explaining the work of the Electronic Frontier Foundation, and the politics surrounding DRM and copyright. Pity the sound quality is poor.