KBD

Keith Devens .com

Saturday, July 5, 2008 Flag waving
Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will... – Eric S. Raymond

Archive: April 14, 2004

← April 12, 2004April 15, 2004 →

Daily link icon Wednesday, April 14, 2004

Stripeless Zebra

"Rangers in Nairobi, Kenya are puzzled by the discovery of a baby zebra born without stripes, according to a Local 6 News report."

A sure sign of the impending apocalypse.

The song, not the singer

Via IP comes a great post on Blogcritics.org: The Song, Not the Singer: Bush On the War.

Haha, "Airheads"!

Haha, Airheads.

I've tried to listen to Air America. Unfortunately I've only gotten to hear the woman who's on opposite Sean Hannity (I think her name is Rhodes?). The station is very weak so I only get it (weakly) during a portion of my drive (WABC, OTOH, I get from everywhere). It's funny though, because she's often so predictable I can say what she says before she says it. I only had to listen for about a minute the other day to get a Bush=Hitler reference before I turned it off.

Update: Thoughts on Air America here. Plus, Drudge has a hilarious headline up right now:

AIR AMERICA 'BOUNCES CHECK'; LIBERAL RADIO NET TAKEN OFF AIR IN LOS ANGELES, CHICAGO AFTER ONLY TWO WEEKS

After just two weeks on the air, Air America Radio, the fledgling liberal talk-radio network featuring Al Franken and Janeane Garofalo, appears to have encountered serious cash-flow problems.

The CHICAGO TRIBUNE is developing a story, insiders tell DRUDGE, on how the network was pulled off the air this morning in Chicago and Los Angeles, the network's second- and third-largest markets, because, the owner of both stations said, the network bounced a check and owes him more than $1 million! A charge the network strongly denies...

A Chicago source familiar with the situation said a Multicultural representative showed up at WNTD's offices Wednesday morning, kicked out Air America's lone staffer overseeing the network's feed to the station from New York, switched over to a Spanish-language feed, and changed the locks on the doors...

Air America filed a complaint Wednesday in New York state Supreme Court charging Multicultural with breaching their contract and seeking an injunction to force Multicultural to restore the Air America broadcast on both stations, the TRIBUNE has learned... Developing...

What the hell... they're financed by a billionare. At least it's still on in NY. I want to catch Garafolo's show Smiley

Update: Links at InstaPundit. Ryan's comments were good. I got to listen to Garafolo's show a little bit on the way home tonight and they had someone on explaining the situation. If their side of the story is completely true, then they're not at fault, and I hope they get things straightened out. They're taking things to court, so we'll all see what the courts decide.

Gas is cheap! (Or... games Democrats play with the economy)

Via Dane Carlson comes this neat blog post backed up by actual data showing how gas prices now are historically very cheap. It's also worth mentioning that gas prices in the US are far lower than they are in pretty much the rest of the world.

It's like the deficit, which is enormous in raw dollars, but isn't historically large(PDF) as a percentage of GDP. Here's some of the raw data. Not that I support having a deficit or think it's not a problem, but it's just not that high historically. If the drunken sailors in congress can just sit on our collective wallet we should be able to grow out of it like we have in the past.

These things are interesting just economically, and I didn't start this post to take a jab at Kerry, but I feel compelled to point out that facts like these show that Kerry's complaints about gas prices and such aren't very serious. The Democrats constant harping on how "bad" the economy is is fundamentally dishonest[1], and ultimately unhelpful (to say the least), given that so much of economic activity is driven by collective psychology.

Footnotes:
[1]: I find it funny that Kerry invented a new 'misery index', which is completely different from the conventional and well-established "misery index", that's of course designed purely to point out whatever negatives he could find. One consequence of it is that it makes 1978 (Carter's "stagflation") appear to be a better economic situation than now!

XML Serialize

This code has been a major part of my XML-RPC library from the beginning. It takes a PHP data structure and serializes it into XML (simple).

For example, the following PHP code:

<?php
$foo 
= array(
    
'foo'=> array(
        
'bar'=>array('blah','<i>blah</i>'),
        ),
    
'foo attr'=>array('att1'=>"this isn't the best song in the world"'att2'=>'this is only a "tribute"')
);
echo 
XML_serialize($foo);
?>

Generates the following XML (reformatted slightly):

<?xml version="1.0" ?>
<foo att1="this isn't the best song in the world"
att2="this is only a &quot;tribute&quot;"
>

    <bar>blah</bar>
    <bar>&lt;i&gt;blah&lt;/i&gt;</bar>
</foo>

I've recently revised the code as part of getting rid of my CMS. I was generating my RSS feed for my weblog with a template, when, since it's data, it should really be generated by a library from a data structure. The result was simpler, shorter, and more maintainable than what I had before.

Here's the code:
Update (Jul 24, '04): Code removed. An updated version is available at http://keithdevens.com/software/phpxml

Note that the data you send to XML_serialize had better already be in UTF-8 or you'll be generating invalid XML, and it's your responsibility to not try to generate invalid XML tag names. The $data passed to XML_serialize must be an array containing one element, which is the top-level element of the XML document. If you want to do namespaces, just do it manually by adding namespace attributes to the top-level element, and prefix your tag names with the appropriate namespace name.

For example, here's essentially how I go about generating my RSS (code altered slightly):

<?php
function weblog_rss(){
    
$xml = array();
    
$xml['rss attr'] = array('version'=>'2.0');
    
$xml['rss']['channel'] = array(
        
'title'=>"Keith's Weblog"
        'link'
=>'http://keithdevens.com/weblog'
        'description'
=>'The personal weblog of Keith Devens',
        
'language'=>'en-us',
        
'image'=>array(
            
'link'=>'http://keithdevens.com/weblog',
            
'title'=>'Keith Devens .com',
            
'url'=>'http://keithdevens.com/images/kbd.gif'
        
)
    );
    
$rss_items = array();
    
$entries = &weblog_getEntries();
    require_once(
'markup_library.php');
    require_once(
'xml_library.php');
    foreach(
$entries as $e){
        
$timestamp convert_mysql_datetime($e['creation_datetime']);
        
$url 'http://keithdevens.com'.weblog_getUrl('entry'$e);
        
$rss_items[] = array(
            
'title'=>utf8_encode($e['title']),
            
'link'=>$url,
            
'guid'=>'http://www.keithdevens.com/weblog/'.$e['id'],
            
'guid attr'=>array('isPermaLink'=>'false'),
            
'description'=>utf8_encode(markup($e['text'], array("enable_abs_links"=>true))),
            
'pubDate'=>date('r',$timestamp),
            
'comments'=>$url.'#comments'
        
);
    }
    
$xml['rss']['channel']['item'] = $rss_items;
    
header("Content-type: text/xml");
    echo 
xml_serialize($xml);
}
?>

All of this code should be translatable to pretty much any other scripting language. The only issue is that PHP maintains the order of keys within an associative array while most other languages don't. So, if that's important to you, the code won't be applicable in other languages as it is in PHP. However, since this is meant for data-oriented XML anyway, the order of keyed elements probably won't matter to you.

I don't look at XML as some change-the-world semantic-web savior. It's just a relatively pain-in-the-butt-to-use file format. I may release this code as well as my parser code as an open-source library separate from my XML-RPC library, though to some degree both will be obsoleted by SimpleXML in PHP 5. Anyway, consider this code public domain.

Update (May 28): I've updated this code and released it along with its corresponding XML_unserialize function as an open source library, available at http://keithdevens.com/software/phpxml.

← April 12, 2004April 15, 2004 →
July 2008
SunMonTueWedThuFriSat
 12345
6789101112
13141516171819
20212223242526
2728293031 



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

Recent comments XML

Girls, please don't get breast implants

> And no, you will not be receiving​a picture.

:-(...

Keith: Jul 2, 6:05am

Javascript clone function

This is a clever way to clone an​object if you are using YAHOO UI.​Same tec...

Antonio: Jul 1, 12:47pm

I hate Norton Antivirus

Oh just one other thing norton is​great at keeping people out of your​compu...

kevin.sands: Jul 1, 12:50am

Terminator 3 was awful

I think the biggest reason why T3​totally blew was because Edward​Furlong g...

76.167.172.64: Jun 29, 3:06am

Generated in about 0.051s.

(Used 7 db queries)

mobile phone