Archive for March 7th, 2006

SJR127: Eroding Tennesseans’ Privacy

March 7th, 2006 by daryl

The speakeasy-type abortion clinic I’ve previously blogged about as a harrowing possible scenario in South Dakota shouldn’t scare only South Dakotans. As progressive and rational as the citizens of Tennessee are renowned for being (ahem, Scopes trial), our government is also seeking to pass legislation that would erode women’s privacy and quite probably force some women into such dire straits. The offending bill is SJR127, and, procedural “WHEREAS” type stuff aside, it reads as follows: “Nothing in this constitution secures or protects the right to an abortion or requires the funding of an abortion.”

According to an alert published by the Tennessee ACLU, here’s why this is a much more dangerous bill than it appears on the surface:

The introduction of this amendment is the result of the ACLU/Planned Parenthood victory in the Tennessee Supreme Court. We successfully challenged several restrictive provisions in the Tennessee Abortion Statute. In September 2000, the Tennessee Supreme Court ruled that several provisions were unconstitutional and that the Tennessee Constitution afforded women a right to privacy regarding their right to seek an abortion. The decision is momentous because it reaffirms the right to privacy found in the Tennessee Constitution.

In short, the idea in South Dakota, Tennessee, and other states is to slowly introduce legislation that erodes women’s privacy so that when Alito and Roberts overturn Roe v. Wade, women in these states will have no rights to an abortion within their states. To pass these laws is effectively to hand state sovereignity on this issue to the federal government.

This matter is of very little consequence to the daughters of the sorts of privileged people who pass such legislation. Their rich white daddies will fly them secretly to the progressive state of their choosing for an abortion should one ever prove necessary. Meanwhile, the welfare mom raped on her way home from her second job will have no choice but to bear an unwanted child she can’t support or rely on an unsafe alternative for an abortion.

If you have an opinion on this issue, please consider contacting the relevant politicians. Tennesseans can find contact information pretty easily using the following links:

Putting the Pieces Together

March 7th, 2006 by daryl

Lennie’s had seven or eight wooden puzzles for months and months now. A couple of them she can probably boast to have had for well over a year, and it’s been long enough since we bought her one that I can’t remember when we did so. She never really mastered the art of the puzzle. She got to where she would get a piece in the right place but couldn’t get it rotated around so that it would drop into its recess in the puzzle board. Eventually, she lost interest, and we shifted the puzzles out of the rotation of the toys we keep out in plain view. Yesterday, Mleeka got them back out, and Lennie took right to them. Her puzzle-working skills flourished during the puzzles’ hibernation, and she now works them almost instantaneously and with no trouble. This morning, we were lying around having family morning time, and she slid out of bed, went into the den to get a puzzle, brought it back, went back into the den to grab a few of the pieces, and had us bring the puzzle up into bed so she could play with it. Tonight, I dumped the pieces to two of her animal puzzles on the floor in a promiscuous heap, and she put both of them back together in short order simultaneously. Somehow, she seemed to know intuitively which pieces went to which puzzle. The two we were working are of slightly different thicknesses (I’m talking milimeters) but are otherwise similar, save that one is mostly of barnyard animals and the other is of savannah animals. She’d pick up one piece and, without giving the other puzzle board a glance, move it toward the right puzzle before she can realistically have had a chance to see which board the piece belongs to. I figure she must either be anticipating which piece to grab from the pile after having seen what spots are empty on the board (this strikes me as being a rather complex bit of thinking for a 20-month-old) or she’s got some sort of intuition about the pieces. The former seems more likely if also — ahem — brilliant. In any case, here’s one more bullet point for her baby résumé.

Lennie and I read a lot of books tonight. We identified pictures (she learned “gnome” and “troll,” though I don’t know that she’ll keep them), and then she did some reading aloud of her own. She did this a lot when she was much younger, holding a book open and babbling in a tone very much like what we use to read aloud to her (which differs, of course, from the phone voice, which differs from the normal talking voice, which differs from the talking to the baby voice). I hadn’t noticed her doing this very much lately, but she revived it tonight, but with a new twist. Amid the babbling, she’ll say words she knows that correspond to things in pictures on the pages. So it’ll be “Duh dn duh poo bah spoon duh fnnruh bear duh dnduh.” At one point, she was saying something that sounded very much as if she was saying “I know how to read.” I can’t imagine that’s what she was actually saying (though it was pretty clear), but I certainly reinforced it and encouraged her to keep saying it.

I’ve been Lennie’s porter this evening. On the way home from an evening session of a singing and dancing thing she goes to pretty regularly, we stopped to get her a smoothie, and when we got home, she was very intent on my holding it for her. Mleeka had gotten a puzzle out and was holding it for her while they did a puzzle on the bed, but when I came into the room, Lennie insisted that I hold it for her: “Daddy hold it.” A couple of other times this evening, she insisted that I hold things for her, a sock once, I think, and then a cloth she had been using as a baby wipe for her doll.

Lennie has quite a music collection. The songs I’ve been listening to most frequently with her of late are as follows:

  • Victor Vito (who eats spaghetti with Freddy Vasco)
  • I Know a Chicken (Lennie dances like crazy to this one and sometimes shakes an egg noisemaker)
  • Monster Boogie (nuff said)
  • Elvira (by the Oak Ridge Boys; it’s campy and awful and great, and I had it on a 45 when I was a kid, so I got it mostly for my own nostalgia’s sake, though what made me think about it in the first place was hearing it on one of those kitschy music compilation TV ads, upon which hearing Lennie did cut a rug otherwise unprompted)
  • Gold Digger (yes, the Kanye West song. I know, I know, we’re bad parents for exposing our child to such lyrics, but it’s a darned catchy tune.)

That’s it for this edition.

Inviting JSON to the Table

March 7th, 2006 by daryl

I’m doing some preliminary work on a project for which it’s been suggested that I consider using JSON rather than XML as a data transport. “JSON?” you ask. “What’s that?” It stands for JavaScript Object Notation, and for those of us who’ve spent a lot of time writing javascript, it’ll look very familiar. It’s a subset of the javascript language and can be described as the convention whereby one represents object members as name/value pairs. In short, it’s a form of serialization native to javascript and is therefore understood by all modern browsers out of the box and by many other programming languages either natively or by simple extension. A javascript function can eval a JSON text string with no additional parsing needed and can then use the decoded values directly. This can be beneficial to web applications in at least two potentially notable ways:

  • It eliminates the need to parse a verbose XML document into an object and then perform operations on the object.
  • The format can be (though isn’t necessarily) less verbose than XML.

Transfer time and processing overhead can therefore be optimized when using JSON in some circumstances. Furthermore, for some uses, JSON might actually save programming effort required on the server side to generate XML from objects or on the client side going in the other direction.

Those advantages notwithstanding, I was originally hesitant to give JSON more than a passing glance. For most web applications that feature the sort of functionality I had in mind (including, as far as I was aware at the time, the one I’m doing R&D for), existing AJAX toolkits fit the bill, and I was inclined to use an existing AJAX toolkit rather than to implement JSON for the sheer novelty of doing so. Consider an editable grid table, for example. You have a text field with an onchange event. On change, you send a small piece of data to the server and you get a small piece of data back that tells the client how to provide UI feedback. None of the three benefits of JSON I mentioned above really apply here, as the data in both directions is small, requires almost no processing, and need not be an otherwise usable object. It’s text out, text in, and minor DOM manipulation. In such a case, JSON provides no real advantage, and you might as well go with a standard AJAX toolkit.

A colleague working on the project with me pointed out some other possible use cases, however, that might render JSON worth further investigation. For example, if the data comes down as an object, it can be sorted and have calculations performed on it more readily on the client side without a round-trip to the server and back per operation. There’s something very appealing to me about this. So I’ll be doing more diligence on JSON.

As my first foray into coding with JSON, I wanted to test the example my colleague brought up. Doing so required me to grab a few libraries, and I haven’t packaged it all up nicely, but it’d be reasonably easy to assemble these things and test this out for yourself if you’re interested. Here’s what you need to grab:

So, in a web sandbox, save the PEAR class as JSON.php and create a file named “process.php” with the following contents:

<?php

include("JSON.php");

$rows = array();
$cols = array();

$colcount=20;

for($i=0; $i<$colcount; $i++){
array_push($cols, "col $i");
}

for($i=0; $i<100; $i++){
$row=array("count"      => $i);
for($j=0; $j<$colcount; $j++){
$row[$cols[$j] ] = substr(md5(microtime() . $cols[$colcount]),0,8);
}
array_push($rows, $row);
}

$response=array(
"error"         => "0",
"message"       => "success",
"payload"       => $rows
);

$json = new Services_JSON();
$output = $json->encode($response);
print($output);

?>

This script generates 100 rows of 20 columns of junk data and returns it as a JSON object. In a real-world application, this would presumably be a data set returned from a database. The XMLHttpRequest issued from your client calls this script and handles the data. Now on to that part of the code. Create a file named index.html and populate it as follows:

<html>
<head>
<title>JSON Demo</title>
<script type="text/javascript" xsrc="sortable.js" mce_src="sortable.js"   ></script>
<script type="text/javascript" xsrc="json.js" mce_src="json.js"   ></script>
<script type="text/javascript" xsrc="xmlrpc.js" mce_src="xmlrpc.js"   ></script>
<style type="text/css">
/* Sortable tables */
table.sortable a.sortheader {
background-color:#eee;
color:#666666;
font-weight: bold;
text-decoration: none;
display: block;
}
table.sortable span.sortarrow {
color: black;
text-decoration: none;
}
</style>
</head>
<body>
<div id="container">
<input type="text" id="thefield" name="thefield" value="" />
<input type="button" id="thebutton" name="thebutton" value="The Button" onclick="json_request(document.getElementById('thefield').value)" />
</div>
</body>
</html>

Note the javascript includes at the top, and be sure to name the downloaded libraries appropriately or to change the file. Now create json.js and populate it as follows:

function json_request(txt){

var myOnComplete = function(responseText, responseXML){
var obj = eval('(' + responseText + ')');
var container=document.getElementById('container');
container.appendChild(make_table(obj.payload));
sortables_init();
}

var myOnLog = function(msg){
alert(msg);
}

var provider = new oyXMLRPCProvider();
provider.onComplete = myOnComplete;
provider.onError = myOnLog;

provider.submit("process.php?txt=" + escape(txt));
}

function make_table(data){
var table = document.createElement('table');
table.className='sortable';
var tbody = document.createElement('tbody');
for(var i=0; i<data.length; i++ ){
var tr = document.createElement('tr');
//Create headers on first iteration.
if(i==0){
for(var field in data[i]){
var th = document.createElement('th');
th.innerHTML=field;
tr.appendChild(th);
}
tbody.appendChild(tr);
//Be sure to start a new row.
var tr = document.createElement('tr');
}
for(var field in data[i]){
var td = document.createElement('td');
td.innerHTML=data[i][field];
td.className=field;
tr.appendChild(td);
}
tbody.appendChild(tr);
}
table.appendChild(tbody);
table.id="table_" + Math.floor ( Math.random ( ) * 100 );
return table;
}

If you get everything linked up correctly, the result should be that when you press the button on the main page, a JSON object is pulled down asynchronously from the server and appended to the page as a table of data. Each such table is independently sortable without round trips to the server and back (and without your having to write sorting validation code to prevent SQL injection attacks, etc.). Of course, this does degrade poorly for browsers in which javascript is disabled. In any case, I’ve modeled one bit of functionality that’s pretty painless to implement using JSON, and I suspect that further work in this direction will turn up even more interesting results.

For more information on JSON, be sure to hit the JSON site.

technorati tags: , ,