Thoughts of a geek

4 November 2009

Rubgy, a safe technical topic, and baking

Filed under: Computers, Me, Recipes — Tags: , , , , , , — qwandor @ 10:33 pm

Continuing on from my last post taking suggestions from Twitter, today I will be blogging about topics suggested by people on Facebook.

Allan Chesswas: Rugby

Here in New Zealand, and elsewhere I hear, some people like to run around a field jumping on each other and chasing an oddly-shaped ball. This activity seems to be more popular among boys than girls. Many other people like to watch them do so. Several of my flatmates are in the latter set, and one in the former. I have never seen the attraction of either activity. The running around does at least provide decent exercise, but at significant risk of injury. Watching seems even more pointless, and frequently people do so (via television) instead of partaking in more interesting and productive pastimes such as good conversation, programming, baking, listening to music or even reading. This can be something of a frustration.

Donald Gordon: Safe technical topics which no one will be offended by.

Well. Most of my ‘recreational’ programming of late has been on Fridge. Fridge is a co-operative honesty system for snackfood which originated in Memphis. The Memphis Fridge is something of an open secret, used by graduate students and their friends. The basic idea is that certain people buy pre-packaged food and drink in bulk. Everyone who uses fridge has an prepay account which they can put money into by putting cash in a drawer and crediting their account, and then they can use this balance to buy the food and drink. The software keeps track of users, money, the various items stocked, markups to make up for lost or damaged stock, various statistics, and so on.

I have made a few minor contributions to the Fridge software in the past (such as adding a QIF export feature to allow users to import their transaction history into their personal accounting software), but my substantial work on it now began with interfridge. Interfridge was an idea that I and others had some time ago, last year I think, to allow users on one fridge to use that account on another fridge. This was motivated by the fact that both Memphis and Innaworks (where I currently work) run the Fridge software, and several of us use both fridges from time to time. The idea of interfridge was that I could visit Memphis, login to their fridge with my Innaworks fridge account, and purchase items from Memphis just like any Memphis user.

At some point Donald wrote some notes on his ideas of how interfridge should be designed. I finally got around to implementing this (the server side in PHP as part of fridgeweb, the client side integrated into the Java fridge client) using a protocol on top of HTTP. After much discussion with lorne, Chris Andreae and Stephen Nelson and several iterations changing the protocol to fix potential security holes pointed out, we came up with the interfridge protocol that is now in use between Memphis and Innaworks.

However, we realised along the way that fridge really could do with being improved in other respects. Currently, the Java client talks directly to a PostgreSQL database which holds all the user, stock and transaction data. This means that the client must include the database password, which is really not a good thing to be giving out to all and sundry. A much better design would be to have a trusted fridge server which talks to the database, and then have the client perform all operations via the server. With an appropriately-designed protocol, this means that the client need not be trusted, and so anyone can write their own client to use with the fridge. I have thus begun to design and implement a fridge protocol based on the interfridge protocol (it can do everything the interfridge protocol can do and more, so will replace it when it is done). For this I scrapped the custom RPC protocol which I had been implementing for myself on top of HTTP, and went with XMLRPC to take care of all the details of procedure calls, encoding and decoding in a standard way. There are various implementation of XMLRPC available for many programming languages. I should note that the documentation linked above does not include all of the API currently implemented in the code, though it will eventually. I am currently still in the middle of designing it, implementing and documenting it at the same time.

As it currently stands, the fridge server has methods to login, check a user’s balance, transfer an amount to a local or remote (i.e. interfridge) user, make a purchase at the local fridge (I still have not yet decided the best way to handle interfridge purchases in the new scheme), list the current stock, and list other fridges with which the fridge is peered. I am writing a client library and simple command-line client in Ruby to test this as I go. The command-line client implements all the features just mentioned. I have not yet done much on the Java client, but that will come at some point. lorne has just started work on an iPhone client, which should be cool.

Felix Shi: You can always blog about cooking weird and wonderful dishes :D

Weird and wonderful? Not sure about that. I made a batch of muesli and a chocolate cake on Sunday, as I mentioned. The weekend before I baked two batches of muffins (apple and sultana for the Skyline walk on Saturday, banana chocolate chip or something for a picnic on Labour Day with gringer, ja and xyzzy).

I am afraid my cooking of late has not been terribly interesting. Suggestions are welcomed, as are visitors interested in consuming baking. As always.

Fixing VMware mouse grab bug on Ubuntu Karmic

Filed under: Computers — Tags: , , , — qwandor @ 9:23 am

I just upgraded my work machine from Ubuntu 9.04 (Jaunty) to 9.10 (Karmic) and came across a couple of problems with VMware Player (version 2.5.3 build-185404). It seemed wise to document the fixes I found here so that other people experiencing the same problems might find these solutions when they Google for it.

The first was an error when it tried to launch my VM complaining that the virtualisation extensions of my CPU were already in use, saying “The virtualization capability of your processor is already in use. Disable any other running hypervisors before running VMware Player.” and then a number of other errors. This was fixed by removing the KVM kernel modules:
$ rmmod kvm_intel kvm

The second problem was that the VMware window would lose its mouse capture whenever I moved the mouse pointer outside the top-left of the VM screen (apparently a 640×480 region), unless I had a mouse button held down. This made it impossible to actually use the VM. This was eventually fixed by adding the following line to /etc/vmware/bootstrap:
export VMWARE_USE_SHIPPED_GTK=yes
This forces VMware Player to use its own version of the GTK library rather than the Ubuntu one, which apparently avoids the mouse grab bug.

8 September 2009

An idea for songfighting

Filed under: Computers, music — Tags: , , , , , — qwandor @ 11:14 pm

I was working to work the yesterday, and I had an idea.

Perhaps you have heard of SONG FIGHT. If not, the idea is fairly simple: each week, a song title is given. Competitors then have a week to write the words and music for a song fitting that title, record it, and submit it. Anyone can then download the songs, listen to them and vote for which they think are best. I guess the main point is to motivate musicians to write more songs, to improve their skills and whatnot.

Anyway, my idea is to automate the process. I want to write some software that, given a title, can produce a half-plausible sounding song matching it. The first step would be to generate the lyrics, which I guess could be handled by an approach based on Markov chains trained on a range of existing song lyrics, probably combined with some sort of syllable and rhyming dictionaries to produce lines with some sort of rhythmic structure. Hmm, perhaps the rhythm should be generated first and then the lyrics made to fit it. The title would be included in one of the lines, probably near the beginning or end, or even several times in the chorus.

Next (or perhaps first), it would be necessary to generate some sort of plausible tune for the verse and chorus, and any other bits in-between (bridge? intro? instrumental bit in the middle?). I am not sure how to approach this, perhaps there is some literature on the subject. Maybe more Markov chains, or some sort of recombination of existing tunes, or some other method. I could really do with some advice from musicians here: how do you put together a tune that actually sounds tuneful, rather than just a list of random notes?

I assume that once the basic melody is generated, generating a passable accompaniment would be relatively straightforward, though again I will need to talk to some musicians.

Once the music and lyrics are sorted, along with an arrangement for the song, producing the final product would be a matter of running the lyrics and melody through Festival’s singing mode (as I have played with before), synthesise a few instruments and some drums for the rest of it, and mix it all together, ready to submit. Simple?

Anyway, reactions? Does this sound plausible? Has it all been done before? Can you offer any advice, especially for the musical side of it?

17 August 2009

An interesting tale of filehandles

Filed under: Computers — Tags: , , , , , , , , , , — qwandor @ 10:25 pm

I just found an interesting bug, so I thought it might be worthwhile to share it with these intertubes to prevent other people from making the same mistake.

I was just transferring some more music onto my iPhone with Amarok while at the same time listening to music. I wanted to listen to a particular track (from a Moby album I bought recently), so stopped and switched to that, but Amarok would not play it and complained about the sound device being busy. This seemed rather odd as it had just been playing fine until I tried to change tracks. Wanting to get to the bottom of this, I checked who had what open:

andrew@rata:~$ sudo lsof /dev/snd/*
lsof: WARNING: can't stat() fuse.sshfs file system /media/iphone
Output information may be incomplete.
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
timidity 4162 root 6u CHR 116,1 4973 /dev/snd/seq
kmix 4511 andrew 10u CHR 116,0 5260 /dev/snd/controlC0
ssh 5605 andrew 16u CHR 116,0 5260 /dev/snd/controlC0
ssh 5605 andrew 33r CHR 116,33 4954 /dev/snd/timer
ssh 5605 andrew 39u CHR 116,16 5236 /dev/snd/pcmC0D0p
ssh 5605 andrew 41u CHR 116,0 5260 /dev/snd/controlC0
sshfs 5609 andrew 16u CHR 116,0 5260 /dev/snd/controlC0
sshfs 5609 andrew 33r CHR 116,33 4954 /dev/snd/timer
sshfs 5609 andrew 39u CHR 116,16 5236 /dev/snd/pcmC0D0p
sshfs 5609 andrew 41u CHR 116,0 5260 /dev/snd/controlC0

I should point out at this point that the way I get Amarok to sync music to my (jailbroken) iPhone is to FUSE-mount the iPhone via SFTP over the network, so that is why SSH was running. But on with the story.

SSH had my sound device open‽ What? That seemed very odd. I wondered whether perhaps there was some new SSH feature I had not heard about to forward sound over the network connection (as it can do for GUI applications using X11), but there I could find no mention of such a feature in the manpage or via Google, nor any possible reason why it might want to open a sound device. I asked lorne, and he was equally confused, but suggested a few things to check.

After a bit of poking around I discovered that I could not replicate this behaviour by mounting the filesystem myself, only when Amarok did it. This prompted a realisation of what must be happening: when Amarok launches sshfs to mount the iPhone filesystem, it presumably does a fork and exec to start the new process. But when you do this, the new process inherits all the open file handles of the parent process. Amarok of course had the sound device open to play the music I was listening to originally, so sshfs and subsequently ssh ended up with the same device file open. Amarok must then have closed it and tried to reopen it when I switched tracks, and this failed because the other processes it had launched still had it open. Of course.

So, lesson of the day: when you fork, remember to close any excess files before you exec. Especially if they are device files or other special files.

I should probably file a bug report for Amarok, but I am not sure that I can be bothered.

30 July 2009

Juvenile humour

Filed under: Computers, Humourous, Lists — Tags: , , , , — qwandor @ 9:32 pm

It turns out that if you take the title of a book and append the phrase “in your pants”, the resulting title is often more amusing than the original. Here I present you some examples:

About the Size of it: The Common Sense Approach to Measuring Things in Your Pants
The Adventures of Huckleberry Finn in Your Pants
All About Worship: Insights & Perspectives on Worship in Your Pants
Being Human in Your Pants
Calculus: A New Horizon in Your Pants
Computer Networking: A Top-down Approach Featuring the Internet in Your Pants
Computer Organization and Design: The Hardware/Software Interface in Your Pants
Coping with Controversy in Your Pants
The Diamond Age: Or, a Young Lady’s Illustrated Primer in Your Pants
Dick Smith’s Fun Way into Electronics in Your Pants
God’s Undertaker: Has Science Buried God in Your Pants?
The Snow in Your Pants

For some automated humour, I have just written a little script that will transform the titles of your books most recently added to LibraryThing in similar manner. Take a look at what it does for my books, or try it on your or your friend’s collection.

Oh, and on the topic of pants, if you have not read Star Wars pants quotes, perhaps you will be amused to do so. I cannot find the original site that I remember from years ago, but they are still funny. The premise is to take a line from Star Wars and replace one word with the word ‘pants’, thus improving the line.

Well, it is said that small things amuse small minds.

8 July 2009

Updates to theQuotebook

Filed under: Computers, thequotebook — Tags: , , , — qwandor @ 9:46 pm

I have made a few updates to theQuotebook over the past few weeks (well, okay, months). For those who have not already noticed:

  • You can now get an email when you are quoted, or when someone comments on one of your quotes (either a quote that you added or one that you said). This will be enabled by default the first time you log in. Users who have been created to be quoted but have not themselves logged in to the site will not get any emails. I originally implemented it so that they would get emails and so could see when they are quoted and log in if they wanted, but this was changed on request from a user. Let me know which way you think is best.
  • It is now a bit easier to sign up if you do not already have an OpenID, as the site now has an option on the login page to get one from myOpenID. The link there will sign you straight in once you have it, thanks to myOpenID’s affiliate programme.
  • It is possible to use some basic formatting in quotes and comments. You can make text *bold* and _italic_ like so, and also use BBCode if you are familiar with that. The formatting options for quotes are fairly limited, but comments allow most BBCode.
  • There is are now Atom feeds for comments as well as for quotes, so you can subscribe to both in your favourite feedreader (I recommend Google Reader) and keep up with them without checking the site all the time. To subscribe to the quotes and comments on your quotebooks, go to the home page, make sure you are logged in, and then click the RSS feed icon in your web browser (in Firefox it is a little orange icon in the address bar, right-aligned after the URL).

There have also been many minor improvements, such as the ability to add a new quote straight from the page for each quotebook, rather than having to click a link first.

Looking forward, we will hopefully have a new style for the site in the not-too-distant future (thanks to Daniel Sherson). If you are particularly curious, more plans and ideas may be found. Or, of course, you could talk to me.

Comments, suggestions, ideas and other feedback are of course welcome. I make no promises about doing what you say, but I will certainly be happy to listen to anything.

29 May 2009

Bob

Filed under: Computers, Humourous — Tags: , , , — qwandor @ 7:32 pm

I have been told that I should tell you all to talk to Bob. Bob is a chatterbot I wrote about three and a half years ago, which learns from what people say to it. Everything it says is based on something it has heard in the past; there is no knowledge of any particular language built into it.

Unfortunately the problem with putting such a thing on the web — or indeed most anywhere on the Internet — is that people tend to type garbage into it most of the time, and so it ends up spouting the same garbage. I have just now cleared its database though, so it should hopefully be relatively sensical for at least a few weeks until it gets overwhelmed with nonsense again. It can even be quite funny at times.

If you are curious, after chatting to it for a while you might want to see Bob chat to itself or see the contents of its ‘brain’.

17 May 2009

Free stuff

Filed under: Computers — Tags: , , — qwandor @ 5:55 pm

I have a few computer bits and pieces to get rid of, so I thought it best before throwing them out to check whether anyone might want any of them. So, does anyone want any of the following:

  • An AMD Sempron processor (I cannot remember the exact model number, but around 1.8 GHz), with heatsink and fan.
  • An SBus framebuffer (graphics card), to suit a Sun Sparcstation of some sort. It takes up two SBus sockets, and has the usual 13W3 connector that Sun used to use for their monitors.
  • An external audio adapter for a Sun Sparcstation with the appropriate socket. It has a speaker, microphone, volume controls and line in / out sockets.
  • Various old PCI graphics cards, and I think some AGP ones too, possibly not so old.
  • Various PCI sound cards.

All of that is free to anyone who wants it, so let me know soon if you are interested in any of it. I also have various other bits and pieces that I might be persuaded to part with, so let me know if you are looking for anything in particular.

7 May 2009

In which the author lists his preferred Firefox extensions (part three)

Filed under: Computers — Tags: , , , , — qwandor @ 10:17 pm

Well, there has been quite a delay since the first and second parts, but this is the third and final post of my series recommending some Firefox extensions that I find useful, and think that you might too.

Here goes.

Google Gears allows web applications to do some things they would not normally be able to do, to do more of the things that it would normally be necessary to install a local applications to do. In particular, it lets web apps (such as GMail and Google calendar) work without an Internet connection by storing data in a client-side database, and also keeping the data for the webpages (HTML, Javascript &c.) locally. It also provides some features to allow Javascript to be executed more efficiently, and — perhaps most interestingly to me — provides access to location information (from WiFi signals, GPS, IP geolocation, or whatever is available). This does require the user to give permission, of course. It is for this functionality that I installed Gears, as it is used by the desktop (iGoogle) version of Latitude.

Ubiquity is a bit difficult to explain without demonstrating it. So, try it. It lets you do all sorts of things in your browser by typing commands. It pops up in front of the current page, and can do things like Googling something, editing the page, posting to Twitter, composing an email, finding a map, and anything else you might think of. The idea is a bit like Quicksilver (or Katapult, or Krunner, or GNOME Do), if you have used any of those, but for the browser rather than the OS, and so with more integration with all sorts of useful web services. It really is quite a cool idea. I tend to use it for quickly looking up in a dictionary words in a page I am reading if I am not sure what they mean, or for Googling things if I want a little more information. It is a bit quicker and less disruptive than opening a whole new tab to do it; I can Google something just by selecting it, then going Ctrl+Space (to show Ubiquity) and typing ‘go’ (for Google; you only need to type enough of a command to distinguish it from the other available commands).
New actions can be added by installing simple scripts (written in Javascript). People have already written all sorts of such scripts which you can install easily, or you can write your own if there is some action you want that nobody has yet thought of.

VeriSign’s OpenID SeatBelt keeps track of your OpenID login, and warns you about Phishing attempts. It will show whether you are currently logged into your OpenID provider, let you login if you need to, and automatically fill in your OpenID when you visit a site using OpenID login. By default it comes configured to work with VeriSign’s OpenID service, but you can easily configure to work with other services (I use it for my OpenID http://q.geek.nz/, which is delegated to myOpenID).
If you use OpenID, it is quite handy. If you do not use OpenID, you should. It saves having to remember so many passwords for different sites, as you can login to any site supporting OpenID with a single account. Actually, there is a fair chance that you already have an OpenID without even knowing it, at least if you use GMail, any Yahoo services, LiveJournal, Windows Live, WordPress.com, or various other services.

Well, that is all from me on this topic. I would be interested to hear what Firefox extensions you, dear readers, use (if, indeed, you use Firefox), and what you think of them. I would also love to hear if you try any of those that I recommended over these three posts.

12 April 2009

New computer (soon)

Filed under: Computers, Me — qwandor @ 9:03 pm

I finally ordered parts for a new (desktop) computer. I have been meaning to do so for at least a year now, but kept putting it off because of being busy or lazy and not knowing quite what I wanted. In the end, I decided upon and ordered:

  • Intel Core 2 Duo E6750, 2.66GHz for $291.38 from XP Computers
  • Gigabyte GA-G31M-S2L (Intel G31) microATX motherboard for $125.28 from PC Genie
  • nVidia GeForce 8400 GS for $61.43 from PC OnLine Shop
  • 2GB DDR2-800 PC2-6400 SDRAM for $32.04 from PC OnLine Shop

Unfortunately the place I ordered the processor from apparently does not have any in stock at the moment, and do not know when they will get more. Others places selling the same model are significantly more expensive, and the closest other model is also quite a lot more expensive. So I guess I will have to wait a while longer yet.

It will be good to have a new machine though, as my current motherboard (I assume) has a lot of problems: the serial port is broken, often when it is cold the graphics card and sound hardware do not initialise properly for the first few attempts at booting it, so I have to keep rebooting until finally it works. Lately it has also been having random crashes at all sorts of times, which may be due to bad RAM or also the motherboard (though I have not tested). And it is a bit old and slow; it was fairly much bottom of the line when I got it about 4 years ago, and even with the new RAM and drives I have got in that time it is a bit of a pain sometimes.

Older Posts »

Blog at WordPress.com.