Tuesday, February 20, 2007

You've seen Google spreadsheets and online word processing.  But how about Visio diagramming?  Introducing Gliffy, a free service for drawing diagrams reminiscent of Visio and sharing them online.

Here's one I tried.  It's not quite up to Visio standards, but not far behind either.

 

posted on Tuesday, February 20, 2007 5:27:28 PM (Central Standard Time, UTC-06:00) by Christopher S. Velazquez
 Friday, February 16, 2007

Well this has been a slow news week.  No astronauts went ballistic this week, and the hype over the death of what's-her-name is over.  The usual body count from Iraq and our casual acceptance of new encroachments by Big Brother just aren't news anymore.

Garfield, eat your heart out

So I guess I'll just introduce my beloved cat, Spot.  We have three cats, but Spot is decidedly "mine"; she often hangs out on the gate waiting for me to come home from work.  I picked her from the litter a month before she was ready to be adopted.  She is about 4 years old now.  When she was about a year old, she was exploring one of our neighbor's abandoned cabins and accidently fell down the chimney.  The fireplace had been boarded shut, so she was trapped in the chimney just above the flue.  I wondered what happened to her, and after about a day and a half of her missing, I heard a very faint meowing.  I found her and rescued her from the cabin, but she had blown out her vocal cords trying to get somebody's attention.  As a result, she barely meows any more.  Now she's kind of fat and indulgent, so I guess it's true that pets and their owners start to look alike.  I took this photo of her this morning; she has spent the night sleeping on some pizza boxes from the night before.

"It's not the fur that makes you look fat", quips my daughter Aria.

Something to think about

I think I've finally discovered the absolute worst programming language.  It's called "Whitespace", and it's even worse than brainf*ck.  All commands in the language are composed of whitespace.  This is not a joke.  I'm seriously considering porting this to Whitespace.NET.  Anyone want to join me?

posted on Friday, February 16, 2007 9:06:45 AM (Central Standard Time, UTC-06:00) by Christopher S. Velazquez
 Friday, February 09, 2007

Remarkable benefits of NASA technology

Having spent the past week in the Clear Lake City area of Houston, in light of the recent flap with astronaut Lisa Marie Nowak, I guess it should not come as a surprise that every time I passed by the NASA Johnson Space Center there was a queue of reporters waiting to have there smiling faces videotaped in front of the NASA front entrance.  Of course, the most interesting aspect of this stranger-than-fiction drama was the fact that Nowak drove from Houston to Orlando while wearing a special "space diaper" that obviated the need for pit stops.  I asked the guard at the gate of NASA if there was any way I could buy or otherwise obtain one of these coveted "space diapers", but he didn't find the humor in this so I left before he could call the cops.

 Lisa Marie Nowak and Nick Nolte.  Separated at birth?  I report, you decide.

A Valentine poem

Valentine's Day is right around the corner, so you should set your MS Outlook reminder to give you the electric cattle prod sometime before Wednesday.  Of course, I like to stay on top of these things, so to speak.  Therefore, in order to display my more sensitive side to my lovely wife, I embarked upon some original poetry.  Chicks dig poetry.  Without further adieu...

Washington Monument
Never looked as grand
As what I have for you
In my hand
Happy Valentine's Day

See what a true romantic I am?  I wonder if I can sell this one to Hallmark?

News from people with similar DNA

My chef brother, Josh, opened his new restaurant, Deep Ellum in Boston last month.  He's been getting some rave reviews from the local press, which is always welcome.  I asked him if he had a web site yet, to which he did not answer.  So I did a registration lookup at DomainTools.com and found that he already did have a domain registered, and when I visited the web site, it was already under construction.  Josh was not happy that I found his web site.  But I hope everyone in Allston gets a chance to sample some of his remarkable cooking.  He's phenomenal.

Yet another case of Texas envy?  I report, you decide.  I'll update when the website is "officially" launched.  Till then, you'll just have to find it yourself.

San Antonio's biggest problem

One thing people certainly will not envy about Texas is that 4 of the 10 "fattest cities" are right here in the Lone Star State, with San Antonio topping that list at position #2, just behind #1 Las Vegas, NV.  Now anyone who's been to San Antonio knows that the food is great here - barbecue, Mexican, and many others.  San Antonio is one of the most hostile cities to bikers, and there are so few bike trails that it's hard to understand how Lance Armstrong got his start here without getting run over.  And the few existing public parks and green spaces in the Alamo City are lame.  If I were king of the world, I would kick the military out of Camp Bullis and turn it into the most wonderful public green space in all of Texas.

On getting noticed by search engines

It's clear that I have much work to do when it comes to search engine optimization.  I read with eager abandon the article on SEO referenced by my friend Big Nellie on his blog.  You would think that because I registered the domain "chrisvelazquez.com" and that my site is called Chris Velazquez, and that in fact my name is actually Chris Velazquez, and has been since birth, that when you type the phrase "Chris Velazquez" in the search engine, that the first entry for "Chris Velazquez" would be one of my own pages.  My home page has the words "Chris Velazquez" in the title tag, the H1 tag, and all over my web site.  Yet if you go to the #1 search engine, you won't find any pages of this website at all unless you place the term "Chris Velazquez" in quotes, and even then it only shows one of the blog pages, sometimes.  It's not that I'm in love with my name; my name is pretty ordinary, and there are a few other people who also have the same name, including a rancher in New Mexico and a film producer.  As you can probably tell, this entire paragraph is an attempt at an experiment to see whether this page will become the first search engine result for the term "Chris Velazquez".  Sorry to have to bore you with all this.

 What Gooooooogle thinks about my website!

 

posted on Friday, February 09, 2007 10:47:10 AM (Central Standard Time, UTC-06:00) by Christopher S. Velazquez
 Wednesday, February 07, 2007

I can't believe that I've been racking my brains for hours trying to figure out how to execute my .NET 2.0 code in Microsoft Excel 2003.  Hopefully this tidbit of information will save somebody else on the web some pain, frustration and time.

Punchline: You need a file called EXCEL.EXE.CONFIG in the same directory as EXCEL.EXE.

I created a class, written in C# and compiled with Visual Studio .NET 2005, with the .NET 2.0 Framework.  This class has a COM Interop wrapper so that it can consumed by ActiveX clients, most notably Excel 2003.  This class was compiled with the "Register for COM interop" setting in the properties turned on.  This arrangement autogenerates the GUIDs and COM interface for you, though I prefer to define my own COM interfaces manually in production code.

Here is a sample class in C#:

// COMClass.cs
using System.Windows.Forms;

namespace AnyCOMLib {
    public class COMClass {
        public void DoSomething() {
            MessageBox.Show("I did something.");
        }
    }
}

When I compiled this C# class, Visual Studio generated the DLL and TLB files I expected.  You can invoke it from a COM client, and it seems to work.  Here is the VB code:

Dim thing As Object
Set thing = CreateObject("AnyCOMLib.COMClass")
thing.DoSomething

I typed out a simple VBScript file with this code, and it worked.  A message box popped up saying "I did something.".

I created a simple VB 6.0 program with this code, and this worked, too.  The same message box displayed.

I created a VBA macro in Excel 2003.  This did not work.  I had a message that read:

Run-time error '-2147024894 (80070002)':
File or assembly name AnyCOMLib, or one of its dependencies, was not found.

So I thought - If I can create a VB6 DLL that can be called from Excel (true) and VB6 code can call my COM-wrapped C# code (also true) then why not create a VB6 DLL that calls my C# code and call that from Excel?  Unfortunately, Excel was not easily fooled by this subversion, and I continued to get the -2147024894 error.  That was a waste of time.

After spinning my wheels for too long, I finally found something helpful.  It turns out that I need a file named Excel.exe.config to be placed in the same directory as Excel.exe (typically at C:\Program Files\Microsoft Office\Office11).  That file has the following format:

<configuration>
    <startup>
        <supportedRuntime version="v2.0.50727"/>
        <supportedRuntime version="v1.1.4322"/>
    </startup>
</configuration>

You have to make sure that you have the correct supportedRuntime elements for the .NET runtime to work.

Here are links to the pages that helped me find out about this:

newsgroup microsoft.public.dotnet.framework.sdk

topic in msnewgroups.net

These were specifically targetted for MS Word, but the same method applies to running .NET assemblies in Excel 2003 as well.

I hope this helps somebody!

posted on Wednesday, February 07, 2007 11:27:09 AM (Central Standard Time, UTC-06:00) by Christopher S. Velazquez
 Friday, February 02, 2007

You can attach the search functionality of your web site right into MSIE 7.0.  If you're using IE7, check out the search widget and see for yourself.

 

What you need:

  • An XML file (or script that generates XML) in the Open Search Description schema.
  • Add a <link /> tag in the <head> section that points that XML file or script

Here is the link tag I added to the hometemplate.blogtemplate dasBlog file:

<link rel="search" type="application/opensearchdescription+xml" href="/blog/opensearch.xml" title="In Chris Velazquez's words" />

I put this right before the line that has <%radio.macros.headLinks ()%>.  I'm not a dasBlog guru, or I would figure out how to get this in as a headLink.  Suggestions are welcome!

Now I need the file (opensearch.xml) that it points to:

<?xml version="1.0"?>
    <OpenSearchDescription
        xmlns="
http://a9.com/-/spec/opensearch/1.1/">
    <ShortName>In Chris Velazquez's words</ShortName>
    <Description>In Chris Velazquez's words</Description>
    <Url type="text/html" method="get" template="
http://www.chrisvelazquez.com/blog/SearchView.aspx?q={searchTerms}"/>
</OpenSearchDescription>

The template attribute has {searchTerms}, which is where the parameter would normally be entered.

 

Here are some of the custom search providers I use in MSIE 7

posted on Friday, February 02, 2007 12:40:43 PM (Central Standard Time, UTC-06:00) by Christopher S. Velazquez

This describes yet another way to do things.  Suppose you have input coming from a common source, but based on the content of that input, you want your program to do different things.  Naturally, the first thing you think of is the switch statement.  But I've stumbled across an interesting alternative.

Here is a simplified class in C# that uses a switch statement:

public class MyGame: IGame {
   
    public string ExecuteCommand(string command, string parameter) {
        string result;
        switch (command) {
            case "ECHO":
                result = DoEcho(parameters);
                break;
            case "JOIN":
                result = DoJoin(parameters);
                break;
            case "READY":
                result = DoReady(parameters);
                break;
            default:
                result = DoError();
                break:
        }
        return result;
    }
   
    public string DoEcho(string parameters) {
        string result;
        // code here
        return result;
    }
   
    public string DoJoin(string parameters) {
        string result;
        // code here
        return result;
    }
   
    public string DoReady(string parameters) {
        string result;
        // code here
        return result;
    }
   
    public string DoError() {
        string result;
        // code here
        return result;
    }
}

I decided to play around with generics to see if I could come up with an alternative to "switch".  By using a Dictionary of delegates, I can look up what the appropriate action to take would be, and then do it in a generic fashion.

public class MyGame: IGame {
   
   
private delegate string CommandHandler(string parameters);
   
protected Dictionary<string, CommandHandler> commandHandlers =
new Dictionary<string, CommandHandler>();
   
    public MyGame() {
        commandHandlers["ECHO"] = new CommandHandler(DoEcho);
        commandHandlers["JOIN"] = new CommandHandler(DoJoin);
        commandHandlers["READY"] = new CommandHandler(DoReady);
    }
   
    public string ExecuteCommand(string command, string parameter) {
        CommandHandler handler;
        if (commandHandlers.TryGetValue(command, out handler)) {
            return handler.Invoke(parameter);
        } else {
            return DoError();
        }
    }
   
    // handler code is same above.
   
}

I don't know about you, but this is much more satisfying at varying levels.  I've never liked the switch statement syntax, ever, and this code is easier on the eyes.  This transforms the dispatch mechanism from a procedural approach to a table-driven approach.  The one disadvantage is that all the dispatch methods must have the same figure, but usually uniformity is a welcome attribute to code.  One cool thing is that by adding a new handler, Resharper will automagically generate the signature for the new dispatch method.

A place where this approach might be useful is by assigning abstract factory methods as delegates.  Those have to be uniform, by design contract.

One thing I would like to see is the ability to assign all of the elements in the dictionary in a single statement.  I understand this will be a new feature in C# 3.0, but I haven't experimented with that yet.  I just downloaded the SDK yesterday!

posted on Friday, February 02, 2007 11:10:53 AM (Central Standard Time, UTC-06:00) by Christopher S. Velazquez
 Thursday, February 01, 2007

At CodingHorror.com, Jeff shows how to make your website look good on a mobile device.  It's pretty easy.

<link rel="stylesheet" href="http://www.yourdomain.com/css/styles-site-mobile.css" type="text/css" media="handheld" />

Unfortunately, you still have to download all the HTML as before, but at least it will look nicer.  And CodingHorror does look swell on a cell.

http://www.codinghorror.com/blog/archives/000782.html

posted on Thursday, February 01, 2007 1:11:20 PM (Central Standard Time, UTC-06:00) by Christopher S. Velazquez
 Wednesday, January 31, 2007

I have this habit of underestimating Microsoft, especially when it comes to the Office product line. At first blush, I was unimpressed with Office 2007.  To the average user, on first glance, it looks like Microsoft has traded one set of GUI widgets for another set of more complicated GUI widgets.  Combining this with the IT pundits declaring Office 2007 dead on arrival, I ignored it.  It's hard for me to get very excited about new widgets.

But last night I chanced upon the VSTO site (Visual Studio Tools for Office), and took a peek at this video.  I was amazed, and had to concede that Microsoft had pulled it off once again.  They have raised the bar for us programmers and expectations of users.  Briefly, your WinForms user controls can plug right into the Office environment, into either the ribbon or in the side docking panel.  Having worked on a system in C# that emulates a similar behavior, I was very interested, and a little disappointed that my craftily written code would soon be obsolete.

The thing about Office, and Word and Excel in particular, is that everyone uses it.  People get a warm fuzzy from software they use frequently and have some understanding of.  The number one feature request I get is to be able to download data into an Excel spreadsheet.  And VSTO 2005 SE (Second Edition) makes the job for programmers integrating into Office a whole lot better.  And it gives a compelling reason to upgrade to Office 2007.  This is only a minor upgrade for the end-user, but this is a sea-change upgrade for the Office developer.

VSTO 2005 SE will also allow Office programmers to achieve the type of service-oriented architecture that was difficult to achieve with our previous tools.  Since your user controls can do all those wonderful things like consume web services, chat over networks, query databases, access the file system, etc., the integration possibilities are nearly endless.  And the ability to dock your components right at the user's fingertips within the Office application makes the software convenient to summon for the end-user.

Now to work on my "reasons to upgrade" spiel for my clients...

posted on Wednesday, January 31, 2007 11:13:09 AM (Central Standard Time, UTC-06:00) by Christopher S. Velazquez