Wednesday, August 24, 2005

Typing Accents


I was working on reformatting my résumé a little bit today, and I wanted to change my MSN IM tag to reflect the fact. So I set it to "Resume" and went off to work. Of course, all that did was draw a smartass remark from Ian about me powering my brain back up after suspending it. :)


While we were chatting, I finally remembered the key sequence that would have let me type "résumé" instead of "resume". It's control-' followed by e. Similarly, control-` followed by a letter renders the other accent (although not for all letters). And control-~ a gives ã.


Two interesting things about this:

  1. Ian's keyboard gave reversed accents from mine for the same key sequences. But he's in the UK - maybe this has something to do with driving on the wrong side of the road. :)

  2. These key sequences don't work in all text controls. So far, from what I've tested, it works in Word and in MSN IM, but not in notepad, notepad2, nor InfoPath.


At any rate, I'm sure I could have found this on Google, but now I know where to look. Also, hopefully blogging this will remind me to make sure I put support for it into my TextEditor control.

Centering with CSS

After all that "I'm so great" in my post yesterday, I figured today would be a good time to show off how little I know about most things. :)


I'm an HTML/CSS neophyte. I can manage a basic page okay, but fancy-pants layout is well beyond me. CSS, in particular, is a topic whose further reaches I've never explored. Heck, I've barely wandered a few feet from its parking lot. (Although the FireFox EditCSS extension has made my HTML look loads better by making it easy to experiment.)  


One of the things I always have trouble with is figuring out how to center stuff. I'll slap a text-align: center on things sometimes, but that doesn't always accomplish what I want. So today I ran across this little nugget:




  position: absolute;
  left: 10%;
  right: 10%


It gives me the ability to center something in the middle 80% of the page. It worked so well I wanted to record it here for my own future reference. I'm sure anyone that has spent any time with CSS already knows this (or a better version), but at least now I can find it again when I need it.

Tuesday, August 23, 2005

Transitions (Subtitle: Whore for Rent)

Update: fixed minor typo.


Keith just outed me, so I'd better come clean. :)


I've been an independent contractor for about the last six years. I love it. One of the great things about it is the flexibility: my schedule is flexible, my working arrangements are flexible, and indeed my very career track is flexible. Of course, all that flexibility comes with a price - I have to self-direct, and sometimes you wind up on the bench for a bit. But I don't mind those.


One of the very positive outcomes of all this flexibility has been the ability to alternate between what I think of as an "academic" track, and what I think of as a "practical" track. In my "academic" mode, I spend a lot of time sitting around and looking through docs, playing with betas, and generally examining all the corners of a particular piece of technology. In my "practical" mode, I help my clients build real systems.


I can't imagine doing just one or the other. If I were purely academic, then there are all sorts of things that I'd never be forced to do, like write a real build script, fix really difficult bugs, or, generally, ship a product. And if I were purely practical, then I'd almost always be constrained by time pressure to only learn the parts of technology that I actually use, as they became needed. That sort of need-driven education tends to leave big holes in your knowledge, and you never know when the stuff you don't know might come in handy.


Teaching for DevelopMentor was a great way to live the academic life. The fear induced by the thought of standing in front of an audience and not knowing what the hell you're talking about is an excellent motivator. I learned tons of things I never would have, simply because I wanted to know the answer in case anyone ever asked me.


At the same time, not being forced to apply all that theoretical knowledge means that you can't fully appreciate it. You can think all you want about things like the performance of the .NET garbage collector, but there's no substitute for experience to tell you that in the real world you hardly ever care about it.


For roughly the last three years, I've been in a almost purely practical mode, and it's been great. I've worked on a bunch of open source projects (most notably FlexWiki), contributed to the MSDN2 rewrite, and helped my client Integic with a massive .NET port of their workflow product. It has all been highly educational. But the pendulum has swung, and now I miss the academic side of things, particularly now that we're so close to the release of the next version of .NET. So I'm making a change.


I'm proud to announce that I will once again be taking on the role of itinerant instructor, this time with Pluralsight. It's a first-rate organization, and I'm really looking forward to working with these guys again. I'm not entirely sure what class(es) I'll be teaching yet, but I'm definitely eager to get to it - diving deep into the details of something and then sharing it with my students.


The timing on this is pretty good. I'm ramping down with my existing client as their ship date approaches, so it's a good time to change gears. Which is where you (and the subtitle of this post) come in: I'm also looking for work. I'll be teaching, of course, but that's only a fraction of my time, and as I explained, I don't think I can be the best instructor I can be unless I'm continually applying the knowledge I've gained in the real world.


Here's the part where I shamelessly promote myself (you can skip to the last paragraph if you find this sort of thing embarrassing):


I graduated with a simultaneous BS/MS in 1995 from MIT. I've got about five years experience working with .NET. I consider my specialty to be the design and implementation of large-scale distributed systems. I'm quite good with C#. I know my way around XML, including web services technologies and XSLT. I've written for MSDN Magazine. I'm a mean debugger. I learn very quickly. I helped rewrite a significant chunk of the fourth biggest website on the planet. I've spoken at conferences around the world on topics from Visual Studio to Direct3D. You can find my resume here.


So, if you've got a project you think I could help with, please do contact me. And if not, hopefully I'll see you in class!


Like I said, I love being an independent contractor; it makes for interesting transitions. We'll see where this set takes me next!

Sunday, August 21, 2005


A few weeks ago, I blogged about a problem with SourceForge's bug/feature request tracker export feature. Specifically, they aren't escaping illegal characters in the generated XML. Very bad, particularly because it renders the output useless to conforming XML parsers like the ones in System.Xml.


The problem is, during business hours the trackers on SourceForge are so slow as to be nearly useless. I assume this is because they're overloaded. Whatever the reason, if all you want to do is scan through all the open bugs in FlexWiki, it's annoying: I'm not going to update anything, after all, and looking through 200 bugs when page loads take in excess of 30 seconds each is not an option.


So I set out to see what I could hack together quickly to fix the SourceForge export. And what I came up with is tracker-tidy. The source is at the bottom of this post. It's an ugly little program that does one thing: escapes & and < within a particular XML tag. It does this by scanning a text file one line at a time, looking for <foo>, where "foo" is whatever you specify on the command line. When it finds it, it replaces all occurrences of & and < with &amp; and &lt; (respectively) between that point and where it finds </foo>.


Like I said, it's ugly. It doesn't deal with attributes on the opening tag, it doesn't know jack about XML namespaces, and it doesn't replace the contents of more than one tag at a time (although it will do all tags with that name). Doing all that would have required a lot more than 70 lines of code. But what I have works against the SourceForge feed, although I have to run it several times, once for each tag that might have illegal content. I use wget and tracker-tidy together in this batch file:


wget^&atid=665396 -O bugs.xml
copy /y bugs.xml input.xml
tracker-tidy summary input.xml > intermediate.xml
copy /y intermediate.xml input.xml
tracker-tidy detail input.xml > intermediate.xml
copy /y intermediate.xml input.xml
tracker-tidy old_value input.xml > intermediate.xml
copy /y intermediate.xml input.xml
tracker-tidy text input.xml > intermediate.xml
copy /y intermediate.xml bugs-tidied.xml


wget^&atid=665399 -O rfe.xml
copy /y rfe.xml input.xml
tracker-tidy summary input.xml > intermediate.xml
copy /y intermediate.xml input.xml
tracker-tidy detail input.xml > intermediate.xml
copy /y intermediate.xml input.xml
tracker-tidy old_value input.xml > intermediate.xml
copy /y intermediate.xml input.xml
tracker-tidy text input.xml > intermediate.xml
copy /y intermediate.xml rfe-tidied.xml


del bugs.xml
del rfe.xml
del input.xml
del intermediate.xml


This simply downloads the tracker bug and feature request exports for FlexWiki and tidies up the output with multiple passes of tracker-tidy (one for each problem tag in the export).


Once I have the tidied files bugs-tidied and rfe-tidied, it's a simple matter to open them up in Excel or InfoPath, or whatever your favorite XML-based tool is. From there, sorting and searching is dead easy. If I get really ambitious, one of these days I'll write an XSL to generate a nice little web report instead. But given how little effort went into getting something that works as well as this does, I sort of doubt it.


Anyway, hopefully this will help someone else. Obviously, you'll need to replace the URLs in the batch file with the group_id and atid for your project, but other than that it should work fine. Just remember to escape any & signs in the URL with ^, the command-line escape character.


using System;
using System.IO;
using System.Text;


namespace Wangdera
  public class App
    public static void Main(string[] args)
      string tag = args[0];
      FileStream inputStream = new FileStream(args[1], FileMode.Open, FileAccess.Read, FileShare.None);
      StreamReader inputReader = new StreamReader(inputStream);


      string startTag = string.Format("<{0}>", tag);
      string endTag = string.Format("</{0}>", tag);


      string line;
      bool inTag = false;
      while ((line = inputReader.ReadLine()) != null)
        int tagStart = line.IndexOf(startTag);
        int tagEng = line.IndexOf(endTag);
        int escapeStart = 0;
        int escapeEnd = line.Length;
        if (tagStart != -1)
          inTag = true;
          escapeStart = tagStart + startTag.Length;
        if (tagEng != -1)
          escapeEnd = tagEng;
        if (!inTag)
          string beginning = line.Substring(0, escapeStart);
          string middle = line.Substring(escapeStart, escapeEnd - escapeStart);
          string end = line.Substring(escapeEnd, line.Length - escapeEnd);


        if (tagEng != -1)
          inTag = false;


    public static string Escape(string input)
      StringBuilder builder = new StringBuilder(input);
      builder.Replace("&", "&amp;");
      builder.Replace("<", "&lt;");
      return builder.ToString();



Tuesday, August 16, 2005

A friend of mine showed me today. Despite the possible scatological interpretations of the name, it's actually a nice little site. Very simply, you can use it to transfer files to a friend by uploading stuff to dropload via a web page and providing your friend's email address. They'll get an email with a link that lets them (and only them) download the file within seven days. They're only allowed to download exactly once.

Upload requires free registration, but download does not. And if you believe their privacy statement (I do) they won't share emails with anyone. Poking around the FAQ, the site seems legitimate enough.

I'll definitely be using this site again.

Wednesday, August 10, 2005

Ian on Projections

Ian Griffith's blog is consistently worth reading - I learn something almost every time he writes. I want to particularly note his latest post, though, because it has a direct bearing on one of my favorite subjects: Direct3D. In the post, he talks about the difference between orthographic and perspective transforms, a topic which is highly relevant to anyone who has ever wondered about the APIs Matrix.PerspectiveFovLH, Matrix.OrthoLH, and all their friends. Go read it.

Monday, August 8, 2005

Talk About Yer Security Vulnerabilities

Bruce O'Dell is a friend of mine from back in my Digital Agility days. He's been very invovled in USCountVotes, so he sent me this link. If you follow it, you can find details of the vulnerabilities of the Diebold optical scan equipment increasingly used to count votes here in the US. Regardless of whether or not you think vote tampering has taken place, it certainly seems to me that election machinery ought to be a bit more tamperproof than your briefcase lock...paper trail anyone? After all, ATMs have them - it's not like the technology is way out there or anything.