Jul 17 2008

IE7, dropdowns, and z-index

Tag: CSS, codejeremiah @ 10:18 am

I spent most of yesterday and most of this morning battling with a IE7 display bug.

Back story: we are using jQuery’s superfish drop down menus (a jQuery based implement of suckerfish/son of suckerfish) for site navigation. Everything works great in Firefox 2/3 and Safari. I’m going to assume that IE6 looks great as well since suckerfish is known to work well in IE6.

IE7 is a different story.

There is a large image directly beneath the navigation menu. Unfortunately for me, in IE7 the menu was being rendered beneath the image, despite having a z-index of 1001.

After some careful (and careless) digging and googling, I came across a solution.

To summarize, IE7 will not render the menu with the appropriate z-index unless that z-index is present on the top level :hover style. To clarify:


/*** ESSENTIAL STYLES ***/
.sf-menu, .sf-menu * {
margin: 0;
padding: 0;
list-style: none;
}
.sf-menu {
line-height: 1.0;
}
.sf-menu ul {
position: absolute;
top: -999em;
}
.sf-menu li:hover {
z-index: 100; /* This is the important style directive, without it IE7 chokes */
}
.sf-menu * li:hover {
visibility: inherit; /* fixes IE7 'sticky bug' */
font-weight: bold;
}

IE7 Suckerfish Hover CSS


Jul 15 2008

Who needs valid XML?

Tag: TFS, Visual Studiojeremiah @ 10:32 am

Team Foundation Server, apparently.

Let’s say that some careless developer (me) forgot to close an XML tag. The aforementioned developer then checked in his build file and attempted to build it.

At this point, I got a bit worried because TFS came back with the following error:

TF42046: The build service used in the build process is not reachable. This error occurs when either the build machine is off-line,the required service is not running, Team Build is not installed on the build machine, Team Build is configured for a different Team Foundation Server or the network is not available.

So, at this point I spent a few minutes attempting to debug this problem. It turns out that this problem can also be caused by silly developers leaving off closing XML tags in their hurry to finish the weekly build script.

Why would Visual Studio throw back this seemingly unhelpful message? Probably because my XML was garbage and TFS simply refused to talk to me on the grounds that I am uncouth and trying to shout the XML equivalent of dirty words at it.

Moral of the story: close your XML tags and don’t hurry.

[edit]
Rick has informed me that I am a horrible developer and forgot to mention his involvement in this whole issue. So, Rick, thanks for helping me troubleshoot this problem. Read his blog, it’s at RickDoes.net. Did you notice that URL? He’s witty, much wittier than I.


Jul 11 2008

SQL Server 2008 Installation Features

Tag: SQL Server, sqljeremiah @ 6:26 am

Eric Johnson has put up a fantastic post detailing the new SQL Server 2008 Installation Wizard or, as it is officially named, SQL Server Installation Center.

Rather than summarize, I’ve just provided a link. It’s short, sweet, to the point, and full of screen shots.


Jul 05 2008

Software Development Meme

Tag: code, nonsensejeremiah @ 9:49 pm

Rick, I’m stealing your post. Which is okay because you stole it first.

How old were you when you started programming?
I originally started learning BASIC when I was very young, probably 11 or so. I gave up on programming for more worldly pursuits, only to come back to it 10 years later.

How did you get started in programming?
The second time around I wanted to create a ‘blog’, although at the time I don’t think we called them blogs. I think we called them e/n sites (everything/nothing). So I taught myself HTML.

What was your first language?
HTML, CSS, and Perl. It was a triple whammy.

What was the first real program you wrote?
The first real business program I wrote was a socket server written in PERL that accepted a rudimentary home grown protocol. It was used to remotely monitor the health of 8 different servers. What can I say, I started out as an HP-UX sysadmin.

What languages have you used since you started programming?
HTML, CSS, JavaScript, C#, VB.NET, ASP.NET, PERL, Python, Ruby, SQL (T-SQL, PL/SQL, PL/PGSQL), PowerShell, BASH scripts, SVG, XPath, XQuery, XSLT, ActionScript. Jack of all trades, master of none.

What was your first professional programming gig?
I worked at Qwest Communications writing unimpressive PERL scripts to automate keeping an Actuate Reporting Server running without too many memory leaks. I graduated to doing the same thing for Local Number Portability software. If you don’t know what LNP is, just think of it this way: it’s the reason your calls go through and the reason you can change carriers and keep the same number.

If you knew then what you know now, would you have started programming?
I might have kept with it when I was younger. Although, frankly, I think a good part of my approach and expertise come from my lack of formal training and my background in the Humanities. Getting a four year degree in CS would have probably proved impossible for me. However, that BA in English has taught me a great deal about the importance of communication, documentation, and solid presentational skills.

If there is one thing you learned along the way that you would tell new developers, what would it be?
Communication is key. This stretches across every aspect of what we do on a daily basis. If you can’t communicate your ideas clearly and succinctly, the boss is never going to push for your pet project. If you can’t describe a problem well to non-technical people, they will never understand the importance of the issue. If you can’t share your failures and successes with fellow developers, someone will end up repeating your mistakes. Communicating is how we all learn. If people didn’t feel the urge to share their knowledge and write books, we would still be building Altair clones in our basements from Radio Shack kits.

What’s the most fun you’ve ever had … programming?
Frankly, every day is fun. I get to share knowledge with some exceptionally talented developers and I’m always learning from them. The best times are when I get to work with a dynamic team of people and build on each others ideas to make the best software we can.


Jul 05 2008

Evaluating IS NULL vs <> with T-SQL DATETIMEs

Tag: sqljeremiah @ 9:20 pm

Many OR/Ms use an UpdatedAt column and some even use a DeletedAt column for soft deletes. This practice also carries over when using date ranges for controlling notification display (StartDate and EndDate).

I’ve often heard many DBAs make the claim that doing a date comparison is faster than checking if the value in a date column IS NULL, so I decided to run some primitive benchmarks to see what I would discover. Admittedly, I’ve also held this belief myself, but I’ve never witnessed any numbers to either prove or disprove the theory.

First, I created two tables with two columns each - CreatedAt and DeletedAt. One table allows NULLs in the DeletedAt column, the other does not.

Next I filled each table with 1,000,000 random DATETIME values. Each table recieved the exact same DATETIME values in each row and a random number seed was used to determine whether or not the NULL table would have a NULL value or a random DeletedAt value. In my test case, 500843 records had a NULL value. I then ran three separate queries to compare the performance of IS NULL against . Before and after each query, the current time was stored in a variable which was manipulated using a millisecond DATEDIFF to determine the total execution time.

  1. -- turn off printing row counts to speed up processing
  2. SET NOCOUNT ON;
  3.  
  4. -- Create test tables
  5. IF OBJECT_ID('Benchmarking.dbo.TestNullDatetime', 'U') IS NULL
  6. BEGIN
  7. CREATE TABLE TestNullDatetime
  8. (
  9. CreatedAt DATETIME NOT NULL,
  10. DeletedAt DATETIME
  11. );
  12. END;
  13.  
  14. IF OBJECT_ID('Benchmarking.dbo.TestNotNulLDatetime', 'U') IS NULL
  15. BEGIN
  16. CREATE TABLE TestNotNullDateTime
  17. (
  18. CreatedAt DATETIME NOT NULL,
  19. DeletedAt DATETIME NOT NULL
  20. );
  21. END;
  22.  
  23. DECLARE @counter INT;
  24. DECLARE @random FLOAT;
  25. DECLARE @threshold FLOAT;
  26. DECLARE @current DATETIME;
  27. DECLARE @deleted DATETIME;
  28.  
  29. SET @threshold = 0.5;
  30. SET @counter = 0;
  31.  
  32. WHILE @counter < 1000000
  33. BEGIN
  34. SET @random = RAND();
  35. SET @current = GETDATE();
  36. SET @deleted = @current + (@random * 9.5);
  37.  
  38.  
  39. IF @random > @threshold
  40. BEGIN
  41. INSERT INTO TestNullDatetime VALUES (@current, NULL);
  42. INSERT INTO TestNotNullDatetime VALUES (@current, @current);
  43. END
  44. ELSE
  45. BEGIN
  46. INSERT INTO TestNullDatetime VALUES (@current, @deleted);
  47. INSERT INTO TestNotNullDatetime VALUES (@current, @deleted);
  48. END
  49.  
  50. SET @counter = @counter + 1;
  51. END
  52.  
  53.  
  54.  
  55. DECLARE @start DATETIME;
  56. DECLARE @end DATETIME
  57.  
  58. DECLARE @null_isnullcompare INTEGER;
  59. DECLARE @null_notequalcompare INTEGER;
  60. DECLARE @notnull_notequalcompare INTEGER;
  61.  
  62. SET @start = GETDATE();
  63. SELECT * FROM TestNullDatetime WHERE DeletedAt IS NOT NULL;
  64. SET @end = GETDATE();
  65.  
  66. SET @null_isnullcompare = DATEDIFF(ms, @start, @end);
  67.  
  68. SET @start = GETDATE();
  69. SELECT * FROM TestNullDatetime WHERE DeletedAt <> CreatedAt;
  70. SET @end = GETDATE();
  71.  
  72. SET @null_notequalcompare = DATEDIFF(ms, @start, @end);
  73.  
  74. SET @start = GETDATE();
  75. SELECT * FROM TestNotNullDatetime WHERE DeletedAt <> CreatedAt;
  76. SET @end = GETDATE();
  77.  
  78. SET @notnull_notequalcompare = DATEDIFF(ms, @start, @end);
  79.  
  80. SELECT @null_isnullcompare AS [NULL - IS NULL comparison],
  81. @null_notequalcompare AS [NULL - NOT EQUAL comparison],
  82. @notnull_notequalcompare AS [NOT NULL - NOT EQUAL comparison];
  83.  
  84.  
  85. -- restore original state
  86. SET NOCOUNT OFF;

The results are as follows:

Run NULL table, IS NULL NULL table, <> NOT NULL table, <>
1 5470 5436 5373
2 5563 5516 5546
3 5936 5750 5466
4 5500 5453 5390
5 5576 5640 5440
AVG 5609 5559 5443

Overall, the <> comparison is faster than an IS NULL comparison, and it is approximately 100 milliseconds faster to perform on a table with no NULLs than on a table with roughly 50% NULL values.

Of course, it’s important to take note these are all hot cache hits. I didn’t take the time to reboot my machine and determine the difference running this against a cold cache, however I suspect that the results would still be the same.

Testing was performed on a 2.0 GHz Core 2 Duo laptop running Windows XP SP2, SQL Server 2005 Developer Edition (patch level 9.0.3054), with 2 GB of RAM and 7200 RPM drives. It’s an HP Pavilion dv9000t, for those who are interested.


Next Page »