Bela Lugosi's Dead, Jim Below are the 20 most recent journal entries recorded in the "Richard Kettlewell" journal:

[<< Previous 20 entries]

November 18th, 2009
11:26 am

[Link]

Drag And Drop The Hard Way

Disobedience, DisOrder's GUI client, uses a GtkTreeView to display its current queue of tracks (and for various other purposes). It allows rearrangement of the queue by drag and drop. The high-level support for this in GtkTreeView is rather unsatisfactory for two reasons:

  1. You can only drag one track (row) at a time. It should be possible to drag the whole selection.
  2. You cannot drag between widgets. Playlist editing in particular is likely to make this important.

(Actually the model where it reports the effects of the drag and drop by inserted/deleted signals on the underlying model is also quite inconvenient for me: Disobedience has to translate it back into a move which it communicates to the server.)

Fixing this involves doing rather a lot of the drag-and-drop work yourself, and while the documentation does exist it is not always clear or even complete. There is existing code out there, and I referred to it while working some of this out; but describing it in English online seems worthwhile. In addition, while some of the code is inextricably mixed with Disobedience's internal workings, a couple of independent modules are presented, which should be usable in other C programs.

This articles assumes some familiarity with GTK+. I have tried as far as reasonably possible to remove DisOrder-specific issues from the discussion here, but note that this isn't always possible.

Read on... )

Tags: ,

(Leave a comment)

October 17th, 2009
01:58 pm

[Link]

Timing bug somewhere-or-other
richard@araminta:~$ cat t.c
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include <assert.h>
int main(void) {
  for(;;) {
    time_t t;
    struct timeval tv;

    assert(gettimeofday(&tv, NULL) == 0);
    assert(time(&t) != (time_t)-1);
    if(t < tv.tv_sec)
      return printf("%ld %ld.%06ld\n", t, tv.tv_sec, tv.tv_usec);
  }
}

richard@araminta:~$ gcc -o t t.c
richard@araminta:~$ ./t
1255784018 1255784019.000000
versions )

Tags:

(14 comments | Leave a comment)

October 15th, 2009
10:17 am

[Link]

Docking
Poll #1471524
Open to: All, detailed results viewable to: All, participants: 35

The dock on a Mac should be...

View Answers

on the left
10 (28.6%)

at the bottom
16 (45.7%)

on the right
4 (11.4%)

auto-hide on
10 (28.6%)

auto-hide off
20 (57.1%)

magnifying icons on
13 (37.1%)

magnifying icons off
15 (42.9%)

at the largest setting
4 (11.4%)

somewhere in the middle
14 (40.0%)

at the smallest setting
4 (11.4%)

I only have inferior computers
6 (17.1%)

Tags: , , ,

(14 comments | Leave a comment)

October 10th, 2009
05:57 pm

[Link]

Soekris so far

Steve gave me a Soekris net4501. I've been gradually getting this into shape for use as the house router. This page covers the details in case anyone else attempts something similar; some aspects were not entirely trivial.

Testing reveals that it can route data at (at least) 24Mbit/second, which is comfortably faster than the nominal speed of our Internet connection. It's much slower than the nominal speed of the house wireless but actually marginally faster than the measured speed, so I'm not worried about that either.

(“At least” 24Mbit/s because that could be a limit somewhere other than the Soekris.)

Usefully for the testing it turns out that crossover cables are no longer necessary, at least when connecting the Soekris to a modern Mac (and for all I know any other modern hardware).

Tags: ,

(9 comments | Leave a comment)

September 19th, 2009
02:54 pm

[Link]

Stacks and better translucent windows

I recently upgraded to Snow Leopard.

Cut for wide screenshots and Diego Maradona )

Tags: ,

(4 comments | Leave a comment)

September 17th, 2009
02:22 pm

[Link]

Laptop trackball

Can anyone recommend for/against trackballs suitable for use with a laptop?

I'm looking for something that's:

  • fairly small
  • won't lose the ball if slung in a laptop bag
  • ideally, uses bluetooth (though usb might be ok)
  • ideally, that could be clipped to the side of the laptop

Tags: ,

(3 comments | Leave a comment)

September 13th, 2009
02:13 pm

[Link]

Blue screen

I was trying to get some (any) kind of network filesystem access from my Mac to a Unix box. I didn't have much luck (which is another rant entirely) but I was amused by the “it's broken a PC” icon...

Tags: , ,

(4 comments | Leave a comment)

August 24th, 2009
05:42 pm

[Link]

Small PCs

I'm planning to get a Soekris net5501 to the be the house router (so: IP routing, NAT, DHCP client/server, secnet VPN, DNS). Before I do, are there any similar devices I should consider as possible alternatives?

What I need is:

  • Silent or at least very quiet
  • At least three ethernet ports (house LAN, house wireless, upstream)
  • Must be able to run Linux without undue hassle

Nice to have but not necessarily essential:

  • Serial console (but I can faff around with a keyboard and monitor if it comes to it)
  • Compact flash storage (I have a spare 2GB card, which is unrealistically small for my camera)
  • x86 architecture (my plan is to transplant an existing lenny install onto it)

Tags: ,

(15 comments | Leave a comment)

July 12th, 2009
06:55 pm

[Link]

VCS 0.6

I have released VCS 0.6.

What's VCS?

Do you find yourself typing bzr commit in Git branches, or cvs diff in your Perforce workspace? Then perhaps VCS is for you.

VCS is a wrapper for version control systems. It presents an essentially uniform interface to the user, allowing ‘muscle memory’ to use vcs commands rather than adapt to the version control system currently in use. Of course, the downside is that you have yet another three-letter command to start using!

The supported systems are Bazaar, Git, CVS, Subversion, Mercurial, Darcs and Perforce. More could be added. The supported commands are add, annotate (blame), clone, commit, diff, edit, log, remove, revert, status, update. Again, more could be added.

Where Do I Get It?

http://www.greenend.org.uk/rjk/2009/vcs.html for source code, .deb files and Bazaar branches.

What's New In VCS 0.6?

Various things )

Tags: , ,

(3 comments | Leave a comment)

July 9th, 2009
07:23 pm

[Link]

Things that annoy me about Perforce

Missing Features

Things that just aren't there, that shouldn't (in principle) be hard to add.

  • p4 resolve won't show the difference between theirs and merged. A motivating example is where you merge from a release branch (theirs) that has changed more, and more recently, than the merge target (yours). In this case I'm more familiar with the branch changes and so would like to see what else I'm getting (i.e. from the branch I'm merging into) in the eventual submit. (Perforce have an enhancement request open for this one.)
  • There is no command to report the current status of your working tree (like cvs -n up, bzr status etc). When writing VCS I had to write my own. p4 opened is part way there in that it will tell you what have open, but the output format is rather verbose; it lacks the equivalent of .cvsignore; and it doesn't tell you if any files need resolving.
  • p4 diff (etc.) won't do the equivalent of diff -N (even if you set P4DIFF!). This makes the patches they generate incomplete if there are any added, branched or removed files, which is inconvenient for review and means that they're not suitable for use with the patch program.

Interface Inconveniences

Nuisances in the user interface. Again, I don't think these would be especially difficult to change.

  • Perforce forms (e.g. for p4 submit) treat visually identical whitespace as distinct. So if you've configured your editor not to insert raw tab characters (because your coding standard says you shouldn't use them, for instance, which is quite sensible given the trouble they cause) then your change description will appear to be correctly formatted when you submit it but be wrongly indented when you look at it in p4 changes or whatever.
  • p4 submit can only take one filename pattern. i.e. “p4 submit one.c” is OK but “p4 submit one.c two.c” is not; you have to manually add files to a change in separate steps before submitting it, or construct a change listing all the desired files manually.
  • If a change cannot be submitted you have to modify it and resubmit it; you can't delete it and start again, which otherwise might well be more convenient. The restriction seems to be an entirely bureaucratic one, too: you can remove all the files from it and then delete it. (For non-p4 users, the “change” here means the description and metadata, which in p4 have an independent life of their own; not your edits.)
  • Output tends to hide important information among unimportant. For example if a p4 sync updates 100 files and only one of them requires resolving, you're likely to miss it. Summarizing the files that need resolving at the end of the list of updates files would improve matters.

Model Problems

Flaws that result from some aspect of the system's design. These might well be difficult to change. (Which doesn't make them invalid; if the underlying design of a system doesn't support useful features, then perhaps that design is itself wrong.)

  • There's no whole-module graphical branch history view (like gitk or bzr visualise). p4v will show you a per-file branch diagram but nothing better than that.
  • p4 describe and p4 diff2 don't honor P4DIFF (because they do the diffing on the server), so if you have a better diff tool than p4's built-in one (which I do) then you don't get the benefit of it.
  • Execute bits are not properly versioned. You can't just edit a file and chmod it, you have to use a special command to change the execute bit. That's just inconvenient, but worse is that integration (merging) doesn't copy the change, so you have to change it on every branch separately. (Updated in the light of comments: apparently there's an option to do this, but, bafflingly, it's off by default.)
  • If the server is running slow or is down, all operations that are in any way related to version control are affected. Since there is no client-side state or caching other than file contents, this includes non-mutating operations (diff, history, etc; even testing whether a file is in version control).

(Yes, some of these problems exist to some extent in some other version control systems too. That doesn't mean they're not annoying...)

Things that aren't annoying

  • The need to p4 edit isn't a big problem in practice (even though it sounds like a nuisance if you're not used to it), given adequate editor integration.
  • It doesn't crash. As a rule the problems seem to be design flaws (such as those above) rather than implementation bugs.
  • It's usually fast.

Tags: ,

(8 comments | Leave a comment)

June 22nd, 2009
01:34 pm

[Link]

Weird Bash time behavior
richard@araminta:~$ cat busy.c
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char **argv) {
  struct timeval now, end;
  sleep(atoi(argv[1]));
  gettimeofday(&now, NULL);
  end = now;
  end.tv_sec += atoi(argv[2]);
  while(now.tv_sec < end.tv_sec || now.tv_usec < end.tv_usec)
    gettimeofday(&now, NULL);
  return 0;
}

This programs sleeps for a number of seconds and then busy-waits for a number of seconds.

richard@araminta:~$ time ./busy 0 1 | time ./busy 1 2 | time ./busy 4 3
0.63user 1.36system 0:03.00elapsed 66%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+133minor)pagefaults 0swaps
1.00user 1.99system 0:07.00elapsed 42%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+133minor)pagefaults 0swaps

real    0m7.016s
user    0m1.932s
sys     0m4.088s

Superficially it would seem that:

  • busy 0 1 slept 1s and busy-waited 2s
  • busy 1 2 slept 4s and busy-waited 3s
  • busy 4 3 slept 2s and busy-waited 6s

Of course this isn't the case at all, and the different output formats are a hint as to what's really going on. Bash interpreted the first time as applying to the whole pipeline (which does indeed survive for 7s and consume 6s of CPU) while the second and third only apply to the individual commands. The whole-pipeline output of course has to appear last since the computer can't predict the future.

In other words, the actual grammar honored by the shell differs sharply from the natural reading of the command. Bash's interpretation is both documented (in man bash) and allowed by a weird exception in the specification, but if you were naively expecting time to behave like every single other command, you'll be quite surprised (if you notice at all). If you don't notice then you'll misled into thinking that the wrong element of your pipeline needs optimizing.

Allowing time at the start of (some or all) compound commands would have been less surprising and more useful, and still allowed timing whole pipelines (when bracketed).

Tags:

(Leave a comment)

June 18th, 2009
02:22 pm

[Link]

More Python character encoding braindamage
rjk@rackheath:~$ python -c 'print "møøse"'
møøse
rjk@rackheath:~$ python -c 'print u"møøse"'
møøse
rjk@rackheath:~$ locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=
rjk@rackheath:~$ python -V
Python 2.5.2

(...but it's the same in 2.6.x.)

I think it's interpreting each byte in the (actually UTF-81) input string as a Unicode code point in its own right, though another (philosophically different but pragmatically essentially identical) possibility is that it thinks all input strings are encoded using ISO-8859-1.

1 and don't give me the nonsense someone came up with last time about Python having no way to know how the input is encoded. It does have a way, that's what LC_CTYPE is for.

Tags: , ,

(5 comments | Leave a comment)

June 9th, 2009
07:15 pm

[Link]

Stupid Apple
chymax$ ls -lL /usr/X11/lib/libXdamage.*
-rwxr-xr-x 1 root wheel 88496 2009-03-13 00:38 /usr/X11/lib/libXdamage.1.1.0.dylib
-rwxr-xr-x 1 root wheel 88496 2009-03-13 00:38 /usr/X11/lib/libXdamage.1.dylib
-rwxr-xr-x 1 root wheel 88496 2009-03-13 00:38 /usr/X11/lib/libXdamage.dylib
-rwxr-xr-x 1 root wheel   936 2007-09-24 05:39 /usr/X11/lib/libXdamage.la
chymax$ grep ^library_names /usr/X11/lib/libXdamage.la
library_names='libXdamage.1.dylib libXdamage.dylib libXdamage.1.0.0.dylib'

Tags: , ,

(Leave a comment)

May 23rd, 2009
09:06 pm

[Link]

Safari 4

I downloaded the Safari 4 beta.

The obvious visual change is that tabs now replace the title bar. AFAIK this feature first appeared in Google Chrome. It seems a sensible use of vertical space.

I have a complaint about Apple's implementation of the idea though: when you have more than a few tabs (depending on the width of the window), the first thing to disappear is the close button towards the left. Fair enough, but when you hover over the tab (for instance to select it) the close button reappears. Since until you're there there's no visual indication you need to avoid that part of the title, the result is lots of accidentally closed tabs. Worse, there appears to be no undo close tab option.

In fact the closed tab will be the first thing you see in the history page, so it's not that hard to retrieve it. But you lose any state that you had in that page (unlike Firefox's undo close tab option, which does preserve at least some of the state).

The top sites page makes is effectively an adaptive bookmarks page, showing thumbs of the dozen sites Safari thinks you visit most often. It's initially populated with the NYT, Amazon, Apple, Wikipedia, CNET and various others. Wikipedia presumably got there for free but I did wonder if the others had to pay and if so how much. As you can see from the linked screenshot it's already accumulated a few of the pages I've visited recently.

The history page uses Coverflow (something that's turning up increasingly often in Apple software). Seems quite convenient and allowing visual recognition of pages is nice.

As in earlier Safaris, text entry boxes (such as Livejournal's update form) are resizable, a nice touch that I wish Firefox would pick up.

The advertised "full page zoom" buttons don't exist, though there are menu and keyboard versions. Zooming in randomly jumps around the page, making it very inconvenient to actually use the feature.

Hovering over a link still doesn't reveal what the destination is, unlike Firefox. It seems like a little thing but actually once you're used to it, not knowing for sure where you're going next makes browsing feel surprisingly uncomfortable.

It actually uses more memory than Firefox (RSIZE is the amount of real RAM used, VSIZE counts swap as well and is generally less interesting). It does seem to use less CPU when idle (where "idle" for a web browser means "running various bits of Javascript"), which would lend a bit of plausibility to Apple's performance claims if it weren't for the fact that visiting a page on Apple's own website took around 30s to load (and then proceeded to lag way behind user input, and SPOD some of the time, when scrolling) where Firefox managed to produce it just like that.

(I think it must be something about that page, since other pages don't produce the same problem. But you'd think they'd test it against its own website!)

Tags: ,

(8 comments | Leave a comment)

03:56 pm

[Link]

Emacs for Macs

Mac support for Emacs (or possibly the other way round) has been a bit of an issue for a while.

The shipped /usr/bin/emacs only runs in a terminal, lacking any kind of GUI support, which is OK for quick edits but rather inferior for extended work.

Compile your own Emacs with X11 support (or use someone else's, e.g. Fink) and that works, but then you're at the mercy of Apple's deranged X11, which gets on badly with Spaces and has very poor cut and paste integration with native applications.

For a while there's been Aquamacs, which bills itself as a Mac-friendly version of Emacs, but I never really got on all that well with it.

A particular problem is that if you type anything while a selection exists, the selection is replaced with what you type. This is Macish enough but if you created the selection using the keyboard rather than the mouse then you can't make the selection go away with the keyboard - you have to use the mouse. The result ends up being a lot of undoing, even after months of use.

It also doesn't tell you what size your window is when resizing and creates new windows (frames, in Emacs's own terminology) with a size matching the last one. So getting a window of a particular size can be rather fiddly.)

Recently [info]fanf mentioned the NextSTEP port of Emacs (or OpenSTEP, if you prefer) which has now been merged into the trunk of Emacs. NextSTEP's direct descendant is of course OS X, so this is a Mac-native Emacs.

The source can be retrieved via CVS. It built an Emacs.app without any trouble. It act much more like my muscle-memory expects Emacs should (no more destructive and un-dismissable selections), but also has concessions to the local OS - for instance it supports native cut and paste using ⌘C, ⌘X, ⌘V etc. Window size behavior is more sane and usable too.

Complaints so far:

  • Trying to save a buffer that doesn't already have a filename offers by default to save it somewhere in the guts of Emacs.app, which isn't very useful.
  • Mac-native means of entering “special” characters don't seem to be available. C-X 8 RET works fine, with tab completion over Unicode character names, but making ⌥⌘T behave as normal would be nice.

These are pretty minor; overall it's a clear improvement over what came before. Perhaps Apple can be persuaded to included it in future releases (with a link from /usr/bin/emacs into the depths of the application bundle)?

Tags: , ,

(9 comments | Leave a comment)

01:37 pm

[Link]

Stupid Microsoft
Further to the instructions here, I'd add that you will need to randomly re-install the new layout from time to time, as Windows randomly breaks or removes it without even telling you.

Tags: , , ,

(Leave a comment)

May 7th, 2009
04:48 pm

[Link]

/usr/sbin/sendmail
Poll #1396328
Open to: All, detailed results viewable to: All, participants: 48

Which MTA?

View Answers

Exim
32 (66.7%)

Postfix
13 (27.1%)

qmail
1 (2.1%)

Sendmail
7 (14.6%)

Smail
0 (0.0%)

PP
0 (0.0%)

MMDF
0 (0.0%)

Exchange
1 (2.1%)

Something else
3 (6.2%)

I have renounced email in favour of Twitter
2 (4.2%)

I have renounced email in favour of pen and paper
1 (2.1%)

Huh?
1 (2.1%)

Tags: ,

(27 comments | Leave a comment)

May 1st, 2009
09:30 pm

[Link]

en_LOLCAT
21:03 <ewx> .oO{en_LOLCAT}
21:06 <crazyscot> ENOENT -> INVISIBLE FILE
21:07 <crazyscot> ENOSPC -> DO NOT WANT
21:07 <ewx> ENOMEM -> they be stealing mah bucket
21:09 <crazyscot> EINTR -> Im in ur systemz interruptin ur callz?
21:11 <ewx> EFAULT -> O RLY?
21:16 <col> ECHILD -> I MADE YOU A PROCESS, BUT I ATED IT
21:19 <col> EIO -> O HAI, I BROKED YOUR DISK
21:21 <crazyscot> EEXIST -> ALREADY HAZ CHEEZBURGER

…any more?

Tags: , ,

(10 comments | Leave a comment)

09:23 pm

[Link]

lj2news

lj2news users may be interested to know it appears to work fine with Dreamwidth. (Or possibly vice versa.)

rjk-nntp-tools (0.10) unstable; urgency=low

  * Separate Keywords: with commas rather than spaces.
  * Documentation updates.

 -- Richard Kettlewell <rjk@greenend.org.uk>  Fri, 01 May 2009 20:30:02 +0100

Tags: , ,

(Leave a comment)

April 27th, 2009
02:49 pm

[Link]

Stupid GCC
$ cat t.c
#include <stdio.h>
int main(void) { return printf(""); }
$ gcc -Wall -c t.c
t.c: In function ‘main’:
t.c:2: warning: zero-length printf format string
$ gcc -Wall -Wno-format-zero-length -c t.c
$ gcc --version
gcc (Debian 4.3.2-1.1) 4.3.2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Can anyone offer a plausible reason why:

  • -Wformat-zero-length is on by default (i.e. implied by -Wformat and thus by -Wall)?
  • Why it exists at all?

FTAOD, empty format strings are perfectly legitimate (and the GCC Manual knows this).

Tags: ,

(27 comments | Leave a comment)

[<< Previous 20 entries]

I deny everything Powered by LiveJournal.com