Skip past navigation, straight to the content

Hidden <Run />

Text content in WPF adheres to a strict content model, with elements (hopefully) fulfilling a specific role. In practice, this is fairly familiar for developers familiar with HTML. However, there are a few things that are useful to know — one of those things is the Run element.

Here’s a simple piece of markup:

<Paragraph><Italic>Neon Bible</Italic> is the new album by the Arcade Fire.</Paragraph>

This XAML parses and displays as you would expect. Underneath the covers, the element tree created is equivalent to the following markup:

<Paragraph>
  <Italic><Run Text="Neon Bible" /></Italic><Run Text=" is the new album by the Arcade Fire." />
</Paragraph>

In the land of WPF text layout, the Run element is the only element that holds actual strings of text. All other elements (Bold, Italic, etc) are ultimately formatting containers for Run elements that hold the actual text being displayed.

Knowing about these Run elements is important when you’re working programmatically with text. If you’re only doing markup, you’re (almost always) fine being blissfully unaware.

Exception to the rule

Of course, there are always exceptions to the rule — there is another element that can contain text in some cases: TextBlock. You can use TextBlock.Text, which is a DependencyProperty, to bind dynamic text. Here’s the thing to watch out for: TextBlock.Text will return the contents of TextBlock only if the content is a simple string. If you have any markup inside (such as a Bold element), TextBlock.Text returns an empty string.

Is this thing on?

For reasons both known and unknown, I’ve decided to start writing here again. I’ll cover WPF, along with other nerdy things like PHP, Ruby, and exciting role-playing games.

A Dash of Color

  • <br />
Ceiling Fan, Seattle, Washington

This page was looking mighty drab, so I thought I’d add some color. I’ll also add a few random updates:

I’ve now been back from China longer than I was there. This means that I may no longer bring it up in conversation, under penalty of law.

The snow season is almost over — I’m trying to squeeze in some trips before the snow all melts. I went twice this week.

This guy went much, much further with his self-imposed restriction (and for similar reasons) — hopefully he won’t quit after two days like weaker people. I’m still tinkering with the balance, but I’ll do it in private for a while, so I don’t bug anyone (you?).

I’ll be in Salt Lake City next week (and two weeks after that, and two weeks after that). I’ve got some friends from High School in Park City — but what should I do in Salt Lake itself? The guides I’ve looked at all seem to say that going to the mall is one of the top three attractions. I hope the Sbarro’s and Cinnabon there are as good as they are here!

When you’re unemployed, people demand you tell them what you did with your day. In detail. Before, no one ever cared — can you blame them?

First albums of 2007

Aesop Rock - All Day+

Aesop Rock - All Day+

This is the latest in a series of running-specific mixes commissioned by Nike. When I started running, I often listened to LCD Soundsystem’s 45:33, which was my first exposure to the series. Although I like LCD Soundsytem, I’m not in love with this mix — it’s a bit too repetitive. In the liner notes for his mix, Aesop Rock writes about the requirements Nike gave:

There had to be a new element every 30 seconds or so (a new riff, a new layer, a new drum pattern) as other elements faded into the distance. Basically, I had to keep the scenery shifting while maintaining the “push.”

It turned out well. I like having a consistent mix to listen to, because it gives me a good idea of how long I’ve been running (without actually looking at the time). Plus, it’s nice to have Aesop Rock telling you “No Surrender” when you’re getting tired.

You can hear a sample of the mix on Aesop Rock’s MySpace.

Amon Tobin - Foley Room

Amon Tobin - Foley Room

I’ve always been a big fan of Amon Tobin’s dense instrumental music, and his latest doesn’t disappoint. It may be a bit dark for some, but somehow I find it to be a great soundtrack while working. The album’s nothing new or groundbreaking for Tobin, but it’s still quite good.

As of right now, it seems like Amon Tobin’s MySpace is the best place for samples (the official website has an annoying flash interface) — although two of his songs will start playing at the same time (scroll down, there’s a video that autoplays).

The Besnard Lakes - The Besnard Lakes Are the Dark Horse

The Besnard Lakes - The Besnard Lakes are the Dark Horse

The Besnard Lakes play long rock songs with country tinges — their style reminds me of 2005’s excellent Z by My Morning Jacket. Although the songs are longer, there are only eight tracks so the album is only about 45 minutes long. As with My Morning Jacket, the lack of filler works to the band’s advantage.

Somehow, the MySpace page wins the usability contest for audio samples again. These artist websites are terrible.

Other Releases

A lot of artists I really like are releasing new albums. Sadly, I’ve been mostly disappointed.

Have I missed anything good?

Running

I never liked running. Although I could play hours of basketball or soccer, if I set out to go running, I would stop before even reaching a mile. I got bored quickly, kept on noticing how tired I was, and eventually gave up and found some other way to exercise like soccer — or a hamburger.

Even though I didn’t like running, I wanted to. There was something romantic about the sport. I was drawn to the simplicity, the minimal equipment necessary, and the lack of dependency on others (no need to wait around for a game of pickup). A lot of runners would tell me how great it was to run while traveling — seeing large parts of the city on foot, especially in the morning, provided context and a different view of the area.

Also, running was a sport that people were to do across their lifetimes. Perhaps its the lack of dependence on others, or the ability to go at your own pace, but I never met sixty year-old soccer or basketball players. The active people that age all seemed to be runners.

During my last weeks in China, feeling unhealthy from the pollution and my emaciated state, I decided it was time to suck it up and become a runner. I emailed some of my runner friends and asked for advice, realized I didn’t have running shoes, and made plans to start running as soon as I came back to the US.

I had a lot of downtime while traveling during those last few weeks in China — so I made up some ground rules for my running: Run every day to build and reinforce the habit, run before doing anything else (like checking email) to make sure it doesn’t get procrastinated away, and run for around a half-hour so it doesn’t take too much time (which could put the habit at risk).

My first runs were terrible, of course. The very first run lasted about twenty minutes, and I probably walked at least eight of those minutes. Luckily, most of my early runs were in Florida, which is drier and warmer than Seattle.

I’ve kept at it, although I’ve revised the rules — I quickly moved to six days a week (taking Sunday off), and now I run whenever I feel like it and the conditions are decent (three to four times a week). I rarely run in the mornings, because it’s usually better to wait until the afternoon when it’s 45, not 35, degrees out.

I’ll typically run between four and five miles, which takes a comfortable thirty to forty minutes, depending on terrain. The longest I’ve run was seven miles, with a mile-long walking break in the middle.

Finding good routes has been a bit of a pain, since Seattle has lots of steep hills — on the upside, I feel much faster when I run in Florida (where the highest point is mostly in Alabama and a hundred feet shorter than Capitol Hill).

My biggest piece of advice to those starting off: Track your progress. Take a note of how far you’re running, and how long it takes. It’ll be depressing at first, but it’s great to see how much you’ve improved since you started. If you’re into gadgets, a GPS tracker is nice to have (got mine for Christmas — thanks!). I’ve found the distance measurement to be accurate and consistent. My only complaint is that altitude readings are pretty much useless — when I ran around Green Lake (which is quite flat) it told me I ascended 500 feet on the first lap, and 360 feet on the second.

The forecast said rain, but it’s currently sunny outside. I’m off…

Top Level Categories Plugin 0.1

Introduction

The Top Level Categories plugin allows you to remove the prefix before the URL to your category page. For example, instead of fortes.com/category/work, I use fortes.com/work for the address my “work” category. WordPress doesn’t allow you to have a blank prefix for categories (they insert category/ before the name), this plugin works around that restriction.

Download

Top Level Categories v0.1

Installation

  1. Download top_level_cats.zip, unzip it and save the top_level_cats.php file in your wp-content/plugins directory.
  2. Activate the plugin through your WordPress admin area (See the official documentation if you need more help with this.)
  3. Go to Options -> Permalinks in your options panel and press Update Permalink Structure.
  4. That’s it! Your category links are now changed!

Donate

If you’re feeling generous, go for it:

Notes

I use this plugin in conjunction with the excellent Permalink Redirect Plugin. If you’re using the plugin, you should make sure to fix a simple bug in the program that messes up category feeds. You can do so by adding the following code to the file on line 174 (right before the return $link; line):

        if (is_feed()) {
        	$link = trailingslashit($link) . "feed/";
        }

Known Issues

This plugin will not work if you are using a permalink structure that is only the post name (i.e. /%postname%/ in the options). This is because it creates an ambiguous situation where both categories and individual posts end up with the same URLs. To fix this (if you don’t mind switching your post URLs), switch permalink structure to one of the built-in settings (like Date and Name Based).

Internet Use Experiment

One of the advantages of having a lot of unstructured free time is that I have more leeway to try things out and see what happens.

This week, I will use the internet for no more than thirty minutes a day. This is use it or lose it, and must be continuous (i.e. I can’t do six five-minute intervals). I can use the computer otherwise, but my wireless card is off at all times.

I actually started this yesterday (and went a bit over trying to take care of some things before going offline). Initial results: I can definitely sense a bit of an addiction. Also: it’s unclear whether I should use my half hour in the beginning or end of the day. I originally planned on waiting until the end of day today, but had to look something up online.

Update 2/27: This was a stupid idea, I’m cutting the experiment short. I’m far too dependent upon online references to be able to get things done. Kind of sad.

Sasquatch 2007 Lineup Announced

Pitchfork has the details, this is an awesome lineup:

The lineup includes Björk, the Arcade Fire, the Beastie Boys, Interpol, M.I.A., Spoon, the Hold Steady, Grizzly Bear, Neko Case, the Thermals, the Blow, Loney, Dear, the Black Angels, Electrelane, Manu Chao, Mirah, and Bad Brains.

It looks like Ozomatli are also slated to play. I’m looking forward to it. This will be my fourth year in a row attending.

Post Levels 1.0.9 (for WordPress 2.0.x)

I’ve gotten a few emails from people that are still running the 2.0.x versions of WordPress (which will apparently be supported until 2010). Due to a boring technical reason, the “User Levels” menu is hidden from the admin section if you use Post Levels 1.1.1 with WordPress 2.0.x.

You can download the release from here: Post Levels 1.0.9

Note that this version lacks features in 1.1.1 — this is due to the new capabilities introduced in WordPress 2.1.

Do not use this plugin if you are running WP 2.1 or greater, your waistline will expand and dogs will no longer like you.

Is Technology the Answer for Information Overload?

A few days ago, I ran into a post by Nova Spivack that talks about the work his startup, Radar Networks, is doing. It’s a long article, but here’s a portion that caught my attention (emphasis mine):

As the Web gets vaster and more complex, and as consumers must work with a growing array of content and services, productivity is seriously being threatened — not only in search, but also in every other area of our digital lives. Most of us who work intensively with knowledge and information already have a direct and intuitive experience of how information overload has grown, even in the last decade. Clearly something must be done about this or in another few years we will all be buried in our own information.

The Semantic Web provides the best (and really the only) long-term solution to information overload and complexity. By starting to add richer semantics to data, and by enabling applications to start leveraging this, it will make it possible to help people regain more of their productivity and to make software smarter — without having to attempt to create super-duper science fiction artificial intelligence.

I completely agree with Nova that Information Overload is a serious (and obvious) problem — my love of information has led me down a dark, dark path that keeps my laptop within close range at all times. The technologist in me likes to think that this is a solvable problem — when we finally get around to doing X, Y, and possible Z we’ll look back and laugh about information overload, Y2K, and other crises of yore.

Then reality — or perhaps it’s cynicism — sets in and I realize the only solution to this problem is willpower*.

When I first started using the Internet (in 1995, I’m a huge nerd), my surfing habits were targeted. I would look for something specific, like a technical reference or song lyrics. As time went on, I started adding a set of sites that I visited daily or weekly such as magazines, message boards, and the proto-blogs.

A few years later, I had somewhere between ten and twenty sites that I visited on a daily basis. If it was a slow day, I might conjure up a few other sites to tackle. Time spent visiting these sites was certainly over fifty percent of my time spent on the web — I still used the web for targeted search, more each year, but the daily surfing grew more rapidly.

Fast forward a few years to 2001, when I first started using an RSS aggregator. Suddenly, I was able to get through my daily sites much quicker. So much so, that I found myself with “extra” time. I had developed a habit of web reading, and that thirst wasn’t feeling quenched by the briefer reading sessions.

So I subscribed to a few more sites.

What happens next will surprise no one — my subscription list grew until I was spending as much time reading as I used to, and then increased some more. Unlike my “manual” surfing, the aggregator made sure that I never missed a thing. I thought this was wonderful. I was able to read more than ever, and I nothing got past me!

As I upgraded to newer, better news aggregators, I found myself adding more and more feeds. I was spending more time reading each day, but think of the time I was saving! Eventually, I was subscribed to about 200 feeds, and had over 4,000 unread items — and I completely intended to get to those unread items (in fact, I believe I still have them all shared somewhere …).

At some point, I finally broke, realizing how unsustainable it was trying to keep up with that much news. I switched aggregators, and scrapped my old subscriptions, starting fresh. I’ve done this a few times, and I currently have under 50 feeds — most of which are infrequently updated.

The dream is half right — technology can improve efficiency. It’s just that, at least in my case, I the savings got reinvested back into consumption. This is a risk for all information gluttons, no matter what the technology (blogs, email, etc).

There are many parallels with food consumption — you have to watch what you eat, lest you get fat.

* I should clarify what I mean by “this problem” — search technology has made huge improvements in the ability to find relevant information (topical searching). The problem I’m referring to is the “information overload” of incoming items such as email.

Post Levels 1.1.1

Post Levels 1.1.1 is a bugfix release that will (hopefully) get rid of some of the problems people have been seeing with the 1.1 release.

Download

Post Levels 1.1.1

New Features

  • Use the post teaser as the preview: You can now show the post teaser as the preview for non-logged in users. (requested by Gas)
  • Bug fixes: This release should fix the issues with Ultimate Tag Warrior 3.1415926 (duplicate posts and SQL errors). If you find more, please let me know.

Note: Several people have mentioned that Post Levels is causing their posts to appear in reverse order. I’m unable to duplicate this, so please let me know if it’s still happening in this version.

Who could possibly take the Grammys seriously?

From the list of winners:

Winner of Best Pop Performance By A Duo Or Group With Vocal: My Humps - The Black Eyed Peas

Enough said.