KBD

Keith Devens .com

Thursday, August 28, 2008 Flag waving
in God I trust; I will not be afraid. What can mortal man do to me? – David (Psalm 56:4)

Archive: May 21, 2002

← May 20, 2002May 22, 2002 →

Daily link icon Tuesday, May 21, 2002

SET

Whatever happened to SET?

Buffy finale

So... Spike got his soul back. Interesting. I actually read someone predicting this last night, but I don't remember where. Gotta find it.

I'm pretty sure it was on the WB message board for Angel (they use phpBB!). Can't find the exact post because the bastards make visited links the same color as unvisited links. Smiley

StructuredText Extensions

I just coded the extension framework and the first extension (a PHP code highlighter) into my StructuredText markup parser.

Here's the extension function that highlights PHP code:

<?php
function markup_code(&$document$position$args){
    
$count count($document);
    if(
$position $count){ #if we're not already at the end of the document
        
$source '';
        while(
$position $count and $document[$position] != '?!/code'){
            
$source .= $document[$position] . "\n";
            
$document[$position] = ''#clear each line as we see it
            
$position++;
        }
        if(
$args['language'] == 'php'){
            
ob_start();
            
highlight_string($source);
            
$source ob_get_contents();
            
ob_end_clean();
        }
        
$document[$position] = $source;
        
$position++;
    }
    return 
$position;
}
?>

I probably have to do some more work to ensure that nothing bad happens if the extension text isn't ended, for instance, but I'll do that after pizza, and Buffy, and Smallville Smiley

Ok, it worked on my test script, but not on my homepage. Gotta fix that after I finish eating.

Oh, duh. It wasn't broken, I neglected to put the <?php at the beginning of the code sample Smiley

CityScript

Some neat bits about CityScript, the little language built into CityDesk, via LtU.

Printer Friendly

Just got this message via my mail form:

Hey Keith,

Here's something you could add to your weblogging software - a `print this page' button. I found myself wanting to print a discussion but couldn't.

I actually already have printer friendly pages, just no link for it. For instance, a printer friendly home page is at http://www.keithdevens.com/?printer_friendly=1. However, because of the way I parse the query string for my weblog entries, this doesn't work right. Real easy to fix, and I'll fix it tonight.

(< 10 min later) Never mind, took only a few minutes to fix, so I fixed it. Check out the printer friendly page for this entry.

(A few more minutes later) Ok, now I added a "Printer-Friendly version of this page" link to the left nav.

I hate Norton Antivirus

With my Windows Script Host stuff I've been doing, Norton Antivirus has been complaining that I'm using the WSH. Since there have been so many worms/viruses that have spread using it, NAV just stops all script activity. There's an option to exclude files, but... It doesn't work. I'm very frustrated.

Fun stuff with my markup parser

I'm working out an extension syntax. From my comments in the to do list:

Add code blocks

  • Maybe I'll put in code blocks as my first extension! That's a good idea!
    • My extension syntax will probably be something like this: ?!extension_name:param1=value1&param2=value2
      • How do we escape "=" and "&" within the strings? URL encoding really isn't acceptible. It should really be just \= and \&, but that makes the result a little harder to parse. It's not a simple split anymore. Actually, I guess it could be a preg_split with a "negative lookbehind assertion". Nice! Problem solved. Regexes are good.
    • So the code extension will be something like: ?!code:language=php <- this way we can have language specific highlighters even Smiley
      • An extension function will be passed a reference to the markup, plus the current location, plus any parameters automatically parsed into an array.
      • An extension function must return the location at which to pick up parsing again.
        • How does this interact with some of the flags, such as the "output_directly" flag?
        • Ok, when the function returns, if "output_directly" is on, the master parser immediately outputs all lines from the start line passed to the extension to the end line number the extension returns. This implies that an extension must not modify lines above where it starts.
          • Are there any cases where we'd want to be able to modify output above where the extension starts?
      • The nice thing is that the extension function will have access to the entire document, so it can do whatever it wants. It chooses when to end, etc.
        • But how do we keep this regular so it'll be obvious when an extension ends? Must it be "?!extension_name" (maybe "?!/extension_name"?) again? That implies that each extension knows what its own name is, but that's not a big deal
        • The alternative is to have a consistent "end_extension" flag that every extension has to adhere to.
          • The first way, we have a chance at being able to do nested extensions.
          • But the second way is more regular
          • I have to think about it.

Windows Script Host

I just had to do some stuff with the Windows Script Host tonight, so I added links to it on my programming page.

Oh yeah, this reminds me of a funny story. When using the FileSystemObject in ASP once, I forgot to specify a directory to write into. Actually, strike that, I assumed it would write to the current directory (the same directory of the ASP script) if I didn't specify a directory. Anyway, the file was being written, but I couldn't find it. Turns out it was being written in the Windows NT system directory (c:\winnt\system32). That's awful! I couldn't believe it. Windows is awful. Not to mention that ASP crashed on us every other day. I don't remember whether we ever got resolved whether it was the ODBC library (which had many documented memory leaks), or the ASP.dll itself.

Angel

Pretty good Angel tonight. I hate season finalies. Smiley I mean, I love season finalies, except I hate that I have to wait months to see another new episode.

I suppose the main thing I'm not happy with is the abruptness with which Cordelia's powers were revealed. She went from not knowing what her powers were, to becoming a "higher being" in what, like four episodes? But most importantly, is she leaving the show?

Oh yeah, and I thought Vampires die if they don't drink blood?

Update... I'm trying to find out if Charisma Carpenter is leaving the show, so I'm reading all kinds of Buffy/Angel news looking for it. This is a really neat review of this season of Buffy, and the person caught both the Willow forshadowings that I've caught before:

Those are the same words ["Bored now"] that Vamp Willow uttered in season three's "Doppelgangland." This is the second time the show has picked up on something that was foreshadowed in that episode. The first being Willow's declaration that she thought Vamp Willow was "kind of gay."

The article continues to talk about tonight's season finale, which I'll have to read afterwards! Smiley

Oh, and Angel is moving to Sunday which is kind of awful. This and the previous link from Slayage.com.

Gentoo

Via e7l3, an interview on OSNews with one of the developers of Gentoo Linux.

New Graham Article

Via Lemonodor, a new article by Paul Graham, Revenge of the Nerds.

Believe it or not, there is a reason Lisp code looks so strange. Lisp doesn't look this way because it was designed by a bunch of pointy-headed academics. It was designed by pointy-headed academics, but they had hard-headed engineering reasons for making the syntax look so strange.

And yet these ideas turn out to be responsible for both Lisp's strange appearance and its most distinctive features. Lisp looks strange not so much because it has a strange syntax as because it has no syntax; you express programs directly in the parse trees that get built behind the scenes when other languages are parsed, and these trees are made of lists, which are Lisp data structures.

And this is awesome:

If you try to solve a hard problem, the question is not whether you will use a powerful enough language, but whether you will (a) use a powerful language, (b) write a de facto interpreter for one, or (c) yourself become a human compiler for one. We see this already begining to happen in the Python example, where we are in effect simulating the code that a compiler would generate to implement a lexical variable.

This practice is not only common, but institutionalized. For example, in the OO world you hear a good deal about "patterns". I wonder if these patterns are not sometimes evidence of case (c), the human compiler, at work. When I see patterns in my programs, I consider it a sign of trouble. The shape of a program should reflect only the problem it needs to solve. Any other regularity in the code is a sign, to me at least, that I'm using abstractions that aren't powerful enough-- often that I'm generating by hand the expansions of some macro that I need to write.

Wow

Also check out Design Patterns in Dynamic Programming by Peter Norvig, which Graham links to.

Finally, check out this story about a company (Orbitz) who used Lisp effectively in building its travel system. I got the link from http://imperialviolet.org/, but he has no permalinks!

See discussion on LtU. And funzel is right, Python does have lexical variables now.

← May 20, 2002May 22, 2002 →
August 2008
SunMonTueWedThuFriSat
 12
3456789
10111213141516
17181920212223
24252627282930
31 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 1 posts

Recent comments XML

new⇒Girls, please don't get breast implants

http://war-11.ucufyod.net​http://jewelry-26.wohiles.net​http://games-52.ruz...

Randolph: Aug 28, 5:16am

Generated in about 0.102s.

(Used 7 db queries)

mobile phone