Saturday, December 17, 2005

Fun with Python, JavaScript, and AJAX

As I get further and further away from my work on the VSC, I've found that I better keep up with web development technology or I'll fall quickly behind. To this end, I've started building an JSON enabled contact's database for work. I've found that I've been able to learn very quickly using MochiKit, json-py, and CherryPy. MochiKit is great because it allows you to abstract a lot of the garbage you have to worry about using plain JavaScript.

For example, want to grab some data from your backend using JSON?

<!--assume MochiKit is loaded-->
<script type='text/javascript'>
function showData(data) {
replaceChildNodes("userInput", H3(null, data["userFullName"]), "E-Mail: "+data["email"]);
}
function getData() {
d = doSimpleXMLHttpRequest("http://my.backend/user", {userName:getElement("userInput").value});
e = d.addCallback(evalJSONRequest);
e.addCallback(showData);
}
</script>
<input id='userInput' name='userInput' /><input type='button' value='Get User' onClick="getData()" />
<div id="resultBox">
</div>


This horribly rudimentary example would fetch some user data from a backend process and display it inside of the div with id "resultBox". If you've ever manipulated the DOM with JavaScript, or performed XMLHttpRequest operations with JavaScript, you should be able to see the benefits in this code.

Thursday, December 01, 2005

I was standing in a long line at Wal-Mart this evening, because of course, after 10:00pm, they only have 3 cash registers opened. This is very smart of Wal-Mart, considering its a college town, and half of the inhabitants do all of their shopping after 10:00pm... I digress.

I only make this seemingly random observation, because while I was in line at the register, I had one of those cultural introspective moments - you know, where you listen to the conversation around you (noting that at least one jerk is talking loudly into a cellphone as if to say "look it me, I are cool I have an electronic portable talking device!"), look at the gobs of tabloids on the rack next to you, and think to yourself: "what a fucked up society we live in."

EOT

Friday, October 28, 2005

defeated by a coffee maker...

Stupid bloody worthless coffee maker decided it would crap out this morning right after it got past the 4 line. I ended up letting Talitha have the little it did make while I beat, kicked, fiddled, and pretty much did everything I could to finagle the thing into working again. Alas, I was not successful and I had a mean ride into work.

This is the second coffee maker that we've had in 6 months, both from Walmart. I'm going to Target in hopes that I will find one that lasts longer.

Until then, I'll enjoy mediocre work coffee.....

Thursday, October 27, 2005

Hah! The White Sox live true to my predictions. I was sitting at a local drinking establishment with T on Tuesday watching game 3 of the World Series. It was the bottom of the ninth, and the Sox looked like they might take the game into extra innings... At that point, I turned to T and said that if the Sox take it into extra innings, they'll win game 3, and then sweep the series by winning game 4 tomorrow. Sure enough, they made me look like a swami. Perhaps now I can be a sports columnist? (har, har)

B-Dubs trivia last night proved very fruitless, except for maybe the slight hangover I have right now. Our team name, "Encyclopedia Brown and the Mystery of the Extra Friendly Priest", got a great reaction from the announcer, but unfortunately didn't win the best team name. We will have to go back to the drawing board and work with that theme a bit. I wonder what mysteries Encyclopedia Brown will be investigating next week?

Other team names we thought were good:

  • What do hobos and baseball games have in common? Foul Balls

  • Tea Baggin' with Mr. Cooper (actually won with that one)

  • Went looting in New Orleans and all I got was this lousy t-shirt. (lame)

Tuesday, October 25, 2005

banished...

Today is day two of my banishment to the bedroom. You see, Talitha works at home because she can't concentrate at work because of her coworkers. The downside of this is that she also cannot work with me in the same room either. Ergo, I'm spending the evenings in my bedroom in front of the small (non-HD) TV, while she takes up the room with the HD Widescreen, Athlon64 system, and easy access to the kitchen. One the positive side, I am allowed to comfortably work or mess around on the computer and watch whatever I please, guilt free. Last night, I was able to watch Monday Night Football without so much as a derogatory comment ! :-) (Oh my, do the Jets stink...)

Anyways, I think I'm going to play around more with TurboGears, which is some nice glue for a variety of Python components I'm starting to warm up to (CherryPy, Kid, etc...).

Also, for you MoinMoin users who would prefer to use VI to edit their wikis, check out this utility: http://labix.org/editmoin
Works great on any UNIX based OS (haven't tried Windows).

Sunday, October 23, 2005


Talitha and I carved a couple of pumpkins tonight, since Halloween is right around the corner. I was surprised to find out she had never done this before! :-)

I went non-traditional by carving the Purdue `P', and Talitha went for the traditional face.

EOT