Category: Geekery

  • External PHP via Javascript

    Fed up once and for all with the lackluster reliability and performance of the “free” commenting systems in use by some of my friends, I decided to see if I could rig it so (in theory) they could use a comment script hosted here at greyduck.net instead.

    So what do you do when you want to reference a comment-counting feature that’s written in PHP, on another server, from a server on which PHP is not installed? You call it as if it was a Javascript, of course! (And by “of course” I mean “I learned after a solid hour of Googling and headscratching”.)

    Here’s the trick:

    <script language="JavaScript" src="count.php?id=X">

    X gets filled in with the journal/blog/thingie entry number via whatever mechanism your journal software provides, and the ‘count.php’ is configured not to ‘return’ its calculated result but instead:

    echo "document.write("$result")";

    In other words, PHP is generating what looks like Javascript, and everybody’s happy. My hacked-together ‘count.php’ looks like this (with some obfuscation):

    <?

    function commentCount($n) {
    $comments_path = "/path/to/comments/directory/";
    if($file = @fopen($comments_path . "comments/$n.comment", 'r')) {
    $thisFile = fread($file, '1000000');
    $thisFile = explode("n", trim($thisFile));
    fclose($file);
    $comments = sizeof($thisFile);
    if($comments == 1) {$comments .= " comment";} else {$comments .= " comments";}
    } else {
    $comments = "no comments yet";
    }

    echo "document.write("$comments")";
    }

    commentCount($id);

    ?>

    And the link that calls the comment script and displays a live count of submitted comments looks like:

    <A HREF="javascript:viewComments(X)"><script language="JavaScript" src="http://www.domain.net/location/count.php?id=X">

    Again remembering to replace that X with the unique identifier for that journal/thingie/blog entry. The viewComments() function is your standard “new window popup” trick that I’m sure nobody needs me to detail here. (The X in that function call is passed to the URL for the comment script proper. Nuff said.)

    Granted that this is all designed around the comment code used on this website, so it’s not exactly portable for all uses. The code listed here is only an example of how it can be done.

    Not, mind you, that I’m putting this system into service right away… but working this out certainly was an interesting learning experience for me! Yay, my geek-fu is still strong! *smirk*

    UPDATE: I’m a freakin’ moron. It works great in Mozilla-based browsers but Internet Explorer ignores the living hell out of my count.php script. I have no idea why. I’ve added content-type headers, I’ve tinkered with it six ways from Sunday, and still no-go. So, basically, this was an exercise in utter futility. Argh.

  • Uncluttering My Inbox

    I run my own email server. I’m still convinced this is a good idea for a die-hard geek like myself, but it does have some downsides. For instance, I have an additional layer of complexity to deal with when fighting spam.

    One weapon in my arsenal of spam-fighting techniques is the daily throw-away email address, as seen in the upper-right corner of this website. It works pretty well, all things considered. Only twice have I received spam at an active daily alias. (You almost have to admire the nimble little spammers. And by “admire” I mean “eviscerate.”)

    Letting the address harvesters gather those throw-away aliases, however, comes at a cost. For every message a spammer sends to a now-outdated alias, my server then has to try to successfully bounce that message to sender. Since the vast majority of sender data is faked, you end up with a double-bounce scenario where the attempt to bounce a message bounces back to the postmaster of the domain the spam was being sent to.

    Yep. I get to see the spam anyway, except now it’s buried inside of “delivery failure” notices. How nice. As a for-instance, I can go to bed at 11pm right after checking email for the night, wake up at 8am and find upwards of 50 emails titled “Failure Notice” in my inbox.

    Some of you are probably way ahead of me on this one. “Gee,” I realized this morning, “Why don’t I just create a new administrative email account and change the ‘postmaster’ alias to point to that instead of to my real email address?” (The cleverer geeks among you will be wondering why I ever pointed ‘postmaster’ to my main personal account instead of going this route in the first place. Oh, how I wish I had a good answer for you…)

    And so I have done. The difference is positively astounding. I’ve increasingly been in the habit over the last few months of checking my inbox compulsively because I knew that with every click there would be a new “failure” or two or three to erase while I waited for real mail to show up.

    The only email I now receive is actually addressed directly to my email account. Some of it is still spam, but almost all of that is tagged by SpamAssassin at the server level and filtered accordingly by my mail client. I’m overjoyed by the lack of tedium involved in checking my email!

    All I have to do now is break my compulsive mail-checking habit. That, and convince people to actually send me email…

  • Itty bitty site updates

    In case you’re wondering, no I’m not dead. I’m just busy working and resting, by turns.

    Today I made two minor tweaks to this site. On the right side, you’ll see a new button for DeviantArt which will take you to my DevArt page. (I even posted some new art today, whee!)

    On the left side, way down there, is the BlogSnob advert. Yes, I decided to go ahead and put it back on again. I’ve been meaning to ever since Wander-Lust went away, and just now got around to it.

    This evening marks another get-together for Portland-area NaNoWriMo participants. A report on that, as well as other recent activities, will appear here some time in the next twenty-four hours.

    No, really. I mean it.

  • Stop me before I NaNo again!

    I did it last year, and to prove it wasn’t a fluke I’m going to do it again this year.

    That’s right, November is National Novel Writing Month and once again I’m stepping up to the plate. What’s different this time around? For starters, I intend to actually have the key plot elements figured out in advance.

    I’ll pause while you recover from the shock.

    Producing 50,000 words in 30 days isn’t easy, but it’s also not impossible. The tricky parts will be coming up with a good (enough) story, managing it during the month of OryCon, and improving my ability to convey a sense of environment. That’s right, I’m viewing this year’s effort as part of a learning process instead of a simple challenge to pile words upon more words. Go, me!

    Wish me luck, friends. I suspect I’m going to need it.

    (By the way, does anyone else think that this year’s Participant Icon

    is vastly inferior to last year’s?

    Ah well.)
    NaNoWriMo

  • Wanted: Suggestions, feedback, and opinions.

    A year or so back I decided, “You know what I need? My very own anime fanboy page.” And that’s about as far as that idea progressed, sad to say, unless you count two images, a bit of CSS and a very terse placeholder document.

    I’ve done a bit more tinkering in the last couple of days. (Hey, it’s not like I was doing anything else with my time while waiting for that damned AS/400 to fill tapes.) What I need now are comments, suggestions, snarky feedback, whatever… on what I have accomplished so far.

    And by “accomplished” I mean “threw together willy-nilly while tinkering with nearly-unrelated web technology.”

    Anyway… what do you think I should do with it?

  • Massive Anime Review

    So I’ve been making liberal use of God’s own gift to anime fans, BitTorrent. I’ve also been the recipient of considerable kindness from one of my very good friends. And so I now have what could be called the start of a decent anime collection. Since I’ve been dangerously remiss in writing here lately, I figured on making up for that with a great big mass of fanboy geekery…

    Stellvia treads the oft-followed pathway I think of as “students in space.” For all that it bears a passing similarity to Pilot Candidate, it has the good fortune to actually be enjoyable and bear a reasonably interesting plot. (That would be unlike Pilot Candidate, thank you.) The fact that the lead character bears a passing resemblance to Sailor Moon and her best friend bears a passing resemblance to Washuu shouldn’t deter you from trying out and enjoying this surprisingly well-written series. The plot departs from the norm in a few nifty ways (that I won’t spoil here), and the relationships are portrayed in a way that conveys subtlety and depth. Of all the shows I’m currently following, this is the one I most eagerly anticipate new episodes of.

    Onegai Twins hasn’t quite won me over yet, nor has it lost me. It’s a sequel to something I haven’t watched (Onegai Teacher) and as such seems to be treading ground I’m supposed to already be familiar with. This isn’t necessarily a problem, but that will entirely depend on the writing. One wonders at the pseudo-incestuous overtones of the show, but so far they haven’t crossed any really dangerous lines. I’ll keep watching this one and hoping that it really gels into a compelling series, rather than merely a light and amusing diversion.

    Narutaru is… weird. And dark. And cheerful. And, well, it sort of defies description in a few ways. It’s certainly not for young children, no matter how much it might resemble your average “precocious pre-teen befriends cuddly little creature” premise. I’m only four episodes in and there’s already a clear thread of corruption and death running through the plot. It’s compelling stuff, however, and I’m intensely curious to see how things turn out. There are some strong hints given, but I’m not entirely sure those aren’t red herrings. Yet. My suspicion is that the writers are relying more on their ability to turn what looks like an established “type” of show on its ear than they are on truly clever plot twists. I’m willing to be surprised, however. And I will keep watching.

    Chobits may not exactly be new to most anime fans, but I hadn’t seen so much as one episode until a few weeks ago. I freely admit that I wasn’t really prepared to give it a fair shake, given that it’s a show centered on a clueless perv of a boy and a brainless waif of a “girl.” I sort of gritted my teeth and plowed through the first few episodes. Something strange happened along the way. Two somethings, actually. The first strange thing is that I actually found myself laughing at some of the “hilarity ensues” setups. (You know: Boy has to teach cute(sy) girl-shaped robot how to bathe herself. Hilarity ensues. The sort of sitcom-like setups that usually make me groan in frustration.) The second was hints of a very serious underlying meaning to the series. This isn’t to say that Chobits gets all dark and dreary, but it does tackle in some prococative ways what it really means to be in love, and to be worthy of love. At the end, I found myself glad I watched the show.

    Oh yeah, and Sumomo rocks. I just had to say it. The little pink imp grows on you… sort of in the way Chibi-Usagi of Sailor Moon doesn’t.

    Some other shows, most of which I’m still barely started on, include RahXephon (two episodes seen, seems like Evangelion II but without the blatant Judeo-Christian religious overtones, undertones and middle-tones), Noir (what happens when Japanese storytellers pretend they’re French storytellers… mixed results, but mostly pretty damned cool), Vandread (oooh lookie, 3D-animated space combat, and lots of “battle of the sexes” material… quite fun, though) and the X TV series (I’ve seen the movie; it had better damned well outclass that utter piece of dreck). There’s also the handful of Angelic Layer and Card Captor Sakura episodes available that the kids have been enjoying over and over (and over).

    All in all, this is a happy anime-fandom household lately. Hey, don’t knock the notion of having something guaranteed to bring the family together!