Reg exps, they’ve always been my favs

Today I had a busy/kind of caotic day at work, not much of coding, just preparing excel files out of the SQL Server tables to hand to a translation team. It was soo time consuming and all I wanted was to get back to programming.
Anyways, feeling a little bit frustrated today, I arrived home and remembered I had this job a friend wanted me to do to filter some footers from email messages, I had to remove the original messages from the text.

My target phrases would be like the following ones:

On Tue, 2 Aug 2005 16:14:10 -0500 "Eric Marr"
<northland@charterinteret.cam> writes:

--- <fe.sola@infom.cu> wrote:

On 8/1/05, Belayer via sql-l
<sql-l@groups.ittoolbo.cem> wrote:

So it definetely cried out for regular expressions.
I downloaded the best tool for testing reg exps.
The freeware Regex Coach
My thumbs up for this tool,
I'll donate some money to it as soon I as clean up my CC, heh.

I came up with some reg exps that needs some extra tuning,
they are here on this text file
(Blogger complains of script injection, hehe)
Text file with RegExps

The php function for the final clean up
might come in a following post.
Cheers,
PG



Thomas Hinds Tobacconist

Finally, the tobacco store is launched, here’s the official Thomas Hinds Tobacconist’s website. I sometimes do php work for friends, like this Tobacco Store that is based in downtown Toronto. They have the best Cuban cigars in the market, guaranteed 🙂
Thanks to the Zen Cart team for their wonderfull support, special thanks to QDixon, yes I owe you a box with Robustos. Thanks to Luifo for the terrific 3D tour, Idania for the nice design and the crew at Thomas Hinds for the help and support.
I hope you step in and enjoy the visit.

Ajax, a gal can dream.

There’s a lot of buzz lately on Ajax and the new web experience. Coming from a windows programming enviroment I, like almost any other programmer, found web interfaces quite orthopedic, let alone to compare them with 3D games.
Today I found one of the best blogs on Ajax, and in particular this article about the drawbacks and gotchas of making a fully async web site (see the article here)
My goal for web user interfaces, remember Minority Report? Where Detective John Anderton plays with its highly rich UI to display videos of the precog’s dreams? Hopefully we won’t have to wait till 2054 to have these UIs implemented
Oh well, a gal can dream…

Today, no techie stuff. Promised

I’m beginning to get quite fond of blogging, it somehow helps me to remember what I did a week ago or on what I spent/(wasted?) my time.
So…
Dear Diary:
Last Thursday evening I spent most of my time talking of books with my friend, Eric (there’s no url here cause Eric has his server down at the moment), the conversation didn’t start right on the books thing, but as good friends we are, we let out minds wander from one subject to another and ended up talking about books and the characters we miss the most, after closing the last page.
Eric’s favorite character was a warrior of a fantasy book, I’ll post the link as soon as I find the book at amazon.
Probably Obscured by Code’s blogger already knows all this, as we’ve read more or less the same books, my favorite characters, they happen to be females most of them in order of reading:

  • Lady Jesssica, Paul’s mother on Dune, the reason, all her Bene Gesserit knowledge.
  • Ellie Arroway, in Contact (the book, not the movie), the reason I liked the character, she was fond to playing with signals, white noise, math transforms and why not, if anyone ever talks about Fourier series, my sympathy is taken, for granted.
  • Arianne Emory, in Cyteen, the original Ari, not the clone, the reason, well, it’s hard to tell, she highly qulaified as “evil witch” but somehow her work and dedication outlived her.
  • Lysis de Mileto on “The eye of Dyndimenio”, no link at amazon.
  • Ok now, three male characters I have had a crush on, Aragorn, but what girl wouldn’t fall in love with him, Paul’s father in Dune and the lonely Case in Neuromancer.

Calling a SPROC gotcha

I dunno if I mentioned before that I changed some of the SPROCs in the company databases to accept multiple cultures (this is, retrieve values in multiple languages from the new tables). The main problem is that the company already has more than 10 applications working with those same databases, so the new changes in the SPROCs had to run smoothly without breaking any other application.
I became paranoid, heh, well, close to it.
To day I was veryfying one of the oldest web apps and noticed that one of the dropdownlists that gets the data from the SPROC Q_Regions was blank, gosh!
I promptly opened my Query Analyzer to try figure out what was going on and run this two scripts:

DECLARE @RC int
DECLARE @regionlist varchar(100)
DECLARE @minlevel int
DECLARE @maxlevel int
DECLARE @sitelist varchar(25)
DECLARE @industry char(1)
DECLARE @culture char(5)
— Set parameter values
EXEC @RC = [IRONSearch].[dbo].[Q_Regions] @regionlist, @minlevel, @maxlevel, @sitelist, @industry, @culture

and the script setting the params:

DECLARE @RC int
DECLARE @regionlist varchar(100)
DECLARE @minlevel int
DECLARE @maxlevel int
DECLARE @sitelist varchar(25)
DECLARE @industry char(1)
DECLARE @culture char(5)
— Set parameter values
set @minlevel=10
set @maxlevel=30
set @sitelist=’1′
set @culture=’en-US’

EXEC @RC = [IRONsearch].[dbo].[Q_Regions] @regionlist, @minlevel, @maxlevel, @sitelist, @industry, @culture

I was expenting the same results. The SPROC has default values that should be used if the parameter is null…

The results differ big time, so I was, hrmmm, why the default values are not taken at all?

Anyways, making the story short, if the SPROC is called
EXEC @RC = [IRONsearch].[dbo].[Q_Regions]
without any parameter at all, the default values are taken but if the SPROC is called with the parameters = null as in the first case, the default values are not taken as SQL Server takes the value null for each of them.

It’s good to know this gotcha so I can write the Q_Regions with more robust code, checking for nulls and not let my data layer in the app alone with this.

The devil is in the details, isn’t it? 😉

QA tests

I haven’t written on this blog for quite some time. Having a tight deadline hasn’t helped much. I’m currently writing the testing scripts for the QA lab team, it’s not NUnit, mind you, just an excel spreadsheet with all the steps they should do to double check the application with the different browsers and OS.
We finally decided to go for www.browsercam.com to test the web app over www.crossbrowsin.com. the main reason is the first one includes Mac OS on its remote desktops tests.
I know cross browser compatibility is going to be a pain, it’s always been.

Cross browser compatibility…ain’t it fun?

We are still on the testing period for the application and we found a real cool resource for testing cross-browser compatibility. Visit the website here
The cross-browsing tests are done via a Java-applet that shows a desktop with about 10 types of browsers, you can previously select the OS and screen resolution you want. All versions of Mozilla till Firefox, IE, Opera, and NN are there, Windows and Linux are among the OS to choose and they promise Mac OS in a near future.
I had used BrowswerCam in the past but only for the snaptshops the browser screens, which is good for designers but not very usefull for web developers. I got a reply on a list now that browsercam.com also offers the actual testing with browsers and even has Mac OS that crossbrowsing.com doesn’t. BrowserCam prices are a little higher though.
Okay, our app got an A+ in the tests with IE 5 and 6, all type of Mozilla to Firefox, but failed on NN and IE4, hrmmmmm, probably the JScript that Visual Studio.NET is generating is not the best ECMAScript subset…
I found these two usefull resources to understand the difference between JavaScript, JScript and what ECMAScript is:
Resource 1 at DevGuru
and the best encyclopedia on the net Wikipedia:
Resource 2 at Wikipedia, history of ECMAScript
Oh joy! Tomorrow we’ll spend the day finding out what’s going on, stay tuned!

Class access modifiers and DevPartner Studio suggestions

Finally today I started getting my hands on DevPartner Studio, I had planned to do that yesterday but life is so umpredictable, isn’t it? heh, a last minute bug can change the natural course of things.
Anyway, one of the most frequent warnings I get on the project from the DevPartner Studio is “Class member field with protected access” the suggestion is to make the access identifiar Private instead of Protected.
For a nice explanation on Class access modifiers in VB.NET see this article.
So, there I go looking for Protected fields on my classes and setting them Private, but guess what? The DataBinding of the forms just blows up with this…Weird, I’m accessing those fields inside the form and assigning them to Private web form controls, hrm, well, it doesn’t work, so I just rolled back my Replace All “Protected” by “Private” and the project’s working again. It looks like the UI controls can’t be defined Private instead of Protected if you are going to do a server side data binding or property assignment.

If anyone knows the exact, well defined cause of this, please post a comment…

DevPartner Studio and the art of optimizing code.

The company purchased CompuWare DevPartner Studio…
I spent Friday testing the recently finished ASP.NET application with the new tool. I had quite a lot of warnings and things to fix ASAP. Being this app part of legacy code, it has some long methods that need a major refactoring. So my plan for the day is to put in practice what I recently read/learned in Martin Fowler’s Refactoring, Improving the Design of Existing Code
and remove all those warnings for long methods, stinky code and refactoring needs. I should get my hands on NUnit for the first time (shame on me), and make sure the changes in the code won’t break the whole app. One extra thing though, the refactoring will have to be done manually, there’s no refactoring tool for VB.NET 1.1, there is one for 2.0, but we won’t be using 2.0 on production yet. So here is my formal complaint, the VB.NET community needs a VB.NET 1.1 refactoring tool!

PS. For those who read this post, Refactoring is not Optimizing code necesarily, Refactoring’s for humans to be able to maintain code easily, while some extra encapsulation might not be the most efficient way to have your code doing a task, it’s easier for us humans to maintain, and after all, we are the ones that charge per hour ;).