Categories
General

Magic

Hal Abelson: “I said that computer science is a lot like magic, and I think it’s good that it’s like magic. There a bad side of computer science which is a lot like religion” – (from SICP videos).

Categories
Programming

Working on remote unix hosts

After much tweaking, I’ve found a good way of working with a set of geographically distributed unix hosts. This isn’t the most exciting topic in the world but, like your choice of keyboard, it affects you every minute you spend working at a computer. So it’s worth some attention.

Every day, I work on localhost and three other (distant) servers. I run gnome-terminal with four tabs, one per host so I can switch between hosts with alt-1-4. Each tab has its own ‘profile’ which I use to set a slight background tint as a visual reminder of which host I’m working on, as well as showing the hostname in the tab title. Why gnome-terminal? Well, because it does unicode right and has tabs – it’s dog slow at rending though. I tried urxvt for a while, but went back to gnome-terminal.

In each tab, I run “ssh -tt HOST screen -DR” to login to the remote host and reconnect to my GNU screen session. This gives all of the win. Firstly, it makes it easy to start new shells on that host without the overhead of a new ssh login. When I say ‘overhead’ I mean both time to do ssh connection negotiation (these are distant hosts) and the niggling asymmetry of ControlMaster. Using screen inside gnome-terminal effectively gives me two dimensions of tabs (and two sets of keybindings) but it works well.

The second win of screen is that if my internet connection goes down or my localhost crashes, I don’t lose my state. Any long running jobs on the remote hosts are still running just fine when I log back in and reconnect to screen. I can also connect to the screen session from different places. For example, I can leave a long job running whilst I cycle home and check on it from home.

The last piece of the puzzle is emacs. I love emacs, and the recent multitty support is just awesome. However, it’s a bit of a pain having to have my ‘actual’ emacs running on a real tty, when 99% of the time I ‘use’ it via emacsclient -t. However, I recently started running emacs under detachtty which allows you to run the main emacs process ‘headless’. I also saw a patch to do the same thing direct in emacs. So now I have a ‘headless’ emacs running on each host 24/7. Then, when I want to edit something I used ’emacsclient -t’ to temporarily connect my current terminal to it. And when I’m done, C-x C-c disconnects from emacs but doesn’t actually kill it. So my emacs now acts like a zero-startup time lightweight editor, but I get all the advantages of a having long-running emacs process. And I don’t have to worry about accidentally closing the window which the ‘real’ emacs is running in. Sweet.

It occurs to me that there’s a lot of duplication in the setup. Screen and detachtty and emacs have overlapping features in numerous ways. Emacs/screen can manage multiple shells, screen/detachtty do the ‘tty decoupling’ thing. But it’d take work to make emacs manage multiple shells as nicely as screen does. And screen-inside-gnometerminal is easier to manage than remote-screen-inside-local-screen. I think I’ve got to a pretty sweet spot with this setup.

Categories
General

Recording music on a linux laptop

I have spent too many hours in my life trying to get a good, reliable audio recording solution on my linux laptop. For a while, I defected to mac but this evening I’m back in linux world and very happy.

I figured the first rule out a while ago: don’t use any kind of internal soundcard. Computers generate loads of electromagnetic interference. You want to do your analog->digital conversion as far from your PC as possible. Plus, you probably want some preamps and maybe some XLR inputs too. The Presonus Inspire ticks all the boxes. I’ve had one for a few years and I love it. Two XLR, two 1/4″ jack and two phono inputs plus two builtin preamps and a headphone socket. If you’re tempted to save money and use an internal soundcard – don’t! You’ll waste hours of your life trying to track down and minimize buzzing noises. Life is too short – buy an Inspire and move on.

The Inspire uses Firewire, and my laptop doesn’t have any firewire ports. No problem, the Belkin PCMCIA Firewire card is pretty cheap and works perfectly under linux – Ubuntu recognized it immediately.

Linux support for the Inspire comes from the FreeBob project, which provides a driver which allows jackd to talk to the device. A bit of help from this page got me going. Important: you need to plug the power supply into the Inspire – the PCMCIA firewire card doesn’t appear to supply power directly.

Once jackd is up and running, qjackctl should show that you now have 4 inputs and 2 outputs (they’re named “system”).

Here’s the core software stack I use for recording and mixing:

  • qjackctl: patchbay management. The software equivalent of plugging in cables between things.
  • Ardour – digital audio workstation. I spend most of my time here – recording, mixing and editing.
  • Hydrogen – jack-enabled drum sequencer. It’s no BFD but it’s fine for demos.
  • alsaplayer – jack-enabled audio file player. For play other people’s music when I’m bored of my own stuff.
  • fmit: a really good tuner app. It works well and looks pretty.

Anyone else out there got a similar setup?

Categories
General

Living the ebook dream

Four years ago, I was looking forward to an ebook future. Well, four years have passed and I’m happy to say that we’re finally there.

I picked up an Amazon Kindle when I was in Seattle earlier in the year. Basic summary: awesome.

Everyone has an opinion about what the Kindle is going to be like – typically, they enumerate the ways in which paper books are superior. But it’s interesting to see how my friends have reacted when they finally played with the device. The e-ink screen is a pleasure to read from. It is slightly different from paper because it has a slight plastic-y sheen to it, but it’s easy to read from in the same way that paper is. The page flickers briefly as you change pages, but it’s something which you stop noticing quickly.

I decided to write about my experience because I’ve just done my ebook litmus test: I went on holiday for a week and read only from the Kindle. It was a good experience!

Now, I bought the Kindle in the US and brought it here to the UK so I can’t actually buy any books for it. However, there are quite a lot of old out-of-copyright books available in Kindle-compatible format on the internet and I can copy them onto the device via USB. So my holiday library consisted of lots of history, science and engineering books from before 1950. But, hey, that’s what I mostly read anyway so it’s no bad thing.

First big win: I took about 40 books on holiday with me, and they all fitted into the space which one paperback would take up.

Second big win: You can highlight passages in the book you’re reading as you go, and then view all of the highlighted passages together on a summary page. I used this to mark sections which I wanted to research further, and also to mark out the ‘key’ paragraphs in the book. I’m one of those people who hates scribbling on a book with a pencil. But I also learn best when I’m interacting with the text rather than reading it passively. So I have unexpectedly fallen in love with the highlighting feature on the Kindle.

Third win: Variable font size. I usually wear contact lenses. If I don’t have my contact lenses in, or if it’s low light conditions, I just bump the font size up and read in comfort. You can’t do this on paper.

Fourth win: Ergonomics. When the Kindle was launched, it didn’t wow anyone with it’s looks. However, once you start reading with it, it starts to make more sense. I hold the Kindle in at least two different ways – in my right hand with either my thumb hitting the right-hand ‘next’ button or my fingertips curling round to hit the left-hand ‘next’ button. I very quickly forget that I’m holding “a device” and just tap the button to turn the page. I find it much more pleasant to hold a Kindle than a paperback book because you don’t have to continually hold the pages open. My hands and arms are much more relaxed when reading the Kindle.

That’s the good stuff. Now for some downsides.

I had to recharge it once during the week. I get good battery life because I have the network turned off. Actually, that’s almost part of the problem; the battery life is so good that you forget that the device needs charging and then it comes as a surprise.

The “library” part of the Kindle isn’t very good. It should have different areas for “currently reading” and “read recently” and “unread” and “read”. When you hit the ‘go home’ button on the keyboard, it currently always goes to the first page of your library – it should remember where you were last time. The “read” section is psychologically important. There’s some small part of my brain which likes putting a completed book back on the shelf like some kind of trophy. When I finish a book on the Kindle, there’s no fanfare or celebration. It’d be great to see some kind of cheap trick here – maybe it could tell you when you started reading the book, and how long you spent reading it. Anything, really!

I’d like an easy way to see how much further it is to the end of the chapter – ie. should I go to sleep now, or stay up reading for another ten minutes. I do this all the time with paperback books but it’s not very easy on the Kindle.

The ‘highlighting’ feature doesn’t allow you to span pages, as far as I can tell. This is annoying if I want to highlight a paragraph which spans two pages.

I had two crashes during my week’s holiday which required me to hit the small reset button under the back cover. I guess it’s early days for the software still.

I use highlighting all the time, and never use notes or dictionary. I’d love to customize the click action during reading so that it goes straight to highlight mode without going via the menu.

The number of books available on Kindle is still a limiting factor, although obviously Amazon are working daily to improve selection. The last time I went on holiday, I took four print books and none were available on Kindle at that time. On this holiday, I played to a Kindle strength. There are a huge number of old out-of-copyright books available digitally and, it seems, there’s a lot of really good old books out there!

That’s all the downsides I encountered. Overall, it is a brilliant device for reading. It’s also a game-changing device too. In the US it connects to the amazon store using mobile phone like technology. This means you can browse and buy books from the Kindle without needing a PC. In other words, the Kindle is a true ebook device not “one of those computer things”.

The future is here. The Kindle rocks.

Categories
General

Flying upside down

Someone asked me a while ago how aeroplanes can fly upside down. After all, the wings normally ‘suck’ the plane upwards. So if you fly upside down then surely they suck the plane down to the ground?

The trick is that you don’t just flip the plane over and try to fly horizontally – if you did that, you would get sucked down. Instead, you also point the nose a little bit up towards the sky so that your wings are passing through the air at the same angle as they would do in normal flight (somewhere between zero and fifteen degrees).

Of course, that’s all just theoryschmeery until you see someone actually doing it for real. Awesome.