This is a small collection of things that I think are worth recording or remembering, useful most probably only to myself.

windows setup / 2006-12-02

Things I like to do on Windows XP:
  1. Install Firefox. (I wish there was a truly easy way to migrate Firefox preferences. I'm not sure copying around prefs.js is really reliable. Oh well. Configure this one by hand.)
  2. Download Putty and place it in a new directory \Program Files\Utilities. Change the default font to Lucida Console, 9pt, and select "System menu appears on ALT alone" and "Use font in both ANSI and OEM modes."
  3. Create and save Putty sessions for the usual hosts.
  4. Install Cygwin, and in particular, zsh and rxvt (although Dear God how I wish terminal handling in rxvt worked correctly with Windows programs).
  5. Create a "Bin" directory in \Documents and Settings\<username>. In Bin, create shortcuts to Putty for each saved session, giving them nice short names and setting the target to \path\to\putty.exe -load <session name>.
  6. In Bin, create a shortcut called "xt" to Cygwin's run.exe with the target: \path\to\run.exe rxvt.exe +ls -e zsh -l.
  7. Change cygwin.bat to start zsh -l rather than bash.
  8. Install AppRocket. It is worth buying. Be sure the Bin directory is in AppRocket's search path.
  9. Set up Cygwin environment. In particular, remember the following:
    • .Xdefaults
    • .emacs/.emacs.d
    • .exrc
    • .inputrc
    • .vimrc/.vim
    • .zlogin
    • .zshenv
    • .zshrc
  10. Install other useful programs:
    • Foxit Reader
    • gsview
    • VNC client
  11. Install programming tools. The basics:
    • Java JDK
    • Eclipse
    • PLT Scheme
    • GHC
    • Scala

(I tried nutty as a drop-in replacement for putty. It's convenient, but a little buggy. So, back to putty.)

(Someone told me that I should install something called the "sysinternals suite", and that this would help me kill runaway processes, fix defunct file locks, etc. I haven't tried it.)


vnc on ubuntu / 2007-03-04

I recently had some fun setting up a VNC server on a new Ubuntu box. Here's my setup for posterity. The only tricky bits are:

In any case, here's the rundown:

  1. Enable extra repositories (see "How to add extra repositories" here).
  2. Install vnc4server and xinetd:
    sudo apt-get install vnc4server/edgy xinetd
  3. Be sure XDMCP is enabled. In Ubuntu, you can evidently do this through a GUI as well as by editing gdm.conf (or gdm.conf-custom, I suppose).
  4. Add the VNC server to xinetd. Here is where there are lots of options. Having carefully considered said options, it seemed that the simplest and most consistent answer, involving the least number of extraneous passwords and so on, is:
    • Allow the console user (on X display :0) to use the built-in Ubuntu support for VNC (using vino, I gather) to share his/her desktop as desired, setting his/her own password or whatever.
    • Configure xinetd to start Xvnc servers for other desired displays (in my case one is enough, so I just use :1), never allow sharing, and kill everything when the client disconnects. We require no VNC password.
    This scheme has one major disadvantage, namely that the only way to get a server session that persists across client connections is to log in on the console and share your desktop. But this is IMHO a small price to pay for the simpler security setup: since each VNC connection just starts with a gdm login, no extra passwords are really needed. In any case, this setup works great for me. To implement it, the xinetd config should be something like:
    service Xvnc
    {
        type = UNLISTED
        disable = no
        socket_type = stream
        protocol = tcp
        wait = no
        user = root
        server = /usr/bin/Xvnc
        server_args = -inetd :1 -query localhost -desktop peanut -geometry 1024x768 -depth 16 -once -fp /usr/share/fonts/X11/misc -DisconnectClients=0 -NeverShared securitytypes=none
        port = 5901
    }

Obviously this is nothing like a high-security setup, but we're behind a firewall and convenience is the priority here. Works for me, YMMV, etc.

Update for 9.04 (Jaunty): Most of the above no longer applies (the old edgy package, the font path nonsense). But there's a new bit of nonsense. In jaunty, you need to add "-extension XFIXES" to the end of the server_args line in the xinetd config. Otherwise gdm seems to immediately exit. If a vnc connection gives you a black screen and then immediately disconnects, try XFIXES.


transparent favicon.ico from png / 2007-03-09

The pointless goal: create a Windows icon with proper transparency from a PNG using only the old busted version of netpbm on my machine... Here's the best I have so far:

pngtopnm -mix icon.png > icon.pnm  # the regular pixels
pngtopnm -alpha icon.png > icon.pgm # the gray map

# ok here's the part that sucks...
pnmtoplainpnm icon.pgm > iconplain.pgm # convert to plain
vi iconplain.pgm
# max out all the non-zero values by hand, omg wtf!

# back to the pleasant part...
ppmtowinicon -andpgms icon.pnm icon.pgm > icon.ico # success!
If I could just figure out a way to get a two-color opaque map from the stupid alpha-channel pgm I'd be in perfect shape. I'm sure it's really easy, but I'm totally clueless when it comes to netpbm. And I have no intention of thinking about it again until the next time I need to make an icon.


firefox extensions / 2009-03-25


backspace in cygwin+rxvt+emacs / 2008-04-29

Here's a small but very useful thing.... I've never gotten both backspace and C-h really working properly in Emacs running in a Cygwin rxvt. I don't use help that much, so I haven't cared. But sometimes it bothers me. I know what the problem is (backspace sending ^H), but I couldn't figure out how to fix it. I tried various combinations of stty settings, X resources and so on, with no luck. Here is the magic line in .Xdefaults:
rxvt*backspacekey: ^?
Now everything works beautifully. Knowing it "had to be something like that" wasn't good enough, apparently.

stopping a sigwait user in gdb / 2013-07-31

Sometimes I'm debugging a program and I find that ctrl-c in gdb fails to break the program, instead sending SIGINT to the program as usual (and thus, often, causing it to exit). How infuriating! It turns out that if a program uses sigwaitinfo()/sigtimedwait()/etc. to receive signals, gdb cannot intercept them. Kernel bug 9039 contains some discussion of this issue: it turns out that checking for signals via these functions doesn't count as "delivery" from the kernel's point of view (this is pointlessly confusing and insane), so the debugger never sees the signal. Fine, whatever, what should you do? The solution is to use a signal that isn't in your mask, but that is set up properly in gdb. The quickest thing is to do:
kill -TRAP $(pgrep whatever)
in another shell, because gdb by default handles SIGTRAP the way you want. More convenient is to use:
handle SIGQUIT nopass
in your .gdbinit and then use ctrl-\ in gdb to stop the program. I rarely use SIGQUIT otherwise, so this does't break much else. Obviously whether this works for you depends on the details of your program's signal handling. It may be possible to use stty tricks to use a different signal if you need to, but coordinating your stty and gdb settings seems like a pain.

matt at immute dot net