gists, csharp, net comments edit

A minor follow-up to my JavaScript and Unicode Character Validation entry (and sort of a reminder to myself):

Sometimes when working with characters in regular expressions it’s nice to be able to dump one or more characters as a line of Unicode hex escape sequences. For example, abc becomes \u0061\u0062\u0063.

Here’s a quick snippet for a console app that will let you input a series of characters and will dump out the list of characters entered as Unicode hex:

using System;
public class DumpHexChars{
  public static void Main(){
    Console.Write("Enter chars to convert to Unicode hex: ");
    string chars = Console.ReadLine();
    string output = "";
    for(int i = 0; i < chars.Length; i++){
      output += String.Format("\\u{0:x4}", Convert.ToInt16(chars[i]));
    }
    Console.WriteLine(output);
    Console.ReadLine();
  }
}

Got the cable phone hooked up on Saturday. Decided that we were tired of shelling out to Verizon for what has thus been sub-par service and that we’d go with the ol’ Comcast phone because we’ve always had good luck with their service and it’s actually cheaper for what we end up getting, all told.

While the guy was there he put in three new cable outlets (because not all of the rooms in the house had them… still not all of them have one, but I think there’s only one room that doesn’t that really might need one). That was cool. Plus, due to the new outlets, I can now put the cable modem right down next to the computer and connect directly to the network. Previously I was having to connect through wireless because, well, no cable drop was in the office. I’m movin’ up in the world, people!

Sunday I spent the day playing Paper Mario with Stu, which was hella fun since it’d been a couple of weeks since last we played. Made some good progress there and also tried the Papa John’s “Kong-Sized Pizza,” which was pretty ridiculously giant and filled us up nicely.

I would probably be remiss in not saying that there are a couple of friends of mine that are going through some hard times right now, so time was spent with them during the weekend as well. I won’t say more than that, since it’s not my place, but I hope they’re doing well and will continue to support them as needed.

Less serious: just found the Red Dwarf 8 DVD is coming out soon, and there’s a limited edition with a motorized scutter toy on it. Preordered!

gists, xml comments edit

Hanselman pointed out to me yesterday that Dan Suceava posted a VS add-in that finds duplicate RESX items by ID and prints out the duplicate names in a report.

Now, I’m all over VS add-ins and adding cool functionality to the development environment, but this feels a lot like overkill to me. I admit I didn’t go download the thing because, as neat as it sounds, it occurs to me that you could just jam a 10 minute XSLT together and find out the answer that way. (And who knows - the add-in may be doing just that.)

So, for those interested, here’s a quick-and-dirty XSLT that will go through a RESX file and print out a list of duplicate resources by ID along with a count of how many were found:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/root">
    <xsl:for-each select="data">
      <xsl:variable name="dataName" select="@name" />
      <xsl:variable name="currPosition" select="position()" />
      <xsl:variable name="numDups" select="count(/root/data[@name = $dataName])" />
      <xsl:variable name="numBefore" select="count(/root/data[@name = $dataName and position() &lt; $currPosition]/@name)" />
      <xsl:if test="$numDups &gt; 1 and $numBefore = 0"><xsl:value-of select="$dataName" /> (<xsl:value-of select="$numDups" />)&#0013;</xsl:if>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

A sample report might look like this:

    ResourceID1 (3)
    ResourceID4 (2)
    ResourceID7 (4)

Used in conjunction with a command-line tool like nxslt, you’re set - specify your RESX file as the input XML, and the above as the style sheet. Done!

Another thing we learned in my peer mentoring class was that there are such things as stupid questions.

That sounds bad, but let’s look at that: what constitutes a stupid question? Well, if you flip it around, what constitutes a good question? A good question is one in which the person asking the question has really thought the question through, they’ve tried to answer it themselves, and they have a good grasp on what they’re asking - they’ve put some effort into the formulation of the question. So, then, a stupid question is when the person asking doesn’t think at all about the question, they just blast it out there.

What shows me that you’ve thought about a question? That’s different for different people, but when you ask me a question, especially if it involves me having to stop what I’m doing to answer, here’s what I want to know:

  • Priority: Is this super-urgent, or are you just asking out of curiosity? If it’s not crisis level and I’m busy, maybe you should save it for later.
  • Time To Answer: How long do you think it’s going to take me to answer? More than two or three minutes (from the time you start asking the question to the time I finish answering) and you might want to block off some time in Outlook.
  • Concise Description of Problem: Can you ask the question in one or two sentences (including enough context to make the problem understandable)? If not, stop and think through what you’re asking.
  • What You Expect: What are you looking for from me? Advice? A technical direction? Just someone to vent to?
  • Who Else You Asked: If you asked other people the question first, are they still working on it? Did they give you any additional information?
  • What You’ve Done: What have you done already to try to answer the question yourself?
  • When You Need It: Do I have to answer right now or can I get back to you?

Much of this goes hand in hand with the use of correct communication protocol. If you bug a person too much and/or in the wrong fashion, you’re not going to get a great response.

I’ll also throw out two more tips, specifically for people asking me questions:

  • Do not start your question with “I have a quick question.” I’ll determine if it’s quick or not based on the amount of time you think you need. Instead, try “I have a one-minute question” or “I have a two-minute question.” Make sure your time estimate is accurate - don’t say you have a two-minute question if it’s a fifteen-minute question. Don’t tell me you need one minute when you really need five.
  • Do not show up and drop your laptop on my desk. I know you may want me to review some code or look at something. The fact that you had to bring your laptop over already tells me you’re over the one-or-two-minute limit on drop-in questions and you need to schedule some time in Outlook. Nothing is more frustrating than “*bam* Hey, can you look at this?” Seriously.

I think I’m going to try this out on a larger scale. If folks at work have questions, I’m happy to answer them, as long as they’re good questions.

Stu kills me. It’s always all-or-nothing with everything he does.

Like, every three months or so, he decides he’s not drinking soda anymore, he’s just going to drink water. So he’ll do this cold turkey thing for a week or so, then slide into just having some juice or lemonade or something every once in a while. That lasts a couple of days until he moves to diet soda of some nature… which also only lasts a couple of days until he skips directly to the Mountain Dew. If they had Jolt at work, he’d probably have hit that long ago.

That cracks me up - he can’t just stick on the diet soda or maybe something a little lighter, he goes right from water to the Mountain Dew. If the guy was a poker player, he’d have a pair of twos and go all in.

The latest Stu craze is coffee. Up until about a week ago, Stu had never had a single cup of coffee. When you offered him one or urged him to try it, he’d politely decline. Not sure why, whether it was that he didn’t think it’d taste good, or that it didn’t sound good, or something else. He just wasn’t interested.

Somehow last week Sara broke him down and got him into a Starbucks. Hoo boy. Here’s kind of how it went last week:

Tuesday: Went to Starbucks, had first coffee. Pretty good! Going to have to try this again. Thursday: Went back to Starbucks after work, this time with Trav and Jenn. Had a mocha. Fantastic! Friday: Went to Starbucks at lunch. Decided I need to try one of everything on the menu. Started at the top with the standard “cup of coffee.” Will work through all specialty items. Saturday: Stopped in at Bed Bath and Beyond as well as Fred Meyer to look at coffee machines. Did you know you can brew this in your own home? Brilliance! I must have one. Found one that appealed to me, but decided to do a little research before committing. Sunday: Went back to Bed Bath and Beyond and picked up a nice coffee machine. Trekked past Starbucks for an “official” travel mug because the ones at Bed Bath and Beyond, well, they don’t quite profess my newfound love of coffee the way it needs to be broadcast. Also stopped by Fred Meyer and ground me up a couple different types of coffee (roughly two pounds worth - I anticipate tearing through this like it’s going out of style). Can’t wait to get this stuff home and set up my shrine to the coffee god. I have a tatami mat that will sit perfectly in front of it, and I can face the whole thing to the east so I can see the rising sun as my fragrant new coffee brews to perfection. Next stop, self-actualization!

I won’t lie - I can’t say I didn’t egg him on just a little bit. It’s kind of fun to get swept up in Stu’s waves. I mean, it did lead to bongos before, so I’m curious to see where this one will go. Sara, you’ve created a monster.