Wednesday, July 14, 2010

gtkpod on macbook

I can finally use gtkpod on my MacBook laptop, though it is not completely painless. This may be the last item that was keeping the Linux laptop around.

This was done by running gtkpod on Debian in a virtual machine running in VirtualBox, the ipod file system was attached with sshfs, and the destination where I copied the music to was also attached using sshfs.

First I made sure I could SSH into the MacBook, this was done a while ago and I can't exactly remember how to turn on the SSH server.

Then I installed VirtualBox.

Next I installed a basic Debian instance, and installed the openssh-server, sshfs, and gtkpod packages.

I ssh into the virtual machine with the -X option to enable X11 forwarding, make sure iTunes is not running, mount the iPod file system over sshfs, and launch gtkpod. At this point gtkpod is on the screen.

Monday, July 5, 2010

server from laptop, round three

I re-started the building of the home server from the broken laptop, using Debian Lenny this time. After a basic install, I have added openssh-server and avahi-daemon to allow for remote access.

Samba will follow shortly.

Sunday, July 4, 2010

Push API vs Pull API

I have found that Pull APIs are much harder to implement than Push APIs, but often the Pull API is much easier to use.

First I shall show an example of each, suppose I want an API for generating the numbers from 1 to 100.

As a Pull API I get the following.

public class RangePull {
    private int i;

    public RangePull() {
        i = 1;

    public boolean hasNext() {
        return i <= 100;

    public Integer next() {
        int out = i;
        return out;

    public static void main(String[] args) {
        RangePull r = new RangePull();
        while (r.hasNext()) {
            Integer i =;
            // do something with i
as a Push API I get the following.
public class RangePush {
    public interface Visitor {
        void accept(int i);

    public void visit(Visitor v) {
        for (int i = 1; i <= 100; i++) {

    public static void main(String[] args) {
        RangePush r = new RangePush();
        r.visit(new Visitor() {
            public void accept(int i) {
                // do something with i

The push version is smaller, and in some ways simpler, but the control is inverted so it is not as versatile.

For example, only the pull version can be used to do a side by side comparison of the range generator results, since two of them would be iterating at the same time.

It is also trivial to turn a Pull API into a Push API, by just looping over the result generator and calling back to the visitor.

I have found that the complexity of changing a Push API into a Pull API is braking up the algorithm at the result emitting step, which often requires it to be re-worked as a state-machine. This is especially challenging where the algorithm is recursive.

Friday, July 2, 2010

scanner buttons (introduction)

I am lazy when it comes to usage of my scanner, it has buttons on the front, and I expect to be able to scan using those buttons without having the screen on the computer disrupted. This is not the case on my Mac, but is the configuration I have on my Linux laptop. I have also recently found VirtualBox to work nicely enough to play with, so I may be able to set up the scanner in Linux in a box on the Mac.

So far I installed scanbuttond, and see that the scanner is detected and button presses detected.

apt-get install scanbuttond

Later I will look up the rest of the configuration and return to this mini-project.