Geek Dinner and Superman

Last Thursday I attended my first Geek Dinner. Great food. Good conversation. And then we went to the Wynnsong and watched Superman Returns in our own reserved theater thanks to their great management. And many thanks to Phil Burns and DevUtah for hosting it.

Dinner was at Tucanos in Provo. Great food. Fun atmosphere.

The movie was vintage Superman. I expected more but my kids will love it.

And if you live in Utah, come join us for the next Geek dinner. If you don't, then start your own. Way fun!

Does Pay Per Click Work?

I"m not a marketing guru. Never have been. Never will be. You too? So how do we maximize traffic to our blog, our side project, or our main gig? Well, we tell our clients to hire us, the expert, when they need some coding done.

So hire an expert.

I know just the expert. I've watched these guys in action. They know what they're doing. Check them out at http://www.webevident.com/ppc-management.php.

They can handle all your pay per click campaigns. And you would be surprised how much traffic they can drive to your site on a very tight budget. They do a free analysis for you, so you have nothing to lose by at least checking them out.  

A Requirements Management Allegory

My wife won the lottery. Two hundred thousand dollars. Uncle Sam took half. She said, "I want a new car. Go buy me a new car."

So I took the checkbook and bought a brand new Honda Accord for $30,000. When I arrived home my wife said, "I didn't want an Accord. I want an SUV."

On the way back to the dealership, an accident occurred. I escaped with my life but the car was a total loss.

I still had the checkbook so I wrote a check for $40,000 and took home a nice, new Dodge Durango. I was so pleased with myself.

But my wife was not. She said, "The Durango is too small and I don't like the color red."

So I turned around and took it back to the dealer. I asked for my money back but he whipped out the magnifying glass and pointed out the small print: "absolutely, under no circumstances can you get a refund."

"Besides," said the salesmanager, "we've already spent the money and we can't take a new car in trade. It's just policy."

So I drove the Durango to the Ford dealership and on the way was rearended by a large truck. The Ford dealership gave me $10,000 in trade and I wrote a check for $40,000 more for the last of the new Ford Excursions.

I drove the Excursion home. Finally my wife was happy. "Now let's go buy the boat," she said.

"Sorry, honey," I said. "We're out of money."

So we have this giant SUV and we can't afford to put gas in it, and we have nothing to pull behind it.

But, we do have an SUV that cost $100,000 and in three years will be worth less than $20,000. And as a compensating note, I can haul a ton of groceries with it which helps save the cost of gasoline to get to the grocery store in the first place.

Now if only we could find another lottery to win.

Automate Your Customer Service Complaints

I recently ordered something online. Let's hypothetically say it was a pair of glasses. I won't say which company because your experience will in all likelihood be better than mine. In point of fact, I have a crazy prescription that is hard to make and throws every optical lab for a loop the first time they see it.

Actually, I ordered two pairs. One pair was produced and arrived in a reasonable timeframe. The other has yet to arrive, hence my hesitance to name names. It's been weeks and weeks now. I would call and receive placating assurances that the matter would be looked into and that all would be resolved. I sent email nearly every other day inquirying. No answer. No status update. No way to look at the order status online--okay, yes that's partly my fault. Know before you press "confirm order."

So how did I solve this great quandry. Just a few lines of code which I will share below produced an emailed response within the hour. Have fun with it. Use it at your own risk. I take no responsibility for how you make yourself heard. And I've removed the identifying strings to avoid embarrassing the vendor and further endangering my order. BTW, their response was:

"We apologize for the inconvenience you experienced with us. We are remaking the glasses you ordered in our lab. You will receive them in about 10 days."

Here's the simple code:

using System;
using System.Collections.Generic;
using System.Text;

namespace
CrazyEmail
{
  class Program
  {
    static void Main(string[] args)
    {
       string n = Environment.NewLine;
       string nn = n + n;
       string body = "Hello," + nn
         + "I can think of no other way..." + nn
         + "Can you please respond..." + nn
         + "You can either..." + nn
         + "Thanks," + nn
         + "-Tyler";

       System.Net.Mail.MailMessage msg = 
         new System.Net.Mail.MailMessage("myemail@address.com", customer@service.com
         "order #xyz status inquiry"
, body);

       System.Net.Mail.SmtpClient client = 
         new System.Net.Mail.SmtpClient("mail.myserver.com"
);

       for (int i = 0; i < 100; i++)
       {
         client.Send(msg);
         Console.WriteLine(i.ToString());
       }

       Console.WriteLine("Done.");
       Console.ReadLine();
     }
  }
}

 

Hopper&lt;T&gt;: Queue&lt;T&gt; Class in C# that Caches to Disk

In a recent project, I had a Windows Service that was receiving many thousands of requests which could only be processed at specific intervals. Soon I found that queuing so many requests in a simple Queue<T> class ran away with all my machine's memory.

So what to do?

I didn't really want to change my code. I like the Queue<T> class. So I wrote a class I call Hopper<T> which acts like Queue<T> but caches items to disk. It's constructor gives the class the information it needs to do all the work. Then you just use it like a Queue<T>.

public Hopper(
 
string cachePath,
 
string uniqueFileExtension,
 
int hopperCapacity,
 
int reorderLevel)

This class takes advantage of the System.Runtime.Serialization and the System.Runtime.Serialization.Formatters.Binary namespaces.

Download the code and give it a try. And be sure to let me know what you think.

Hopper.zip (2.74 KB)

Parsing HTML with C# by the Book (DTD)

Recently I had to write an HTML parser for a project I've been working on for some time now. First I tried translating an open source C++ parser but it really wasn't what I wanted and it was also under the GPL. After contacting the author and realizing (or re-remembering) that I could not use a GPL derivative in a commercial library or application, I scrapped that and went back to the source: the official HTML DTD.

Re-remembering how to read a DTD after not having done so for so long was a chore, but the folks at Autistic Cuckoo helped. So I found a very helpful tutorial. I spent the next day or two writing the code in the file you linked below. I took some inspiration from a few files I found while browsing the FireFox code under the Mozilla license. The rest of it came from studying the DTD and trying to figure out a way to encapsulate that in a usable object model.

Here's an example of how to use it:

HtmlDocument doc = new HtmlDocument(url, html);
StringBuilder sb = new StringBuilder();
Collection<HtmlTag> pcdata = doc.GetList(DtdElement.A);
foreach (HtmlTag tag in pcdata)
{
  if (!tag.EndTag)
  {
    Dictionary<string, string> attributes = doc.GetAttributes(tag);
    sb.AppendLine("");
    sb.AppendLine("A: " + doc.ReadSlice(tag.Slice));

    foreach (KeyValuePair<string, string> pair in attributes)
    {
      sb.AppendLine(" " + pair.Key + "=" + pair.Value);
    }
  }
}

I'm releasing it under the BSD license, which I like much more than the GPL as I'm not really a "true" free software zealot. The only think I ask is that if you fix a bug or make an improvement, please share it with me and I'll put up a new version here.  

NetBrick.Net.OpenUtils1.zip (35.31 KB)

Forget Fedora 5

Well, after struggling to get Fedora 5 to run on my machine and get the GUI up and running on an nVidia card, I've given up on this distribution after finding this bit of nasty news.

I think I'll try SUSE next. I've tried using the "YUM" updater and following a variety of instructions from a variety of posts to get my dual monitor eVGA GForce 7800 GT to work. All to no avail.

Once downloaded and installed, I'll post the results of my attempts with SUSE 10.

Venturing into Mono

I've begun the journey into Mono. Fedora 5 is nearly completely downloaded. I've freed up a partition on which to install it. I've downloaded the mono-1.1.1.13.6_0-installer.bin from the official site.

Why?

Because I'm building a system that must scale to many machines and we're considering using a virtual machine hosting system. And they only host virtual Linux boxes.

Will we definitely host the application on virtual system? No, not definitely. But if the port to Mono goes well, it's certainly an option.

My concerns about going to Mono is first, I know very little about Linux. Second, I'm using System.ServiceProcess.ServiceBase for my server, and that namespace, as far as I can tell, is not supported in Mono. So these two items may pose a bit of a learning curve.

After downloading some but not all of the Mono source files, I began wandering about and looking at how the Mono team has implemented various class libraries that we .NET developers take for granted every day. Talk about a wealth of code samples that will be extremely valuable in my daily work, regardless of whether I'm in Mono or MS .NET coding.

I'll post more on my progress into the world of Mono and Linux in the future. In the meantime, if you have any words of wisdom for me, please feel free...