darkness

Tuesday, 31 December 2002

Sometimes Perl just seems broken

darkness @ 05:01:03

Hey, call me crazy, but I was thinking that I could hack something together to check that a package implements all the functions in another package. I called these “interfaces”; you may remember my interface.pm.

Well, today I find that if a package that has use interface is itself use‘d from inside an eval block, the CHECK block that interface.pm sets up creates that Too late to run CHECK block message or whatever it was (see last entry). Joy.

I thought up two or three ways to fix this. First I thought, “OK, I’ll just undef the package namespace, remove it from %INC, then reload the fucking thing manually and slap a CHECK in before interface.pm’s eval is done.” After reading that, I think this is a more appropriate description of what I was intending:

  1. undef caller’s name space.

  2. Profit.

I will take this opportunity to inject a bit of wisdom into the world: don’t undef a name space (undef %{ "SomePackage::" }). This seems to make Perl act weirdly, like apparently corrupting strings (including code it’s reading in, I think) and sometimes you get SIGSEGV. Needless to say the above was a failure.

So then I decide I’ll just force loading of the package with require (after deleting the package from %INC of course), run the function that checks for proper implementation of an interface, and then undef everything that I just loaded so when my import function returns you won’t get a bunch of “redefined” warnings. This method worked for my simple test, but quickly revealed two problems with a more complex test. First, in the process of undef‘ing everything, I undef‘ed some stuff that was imported from other modules. I can’t think of any way around this, except maybe requiring use interface to be before any other imports. Secondly, and most obviously, you’d be loading the fucking file twice. God help you if it’s something like a big Parse::RecDescent parser or something. I also need to restore the entry to %INC when I’m done with my undefining, otherwise the file will get reloaded later, producing those “redefined” warnings we were trying to avoid earlier. Problems aside, the first of which I think is impossible to fix, this is the most successful method yet.

The third thing I tried was just creating a CHECK method in the caller. I.e.: *Caller::CHECK = sub { ... }. This didn’t work; as near as I could tell the CHECK method never got ran. It might work if the caller first defined a CHECK block (save the caller’s CHECK, replace the symbol table entry in the caller’s package with our own CHECK routine) but that would be a silly requirement.

So, any Perl wizards have a suggestion? (Other than, “that’s not the Perl way; stop trying to guarantee interfaces” or something like that.) Please mail me.

In other news I got Icecast 2 working, along with darkice for streaming to the server from my line in. quality = 0.5 in darkice seemed to fill up my upstream pretty nicely. People were semi-frequently (ranging between 2m and 15m) getting disconnected from the server for no apparent reason. The server seemed to be sending the FINs too. Nothing in the logs about it. Still, I was able to spin and others were apparently able to hear me. With a little more bandwidth and a bit more ambition, maybe I could get my USB web cam to stream me spinning too. It’s real exciting to see a guy standing in front of some turntables for an hour, BTW. Trust me.

Monday, 30 December 2002

New vinyl, old program

darkness @ 04:30:18

First, I forgot to mention that I went and bought 8 new records from the local record store. It’s always kind of intimidating when I go in there, so I make sure to bring my kru. (No, they do not fit in my pants.) darkho and euphorik seemed kind of bored, though euphorik did find some CDs. Total bill: $90. I’ve got something between $110 and $200 left in my record budget I’d say. (The low end if I decide to put $100 towards a new hard disk. I need something bigger I think.)

I do have this problem of where to put my music. I’ve always been a fan of keeping it on CD. CD-R media is cheaper for dollar/size (I think!) and is more portable. My friends prefer hard drives. Hard drives are faster for reading/writing, allow you to see a huge amount of music at once, and don’t require anything to be swapped in/swapped out (can access over the network; sort of redundant). I think I’m going to be sticking with CD-R because of the price, but what worries me is backups. Reading about the longevity of CD-R media at CD Media World makes me think about my MP3 discs. Of course, if I had hard disks, what am I going to back those up to? I wish I had a big tape drive/tape changer, and/or I wish magneto-optical disks were cheaper.

I was just reading about “The State of the Scene” or something like that on some site I found called charlottemix.com. Apparently hip young professionals like House, D&B, Ambient, etc. I bought a bunch of Trance. What does that say about me? Probably that I’m boring. Well, fuck them right in their stupid asses.

At some point last night — I can’t quite figure out when — I managed to install Snort. They’ve got binary RPMs on their site and they seemed to work in RH8.0. I installed it, ran it, and nothing real dramatic happened. It keeps having false positives on people sending POP3 commands, especially their passwords; I could swear it’s looking for any occurrence of 0×0A in those packets, but I don’t precisely know how to read Snort rules. BTW, I installed the snort and snort-plain+flexresp packages, IIRC. Sometimes it’s enjoyable to tail -f /var/log/snort/alert.log or whatever it’s called. Sometimes. OK, maybe not really, but after an hour or so it can be interesting. Saw a bunch of port scans, which didn’t really surprise me.

Tried to do offset detection with EAC today on my Plextor PX-R820T (I think that’s what it is). Out of five CDs (from the 11 I think I own) that were on their known offset list, none fully matched the ID codes they had, and only one was considered “known” by EAC itself. Further, on that CD EAC calculated an offset of like +8655. The user reported features database shows a green (”large” number of people) record with +355. Say what? I gave up on that. My drive also claims to support C2 error detection, and it confirmed it was reporting them with a scratched CD, but apparently everyone is reporting that it doesn’t. Either that or they’re just reporting that they’ve left it off. I left it off too.

Worked on DarkWiki tonight. It’s got some problems still. For example, I keep getting errors like:

Too late to run CHECK block at (eval 77) line 3.

Ignore for a moment the difficulty at tracking down what is generating that error, given the content of the message. (I don’t necessarily blame Perl for that, either.) I’m almost positive the only place I’m using CHECK blocks is in my interface.pm code. So that means there’s a problem with it, and I’m going to have to go back and attack that. Don’t know exactly how it got to be too late to run the CHECK block, but I guess I’ll find out. I’m using CGI’s debug/console mode to test right now… or I would be had I gotten to the point of my $query = new CGI; yet. Still, some progress has perhaps been made.

I regret not using something like XP for this project. It might have made the development faster, and probably made for a better design. Note to self: in the future, everything except for tiny scripts (100 lines or less or something) should be done with XP — or at least something different from what I’ve done in the past.

I wonder if anyone has done a web site where you can upload a little package/script, documented or not, with a blurb and some search terms. Might go to furthering reusability. Could make it easy to set up so people can run it for themselves. I just get the feeling I write all sorts of little snippets, scripts, and hacks, and they’re forgotten before their usefulness is at an end. Maybe if it was super easy to send that code somewhere I’d do it. Then we need a brigade of people that like to write documentation for software by looking at the code to sweep through and document things. Yeah. This will never happen, I think.

I need to finish my Donnie Darko soundtrack, install some machines at work, rip all my CDs, reorganize the storage of my CDs, maybe make some more mix CDs, set up all sorts of cool software at work, and… I did start that Java streaming Ogg Vorbis server a long time ago that I’m now thinking I’ll never touch again. And this is just what I can remember right now. Sigh.

Sunday, 29 December 2002

Movie, wedding, party, etc.

darkness @ 03:41:53

Last night went and saw Gangs of New York. Good. Recommended. darkho and I were curious about its level of historical accuracy.

Went to a wedding today, macgyver and his S.O. Congratulations to them (if I haven’t said that enough yet) and I hope they’re quite happy together. We had a good time at the wedding… and thank you for making it so short. The newlyweds and some of the wedding party came back to our place tonight for more punch and pie.

Had a debate today with introvert on the best Win32 CDDA extraction tool. I was behind EAC and he was rooting for CDex. The end result was no ground given by either side. We actually both pretty much conceded that either was just fine (other rippers probably are not, at least not on Win32 — unless euphorik was right and someone has done a port of cdparanoia). Use whatever works for you. CDex has the ability to skip the intermediate WAV file when encoding. Someone ran a test on some damaged CDs between EAC and CDex; the only interesting point I was really able to pick out was that EAC reported errors whereas CDex did not report them, leaving some errors in the resulting WAV files. That’s pretty bad, but the CD was pretty fucked up too. I think the ripping time was pretty long for CDex, so that probably should have tipped you off that something was up right there. Still, a false positive result from a ripping program would be worse than a false negative. Also, WRT some hardware combinations and compatibility, as well as OS compatibility in some cases, I read some testimonies of EAC working where CDex would not. While I’m betting EAC actually has more settings to be checked than CDex, I think I’ll still be recommending EAC first, since I’m thinking it’ll work for more people. OTOH, CDex is open source where EAC is not. Also, I read an rumor that CDex supposedly incorporates some of the same techniques (and I hope code) from cdparanoia. I like cdparanoia enough to make that a definite point for CDex. Still, for now, EAC for me.

But who uses Windows anyway? Right?

I need to do some coding, but I think I’m going to bed in about 20m. Maybe I’ll read. Maybe I’ll set up Snort. I want to set up some IDS stuff. I want to set up Nagios and lots of other things, but I need more machine formatted/installed at work. O, how I long for a genie to insert CDs and things like that at work.

Friday, 27 December 2002

The Christmas Take

darkness @ 17:09:50

So I told some people I’d write here what I got. I don’t mean to brag, but people are interested so I figured I’d make a single point of reference. Also I asked for some stuff I wasn’t sure I’d like or not, so I’ll be able to inform people how I like the toys I thought I might like.

I’m only going to hit some of the highlights of what I got. It’s not necessary to rattle off the whole list. I’ll preface it by saying I appreciate and enjoy every present I got, and thank you to all who gave them to me.

My booty this year included:

  • New satchel. This one is from Eddie Bauer. I can’t find a link to it online, and I don’t even remember what it was called. It’s black, nylon or polyester or something like that (i.e., not leather). It has a zippered pocket on the front and back and two on top. Inside the front pockets are some compartments. There is an internal zipped pocket in one of the larger compartments. This is a much bigger satchel than my previous bag IMHO, though others think it won’t be a problem. A chief concern of mine is the large bottom with feet on it. It’s got some sort of rigid support in it to keep it mostly spread out. The zippers are also causing some problems, getting caught and not zipping and such. I think I’ve worked around that. I’ll have to think on this bag more. I’m going to the mall later today so I might have to consider other Eddie Bauer bags then. (Their web site has one or two promising-looking ones.)

  • CDs. I asked for a bunch of CDs from CD Baby and I think I got them all. Here’s the run-down:

    • Kleckley Sweet, Minivan Killed the Station Wagon

    • The Dinnermints, Love Letters to Our Future Selves

    • Full Blown Kirk, Zero Day

    • Jabberpony, So Far

    • Outloud Dreamer, Drink the Sky

    • Gary Jules, Trading Snakeoil for Wolftickets

    • Merrick, Drive Around a Lot Hard and Fast Driving Club

    • Moonraker, Nada Brahma

    • Stars of Stage and Screen, Dying to Meet You

    • 100 Watt Smile, 100 Watt Smile

    • Bird York, Bird York

    So far I think Moonraker, Merrick, and The Dinnermints are definite favorites. Bird York’s voice sounds like Fiona Apple. I’d link all those on CD Baby, but that’d be a big pain for me. Go there yourself.

  • Gerber Multi-Plier 600 Deluxe. This is way cool. You can fling the pliers out easily with a flick of the wrist (after practicing for a few minutes, at least). No wrapping of the knuckles when closing them either, which was a pain with my Leatherman. Nice tools on it too, and a black nylon belt pouch with room for the tool set (screwdriver bits and a magnetic adapter). The only thing I’m a tad worried about is the longevity of the Velcro. We’ll see.

  • Spyderco Endura Lightweight. This is also cool. It’s a sharp blade (I already cut myself with it) and it’s fun to flick open and closed. I know I shouldn’t be doing that, but… it’s still fun. The belt clip is stiff and hard to attach to my pocket sometimes, but I’ll get used to it.

  • Garmin MapSource Metroguide. This is the US maps for my GPS. I thought I’d have to unlock specific regions and/or GPS units, but that’s apparently not the case. With this I can plot routes and waypoints on my desktop and send them from my GPS, as well as transferring from my GPS to my computer. Primarily I wanted this to load the detailed maps on to my GPS though. I also got a window mount with suction cup for using my GPS in the car, but I haven’t tested this yet (I have to clean off my windows first).

  • A drill. It’s a Black & Decker drill. It looks pretty nice. I needed a drill (luckily I was able to borrow one this past weekend).

  • “All Your Base Are Belong to Us” T-shirt from ThinkGeek. Remember, me == dork.

I think that sums it up well enough. I left out a bunch of stuff. I think I mostly rattled off the stuff I can see.

Making Half-Life sprays

darkness @ 04:56:55

I happened upon Photoshop 7, so to play with my new-found toy I decided to do something I had been meaning to do for a while: make a spray to use while playing TFC.

I started out with the first page from Google, titled “Half-Life Color Logos”. This page was a good place to start, and it has some good references at the bottom. Interesting facts: Half-Life sprays are bitmaps; ideal size is basically 128×64, though apparently 256×32 will work too (according to this page); they’re 8-bit color; the last color in the index table has to be RGB(0,0,255), which signals transparency when the image is rendered in the game. The Color Logo Bible has some other good tips, and some real explicit instructions — though not for Photoshop. They also mention a tool (which is probably better than what’s on the first page) called Wally. I can attest that its Half-Life logo creation wizard is way easy.

I decided to make a picture of a cow, kind of coming out of an elliptical frame. You can see the end result in some in-game shots of me going spray-happy. I found a picture of a cow using Google Images. I cropped the picture down to just the part I wanted to use, but didn’t do any resizing. Then I added in the frame with layers, etc., and generally got the picture looking the way I wanted the end result to look. I did all this without changing the color mode in the image nor the size.

After I had the image complete and ready to be made in to a spray, I saved it to a PSD file so I could always come back and modify it in the original size/color, with layers, etc. Then I selected Image->Image Size. I had previously switched my default measurement mode to pixels, so it showed me the width and height in pixels. I chose the smallest of the two dimensions and changed that dimension to 64, which is the smallest of 128×64. In my case, I changed the width to 64. The height was then less than 128. I guess that, for some images, this could land you with a dimension still larger than 128. Keep changing dimensions to 64 or less until you’ve got it within a 128×64 (or 64×128) size. Don’t worry if it’s less than 128×64 in either or both dimensions: we’ll fix that next. Note that in the Image Size dialog height and width are automatically kept proportional (assuming your “Constrain Proportions” check box is checked by default like mine). When done, hit OK.

Next you have to put it into a 128×64 (or 64×128) size. Select Image->Canvas Size. Whereas Image Size might stretch or shrink the actual picture, Canvas Size just changes the size of the image, without regard for expanding or shrinking the actual image. Set the canvas size to a variation of 128×64 and click OK. You’ll notice your image stays centered, the blank part around it just grows.

At this point you’ve got your image at the right size. Now you need to convert it to indexed color. Note that my image had a transparent background which I wanted to keep. You can’t exactly save it as a “transparent color”, though; I don’t even think the Windows Bitmap format supports that. However… Photoshop will gladly save a bitmap with a transparent color, apparently, at least in indexed color mode. Which is where we’re going. (Actually, I think it adds an alpha channel to the image. Whatever.) Just for the record, if you actually have the color RGB(0,0,255) anywhere in your image, you’re going to need to change that to anything else. RGB(0,0,254) if you’d like. It doesn’t matter. (I think there’s a way to easily replace a color in an image with Photoshop, just poke around.) Go to Image->Mode->Indexed Color. If it asks if you want to flatten layers, say yes. Indexed color images can’t have layers. For palette select “Local (Adaptive)”. I haven’t experimented with this setting, actually, but I’ve heard it works the best. Make sure it says 256 for “Colors”. Change “Forced” to “None”. “Transparency” should be checked, even if your image uses no transparency. I didn’t touch the other options; they were left at their defaults. Click OK. Hopefully your image doesn’t look vastly different.

Now the tricky part which I couldn’t get without the Color Logo Bible (above): making sure that last cell in the color map is RGB(0,0,255). Go to Image->Mode->Color Table. You’ll see the colors Adobe found in your image. That last cell will be the white and grey checkered transparency pattern. Select this cell and change the colors to RGB(0,0,255). Voila, the transparency in your image is changed to blue. Neat, huh?

At this point save out to a BMP file and make note of where you saved it. Now open up Wally (to install it, BTW, I just extracted to a directory and dragged a shortcut to wally.exe in to my Sierra folder) and go to Wizard->HL Color Decal. Select your Half-Life folder, the proper game (tfc in my case), then select “File on hard drive” and point to your BMP file. Click OK and it kicks you back to the main window of Wally. At this point you have to hit save (either on the tool bar or in the file menu, presumably) and it’ll write our your pldecal.wad (I think that’s what it is named) in the proper directory and you’re ready to go.

Also for the record, impulse 201 is the command to actually spray in Half-Life (or TFC at least).

I note that you can apparently make animated logos, though they end up being very small because the size of the bitmaps (frames of the animation) must add up to more than about 12KB IIRC.

It’s 0500 and I’m tired. I’m going to go to bed now, but I promise I’ll write about Christmas and my fight with Nautilus tomorrow. Since I know you’re all twiddling about, waiting for the next exciting chapter in my life. Yeah.

Next Page »

Powered by WordPress