Monday, September 22, 2008

Oracle and XML : Random Nodes

So I solved my "scoring XML" problem from a previous post using XSL stored in Oracle.  A simple XMLTransform function later and all of my profiles now get a numeric value. Awesome.

I thought I'd push my luck.  I want to put in a hint system so, for instance, if the user has not filled out the work experience section, he might get a message saying "You can get 10 more points by telling us about jobs you've had."    I could hardwire the heck out of it, but that's no fun.  What I'd like to do is write out a bunch of "hint" elements to the result of the transform, one or more for each section that's not filled out, and then let the interface pick a random one to use.  So if my result said something like:

<ProfileScore>

<Score>10</Score>

<Hints>

<Hint>Tell us about some jobs</Hint>

<Hint>Take up a hobby</Hint>

<Hint>Get some friends to sign up</Hint>

</Hints>

</ProfileScore>

then I'm looking for a way, using Oracle's XML/XSL functions, to return one of those Hint elements.

It's apparently much harder than it looks. :(  The closest I found was something that said I could use "//Hints/Hint[random()]", but Oracle barfs on that syntax.  Doesn't like 'random'.

Everything I googled on the subject comes back with stuff about how to generate random sequences.  I need to select a random value.  One option is to emit each Hint element with some sort of random identifier, and then when it comes time to pick one, just pick a constant.  But that's a pain in the neck as well, since I need to be guaranteed I'll get one and only one result, I would have to make sure (without knowing how many Hints I'm to have) that I have adequately spanned the 1-n space just right with my random numbers.

For right now we're leaving the hints off.  But it bothers me that something that seems simple -- "Get me one of my random children", does not have an obvious solution.

Friday, September 19, 2008

"Scoring" an XML File

Ok, here's a project.  I've got, in XML format, the profile of a user.  It's a relatively fixed structure, so for any possible section I'll have at least an empty element for that section.  For instance if the user has no Interests I will have an <Interests/> block, but no <Interest>...</Interest> blocks inside.  There could be 0 or more <Interest> elements.  This is true for a number of sections.

What I want to do is assign a score to each of these sections, and then say "If the section is empty you get no points, otherwise you get X points."  Then, report the total.  If this sounds like the way LinkedIn does profiles, you're exactly right. :)

I'm trying to decide how to proceed.  In this particular case I need something fast and not very disruptive.  The XML is stored in an Oracle database, and the most awesome solution would be something that either runs directly in Oracle, or maybe an XSLT transform.  I could certainly whip something up in Ruby in the time it takes me to blog this, but that's not really an option since we have to factor it into our production environment.  It'll be a heck of a lot easier to just say "Call this stored proc to get the score" then to explain why we need to start installing Ruby on the production boxes.

Anybody got any brilliant ideas?  I'm trying to XSLT solution, directly in Oracle, but it's not going smoothly.  I'm wondering if there's enough flexibility in XSLT to do this level of math.

Thursday, September 18, 2008

IPod : Beware of Powered FM Transmitters

I've had this happen before, but never quite so severely.  So I thought I'd post a warning.

As most folks know, the iPod is smart enough that if you unplug the headphones, it pauses any music that you were playing.

But if you're in the car and using a powered FM transmitter (such as those by Griffin), they don't plug into the headphone jack, they using the docking/syncing port instead.  And you know what?  If you're playing music that way, and you unplug it, it doesn't stop playing.  This can be incredibly annoying, because unless you actually notice the little triangle in the upper right corner of the screen, there's no way you could ever know.

Unless you're like me, who has a smart playlist of "New Podcasts" tuned to erase things after they have been played once.

:(

I woke up this morning to find my iPod almost completely out of battery, and every single one of my podcasts played (and, hence, gone).  For the curious it looks like I get about 10 hours of MP3-playing battery life :).

That's annoying.  Worse, iTunes has that self-managing "keep only unplayed podcasts" feature as well, so the act of plugging the device back in (to power it up!) also triggered a sweep of the files themselves, so they're gone from my laptop as well.  If I want to get them back now I have to selectively go through my podcasts, remember which ones had unplayed episodes, go back to iTunes Store, and re-get the ones I missed.

Tuesday, September 16, 2008

Dilbert : On The Economy

http://www.dilbert.com/blog/entry/dilbert_survey_of_economists/

Scott Adams, creator of Dilbert, wanted to get an informed opinion on the coming political election.  Specifically on the subject of the economy - which candidate would be better for the economy?  So he set about finding out.  He's published the results of his survey of over 500 economists.  It's actually pretty cool.  Be sure to read the raw data (Powerpoint), not just the summary.  Judge for yourself.

Don't want to read it, I'll hit you with the highlights.  Economists are generally Democrat, and Democrats favor Obama, Republicans favor McCain.  Big surprise.  However, the independents prefer Obama nearly 2:1 as well (Summary of Key Findings #4, page 91).  When you add them all up, on 20 issues considered important to the economy, Obama is seen as the better choice for 16 of them, including 11 of the 12 deemed most important (by the economists, not the survey people).

Some folks still call it inconclusive because it's not imbalanced, but it's probably more unbiased data on the subject in one place than you're gonna get on the news any given day.  Worth a read.  Pick the issues that you think are important and make your own decision.

Monday, September 15, 2008

Verizon FIOS DVR : Needs Work

I never liked Comcast.  I just don't like monopolies in general, I think it gives them too much freedom to just charge whatever they can get away with.  So when FIOS came to my town I was quick to get on the list and switch over. 

I love the service.  Love the technology, love the customer support, love the whole experience.

Except the DVR.  The DVR is not quite done.  I came from years of Tivo, and begrudgingly tried Comcast when I went to HD and didn't want to get a new Tivo box.  Verizon offers some things that sound like good ideas at first, but when you look under the covers, there's a problem.

The big feature of FIOS is the "home sharing" option.  This is what they hype in commercials - that you record on one tv, and you can play back immediately on any other tv in the house.  This is true, as far as it goes, but it's true like a political commercial is true.  It's not long before you learn the real details behind the scenes.  For instance:

* When playing back a shared program, the response of the controls on the box goes through the floor.  Don't even think about fast forwarding through your commercials, because by the time you get the Play button to register you'll now have to go backwards a minute or so because it fast forwarded so far when you didn't want it to.

* You can't "downscale".  So if the box you're recording on records a HD signal, and you have a standard tv in the other room? You're out of luck.  So for all of your programs you have to decide whether you want to share them, or use HD, because you can't have both.

* Last but not least, here's the big one.  You can only have one sharing DVR in the house, because it has to be the hub.  It is NOT true that you can record on any tv and playback on any tv (note how carefully they do not say this in the commercial!)  You can record on *one* tv and playback on any tv.  So that means if it's 5 minutes before you want to go to bed and you remember something you want to record (Saturday Night Live, for example?) you've got to get up, go to whatever room has the DVR box, and set up your recording there.  Even though you can remotely play programs, you cannot remotely record them.  You can't send a signal from a standard box to a DVR box saying "Record this."

None of these things makes me want to go back to Comcast, but they were certainly disappointing.  If I get another HD tv then maybe I can stream HD content (the tech told me that can't be done, but he also told me that you can't record two programs at once, and that is not true).  But the response time thing is pretty painful, and the "Can't record from any room" is really annoying, especially to those of us that used to have a couple of Tivo boxes. 

There are other little things that are annoying - the guide, for instance, is almost unusable with so many channels moved around, and there is no graphic bar like Tivo had to tell you how far along you are in your program (nor, as far as I can tell, is there the equivalent of a "15 minute skip" when you want to jump to the end of the program).  But it's still the way to go technologically and I expect most if not all of these problems to be fixed in no time.

Monday, September 08, 2008

Why Is My Beep So $%^&*( Loud

I have googled everywhere for this but I can't find an answer.  The error beep on my machine -- the one associated with errors, typically in a shell window but not always - is so effing loud I can't stand it.  I have headphones on, listening to music at comfortable volume, and seriously, when the beep comes on it is so loud I grab for my headphones to rip them off, every time.  It's painfully loud.  In some cases it's also painfully long.

In the Control Panel / Sounds thingie, none of the Windows sounds seem to map to it.  We're talking about the Control-G beep sound, for any old timers who remember THAT.  (Try it in a DOS window, it still works :))

It's killing me :(.  Trying to write code is like some messed up Skinner experiment where everytime I make a typo I'm punished with an electric jolt.

 

UPDATE:  Found it!  From a shell window, "net stop beep" to make it die.  Woohoo!  It was the remembering of Control-G that led me to the solution, found here :

http://blogs.msdn.com/larryosterman/archive/2005/11/04/489135.aspx

which is an "old fogey" discussion of how you used to go about actually writing to the hardware to make the beep, until it turns into a "How do you turn it off???" request.  Oh I am so pleased.  Turns out it is actually a service (beep.sys) that you can stop.  However it does not seem to appear in the Services menu.

Sunday, September 07, 2008

...Therefore I Am?

Today I'm wearing my Geek "mechanics" shirt, with the normal name patch over the left chest pocket reading "Geek."  At work I've always gotten amused compliments, entirely from people who obviously know me and get it.

Today I'm at the gas station filling up, and the attendant says, "Why does your shirt say Geek on it like that?"

....how do you answer that, briefly?

I told him, "It's a computer thing."  I don't expect he cared for a longer philosophical debate.