Monday, November 20, 2006

Ruby : Split ignores empty fields

I was very annoyed today to discover that the split method in Ruby, which turns strings into arrays, was behaving erratically when it came to blank fields at the end of the string.  For instance:

"1,2,3" => [1,2,3]   that is correct, but

"1,2,3," => [1,2,3]   which is not, I'd expect a fourth, empty field.

Turns out that split has a "limit" parameter which controls this.  Here's the doc for it:

If the limit parameter is omitted, trailing null fields are suppressed. If limit is a positive number, at most that number of fields will be returned (if limit is 1, the entire string is returned as the only entry in an array). If negative, there is no limit to the number of fields returned, and trailing null fields are not suppressed.

In other words if I do this, "1,2,3,".split(",",-1) then I get what I wanted - [1,2,3,'']

Not sure why that rule is there, but there ya go.

 

Technorati tags: , ,

Tuesday, November 14, 2006

My Inspiron : Happy Ending!

I haven't posted for a bit on this story (originals here and here), so this will be a long one.  Luckily, it ends happily :).

Context : Had a Dell Inspiron 5150 laptop.  It stopped charging, and I gave up on it.  Then came notification of something called the Lundell Settlement which basically said that if you had such a machine with such a problem, you could get it fixed.  I sent it in, and on top of that a Dell customer advocate apparently found my blog on the subject and checked in to see if he could help me with anything.

Let me just say that it was great to have such a personal contact with customer support.  At first I thought that I should only use that channel for special circumstances, and was still working my way through the automated voice units until Todd just said, "Don't even go through that path, just tell me and I'll get you the info."  Gotta love that.  He even called me instead of emailing all the time.

So, back to the story.  There was a bit of a problem at first when they got the machine open.  I was told that the problem was damage from a spill, that it affected motherboard, video and keyboard, and that it was not a covered problem.  That it would be very expensive.  This was a complete surprise to me, and I ranted like a crazy person.  This had been my daily machine.  I'm the kind of geek that carries his laptop with him daily.  I used it up until the day it wouldn't charge anymore.  I did not have any memory of a spill.  So needless to say, I was upset.  I even accused them of just randomly pouring liquid onto machines on their end, just so they wouldn't have to fix them.

Todd listened quite calmly, told me all about how the system works (they have an independent group Solectron that evaluates the systems, that Solectron gets paid regardless, and so on).  He said that he would request that they re-evaluate the system.

I thought it was over at that point, and started lobbying to get the machine back.  Would I be stuck shipping it back to myself?  Would I be charged for repairs that I didn't expect?  Todd swore to me that there'd be no such costs.

And then, good news!  I get a call back to tell me that they re-evaluated the system and:

 * The only moisture damage was not evidence of a spill, and was only on the shielding, which I am not liable for.

 * The AC adapter is loose at the motherboard, so it is not charging, and that requires a motherboard replacement.  Which I am also not liable for, as this is apparently the original problem we were trying to discover (well, no kidding :)).

I had the machine back within days. No charge to me (shipping or otherwise), and I'm happy to report that I have my computer back!  I'm pleased.  This machine is destined for my family room for games and email.  And yes, it will run Linux.  I'm thinking Ubuntu.

Thanks Dell!  Nice service.  Was Todd scanning specifically for mention of the Lundell case?  I don't know.  Did my machine only get serviced like that because I had an advocate on my side?  Again, who knows.  But I'll tell you, if you've got an Inspiron 5150 that stopped charging on you, you're gonna want to go check that out.

 

 

Thursday, November 02, 2006

.NET : A Potentially Dangerous Request.Cookie (HttpRequestValidationException)

Had an interesting problem today.  While working on an ASP.NET web service that worked fine the other day, I suddenly start getting this error, immediately upon hitting my code, about "A potentially dangerous Request.Cookie".  Just this past week I installed our main product on my laptop and hit it via localhost, therefore dropping a cookie.  In other words, a cookie that we're dropping is considered "potentially dangerous" by .Net.   It's annoying, since I can't really ignore it (you can't try/catch it, because all attempts to access the Request object throw it), and I can't go and change the product at the drop of a hat, either.  I know that it's not a malicious cookie.

Turns out there's a simple solution.  To your @Page directive, add ValidateRequest="false".

Easy!

The more I think about this, it's an interesting error.  If my .Net code can only read cookies from my own domain, does that imply that it thinks I'm sending malicious cookies to myself?  Or that somebody is actually going into their own cookie file and modifying the cookie before sending it back?  Not really sure what this is protecting against, since it runs on the server, not the client.  That implies that the client is trying to be malicious toward the server, rather than the other way around.  That's a new one on me.

 

Technorati tags: , , ,

Wow - Dell Customer Support Comes Through!

Ok, check this out.  A couple weeks ago I blogged about the possibility of bringing my Dell Inspiron 5150 laptop back from the dead.  Seems that my problem, where it fails to powerup anymore due to motherboard problems, was a problem for many people indeed.  In something called the Lundell Settlement, Dell agreed to basically fix them all.  So I figured what the heck, I never through the thing away, I might as well send it in.

After a few emails back and forth, they confirmed that this would be a motherboard fix and then sent me a box in which to pack the machine.  I DHL'd it back and have been waiting to hear back on its status.  This was just over the last few days, so I'm sure it's still being processed.

But!  Imagine my surprise when, completely unsolicited, a "customer advocate" from Dell contacts me and says "Hey, I saw your blog and wanted to make sure that you were getting all the help you needed.  Anything I can do for you?"  I wrote back to him with an update (thinking the whole time that this could turn out to be the weirdest phishing scam ever :)) and not only have we been having an ongoing conversation, but he (Todd, by the way) responds in very short time indeed.  It's not like it takes 2 business days to get a response.  It's like I've got my very own contact person at Dell.  Someone, I might add, who is NOT offshore outsourced, nor going through a script and saying things so generic they border on offensive like "Ok I understand that you are calling to ask about a motherboard problem, I can help you with that, for security purposes can I please ask your mother's maiden name?"

So, I'm very impressed that Dell did that.  I don't know if they're always out there ego surfing the blogs, or if there was something about this particular settlement that's got them anxious to please.  Either way, if my machine manages to get fixed, I will be a happy customer indeed.

Thanks Todd!

 

Technorati tags: , , , , ,