/// Frank Hagen: Professional Web Developer, C# User, Reformed Über-geek RSS 2.0
# Monday, June 01, 2009

This past weekend, I sat down with my 6 year old daughter and watched Star Wars.  It was her first time, certainly not mine.  She really likes the Clone Wars series on Cartoon Network, so I thought it was time.  It was an interesting experience.

Star Wars came out when I was 7.  I never saw it in the theaters in its original release; my parents seldom took us to a theater, and then only for "kids" movies.  I did see it years later, but never the original cut.  My first exposure was a VHS tape that our uncle gave my father.  I watched that tape over and over until it wore out, literally.  I bought the trilogy on VHS when it was released as a boxed set later on, and again when it was remastered with THX sound.  And I got a copy when the whole set was reworked with new CGI content.  Oh, I have seen Star Wars a few times...

The version I showed my daughter was in HD.  Obviously the latest remastered, cleaned, reedited, Greedo shot first, equatorial shock wave edition.  It was beautiful.  After the attack on Leia's ship, I remarked to my wife, "I don't believe I have ever seen this movie look so good!".  Funny, the version I always remember was grainy and almost smoky; it was thick with atmosphere.  This version was crisp and clean, clear and sharp; it looked great, yet somehow lacked something.  She loved it. 

It's funny how 32 years has changed so much.  The impact the film had on me was dramatic, even life changing (OK, I was only 7).  Not so much for her.  That old tape was a treasure to be handled carefully and saved for the future.  The copy from this past weekend was just so many bits on our DVR.  It is marvelous to see the world through her new eyes, yet make my own feel that much older.

Monday, June 01, 2009 9:09:55 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Life

I finished this book some time ago, but delayed the review of it because I was not sure how to do it properly.  Every once in a long while, I will read a book that is so good, so meaningful, that it can change perceptions.  This may very well be one of those books.  While watching an episode of Dogfights on the History Channel, I learned of Bud Anderson who flew the famous Old Crow P-51 Mustang in Europe during WWII.  So I looked him up online and discovered he had written a book.

I grew up believing, and well into adulthood, that Chuck Yeager was probably the greatest (American) pilot of all time.  But Yeager himself disagrees:  He names Bud Anderson that pilot.  He is the only combat pilot in WWII to achieve triple ace (17 kills) and never get hit.  His tour of Europe never included a scrubbed mission due to his ability or aircraft.  He was incredibly lucky and extremely skilled.  The story of Clarence E. "Bud" Anderson reads like a novel but yet contains great technical and tactical data.  He grew up a poor farmer, joined up at the opening of the war, flew combat in Europe with one the first squadrons to be outfitted with the Mustang, was a wingman of Chuck Yeager and flight leader as well, a test pilot during the glory days at Edwards, and even flew combat during Vietnam in F-105s.  The man is a hero, deserves to be a legend, and still lives today.

To Fly and Fight is written in a humble voice, quick to give credit where due, not afraid to call it like he saw it, and reluctant to believe he is the great hero that he so evidently is.  The problem with writing a review of a book such as this, is not to come off sounding ridiculous, but that is a difficult feat.  I truly enjoyed this book, and have made it part of my permanent collection.

Monday, June 01, 2009 8:46:08 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Books
# Thursday, May 07, 2009

I have a need to take large random numbers (on the order of 20 digits) and encode them to easily typable strings.  I created a quick method to do this in C#.  This is the code:

private string ConvertToBase(ulong id)
{
    // Seed replacement characters for baseX values
    string NumericBaseData = "0123456789ABCDEFGHJKMNPRSTUVWXYZ"; // this string may be in any order as long as each char used only once
    ulong OutputBase = Convert.ToUInt64(NumericBaseData.Length); // baseX determined by number of unique chars in seed string
    string OutputValue = "";
    ulong In = id;
    while (In > 0)
    {
        ulong tn = In % OutputBase;
        OutputValue = string.Concat(NumericBaseData.Substring(Convert.ToInt32(tn), 1), OutputValue);
        In = In - tn;
        In = (In / OutputBase);
    }
    return OutputValue;
}
 
For simplicity, I used unsigned longs (64bit), since I am dealing with really big numbers.  Performance is reasonable, I am able to generate a large System.Random, mod it against an arbitrary number of DateTime.Now.Ticks, datestamp it, and convert it using the method above in under 9 ms each.  (I also have an algorithm to test for uniqueness against previously generated values, but the timings grow with greater sample size as expected.)  This method can be modified with any number of cipher characters as long as they are only used once.  This particular one uses all letters and numbers except 'O', 'Q', 'L', and 'I' to avoid confusion to end users and is URL freindly.
Thursday, May 07, 2009 10:23:13 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET | Programming
# Friday, March 20, 2009

I am in the market for some quick, effective training in Oracle Development focused on consumption from a ASP.NET development point of view.  I don't need to know how to admin the Oracle server, just how to write effective, efficient queries, setup performant data models, optimize data access and fix our overabundance of foreign keys, indexes and CLOBs.  I am advanced in SQL Server development, but need to know the nuances that differ in Oracle.

Any recommendations?  Thanks in advance!

Friday, March 20, 2009 8:33:59 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Oracle | Programming
# Wednesday, March 11, 2009

After many years of trying, I have finally managed a good (enough) solution to playing video files on my TV.  And to make it more desirable, last year, we finally bought an HDTV.  I had bought an upconverting DVD player a few years ago for when we did finally do it, and it worked well enough, for awhile.  It was just too slow, and unreliable.  So when I finally upgraded the wife's computer, I used her old hardware along with some other pieces I had laying around to finally build a media PC.  I will never go back.  And the family is almost ready to go for a more expensive (really only a few hundred) solution.

Initially, I talked everyone into just running DVDs as normal, using the optical drive in the machine.  avi.netWindows does a much better job of scaling video than any consumer device I have used (or can afford).  Then I started ripping them to files.  I have been doing this for years, but not very successfully.  Decrypting the discs is easy.  Getting a good transcode has never been satisfactory.   Then I found avi.NET.  This great little tool does only one thing, but it does it very well.  It takes the decrypted DVD files and encodes them to an AVI file.  It has very few options, but does a really remarkable job. 

When encoding a video, I personally never use a fixed bitrate.  And the actual size of the end file is not strictly important to me, so I never choose the default option either.  I always choose the quality setting called Single Pass Quant.  The value used is dependant on the source video.  Animations tend to compress very well, so can use a higher value than FMV.  I tend to use higher numbers on the kids movies and lower on the movies I want very high quality viewing.  Like LAME, lower is better quality.  Below 2 makes for huge files, and above 6 starts to impact quality. 

The screen.SIZE attribute allows you to reduce the overall resolution of the output movie where 720 is typical max horizontal resolution for a widescreen DVD.  The aspect ratio is usually very accurate, but can be adjusted if needed using Height.  I have only had to do it 1 time, and then on a foreign title.  The Deinterlacing Filter works very well where needed and occasionally I will use the Smooth/Sharp if the source quality is poor.  Always use HQ mode; it makes the process slower, but it is very worth it.  I have not found much difference between DivX and XviD, except that DivX will thread across all 4 cores of my Q6600, so I use it, where XviD only seems to use 2.

It may take some experimentation as I am sure Your Mileage May Vary, but I am very pleased with results.  Sometimes I do have a problem reading some DVD rips, but running them through DVDShrink with no compression has always worked.  In fact, DVDShrink is a really convenient way to pick the tracks you want to convert and rip them to a convenient location. 

Keep in mind that avi.NET is only useful for converting DVD .vob files.  It will do nothing else.  For that I use MediaCoder; but that is another show.

Wednesday, March 11, 2009 7:52:01 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Software
# 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
<%--
--%>
Statistics
Total Posts: 189
This Year: 2
This Month: 0
This Week: 0
Comments: 74
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 2012
Frank W Hagen
Sign In
All Content © 2012, Frank W Hagen
Custom DasBlog theme based on 'Business' by Christoph De Baene