Pork with Ham, Salt, Water, Sugar, Sodium Nitrite

Posted by David on Feb 12th, 2007

I guess the primary lesson of the Internet is that there are people who will waste their time annoying the piss out of you if they think there’s any chance they can make a buck. We’re all familiar with email spam, but the Web opened up a new variety of ways to try to trick people into visiting some stupid online pharmacy and Texas hold-em site. While we were all busy remixing and mashing-up and all that other nonsense, spammers were busy figuring out the implications of link-based scoring systems. The rel="nofollow" trick seemed like a good idea, but its spotty deployment makes it easier for a spammer to just aim the shotgun of suck everywhere instead of figuring which sites are actually vulnerable. We all screwed up at the beginning, so we all get to pay.

Comments are an obvious spam vector, often allowing arbitrary links to be posted in most any webpage, and this is where most of the anti-spam work goes. I don’t do anything fancy myself, any the half-assed bot test I took from NBCom has so far only allowed one spammer through. Trackbacks were a neat idea from Movable Type to allow for a blog entry to be a comment to another blog entry, but that protocol is impossible to effectively protect from spammers. The only protective measure I’ve seen is to check the commenting page for the relevant link when a trackback ping is received. This makes the implementation of pings annoying by forcing blog entry creation and publishing to be closely linked, but it is an effective and, at some level, sensible (if you’re sending me a thing saying you linked to my site, why is there no link?) device. It’s the only thing I use, and I’ve never gotten any trackback spam. This is quite possibly because my trackback links are completely broken, but I suppose that works, too.

The form of Web spam that has most recently bothered me is referer [sic] spam. The motivation behind this spam is the same as the others. Some people post referer statistics on their sites, and since the Referer HTTP header is just an unverified chunk of text, this allows for spammers to inject their URLs into other people’s pages. I don’t make my log statistics publicly accessible, but I do like to watch them from time to time just out of curiosity. The referer stats have been completely unreadable lately because of the flood of crap, so I figured it was maybe time to do something.

The most popular means of I’ve seen of blocking referer spam in Apache are to either use mod_rewrite to deny requests based on a list of undesirable strings or to filter the logs themselves either to remove bad lines before processing or to generate new rewrite rules based on excessive hit counts. Several other people have posted a lot of good information on setting up these techniques (ReferrerCop for white/black list filtering, spam list 1, spam list 2, spam fucker script to generate rewrite rules), so I’ll just be going over some of the variations I used in my implementation. There are some RBL lists similar to what things like Spamcop do for email, but I didn’t look heavily into those since I don’t think that the lookup delay is appropriate for HTTP. I went with a set of regular expressions developed from my own spam logs, but I went about it a little differently.

Returning a 403 for bad hits is great and all, but those still get logged. Many directives in Apache can use environment variables as a conditional, so you can set an environment variable once based on regular expressions and use that condition to both deny requests and change logging behavior. So I use something like this to set up the spam strings:

SetEnvIfNoCase Referer “^http://([^/]*\.)?hejazholdem\.com” refspam=1

My log line now looks like this:

CustomLog /var/log/httpd/access.log combined env=!refspam

And I added the following to the <Directory> section for the main site:

Order allow,deny
Deny from env=refspam
Allow from all

This gives me enough flexibility to do what I want with the referer matches, and I can add new rules by making new SetEnv cases similar to how I handle blocking hotlinked images on myspace and xanga. The rules are probably best served by either a personal reflection on site statistics or the use of one of those lists from somewhere else, but I did notice a particular pattern in the spam urls. Several of them were of the form “http://clickme/#”; that is, they had a “#” at the end of the URL. About the only time this bare anchor shows up in the wild is in bad javascript, and I’ve never seen any sort of URL fragment sent as a valid referer. Forbidding any use of “#” may be a bit extreme, and that sounds like a good way to find that one guy using the browser that sends fragments in referers, but I found the addition of “^http://.*#$” to my pattern list to be very useful.

I hope this helps.

Drivetrain failure

Posted by David on Feb 11th, 2007

All of these uphill bicycle failures are kind of making me feel fat. My metal replacement for that pedal that broke can probably hold up to whatever abuse I can give it, but I can’t do a whole lot about the chain.

I decided this weekend to avoid the Peachtree Dunwoody Publix by visiting the one on Abernathy instead of the one by Chastain Park. I guess part of this is because memories of it hurting to breathe still have me a little wary of Roswell Road. Abernathy scared the crap out of me even before the wreck, and my usual northward routes give out around Mount Vernon, but I was able to find a way up to the grocery store that didn’t use Roswell Road and only required me to coast down a hundred feet or so of sidewalk next to Abernathy. I had to cut through some residential streets, and they have a lot of traffic calming tools that I found kind of annoying. In addition to the speed humps placed on longer straight stretches, intersections are either implemented as tiny little roundabouts (not to be confused with traffic circles) or a four way stop with a speed hump island in the middle. The speed hump surfaces are all topped with cobblestones, and uneven rocks aren’t really pleasant on 25mm tires. It would be nice if there were a way for bikes to bypass the humps, but I guess that the residents don’t want me speeding down their quiet streets any more than they want cars doing the same. The humps outside of intersections don’t extend to the gutter, and I thought about trying those paths, but I don’t think I could have made it without eating a mailbox or two. In addition to all of this, the roads used another measure I hadn’t seen before: sometimes they’ll take away the lane you’re in and plant a tree in the middle of the damn road and then do the same thing about fifty feet down on the other side. I’m not sure how this is really supposed to help.

I made it through this obstacle course and arrived at Publix rattled but in one piece. The hills were steep but short, and there was no traffic, so I might end up taking this shortcut again. I wanted to shop at a full-sized Publix this weekend so that I could get some spinach. I’ve had vegetables on the brain lately for some reason, so I got this weekend’s dinner recipe from the kind of creepy but informative vegan website that I used the last time I needed to figure out what to bring to one of Moshe’s potluck dinners. My shopping was a pleasure, and I stuffed everything into my backpack (I still haven’t replaced my panniers, though I really hate carrying things in a backpack) and headed back home on the same route as before. I almost got back to Mount Vernon before my chain broke. I wasn’t pedaling particularly hard at the time, so I don’t really know what caused the failure. Atlanta is about 90% uphill, so I guess all the stress of dragging me around against the will of gravity was too much. The pin of the broken link was still intact; it looked like one of the plates just bent and popped off. Of course I didn’t pack my shiny new chain tool, so I had a couple mile walk back home. That’ll learn me.

I guess I should probably get a new chain at this point, but the current chain isn’t worn, so I’m just going to ride it for a while longer and keep a chain tool with me. I pulled a couple of extra links off of the Trek to get it back to the right length, and I got some good use out of that fancy workstand I got for Christmas (thanks mom and dad). I’m not really sure what is implied by the Trek’s chain being barely worn while I tore through the last one on the Schwinn in just three months. I also wasn’t quite able to use Sheldon Brown’s chain length guide—the only article I’ve ever seen on the topic—to full effect since I was half a link off. Oddly, this situation is illustrated in both of his “bad” pictures. I have no idea how you’re supposed to handle it. I handled it by going half a link short since I spend more time in the small-small combo than big-big. If I post in a couple months about replacing my rear derailleur, you’ll know why.

When the chain whipped its way off my bike it apparently did so with enough force to move the front derailleur. The cage wasn’t bent, just angled wrong. That was a pain to readjust, but at least I didn’t need to replace anything. While fixing this, though, I noticed that a tooth or two of the big chainring are messed up, probably from where they hit the road a month or so back. I have another broken bike, and it has chainrings, so I think I know the solution to this problem. I’m going to need some more tools.

I don’t know if I’ve just been forcing it or what, but, since this is America, I’ve up to now been servicing my bike with English Allen wrenches. The 3/16? size fits most every bolt on the bike, and the fenders and rack use a 5/32? wrench. The crank, however, uses an 8mm hexagonal hole, and I can’t fake that. I bought a metric Allen wrench set at Ace today which I hope will satisfy all of my metric wrenching needs. The 8mm wrench is (hopefully) enough for the Schwinn, but the Trek is a different beast. Where the Schwinn has one of those fancy self-removing cranksets (I think), the Trek has the kind with the weird size hex bolt. I have a deep socket set, but, again, they’re only English sizes, and 14mm is bigger than half an inch. Some book I have says that I’ll need a crank wrench and a crankset extractor. I’ve ordered the extractor online (along with new brakes, since I’m close to burning through another pair), but I decided not to get the wrench. Park Tool, who makes most of the bike tools I have, sells a wrench with a 14mm socket on one end and a 8mm Allen wrench on the other, but I already have the 8mm piece, and I don’t like having two tools to do the same thing. I’m going to try to find a deep 14mm socket instead and go from there. I hope I don’t need to buy a metric handle.

I AM ERROR

Posted by David on Feb 6th, 2007

I’ve beaten the first level of Zelda II, the castle in Parapa the Rappa desert, so I feel qualified now to form sweeping opinions on the game. It’s different, but I like it. I don’t like it as much as other Zelda games, for reasons I’ll elaborate, but it still has some fine qualities.

Zelda II is different from all the other Zeldas in that it’s basically a side-scroller. There’s still a top-down overworld map, but, much like Final Fantasy, you don’t do anything in it; the battles and levels are all handled in the side-view environment. That’s not bad, of course—we all liked Metroid and Castlevania—but it’s a major shift in gameplay from the original. One of the things that made the first Zelda so great was that it stood more or less alone in a world of platformers. This return to basic form is fun, but it isn’t as interesting. There’s no innovation like there was before. The new gameplay isn’t bad, but it’s a little disappointing.

This sequel adds the concept of experience points, to some extent taking teh place of money, which is absent. I don’t like the experience system. While the first Zelda game had a certain amount of tedium in finding rubies (retranslated as rupees in later games, turning precious gems into any of a variety of currencies worth less than the Mexican peso), the money was more manageable than Zelda II’s experience points. Firstly, money in the original Zelda game was saved across sessions, whereas experience points are not. Secondly, there wasn’t as much need for money for advancement purposes. You needed to buy the candle, the arrow, the fancy shield and the red bracelet, but that was about it. For the most part it was possible to earn enough cash at the appropriate points simply by playing the game without worrying about buying the next big thing. Zelda II has seven possible advancements across three different axes, and, unless you want to spend all day trying to beat the horse-headed guy with no defense or attack multipliers, it’s necessary to wander around in the woods for a while to kill monsters and rack up points. This really isn’t fun. Wandering off the road opens you up to something similar to the random encounters in Final Fantasy, but now you have to seek these out by choice instead of just passing through each new annoyance as part of the normal path through the game, forcing you to ask for your own annoyances. I think the experience system was a mistake, and I don’t believe it appeared in any later sequels.

Health is kind of weird in this game. While in the first game, and other Zelda games, you got a certain number of hearts and maybe some life potions and nothing else, Zelda II gives you both a life meter and lives. The initial number is three lives, and if you empty your health meter, you restart on the same screen sans one life. If you lose all three lives, you restart back at the beginning of the game with all your items but no experience points, just as if you had saved the game. This is similar to how arcade games handle health and lives. I don’t think it’s appropriate for an RPG, but it does fit with a side-scrolling action game. I have mixed feelings about the life system, in part because since the interaction with the save system is somewhat interesting. Like the first game, Zelda II keeps a count of how many times you’ve died (with death in this one being the loss of your last life), but in this game a save also counts as a death. This feature rankles with the perfectionist in me (I beat the first Zelda with a zero death count by using save games as an escape mechanism), but it also both reduces the importance of the death counter and changes the way I handles saves. Saving the game after reaching a milestone no longer holds any advantage, so I’m more willing to simply play until I die and only save when I want to quit. This is an important detail for getting me to actually use the three-life system; I’m not sure that restarting on the same screen would be enough to keep me from hitting reset every time I lost a life. I’m not even sure if the death counter is around anymore (Link’s Awakening had it, and that’s about all else I have to go on), but I think the game would be best served by a removal of this arbitrary indicator of how badly you’re doing. Since the death counter is my primary motivation to use the multiple lives, I think the lives, too, should go; the game could be better without this extra and somewhat confusing strategic element.

The health meter in Zelda II is a bar rather than the familiar heart containers. The effect is about the same, but the hearts had a certain aesthetic appeal, and the lack of granularity on the heart meter (you could only lose half a heart at a time, even if the bracelets allowed you to effectively take quarter hearts in damage) made it easier to quickly figure out how many more whacks you had before you died. The bars have discrete units, but the partial units allowed are too fine. The hearts at the very least made the health meter something special to the game, and I’m glad that they were brought back in the sequels.

The use of magic points is new, and I don’t think it’s either good or bad. It adds a new element to battles beyond the usual hack and slash, and, regardless of whether the sequels needed it, this game needs it since it lost the panoply of equipable items found in the first one. Wiki says that all sequels except Twilight Princess use a similar magic system, which I know to be false, since Link’s Awakening had no such thing, but I don’t want to break my streak of creative vandalisms, so I’ll leave fixing the page to someone else. The magic seems like a good idea, but its implementation is a bit weird and annoying. You can’t use magic until you select it, which resets every time you use magic, producing unneeded interruptions in gameplay, and you use magic by hitting Select, which is hard to reach. I guess they just ran out of buttons on the original NES, so that particular problem is solved with later systems and better controllers, but the implementation of magic in Zelda II isn’t frequent or diverse enough to replace the variety of b-button items available in the first.

You can’t return to finished levels in this game, which makes me worry that it’s possible to get stuck without a necessary item. The first Zelda game let you wander through any level you wanted after beating it, which was quite often useful or even necessary. The second quest had at least one item on the other side of the triforce room, and there were a couple cases where you could go back to get previously inaccessible items, like returning to level 3 or whatever it was to get a key on the other side of a lava river only crossable using the ladder you get in level 5. Maybe the Zelda II level layouts are more simple (I don’t even know yet if there any secrets to be had at all), but the finality of beating a level removes at least that safety net of knowing that the parts parts besides the boss can still be replayed.

Non-player character interaction makes its first appearance here, and I wholeheartedly support that. Talking to NPCs can do a lot to further a story and provide hints, but, unfortunately, Zelda II did not use this to its fullest potential. Link’s Awakening is the best example I know of nearly any genre or series of using the NPCs to develop the story: the manual tells you that you’re shipwrecked on some island, and that’s it. Figure the rest out from there, chief. The rest eventually became a gut-wrenching realization around level 6 or so that the people you’ve gotten to know so well are going to cease to exist if you continue playing the game. It was one of the most moving and well-developed video game stories I’ve ever played. Zelda II, on the other hand, provides eleven pages of text to explain why you’re here and what you’re doing, and the people in the towns mostly take the place of the old man in the first game in providing nonsensical hints. Baby steps, I guess.

In all, I think that Zelda II is a decent side-scroller, but it fails in that it can’t figure out what it’s supposed to be. A lot of new ideas were thrown at this sequel, and some of them stuck, but a good number of them didn’t work out. Maybe the designers should have taken more time to figure their stuff out, or maybe the radical elements in this game were important to pioneer future development. I don’t know. Either way, this is an ok game, but it’s not a good Zelda game, and I think that’s what makes some people bristle at its name. The first game managed to be fun with hardly a semblance of a story, but this game tries to construct an entire world I don’t care about. All I’m doing is fighting some monsters Metroid-style so I can get to the seventh level. The music, too, is below the standards of the first game, which removes that epic spirit found in the original. Zelda II has a different composer, but, looking at some of the other entries on Koji Kondo’s résumé, I wonder if in that aspect they simply set the bar too high in the first game. I dare you start humming the themes to Legend of Zelda or Super Mario Brothers in public and see how many people join along by the fifth note.

I win

Posted by David on Feb 3rd, 2007

The end of the second quest of Legend of Zelda

There, I beat the thing. The Nintendo Power maps kept me from giving up in frustration, especially by letting me know the locations of heart containers and the levels. I didn’t need the maps for the levels themselves as much, which is good, since in what I suppose was an effort to be more of a set of hints than a complete walkthrough, Nintendo Power stopped mapping the levels after 6. This wasn’t really a problem until level 9. The first quest level 9 was tough, but it wasn’t so hard to find my way around that I missed anything other than the red bracelet. In the second quest, I found myself bombing the same walls more than once because I couldn’t find anything and couldn’t remember where I’d been. The game provides two different maps: there’s the one created as you explore the rooms that includes doors but nothing else (one-way doors are shown as a half line), and there’s the one that you find in the level that only provides the locations of all the rooms. Neither map shows the various underground warps between rooms, but it’s not usually too hard to find your way around. The second quest adds that annoying walk-through-some-walls aspect, also not indicated on the maps, and I found it impossible to keep track of everything. I decided to further complicate the cartography provided by the game and make a map on paper with notes on what walls I’ve bombed and tried to walk through. I probably wouldn’t have found the silver arrow had I not done that. I still didn’t find the red bracelet, but whatever.

So I’ve finally patched that gap in my wasted youth and beaten the first Zelda game, and I did so using only period-appropriate hints. It was actually a lot of fun. I guess it’s time to take on Zelda II: The Adventure of Link, which is supposedly the sucky one. I guess I’ll find out. The game already has me pretty confused just by the story. I really hope that the manual read better in the original Japanese, but even beyond the poor wording in the translation, Zelda II has a lot more text to set itself up, and I’m not sure that it all makes sense. Like a Victorian novel, the continuing trouble in Hyrule is blamed on the bad vibrations of Ganon’s residual evil rather than the marauding bands of his leftover henchmen or the economic depression after the war that kicked off the first game. After only a very brief explanation of this motive for Link to go all hero again and a motive for everything around to attack him (every evil wizard has a ridiculous backup plan, and Ganon’s apparently was to have the blood of his killer be poured on his ashes in order to be resurrected), the story dives and twists into an explanation of why the princess is in a coma (I guess that happened between games? It makes it sound like Ganon showed up after the events leading up to the long sleep, but that wouldn’t make sense), why everything in Hyrule sucks (hiding the pieces of the spirit of the kingdom or whatever it’s supposed to be sounds like kind of a jerk thing for that dying king to do, suitable heir or not), and why Link is the only one who can help. The first game didn’t use nearly so many words or so many confusing plot elements to craft a motive, and it had eight dungeons to this game’s six. I hope the rest of the game isn’t so convoluted.

New chain tool arrived

Posted by David on Feb 2nd, 2007

I had pretty much forgotten about my chain tool trouble until recently when the bicycle crash forced me to empty out all the junk I had been carrying around in my now broken panniers. One of the items poured out from these bags was the barely-usable chain tool which I had been carrying since I replaced the chain, just in case it turned out that I had screwed something up (which, it turns out, I did: I ended up having to push a pin back in while on the road). I held the broken chunk of cheap metal in my hand and, after staring at it for a moment, mentally wrote off Topeak and the inherent hassle. Sure, their customer service response was friendly, but, it would seem, ultimately unhelpful. I set the broken tool aside and resolved to buy a new one in a few months when I start caring about chain wear again. As it turns out, my resolution was premature. I returned home this evening to a package at my doorstep from Todson, makers of Topeak brand bicycle accessories, containing a new Chainbot chain tool.

This new tool is the same thing as the old tool, of course, so I’m a little bit wary. I’m still not sure of the exact mechanics of the first one’s failure, but I’ll provide my hypotheses after this handy picture:

Topeak Chainbot chain tool

The tool is designed to work with two different chain widths: 3/32?, used on most multi-speed bicycles, and 1/8?, used on single speeds. The smaller chains fit in the fins at the top of the picture and are pushed down against that thick metal part as the pin is extracted. Wider chains fit on the lower pair of fins and are pushed against the upper fins. As I note in the letter to Topeak, I used the pair of fins closest to the thick metal part. There’s a problem with this design that’s shared by most chain tools: as the pin is pushed (up in this picture), this pair of links will twist down and press against the tops of the fins which, in my case, caused one of them to snap off. It’s either that or I did such a bad job of chain removal that I twisted the tool apart. Either way, the tool shouldn’t be so freaking delicate, but I don’t think that the weakness of my old tool was the result of a manufacturing defect so much as a weak design, so I’ll have to be a little more careful with the new one. I guess those thin pieces can’t get too much stronger without making the tool too heavy.

Regardless of whether this tool is a piece of junk or I just manhandled it to death, this whole replacement experience, though slow, came out as well as I could expect. Thanks, Topeak.