a week without bloggin’, tsk tsk

It’s been a busy week indeed. Not busier than before though. I managed to create an installer for the windows service, fine tuned the algorithm, refactored the code with this new cool tool I found netRefactor from KnowDotNet and have kept myself busy in the evenings doing some code for fun…
Kenny and I are trying to start studying for the MCSD cert online, already set up our YMs for that and I hope we don’t procrastinate longer than this weekend, heh.
On the code for fun side :). It’s been a fun project, kind of tricky, reading emails from an IMAP inbox and importing them into a database, handling attachments, the always messy MS Outlook stationeries et-cetera. I’ll talk about it as soon as I get home…yup, a gal have to work 😛

PS. And we got a comment at TNW’s Resources about an Ajax debugger, can’t wait to try it to finally set up TNW’s home page, Google won’t score us in the first page yet, so we need to improve that “under const” space, hopefully with some Ajax stuff 😀

The windows service works, let’s go party!

TGIF!
I’ve spent two weeks in a row working on this part of the project. We have an old database that is internal to our intranet and want to publish part of its data online, the old database is still in use. For publishing the data we should feed an online MSSQL DB. Due to the fact that the old database is offline and on an intranet the sync process has to run on a machine inside the intranet. There were three possible paths for this task:

  1. Use a DTS package running on the MSSQL every certain time, probably midnight, SQLAgent would deal with scheduling/running the job. The main drawbacks for this option was the offline old database, that we still had to convert/translate some datatypes between databases and the internal staff had no access to run the DTS.
  2. Use a DTS package and make it run from a client machine with a dtsrun utility (worse case scenario SQL-DMO). Still the DTS package would have to translate datatypes, the server would have to have access to the old DB datasource, still the DTS would have to be invoked from/wrapped into an application of some sort (windows app/service/console app)…
  3. Use some client application (probably windows service) that would do the sync process at midnight and also on demand using ADO.NET.

We chose the third option, it’s probably not the most efficient way, to use ADO.NET over DTS, but the fact that the internal staff needed to run the sync process on demand and to receive notifications of success or failure plus the location of the old database, made us think this was a way to go.
There was actually a huge thread on DOTNET-WINFORMS dicussion list at Develop.com regarding architectural issues, I was almost convinced to give up on the windows service implementation and make a DTS package, I might give it a try later with the help of the sysadmin. Creating the DTS is not the issue here but giving a client machine/user access to run the DTS package on demand. You can see the thread Changing the DataRow.RowState Property

Anyway, I found a good article on how to create and debug a windows service at OnDotNet.com
Developing Windows Services
and got the chance to code a windows form wrapper for the service. The service is showing a notification Icon on the systray, trying to emulate the MSSQL Server Service Manager’s behavior.

Right now I’m having issues accessing the configuration file from the dll that has the service. The rest of the code works :). I just googled and found a discussion thread about this
Config Files for DLLs
and I’ll give it a try on Monday.
TGIF, let’s go party!

The Ideal Programmer

I forgot the exact source of this paper. I believe it’s used at UCLA, to impress junior students.

What an ideal programmer should be/do/have done:
(1) Read a manual
(2) Written a program from scratch on your own
(3) Written an application used by more than 10
people
(4) Written application code that was used (is being
used) for 3 consecutive years
(5) Documented your code
(6) Published your documentation (for posterity)
(7) Written code and shared it with another
organization
(8) Use consistent naming conventions within your
code
(9) Use a database
(10) Use source control (any form of history of
previous versions of code)
(11) Have separate development and production
environments
(12) Have separate development, test, and production
environments
(13) Have done a security analysis of your application
and environment
(14) Designed and tested a disaster recovery plan for
your application

The bitter-sweet taste of open source

From an essay of Paul Graham: (Original essay here)

That’s why the business world was so surprised by one lesson from open source: that people working for love often surpass those working for money. Users don’t switch from Explorer to Firefox because they want to hack the source. They switch because it’s a better browser.

It’s not that Microsoft isn’t trying. They know controlling the browser is one of the keys to retaining their monopoly. The problem is the same they face in operating systems: they can’t pay people enough to build something better than a group of inspired hackers will build for free.

I’m a professional programmer, eventhough I use open source to do ocassional jobs and I certainly enjoy the work in the open source community, I do tend to agree with Joel Spolsky on an interview he offered on the radio about the different types of software licenses and software economy in general. Open Source take us, professional programmers, to the edge. Here’s the original interview in mp3

Here’s a good thread on Open Source vs Commercial

The point is, Open Source value comes from Darwinian selection and thousands of volunteers all over the world, who are willing to do things for free, who are, some of them amateurs, that want to try how far they can go and who offer their code for free. The only thing Commercial software might have in its defense is Support and sometimes you get good quality support on open source forums.

How can software companies survive open source? I frankly don’t know.

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? 😉