Thursday, January 24, 2008

Fifth place ...

And, after going 2-2 in their last four games, the Lakers are now the fifth seed in the Western Conference. They're tied with four teams in the loss column (13 losses) and behind New Orleans. The Lakers best on-the-ball defender after Kobe, Trevor Ariza, is down for 8 weeks. Three of the Lakers four tallest players are out -- Bynum, Chris Mihm, and Vlad Rad.

On the upside, the Celtics are 6-4 across their last 10 games and aren't going to come close to 72-10, but that does the Lakers no good if they don't get healthy again. Healthy, this is a contending team. But they do seem cursed by the injury bug, recent years ...

~~~~~

Having some eye problems -- nothing major, but impacting my efficiency. I've had no time in front of my own computer for the last 2 weeks to speak of, unfortunately, which has slowed me down on a number of areas. Those two new e-books are still hanging fire, and my apologies for that. I did install Linux (ubuntu) on my notebook while on the road last week -- not impressed so far. It failed to recognize my wireless adapter (a fairly standard Broadcom chipset) -- so being unable to get online, I spent some time trying to get OpenOffice to handle my Word documents instead. Mixed results there, too -- Writer doesn't support the ability to center text vertically on the page without using frames, so all my heavily formatted e-books look awful when ported into Writer. I could probably fix all those docs with a day's work, and I may have to, but I wish it just read them correctly.

On the upside, there's PDF export ability built into Writer.

~~~~~

No way the Patriots can lose in the Super Bowl. Inconceivable....

Tuesday, January 15, 2008

First Place ...


The Lakers have the best record in the Western Conference -- tied with Phoenix, but since they've beaten Phoenix twice head to head, which is the first tiebreaker, they're in first place as of today.

Enjoy it while you can, if you're of the Laker Faith: Andrew Bynum's out for 8 weeks -- about a third of the season. If he gets back in mid-March, he has 17 games to round himself back into shape before the playoffs start.

The Lakers' title hopes were a little wishful even before this -- without Bynum they're going to have a hard time staying in the top half of the Western Conference. Now, they look like a bottom half seed, again, and even with a healthy Bynum, winning 4 series without home court advantage is probably beyond them. Winning one might be.

Enjoy it now. The Lakers are better than the Spurs, better than the Suns, better than the Mavericks, and at the top of the NBA.com and Fox Sports Power Rankings. I didn't expect to see that this year -- I half figured Kobe would be traded by now -- and by God, I'm going to enjoy it while it lasts. (Hell, the Celtics even lost 3 of their last four. This is a good week, and I will not look at the Ugliness to Come ... the Lakers play fourteen out of fifteen games on the road starting in late January, all without Andrew. I Will Not Look, And Maybe It Will Go Away.)

~~~~~
Congratulations to the New England Patriots. They're the only team I've seen as an adult I really thought had a real shot at going undefeated, and so they did. And now they get to play the San Diego Chargers in the AFC Championship game, and either the Packers or Giants (they hope) in the Super Bowl. In any event, the only teams I really thought had a shot at upending the Pats -- Dallas and Indianapolis -- are out. So There Is No Chance The Patriots Can Lose Now. No Chance. No Chance At All.
.... Pats fans, I'm doing my best to help out here. I know you appreciate it. No Chance They Can Lose. Period.

~~~~~
Sports is stupid and trivial, and all my SF readers tune out as soon as I start writing about it: through the keyboard I can actually feel eyes glazing over. But that's OK. Greatest thing about a blog, particularly one not selling ads -- all I have to write about is what interests me. If this intersects with what people want to read, then, to quote Jack Handy: "Hey, Progress."

Friday, January 11, 2008

A nice Title-case SQL function

This is written for Microsoft T-SQL, but should work with minor tweaks in most SQL environments. I only know of one guy who reads this blog who also writes SQL (besides me) ... but for him and whoever else may run across this, this will save you some time ...

The problem with most string handling in SQL Server (and other SQL environments) is that it invites programmers to write non-set based code. Every function I've ever seen to put a string into title case ('Something Like This') parses the string, character by character, and writes the output. Functional, sure, but slow (in a SQL environment) -- this code does the same thing, using set-based updates. It's about 15 times faster than the code it replaced:

First, put the string to be altered (Address, in this example) into lower case. I used a temp table while developing this --

UPDATE #TMP
SET Address = LOWER(Address)

UPPER the first character in each Address column --

UPDATE #TMP
SET Address = UPPER(LEFT(Address,1)) + RIGHT(Address,LEN(Address) -1)

Look for the occurrance of a space in the Address column ...

-- WHILE through the available addresses
WHILE EXISTS
(SELECT 1 FROM #TMP WHERE Address LIKE '% %')
BEGIN

-- Replace space plus a character with ~ plus an UPPERed character
UPDATE #TMP
SET Address = STUFF(
Address,
CHARINDEX(' ',Address),
2,
'~' + UPPER(SUBSTRING(Address,CHARINDEX(' ',Address) + 1,1))
)
FROM #TMP
WHERE Address LIKE '% %'

END

--When we're done, we replace the ~ with spaces.
UPDATE #TMP
SET Address = REPLACE(Address,'~',' ')

Conceptually this isn't difficult; lots of string handling code does similar stuff, just without the set-based orientation. The first update statement will update only the first case it encounters of the space + a character, so we keep hitting the recordset until there are no more spaces in it. Then we replace the ~ with spaces, and we're done.

In my environment I have further processing to do after this -- I have to make sure that directionals like 'NE' don't turn into 'Ne,' for example, that MacAdams Drive doesn't turn into Macadams Drive, and so on ... but for most simple title case scenarios, this should suffice, and run quickly -- as I said, about 15 times faster than the non-set based code it replaced.

Tuesday, January 8, 2008

Bugs and Obama

Great piece by JJ Sutherland on Weekend Edition. The page has a link to a clip for "Long Haired Hare" as well -- not the best of the Bugs oeuvre, but not bad: Bugs at the Hollywood Bowl in a feud with an opera singer.

~~~~~

Created the files for Devlin's Razor and Terminal Freedom. Dave Aitel's out of town, so it won't be up on Immunity for a few days yet, but it's coming. (I may change the copyright notice anyway before he gets back, and reupload all those files.)

~~~~~

Been an interesting political season. It looks like Obama may be on the verge of running away with the Democratic nomination -- I think this is a sign of real optimism on the part of Democratic primary voters. If primary voters were more concerned about the general election, they'd elect a more apparently moderate nominee, presumably Clinton. Instead they're going with an unabashed liberal for the first time since Mondale. (Dukakis was a liberal, but he was embarrassed by it; there's no sign Obama is.) I think the calculation with Obama is that he can beat whoever the Republicans throw at him, so no need to fall back to the safer, general-election candidate -- which is what they did with Kerry, four years ago.

It's been a long time since a liberal with convictions was on the national political stage. It'll be very interesting to see how Obama does, and in advance, here's hoping he doesn't get on any small planes any time soon.

I used to vote Republican occasionally, though I haven't done it in the last decade. The modern Southern-based, evangelical Republican party does nothing for me, and the small government, avoid-foreign-entanglements, protect-the-Constitution crowd has ceased to hold any sway in that party, except for genetic sports like Ron Paul. There's no Democrat in the top 4 (Richardson, Clinton, Obama, Edwards) I wouldn't vote for over any Republican, including Ron Paul, who I personally admire.

I think Republicans are going to have a hard time going forward. (Which might draw me back to them, if some of their positions change; historically I'm prone to voting for losers....) The country is growing darker and as whites decline to a sub-50% portion of the population, the Republican Party's either going to grow increasingly irrelevant, or it's going to shed the hardest-core nativist wing of its party, find some way to do business with Latinos, and build a new coalition. Because the old coalition's dying....

Wednesday, January 2, 2008

Chrome, Random Thoughts

chrome

he awoke staggered to the bathroom
brushed his teeth
a foul taste in his mouth,
blood maybe

he went back to bed and dreamed
foreboding, of monsters

it rained and slowly
the wind rose clearing
the light of the full moon gleamed
on the wet grass

he awoke again and
sat in the bedroom
alone
listened to the sounds of the freeway behind the house
the cars the horns
tires on wet pavement
whistle of passage

the monster
came through the window
in a shower of glass
and killed and ate the man and

ever after its nightmares were
of chrome

~~~~

I reworked this from a piece I wrote 15+ years ago -- not sure I like it. I really like the central gag -- a monster who's afraid of cars. But this isn't rocking my world.

~~~~~

I've almost finished the proposal for "The Elements of Speed," my book on database design. I'll probably send it to O'Reilly for starters and see if they're interested -- Tim O'Reilly mentioned me in a blog post recently, so he knows who I am, in any event.

~~~~~

I finally got the edits into DR & TF last night at 3:30 AM. One more pass to make sure I haven't missed anything and they'll go off.

I'd been up about 36 hours straight when I finished the edits -- Wednesday afternoon I took a nap from noon to two, knowing I had to work all night, and then ran until Friday morning. I can't do that the way I used to, but I still like those stretches when I have to execute at top capacity under real stress. Delivered code to two clients, jumped rope with my new jump rope intermittently, went to the gym, wrote several hours, edited several hours, dictated some ideas for a standup routine I'm never going to perform but might put into a character's mouth ssomeday, babysat two groaning databases that had been pushed to their endurance and got them into a happy state, swung Connor by his ankles, and watched some "Babblestar Galactica" with my sons. Good times.

(I kept calling "Battlestar Galactica" "Babylon Galactica" -- one day I popped off with "Babblestar Galactica," and now this is what we call the show at my house. This is one of the problems of watching TV only on DVD -- the world is bored with your discovery of fine work: "Yeah, we knew that." But for those of you like me who only watch time-shifted, sometimes by years -- "Galactica" is hugely entertaining. It approaches Babylon 5 for scope, exceeds it on execution (in every way -- the dialog is merely good, but that's a huge upgrade from B5; the characterization and other writing approach NYPD Blue in good stretches, which I never thought I'd see from an SF show. The acting is first-rate, the cinematography and effects and soundwork kill. But you knew all that already, didn't you?)

~~~~~

I'll post a new draft of the copyright statement in the next few days. I do like the Creative Commons "Attribution-Noncommercial-No Derivative Works 3.0 United States License," though it'll require a little tweaking. If no one has further comment, I'll reissue all the PDF/RTF files to Immunity.

Ran across audio of a speech I gave in D.C. 10+ years ago -- not long after the '94 bloodbath when Republicans took the House. Audio quality's not great, but if I can clean it up, I'll mp3 it and send it to Immunity.