Home

Advertisement

One hdsentinel data point

  • Dec. 20th, 2008 at 6:51 PM
oscar
HDsentinel output:

HDD Device  0: /dev/sda
HDD Model ID : HTS541080G9AT00
HDD Serial No: MPB4AAX6GRTSVF
HDD Revision : MB4IA60A
HDD Size     : 76319 MB
Interface    : IDE/ATA
Temperature  : 31 °C
Health       : 69 %
Performance  : 100 %
Power on time: 299 days, 3 hours
Est. lifetime: 726 days


This is a disk in a laptop which consistently corrupts data written to it (e.g. I copied a 4 GB file and only the first 1 GB was readable, it has eaten dozens of mp3 files, etc.) and routinely fails SMART self-tests, which, god willing, I will replace tonight. I've tried scrubbing away the bad sectors by reading/writing to prompt the disk to relocate them, but it hasn't been enough. I don't think the SMART reporting of this Hitachi disk is very good, though.

Linux 60 Hz refresh loop

  • Dec. 16th, 2008 at 10:41 PM
oscar
Every so often, I dust off the code for an NES emulator I wrote years ago and tinker with it. It isn't a particularly good emulator, but it can play Super Mario Brothers, and it's fun to hack on. I wrote it using SDL, and one issue I always had was the overall timing. The SDL documentation rightly warns that timers can't be relied upon for accurancy less than 10 milliseconds. An NTSC NES runs at 60 Hz, so we need to update the video every 16.67 ms. For whatever reason (portability foolishness, probably), I used the SDL timers anyway, with the result that it got rounded up and the machine effectively ran at 50 Hz. You can downsample from 100 Hz instead, but it's jittery, and jitter looks horrible with 2D scrolling. Tonight I'd intended to hack on the audio, and I just couldn't suffer listening to the music play that much slower, so I set out to fix it.

I really didn't want to spin and use 100% CPU, so my first attempt was to record the time before and after the frame processing using gettimeofday, then sleep for that interval using usleep. This didn't work any better than the SDL timers work, generally missing the scheduled wakeup time by six milliseconds or so every frame. The usleep manpage says "The sleep may be lengthened slightly by...", which seems like an understatement. nanosleep did no better. I mostly expected this.

Relenting, I changed it to spin in a loop, checking the time with gettimeofday until the scheduled 1/60th of a second elapsed. Predictably, this worked perfectly, but used 100% CPU. Here I had an idea - if I have to wait for, say, 15 ms, I ought to be able to sleep for a little bit (10 ms, perhaps) then wake up and just spin the last 5 ms or so until it's time to run the next frame. That way I can stay off the CPU for 2/3 of the time, and still meet my timing obligations. So, I added a conditional 10000 us usleep when the time between now and the next frame was greater than 10000 us. This left me missing my wakeup time again, generally by around 3 ms - I guess the sleep time gets rounded up sometimes. Experimenting with shorter sleep periods, I've found sleeping for 5000 us or 6000 us actually works really well. The CPU usage stays at 30-35%, and the timing is just as tight as if we'd spun 100% of the time. I don't understand precisely why this works as it does, but I'm happy with the result. Here's the code from my emulator which sleeps until it's time to run the next frame:

void sys_framesync (void)
{
    struct timeval tv;
    long long start = time_frame_start.tv_sec * 1000000 + time_frame_start.tv_usec;
    long long target = start  + (1000000 / 60);
    long long now;

    do {
        if (gettimeofday(&tv, 0)) return;
        now = tv.tv_sec * 1000000 + tv.tv_usec;
        if (target-now > 10000) usleep(5000);
    } while (now < target);
    
    // if (now-target) printf("framesync: off by %lli\n", now - target);
}

Tags:

Game maps

  • Dec. 6th, 2008 at 9:40 PM
oscar
A moment ago I idly wondered if there was a screenshot of the complete Ultima 6 map on the web at full resolution, and how big it would be. It turns out the answers are yes, and 16384x16384 pixels. This guy Ian Albert has a bunch of great maps of games to interest to me at his site. Most notably, Ultima 6 and 7, Zelda, DOOM 1 & 2. Panning across the vast landscape of those Ultima games is incredible - how long did Origin's designers spend building those worlds? People who haven't played or otherwise don't appreciate the achievement of Ultima 7 (a game which IIRC listed as its minimum requirements a 386 with 2 MB) ought to just pan around the map for a bit and take it in.  I still count Ultima 7 and the most impressively vast and detailed game world for an RPG (Oblivion attempts to rival it, but falls short in a lot of respects, and I suppose Fallout 3 does a little better, apart from only having one real town).

Cleverly, the DOOM maps are presented in an isometric view, which works reasonably well with the sprites, and suggests to me the great idea of hacking a DOOM engine to turn it into a 2D, isometric shooter played with a joypad or analog stick. Apparently someone did this with DOOM 3, but I'd think it'd work much better for the original games, as they're essentially 2D to start with.

Tags:

Follow the arrow!

  • Nov. 29th, 2008 at 11:19 PM
oscar
I've passed some extraordinary amount of time recently playing and replaying Fallout 3. Just prior to this I replayed the original Fallout and its sequel. I enjoyed playing Oblivion several years ago, but hoped Bethesda would not repeat some of that game's mistakes in FO3. Fallout 3 is an excellent game, much better than I expected, but is subject to some generic criticisms - first, the game is too easy. Second, the main quest of the game only takes you to a small fraction of the locations, leaving vast swathes of the game unexplored (and some of the most interesting locations are completely optional and pretty far out of the way).

There's something in particular which bothered me in Oblivion and continues to irk me in Fallout 3 - the automap and navigation markers. My complaint is that too many quests consist of being lead around by the compass marker from place to place until the quest is finished. Many of the quests in Oblivion were simply ruined by this. Fallout 3 is not so bad in this respect, but the arrow is still there to lead you around, and there are at least a few quests that are outright spoiled on account of it - one notable example on the main quest sends you to a certain vault, which is described to you only as being near some other place I also never heard of - but instead of having to do a little detective work and exploration to find it, the map arrow immediately points to it, without even the usual undiscovered marker on the location.  Perhaps I show my age by appealing to the time when a game such as this required at least several pages of pencil and paper notes, but I think Fallout would be improved by applying the following principle:

If you've never visited a location, you should be forced to search for it. This includes finding random sites in the wastes and weaving your way through the metro tunnels which connect the patchwork of the DC Wasteland. This would help lengthen the game and increase the difficulty, and give you a little something extra to think about on the way to a new location (namely, figuring out where it is). In the process, you'd discover extra sites and perhaps get sidetracked on side quests. Far from leaving you to wander aimlessly searching, this opens new opportunities to enrich the game world:
  1. Passing NPCs could offer directions toward your destination. They would be relative to landmarks, and not necessarily perfect directions. Occasionally, someone might deliberately mislead you (to stop you from discovering something, or lead you into a trap).
  2. Party members might also offer directions if they are familiar with the area, as above. There isn't enough meaningful interaction with party members - this would be an easy way to make them more engaging. This could come at a low implementation cost - at a minimum, just a half dozen generic lines per character ("I think it's a little north of here", etc.). For fun, a couple extra lines of dialog as glue could give the impression of NPCs disagreeing (although it seems rare to have more than one human NPC, so this might not be worth the effort).
  3. Road signs and billboards could provide navigation clues.
  4. If you really don't want to spend a little time searching the wastes, researching beforehand, or thinking about where you're going, a guide NPC could be available for hire.
If this isn't convincing as sufficient to take the bite out of any potential tedium, remember - in a sandbox game, wandering around and exploring is supposed to be fun. Indeed it is - I've engaged in quite a few aimless jaunts across the wastes to see what I could find.

While I'm indulging in armchair game design, I should probably come out against fast travel. I think it's incredibly cheap that you can instantly warp back to town to sell off your loot, with no risk of an enemy encounter, although on the other hand Fallout 3 would be very tedious without it. I can think of two solutions to this, only one of which I fully endorse.
  1. Add a vehicle. A motorcycle or dune buggy would work great in the wasteland, and provide a lot of fun (particularly if you could purchase weapons for it), but it'd be totally useless when you had to travel within DC (and having to repeatedly hike through the metro tunnels would be a real drag). Also, I fear this might make the game world feel too small.
  2. (My favorite) Add random encounters and a smooth fast travel mode that zooms out far out, pans across the landscape along the path of travel at a greatly accelerated rate (the passage of time being visible by the changing light, as always), or suddenly zooming back in to the party if there's an encounter. This might work for DC too, except it'd be panning over the city and so the scene would have to suddenly jump if you encountered someone while traveling in a tunnel.
These points and wishlist items aside, Fallout 3 is very cool, upping the ante for this style of game. I like it. For another perspective, this interview at No Mutants Allowed rightly lays into the game for a number of flaws and its general bastardization of the Fallout universe. Recommended reading! :)

Tags:

Halloween Pumpkin

  • Oct. 31st, 2008 at 7:04 PM
oscar
I carved a pumpkin this year for Halloween. I'd seen pictures of fancy pumpkins carved to different depths to acheive shading, so this year I tried the technique for myself, starting from a caricature of our fearless leader. It came out pretty well, I think!

Pumpkin in the dark

Pumpkin awaiting deployment

Tags:

Python, Interfaces, and CLOS

  • Oct. 29th, 2008 at 12:31 PM
oscar
I'm going to comment on a point or two about Python and program design from the perspective of someone who primarily hacks in Common Lisp and C, with the disclaimer that I'm very new to the language and admit to knowing little of the common practices and folk wisdom.

I've done some trivial hacking in Python lately. I started with what a trendy hacker might refer to as an embedded DSL - basically a half dozen classes out of which I can build a sort of document tree. This went smoothly, and having constructors named after classes (i.e. "foo" versus "make-foo" or "make-instance 'foo") along with judicious use of optional and keyword arguments lets the resulting tree expressions read very nicely. Moving on, I began to interface these classes with a GUI and some persistence code. This is where my experience soured..

The document classes have varying interactions with the UI according to their type, and I did not want to pollute their definitions by rolling UI logic into them. In CL or Factor, I'd have generic functions (e.g. add-to-table-of-contents, selectable-p, display-in-frame) which would recurse through the tree, with methods for each document class. In Python, I suppose my solution will be to walk the tree from a function with seperate tests and branches for each type, but the prevailing wisdom among Python people advises against testing the type of an object to decide a conditional, discouraging my approach, with an argument along the lines that they might want to substitute some other class and make it behave the same. I suppose it is this constraint that distinguishes "duck typing" within the broader realm of dynamic typing.

It seems then that adhering strictly to that guideline makes it impossible to implement interfaces independently of a class and thus to cleanly separate concerns. This seems terribly ad-hoc and a dead end with respect to extensibility and good design. Hacks like the Visitor pattern don't avoid this underlying problem of class identity, and this is no doubt a case where breaking the rule is in order. I happened upon an interesting article on the subject of interfaces in Python here by Ned Batchelder, but he fails to find a good approach and leaves it as an open problem. On the other hand, CLOS-style generic functions (and the CLOS approach to interfaces via the informal notion of a protocol) provide an effortless solution and would really shine here, quite independently of CLOS's more hyped features (multiple dispatch, metaclasses, multiple inheritance, etc.).

Apologies for the triviality of this example. I probably come across as rather sheltered in having not considered this before (presumably the same issue occurs in Java, modulo analogies to the animal kingdom), but again, despite being relatively young, all my serious experience is in C, C++, or Lisp, rather than Java, Python, or the like (and perhaps we have similar issues in C++, but I'm strictly results oriented in C++ and not inclined to spin my wheels on trying to write beautiful code in an ugly language).

Grumbling about the Macbook Pro

  • Oct. 17th, 2008 at 1:51 PM
oscar
Terribly curious about the new laptops, I stopped by the Apple Store this morning to check them out. My everyday computing environment consists of a desktop machine and a Thinkpad, both running Debian. Acquaintances on IRC and elsewhere have endured my incessant griping about the faults, both real and imagined, of OS X. Why, then, would I consider abandoning Linux for OS X? Well, I wouldn't. I'd like to replace my aging and seldom booted Windows box, which occasionally runs Cubase and various software, cabled to my spiffy MOTU firewire audio interface. Either I replace it with a new laptop running Vista (a prospect which could sully even the nicest hardware), or a buy a Macbook Pro with Logic.

So, the Macbook Pro. When I went to check them out today, what really blew me away is how large they are. Same depth, a few hairs thinner, but a full two inches wider than my Thinkpad (with its 1400x1050 14" display). That sounds a little bigger than I'd prefer to carry that around. Hell, it'd barely fit in my current bag. And lets face it, isn't the ability to whip it out in public and flaunt your unrivaled taste and disposable income half the appeal of buying a Mac in the first place? That extra width is just wasted space on either side of the keyboard, too, and I never thought that looked good (although at least it doesn't look like the speaker grille of a cheap plastic radio anymore, like the previous design). The really bizarre thing is that the previous generation Macbook lost points with me for looking like a plastic toy, decidedly inferior to its "Pro" cousin. The new MacBook actually looks better to my eye than the MBP, on account of its keyboard being better proportioned to the width of the body (and no funky stripes!).

I do think the aluminum unibody is a fabulous concept.

Initially skeptical of the new "buttonless" trackpad, it won me over fairly quickly. I'm not sure the two fingered scrolling gesture is a win over the traditional scrolling stripe on the right edge of the pad, but it felt refreshingly novel. I was skeptical about living without a primary button, but I think now that I could manage it. I reached for a button a couple times while playing with the machine, providing some insight into my trackpad habits - it turns out I tap the pad for most buttons and links, and I use the button for more precision pointing, such as clicking the close button on a window, where I'm afraid that I'd move the cursor in the process of the tap gesture, and also in situations like dragging and resizing where I have to hold the button for a longer period. Still, I think I could adapt.

What really sold me on the new trackpad is that in a sense, they've traded the left button for a right button! Has an Apple laptop ever had a right button before? On these machines, there is literally a button underneath one corner of the pad. Just like a mouse button, it makes a satisfying click. This came as a surprise to me.

Then there's the display. At 1440x900, those extra two inches in width buy me 40 more pixels? And incredibly it's the same depth as my Thinkpad, but somehow the display has 150 pixels less vertical resolution. That's.. fucking retarded. I need vertical resolution, not horizontal resolution. I've seen shitty Dells with 1600x1200 displays, for god's sake! For the cost of the MBP, I expect better. Widescreen displays are just brain-damaged. I don't buy computers (laptops especially!) to watch video, and we've already witnessed the pointless video idiocy ravage the design sensibilities of the iPod line. The only way a wide screen makes any sense is if I can stand the damn machine up on its side and have the display rotate (wouldn't that be quite a sight?).

Oh well, at least I can admire my reflection in the glossy screen.

If I had a point in writing this, which I'm not sure I do, it's just that I'm a little underwhelmed, and an ostensibly "Pro" line of computers ought to offer a matte display with higher resolution and a 4:3 aspect ratio, which countless nerds across the intarweb have no doubt already stated thousands of times. But I'm special, dammit, so I'll repeat it here, because I know Steve Jobs himself will read this and personally set about rearranging his product line to meet my requirements. Thanks, Steve.

Dwarf Fortress

  • Oct. 15th, 2008 at 11:05 AM
oscar
Earlier this year I spent several weeks heavily into Dwarf Fortress. DF is exceptional as a simulation and a software toy, but I've come to the conclusion that it isn't that great as a game.

My first attempt at a fortress crashed and burned when I accidentally flooded the level containing my farms and food stores. A year of attempts by starving dwarves to tunnel in and channel the water away, culminating in a final desperate attempt to drain just the storage room long enough to salvage its contents (assuming it wasn't already ruined), failed miserably, and eventually the entire population had starved it killed themselves. That was a lesson.

My second fortress went much better - in fact, it seems like it could go on indefinitely. Herein lies the problem. I built it in a river valley and found I could farm underground with no irrigation. Having gotten my farming going, I turned to defense. The valley narrowed to the north, so I took advantage of the winter season to excavate and dam the river, then build a wall straight across, sealing the valley to the north. This was just in time, as a goblin siege arrived from the north only a few months later, and milled idly about outside the walls for several months before giving up and going home. Recognizing the thread, and having no military to speak of, I made it a priority to damn the river to the south and build walls and trenches to seal the southern entrance to the valley. This expanded into a system of locks connected by drawbridges providing two parallel paths in several segments into the fortress, with a trade depot in the middle. Nobles and unwanted peasants are locked outside and left to starve, while dwarves with useful skills are carefully admitted by drafting them into the military and moving them away from the pack, across a lowered bridge, then raising the bridge and opening a path into the fortress. Possessed and exceptionally unhappy dwarves whose demands I cannot satisfy are locked in their bedroom/workshop to die.

In this way I've weathered countless goblin sieges. Megabeasts such as the Bronze Colossus are dealt with by luring them over a bridge and and locking them in (there are multiple paths in and out, so I can route around them). In the event of a siege I let them loose to play with the goblins (in theory, anyway). Cognisant of flying threats, I've carved several fortifications into rock faces around the map which can be reached from underground tunnels, where dwarves can fire in relative safety upon wild animals and other intruders to hone their crossbow skills. Goblins aren't smart enough to scale the walls.

It got pretty boring. There's no foreseable military threat to my fortress, the dwarves are self sufficient and relatively happy, and the biggest difficulties I've faced are a shortage of bins (leading to acres covered in useless carved trinkets), drink shortages whenever a harvest uses up all the barrels and stalls the breweries (forcing me to discard food and idle some of the fields), and inventing work to keep the dwarves busy. I've had some fun expanding my walls ever further toward the map edge, clear-cutting the valley, and attempting to perfect a trap I can lure a part of goblins into where I close the bridge by which they entered, forcing them to exit along a long corridor of weapon traps (adamantine short swords!), but really it's gotten pretty tedious and it seems like I sustain it forever. The only thing I can really imagine going wrong is some fool letting the trapped Bronze Colossus out of his cage in the middle of the fortress, but I don't really know what to do about that. :)

I've tried a few more games, and they all progress similarly - either I slowly wither and die due to a bad site with no farming, or I wall in and become self sufficient (as an exception, I put some time into a volcano fortress which can't farm and trades metal crafts for food, but it has a similar system in place). It seems like earlier versions of the game, where there was a standard map layout and a sequence of events leading to an endgame, would've been more fun. It gets old quick once you realize that nothing can attack you and you're going to spend the rest of the game micromanaging.

I has a twitter

  • Oct. 10th, 2008 at 9:18 PM
oscar
I made a twitter at twitter.com/robotickilldozr/. I wonder if the net effect of this sort of thing is just to divert the random stream of crap I'd normally inflict on random people via IM into a new channel.

I must be getting too old to keep up with the pace of the web. Not more than seven months ago I recall sitting around thinking "I'd like some kind of 'micro-blog' thing to paste random stuff at", with no clue that twitter or the like even existed (or more accurately, no idea what they were).

Tags:

Shameful Interface I

  • Sep. 25th, 2008 at 9:29 PM
oscar
Power and reset button next to USB ports and audio jacks????

Yes, I've accidentally hit them. More than once.

Firefox 3

  • Sep. 7th, 2008 at 6:47 PM
oscar
It's really not very good, is it?

XMMS, music players, and a lisp hack

  • Sep. 4th, 2008 at 5:51 AM
oscar
Funny me forgetting that Debian doesn't package xmms anymore. This is a shame, as I'm not aware of a superior alternative. As recently as a year or two ago, I was using packaged xmms and plugins, and everything was wonderful - there were plugins for all the oddball stuff, modules and half a dozen chiptune formats, and everything worked swimmingly. Lately, I'm stuck using half a dozen different players from the command line, usually through aoss, and some of them (such as adplay) stutter and spit unless the machine is otherwise completely idle (just clicking around in firefox is enough to glitch the audio, four cores or no).

Audacious - No, this one is a step backward. The file dialog (which I suppose is just the Gtk2 file dialog, tarted up with their obnoxious theme) is noticeably slower than the one you get in xmms (the old Gtk 1.2 file selector, which responds practically instantaneously under any reasonable circumstance), and the loss of the "Add selected files" button destroys the workflow - I'm not going to make ten round trips in and out of that dialog just to pick a handful of files in different directories. This program would be much more useful to me if this feature were restored.

xmms2 - Imagine my dismay when installing xmms2 didn't yield any UI except a command-line interface, and expected me to run a separate server process. A client/server music player? Thanks, but no thanks. Enough with the servers. Trying to be a good sport, I apt-got a graphical client, gxmms2, and attempted to play a song. Oops, "xmms2d" isn't running - why can't it start the goddamn thing itself? The UI is a bit clumsy, but I poked around and added an mp3 to the playlist, or so I thought. Upon hitting play, it instead played "/usr/share/xmms2/mind.in.a.box-lament_snippet.ogg" very loudly, a noise so horrible and unexpected that I slammed the "kill window" shortcut as fast as I could and hastened to torch the whole mess. This is probably a great system for people who enjoy configuring sendmail.

iTunes style players - These don't really compete - the style of use is different. I often run Quod Libet and xmms at the same time, but most music is played through xmms, for at least two reasons - first,  iTunes-alikes have large windows that deserve a whole desktop to themselves, whereas xmms is tiny and fits on whichever desktop I'm working without cluttering it, such that I use xmms just because it's closer. Second, having organized my music into a reasonable tree on the disk, I can find whatever I want just as quickly as you might using a fancy overengineered browser based on id3 tags, and without the headaches of bad or missing tags, multiple spellings of artists names (plus the mess of various artist + collaborator combinations), etc. Indeed, even in Quod Libet, I usually use the "Filesystem Browser" mode.

Although think Quod Libet is the most usable of the iTunes-style players, it's been a couple years since I last surveyed them and settled on it, and there are some very irritating things about the UI - that the volume and seek bars are hidden inside of little popup menus, or the height of the "queue" not being resizable (such that if you want to rearrange songs in the queue, you can only move them a few spaces at a time between scrolling, like some kind of goddamn bubble sort).

In fact, the whole reason I reached for xmms is because I'd been using Quod Libet on this machine to sort through some new music, but this particular instance of it frequently misbehaves such that I'd just prefer something simpler.

Search seems like a promising way to find files to play, but I haven't used a player that embraces this concept. I used the search in iTunes on occasion, but it was unnecessarily sluggish. Quod has a search feature too, but it's hidden in another tab with no obvious keyboard short cut, and is outrageously slow (many seconds to conduct a search). I never understood why this sort of thing should be anything less than instantaneous, even over many tens of thousands of files, so one day a couple years ago I quickly hacked together something in Lisp that used a Boyer-Moore search across the filenames and showed the matches interactively as you typed with a simple mcclim gui, and it didn't take more than a few hours of effort to get this fast enough to feel instantaneous, even running synchronously inside the text field's "value changed" event handler. So all the really fun stuff I imagined implementing, like doing the searching in a background thread, and pipelining the search to refine the results of previous searches as you continued to type (rather than searching the whole data set on every keystroke, as it currently does), turned out to be completely unnecessary! So you'd type, and as you did the matches would appear in a list below the search line, and you could click one to play it in xmms. Very simple. I used this on and off for a few weeks, and had some ambitions of turning it into a genuinely useful music player, but never got around to it due to short attention span and various mcclim issues which I am unable or unwilling to fix, such as the focus insanity and difficulty in establishling workable keyboard controls. I think I'll just wait until I have a better substrate for the UI. A fuller implementation would have to do several times as much work due to searching metadata in addition to filenames, but several times a small number might still be a fairly small number, so no problem.  Anyway, with Lisp's reputation for being slow (or within the Lisp community, mcclim's reputation for being slow ;), maybe the authors of the more ambitious music players can be shamed into improving their search and making it fast.

And now I'm off to compile xmms and see how many of the plugins I can 1) locate and 2) succeed in compiling.

Tags:

Another thing I learned today..

  • Sep. 4th, 2008 at 3:58 AM
oscar
The irritating 1/2 second delay between when xterm appears and bash printing its prompt? That's the time spent executing /etc/bash_completion, for a feature I don't want anyway. Easily fixed!

Tags:

I hate linux, Part 7

  • Sep. 3rd, 2008 at 11:45 AM
oscar
Another little land-mine that linux planted for me to discover is that upon installing this Debian system with Linux 2.6.26, my vfat filesystem (a USB key) has suddenly become case sensitive in ways that no combination of mount options seems to fix. Granted, I'll probably go to hell for depending on it to work in the first place, but for the moment it means that I've spent 45 minutes trying to do a CVS update from the key (which probably wouldn't be an issue in the first place, if it hadn't already changed the case of my filenames in unpredictable ways, which - regardless of whether it's imitating Windows conventions or not - is obnoxiously sleazy). Indeed, playing with the mount options in seemingly innocuous ways, such as setting check=normal, which should be the default anyway, breaks in entertaining ways - such as being able to create files which you can't delete on account of the schizophrenic case normalization.

I hates it!

Incidentally, this sort of ranting and raving is precisely the reason I was reluctant to create a blog for a number of years. Well, screw it. I need to vent.

Tags:

Making the world safe for Sawfish

  • Sep. 1st, 2008 at 9:55 PM
oscar
After losing an argument with Gnome's network-manager last week, I found myself faced with the prospect of attempting to repair my deteriorating Ubuntu 8 install, or reinstalling Linux. I'd grumbled for months about reverting to Ubuntu 7 (mostly on account of Firefox 3, which gets into fits where it refuses to run until I restart X), so either I'd reinstall that, or follow through on my threat (to no one in particular) to switch it to Debian (which I strongly prefer, but anticipated some extra effort getting everything working - the machine is a laptop, so the bar for everything having to work Just So is already considerably higher). I elected to go with Debian this time around, and additionally tackle the chore of stripping it of the Gnome nonsense.

First, a few words about desktops environments. I've never met one I liked. They clutter the screen, and their branded applications are usually lame and redundant. The few genuinely useful bits garner resentment for threatening to lock me into using their pet window manager, panel, file manager, etc. I don't think it's a simple matter of not yet having found the right desktop environment to suit me, either. Instead I suspect they are not unlike political parties, diverting energy into self-aggrandizement with priority over their essential duties.

Specifically, with respect to Gnome, I don't like Metacity, and I really don't like the panels. I've tried to configure Metacity to my liking, and even gotten close enough to live with, but it's always felt off - clumsy, claustrophobic, maybe even a little slow. Granted, the claustrophobia might just be the gaping maw of the two Gnome panels, threatening to crush my windows which linger perilously between them.

The default two-panel setup loses on a number of fronts:
  • Horizontal window-selector of the bottom taskbar can't devote enough width to each button to read the labels unless there's so few windows open that you don't need help managing them (implicit in this is that I'm not concerned with hidden/minimized windows, but if you can't read the labels, the taskbar is not the ideal mechanism to help you locate a minimized window anyway).
  • Pagers are a pointless gimmick - you have to change desktops from a hotkey rather than clicking around the pager, or they become too cumbersome to be worthwhile, and a tiny rectangle inside the pager doesn't help in identifying which desktop I want anyway.
  • The top panel bar is mostly empty space, and the only really indispensible bits are a couple of the tray icons.
  • The vertical dimension is (within reason) more valuable than the horizontal, and neither of these panels provide utility in proportion to the space they occupy.
Of course many of these complaints are addressible via the numerous configuration options, but I dismiss that line of argument out of hand - wrestling with configuration options costs time, and that time is at least as productively (and certainly more satisfyingly) spent replacing the offending software. The default configuration is so thoughtlessly awful that there's little question as to whether seeking alternatives is justified. (Another interpretation is that I'm too lazy to learn new keyboard shortcuts and will fabricate any rationalization while clinging desperately to a Sawfish configuration I've used since 2002, but I'll assume for the moment that isn't entirely true.)

That's more rant than I intended, but there's really just the two problems to solve:
  1. Where to put the init scripts, so that I can start everything up automatically - I noticed some time ago that my .xinitrc didn't seem to work as I remember, I guess due to GDM, but it isn't an issue on my desktop because it only reboots every few months, so I've never taken the time to automate things. My laptop power cycles much more frequently, so this isn't acceptable.
  2. How to use network manager without running the Gnome panel.
This turned out to not be terribly difficult. As for #1, using the "Run Xclient script" session does the trick, provided I have a .xsession file. I don't know what the correct relationship between .xinitrc, .xsession, .Xclients is, but in the course of flailing around I ended up symlinking them all together. Whatever. It works.

For #2, I discovered here that we need a system tray, and to run nm-applet. A program called Trayer does the job admirably, although it's a little fussy:

  • It seems like the command line arguments have to be in a certain order if enabling transparency.
  • I don't know what the underlying X11 magic is, but the transparency only works when you set your root window image with certain programs. Esetroot works here.
  • Certain gtk2 themes break transparency (you'll see a gray panel with correct transparency old under the applet icons).
Having gained a system tray, we can run nm-applet and gnome-power-manager, which get us the two essential applets for a laptop (wireless control and battery). Trayer has lots of fun knobs and dials to turn, and I set mine up running vertically along the left edge of the screen, with the ability to place windows over it if I like. I'll probably change my mind and move it to the right side.

I also found a nifty program called yeahconsole which provides a togglable xterm as a quake-style console. I'm trying it out with hopes that it could help combat the proliferation of abandoned xterms strewn across desktops.

In the end there wasn't much to it (the hardest part was getting GDM to run my damned script!), and I seem to have all I need for laptop use. There's quite a bit more in the standard gnome desktop that I don't have running (volume manager, software update applet, file manager), most of which won't be missed.

Here's the final .xsession / .xinitrc / .Xclients / whatever:

#!/bin/sh

Esetroot ~/morning-clouds.jpg
xset b off
xmodmap ~/.xmodmap-conjugate
trayer --edge left --SetDockType true --tint 0x0 --transparent true --alpha 180 &
nm-applet &
gnome-power-manager&
yeahconsole&

exec sawfish

And the obligatory screenshot:

Desktop Fanciness

Tags:

Backroads Timelapse

  • Sep. 1st, 2008 at 10:31 AM
oscar

There's a lot of chatter about the video feature of the forthcoming Nikon D90, but just a few months ago I made a video with the modest D40! =p





It struck me in the car to try this, and I wanted long (1/4 s) exposures for motion blur, but didn't come prepared with an ND filter, so I stuck my polarizer on the front and hoped for the best, and it's generally pretty washed out. I essentially set the camera on the dashboard and held down the shutter trigger for 30 minutes. Every few minutes it would stall and I'd have to press the trigger down again, losing a few frames here and there. I'm amazed I didn't burn the poor thing up. In hindsight I should have used manual mode instead of shutter priority, to stop it from randomly adjusting the aperture whenever it would freeze and I'd have to depress the shutter button (this is responsible for the sudden jumps in brightness).

Two or three minutes after I turned the camera off, we passed a Ferrari, which is the last thing I'd expect to see out there.

Tags:

Interval sequences

  • Aug. 19th, 2008 at 1:05 AM
oscar
Lately I've done some programming in Factor, and one feature I've grown fond of is that integers are considered sequences, usable with map and other combinators. As an excuse to take the extensible sequences protocol for a spin, I implemented this in CL (or really SBCL, since I don't think any other implementations have implemented extensible sequences).

The extensible sequences protocol requires that sequences be subtypes of the SEQUENCE class. I didn't like this at first, wanting to implement sequences directly on integers, but soon decided that wrapping things up in a class wasn't so bad - I can just write (below n) instead of n, and it suggested that I go a little further and implement intervals as sequences. Using the constructors below and interval, I can write the following:

(map 'vector 'list #(a b c d e) (below 3)) => #((A 0) (B 1) (C 2))
(map 'list '1+ (interval 20 25)) => (21 22 23 24 25)

Only a few definitions are needed to make this work:

;;; Interval sequence class

(defclass interval-sequence (sequence standard-object)
  ((minimum :reader minimum :initform 0 :initarg :minimum)
   (length  :reader sequence:length :initarg :length)))

;;; Constructors
  
(defun below (n)
  (unless (>= n 0)
    (error 'type-error
           :datum n
           :expected-type '(integer 0)))
  (make-instance 'interval-sequence :length n))

(defun interval (min max)
  (unless (<= min max)
    (error "Interval minimum must be less than or equal to maximum"))
  (make-instance 'interval-sequence :minimum min :length (- max min)))

;;; Core sequence protocol

(defmethod sequence:elt ((interval interval-sequence) index)
  (with-slots (minimum length) interval
    (unless minimum
      (error "Attempt to read from an uninitialized interval"))
    (when (or (< index 0) (>= index length))
      (error 'type-error
             :datum index
             :expected-type `(integer 0 ,(1- length))))
    (+ index minimum)))

(defmethod (setf sequence:elt) (new-value
                                (interval interval-sequence)
                                index)
  (with-slots (minimum length) interval
    (cond
      ((or (< index 0) (>= index length))
       (error 'type-error
              :datum index
              :expected-type `(integer 0 ,(1- length))))
      ((null minimum)
       (setf minimum (- new-value index))
       new-value)
      ((/= new-value (+ minimum index))
       (error "Incompatible setf of interval element - expected ~A, got ~A"
              (+ minimum index) new-value))
      (t new-value))))

(defmethod sequence:adjust-sequence ((interval interval-sequence) length 
                                     &key initial-element initial-contents)
  (declare (ignore interval length initial-element initial-contents))
  (error "Interval sequences are immutable"))

(defmethod sequence:make-sequence-like 
    ((interval interval-sequence) length
     &key (initial-element nil iep) (initial-contents nil icp))
  (declare (ignore initial-element initial-contents))
  (when (or iep icp)
    (error "Can't create intervals using initial-element/initial-contents."))
  (make-instance 'interval-sequence :minimum nil :length length))

An odd bit above is the notion of uninitialized sequences (where length is known, but not the minimum) and the behavior of (setf elt). Intervals are considered immutable, but (setf elt) is permitted provided it would not change the sequence. It is also permitted when minimum is unset, in which case it completes initialization by setting minimum to (- newvalue index). Intended to support initialization of intervals by map, this allows a neat trick:

(map 'interval-sequence (lambda (x) (+ x 7)) (below 5)) => #<INTERVAL-SEQUENCE [7,12)>

I thought there was some chance that remove would just work in the case where the element is on an end of the interval. It doesn't. The reason is that generic remove is implementing by calling delete on a copy of the sequence. As there is no way to distinguish destructive operations on a full copy during initialization from any other time, it seems like any immutable sequence has a bit more work to do in implementing the (non-destructive) utility functions.

I've filed my implementation away here in case anyone is interested.

Tags:

An island of sanity

  • Jul. 14th, 2008 at 11:58 PM
oscar
I've just discovered the Linux Hater's Blog. I love it. It gives me enormous peace of mind to know that someone is already out there complaining not only about all the same stuff that drives me up the wall, but also various topics I think I hate but can't be troubled to confirm (Fedora, KDE), and all kinds of exciting new stuff I never realized I need to be pissed off about (PulseAudio? What the fuck is PulseAudio?). Linux Hater puts the fun back into Linux.

Tags:

Favorite Chiptunes

  • Jul. 11th, 2008 at 12:15 AM
oscar
I like chiptunes, and there's a virtually unlimited supply of them. I also like lists. By combining the two, I cement my memory while providing motivation to dig around and find new stuff to listen to.

These are the first things that leap to mind when attempting to enumerate my favorite chiptunes:

  • Highscore (Adlib), composed by Drax and Metal of Vibrants for the game Lollypop, but not used. I peeked at the 'source' in Edlib so I could play it on piano. Too bad there isn't a longer version. [mp3]
  • Breaking Wind (Adlib), another by Drax/Metal. I'm not normally fond of the OPL2, but these guys really make it sing. [mp3]
I don't really count modules as qualifying as chiptunes, but if I had to, I'd probably add Unreal 2 (Scirreal mix) to the list. Oddly, several of the copies of this found via Google were corrupt.

I could list more, but I think I'm already cheating by including music from well-known games. Time to get my players in order and find another list worth of tunes. Kohina is a start.

Tags:

user-homedir-pathname

  • Jul. 9th, 2008 at 5:58 PM
oscar
CL-USER> (defun ~ (name) (merge-pathnames name (user-homedir-pathname)))
~
CL-USER> (~ "foo")
#P"/home/hefner/foo"
CL-USER> (~"cl/foo/myhack.lisp")
#P"/home/hefner/cl/foo/myhack.lisp"
CL-USER> 


Not as nice as Zach Beane's approach, of course.

Tags: