/// Frank Hagen: Professional Web Developer, C# User, Reformed Über-geek RSS 2.0
# Wednesday, March 04, 2009

The following code should be failed by the C#.NET compiler:

if (eventName != null && eventName.Length > 0)

It should never be used.  People, always use this instead:

if (!String.IsNullOrEmpty(eventName))

It is much more compact, clearer, singleton, and as a String class method, more efficient.

So stop it!  You will thank me later.  Not to mention:  Where are your parentheses?  Block your code.  Other people have to read it too!

That is all.

Wednesday, March 04, 2009 10:43:27 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
.NET | Programming | Rant
# Thursday, February 19, 2009

Charting from LogParser is a very useful and powerful feature.  I enjoy collating our data into charts on hourly and daily summaries.  One of the charts I produce for my own use for the websites at work is Browser shares, like this one:

I especially like how all of the IE points are shades of blue.  Of course, you don't get that behavior out of the box.  But you can "style" the chart using a JScript config file.  The one I use is below:

// Title info
chart.Title.Font.Name = "Verdana";
chart.Title.Font.Size = 11;
chart.Title.Font.Bold = "True";

chart.SeriesCollection(0).DataLabelsCollection(0).Font.Size = 9;

for(nI=0; nI < chart.SeriesCollection(0).Points.Count; nI++)
{
    if (chart.SeriesCollection(0).Points(nI).GetValue(1) == "IE8")
        chart.SeriesCollection(0).Points(nI).Interior.Color = "#0099FF";
    if (chart.SeriesCollection(0).Points(nI).GetValue(1) == "IE7")
        chart.SeriesCollection(0).Points(nI).Interior.Color = "#008FE1";
    if (chart.SeriesCollection(0).Points(nI).GetValue(1) == "IE6")
        chart.SeriesCollection(0).Points(nI).Interior.Color = "#3876B7";
    if (chart.SeriesCollection(0).Points(nI).GetValue(1) == "Firefox")
        chart.SeriesCollection(0).Points(nI).Interior.Color = "#D87023";
    if (chart.SeriesCollection(0).Points(nI).GetValue(1) == "Safari")
        chart.SeriesCollection(0).Points(nI).Interior.Color = "#CFCCCC";
    if (chart.SeriesCollection(0).Points(nI).GetValue(1) == "Chrome")
        chart.SeriesCollection(0).Points(nI).Interior.Color = "#2DB632";
    if (chart.SeriesCollection(0).Points(nI).GetValue(1) == "Opera")
        chart.SeriesCollection(0).Points(nI).Interior.Color = "#BC1B12";
    if (chart.SeriesCollection(0).Points(nI).GetValue(1).substring(0,8) == "Netscape")
        chart.SeriesCollection(0).Points(nI).Interior.Color = "#246C6D";
}
Thursday, February 19, 2009 2:54:38 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
LogParser
# Wednesday, February 11, 2009

FLAC may be the perfect format for music storage with its far superior quality, hardly any players support it.  Especially my OEM in-dash player in the car.  So it is necessary to convert.  The batch file below will convert the FLAC to MP3 via WAV and tag from the original, assuming the correct pieces are installed as demonstrated.  I have it loaded into a batch file which I have placed in my Send-To folder for easy right-click/convert use.

"C:\Program Files\FLAC\flac.exe" -d %1 -o temp.wav
"c:\program files\lame\lame.exe" -V2 temp.wav %1.mp3
del temp.wav
"C:\Program Files\Lame\Tag\tag.exe" %1.mp3 --fromfile %1     
pause

By the way, do go out of your way to find the version of LAME that is compiled for your specific CPU.  My Q6600 does VBR2 at 28x.  I literally cannot rip as fast as it encodes from CDs.  (Note: while there is a multi-threaded version, mp3 encoding is really a single-threaded operation, so quad-core just means I can encode 4 streams at once.)

Wednesday, February 11, 2009 8:47:19 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Programming
# Tuesday, February 10, 2009

Why are Unicorns hollow?

Tuesday, February 10, 2009 8:31:05 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Life
# Tuesday, January 27, 2009

Sometimes I think this site is turning into a Book Review site instead of a technical site.  And in support of that concern is Beyond the Blue Event Horizon, book 2 of the classic Heechee Saga of Frederick Pohl.  While Gateway is a very different read, the second of the saga promises to be a bit odd, but more mainstream than its predecessor.  And is just so.

We join Robinette Broadhead again, but only as one of the primary players in the story.  More closely we follow the expedition to another artifact dubbed the Food Factory located in the Oort Cloud.  The expedition indeed finds a food processing facility but cannot get it to move closer to inhabited space.  They also find a surprising inhabitant:  A teenaged boy stranded there since birth.  Or rather stranded there and at another location they call Heechee Heaven.  And there the surprises are even greater.

The Heechee Saga is nearly as important to Science Fiction as the Foundation Trilogy and 2001 and its sequels.  If you read Dune and the Ringworld stories, you should read these.  But having said that, the books really are not that great to read.  The stories and the ideas in them certainly are, however, and has shaped much of modern SciFi.  At least in my mind.  Even 30 years later, I still think the AI entities in the books as pretty accurately modeled.  And his treatment of the vast distances within our own solar system is very refreshing.  I am really enjoying re-reading the series, although, I don't believe I have ever read the remaining books.  I am doing so now, but have also picked up some other material as well, so it may be awhile.

UPDATE: When writing up the sequel, I noticed I posted the wrong title for this book. It is now corrected.

Tuesday, January 27, 2009 8:57:30 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Books
# Friday, January 23, 2009

Everytime I need to render date and time to a DateTime field, I have to scour the Internet to figure out how.  Well, here is how:

If you need to get hourly statistics on your website, select and group by the following metric:

TO_LOCALTIME(QUANTIZE(TO_TIMESTAMP(date, time),3600)) AS Hour

This will properly combine date and time and offset by the correct timezone to a single datetime field recognized by most data parsers.  And it will look like this:

2009-01-21 12:00:00

It shouldn't be too difficult to change that to minutes, seconds, periods, whatever you need.

Friday, January 23, 2009 8:46:18 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
LogParser
# Tuesday, January 20, 2009

And so, today we begin the four years of our Great Nation's biggest electoral mistake.

I truly hope I am wrong.

Tuesday, January 20, 2009 8:43:51 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Politics
# Thursday, December 11, 2008

I am learning and working with a Business Objects framework at work called CSLA.NET (Component-based Scalable, Logical Architecture).  It is built heavily using the best of OOP especially polymorphism and abstraction.  You build your objects all based on a handful of base classes that provide a huge variability of useful features.  It also abstracts out data and .NET remoting layers to make the developers life easier.  If you are building large, scalable n-tier applications, you should definitely look this one up. 

Also check out the book Expert C# 2005 Business Objects, which is the companion to the framework.  If nothing else, it contains a great description of n-tier architecture and why to use it.

Thursday, December 11, 2008 8:13:21 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
.NET
<%--
--%>
Statistics
Total Posts: 186
This Year: 0
This Month: 0
This Week: 0
Comments: 72
Locations of visitors to this page
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Frank W Hagen
Sign In
All Content © 2010, Frank W Hagen
Custom DasBlog theme based on 'Business' by Christoph De Baene