Archive for June, 2007

HTML & more

Monday, June 25th, 2007

If you’ve ever coded anything in raw HTML you likely have come across the need to escape a certain special character now and then. For example, you should never use the ampersand (&), or the greater-than (>) or less-than (<) symbols in raw html because those symbols represent special control characters. Instead you use coded character entities, sometimes called ampersand-escape sequences because they look like ampersand, followed by a code, followed by a semi-colon (see what the raw ampersand is used for?)

So, to get an ampersand you would put & There are a handful of commonly used escape sequences like this one such as ” = “, < = <, and > = >. These mnemonic escapes are nice, but they don’t cover everything. To get at the rest, you use &#NNN; where NNN is the decimal character code in the ISO-8859-1 character set …. uh, yeah whatever that means. Sometimes I think it would be easier to just look at a list and find the code for the character you want.

Here’s an awk script that generates a primitive html list of all the characters up to 1000:
awk 'BEGIN {
print "<html><body>";
for (i=0;1000>=i;i++){
printf "&#%0.3d; = &#%0.3d;<br/>\n",i,i;
}
print "</html></body>";
}' - > ampersand.html

drop ups?

Saturday, June 23rd, 2007

Here’s a slightly generalized revision of the drop down awk script (this one can go up):

awk 'BEGIN {
  t=start=60;stop=120;drop=2;
  count=(start-stop)/drop;
  if(0>count){drop=-drop;count=-count};
  while(count>=i){
    if(59<t){m=t/60;s=t%60} else {s=t;m=0};
    printf "#%2d on %1d:%02d leave on :%02d\n",++i,m,s,c;
    c=(c+s)%60;t-=drop;
  }
}' -

creating an iso 9660 disk image on Mac and Linux

Monday, June 18th, 2007

Yesterday I was getting frustrated trying to use a CD. One of the annoying problems with using CDs is that they have very slow access times compared to hard disk drives. Painfully slow. It’s a lot faster to read the whole CD at once and save the data as a disk image file, and then use that disk image for … whatever you like.

So that’s all I wanted to do. Seems simple enough right? (hint: it is) Well, simple or not, it turns out to be a rather non-obvious procedure, at least on the Mac. You see, the Mac has a lot of pretty GUI applications for doing little tasks like this. The obvious first choice is a program called “Disk Utility,” which happily creates a disk image from most types of readable disk. The problem I encountered with using Disk Utility is that it creates “HFS” formatted disk images, which was not what I needed. I needed an ISO 9660 disk image.

The solution turns out to be beautifully simple. You end up doing just exactly what you think needs doing, which is to just read the CD from start to finish and save the data to a file. dd is the program that does exactly this kind of thing, and you use it at the command line like this:

$ dd if=/dev/rdisk3s0 of=~/Desktop/savedCD.iso bs=4096

here if=<...> specifies the “input file,” of=<...> specifies the “output file,” and bs=N overrides the default blocksize, which is just how much data to read and write at once. The default blocksize is 512 bytes, which is very tiny value and imposes a lot of overhead. Here I’m using 4KB blocks, but 4 MB is probably even faster. The output file name can be anything; I’m naming the disk image savedCD.iso and saving it to the Desktop (noting that any existing file with that name is overwritten without further warning).

It’s important to note that dd is not actually authoring an iso disk image. It’s simply reading the iso-formatted data from the CD and writing that back out to a file.

some action shots

Monday, June 18th, 2007

I’ve recently acquired some action photos from the USMS 2007 swim meet. This one is from the start of the 200 backstroke:
200 back start

Sometimes it hurts.

Tuesday, June 12th, 2007

This morning I woke up about an hour late. I’ll spare the details, but I got to workout about 18 minutes after it started, which turned out to be almost exactly how long it took everyone else to do the warmup set. Now ordinarily, the various lanes will finish warmup at different times, since most people swim at different speeds. But today everyone finished warmup around the same time so that we could all do the main set together, which is usually a sign of something testing or tough.

And so it was. The main set turned out to be 1 x 100 (any stroke) for time, followed by 100 EZ followed by 10 x 100 @ 2:30 holding within 5 seconds of your time on first 100. Did I mention it was long course? Did I mention that I missed all of warmup? I dove in dry for the first 100 and just tried to build it. I surprised myself pleasantly by going 1:00, and then unpleasantly by realizing I had to do 10 more holding 1:05 or better. Ouch.

Historically, a “lactate set” like this, where the muscles fill with lactic acid faster than the body can remove it, has never been my strong suit. I really like resting between hard swims … or more importantly, my arm and shoulder and leg and core muscles like it. A lot. So probably I should do more lactate sets.

Drop downs

Monday, June 11th, 2007

This morning at swimming we did drop downs. Coach Whitney just got back from a week at the beach looking tan and happy, and I guess she wanted to test how we had done in her absence.

The drop down set works like this: you start with a two minute interval and swim as far as you can while still starting and stopping at a wall; then you drop the interval by two seconds and repeat this pattern until the interval reaches one minute. When you miss an interval you just drop down to the next shorter distance and get back on pace.

We did this set in a 25 yard pool, so the typical distances for most people ranged from 150 at the start to 50 at the end, with 125, 100, and 75 in between. The send-off times can get rather tricky if you aren’t a natural math whiz, so it helps to figure them out in advance. Here’s how it’s supposed to work if you start the set when the pace clock is “on the top”:

# 1 on 2:00 leave on :00
# 2 on 1:58 leave on :00
# 3 on 1:56 leave on :58
# 4 on 1:54 leave on :54
# 5 on 1:52 leave on :48
# 6 on 1:50 leave on :40
# 7 on 1:48 leave on :30
# 8 on 1:46 leave on :18
# 9 on 1:44 leave on :04
#10 on 1:42 leave on :48
#11 on 1:40 leave on :30
#12 on 1:38 leave on :10
#13 on 1:36 leave on :48
#14 on 1:34 leave on :24
#15 on 1:32 leave on :58
#16 on 1:30 leave on :30
#17 on 1:28 leave on :00
#18 on 1:26 leave on :28
#19 on 1:24 leave on :54
#20 on 1:22 leave on :18
#21 on 1:20 leave on :40
#22 on 1:18 leave on :00
#23 on 1:16 leave on :18
#24 on 1:14 leave on :34
#25 on 1:12 leave on :48
#26 on 1:10 leave on :00
#27 on 1:08 leave on :10
#28 on 1:06 leave on :18
#29 on 1:04 leave on :24
#30 on 1:02 leave on :28
#31 on 1:00 leave on :30

This morning I did 2 175s, 11 150s, 4 125s, and 13 100s, and I just made the last one on 1:00 going :59. This was only the second time that I’ve finished out the set on 100s, so I was fairly pleased. Immediately afterwards, there was a brief discussion about whether I should have done one more, but in any event, I wasn’t prepared to do another one right then so I didn’t. I think Whitney was correct that we did only 30 and not 31, but I think this happened because we skipped the first one (not the last one)!

Here’s the Awk script that I used to generate the send-off times:

awk 'BEGIN {
  t=start=120;stop=60;drop=2;
  while(stop<=t){
    if(59<t){m=t/60;s=t%60} else {s=t;m=0};
    printf "#%2d  on %1d:%02d  leave on :%02d\n",++i,m,s,c;
    c=(c+s)%60;t-=drop;
  }
}' -

CosMac Cloud

Sunday, June 10th, 2007

Mac cosmos (in icon view)

Tomorrow marks the kickoff of WWDC, the WorldWide Developer Conference hosted by Apple, Inc. at Moscone West in San Francisco. WWDC is the venue where Apple provides information and guidance to developers (and press) on its new (and existing) technologies and the directions in which they are heading. It’s part showcase, part technical conference, part elbow rubbing, and part party. It’s also part pulpit.

Quite frequently, Steve Jobs, the charismatic Apple leader, will use the keynote speech that kicks off the conference to pull back the curtain on longtime secret projects, thrusting them into the light. Sometimes the secrets are mostly hardware, but there is always software (Apple never ships hardware sans software).

The big software introduction that is sure to happen tomorrow is Leopard, aka Mac OS X 10.5, which is the operating system that drives the Mac, as well as (apparently) the upcoming uberhyped iPhone. I found portions of the image above on cnet, which purports to depict a banner currently hanging in Moscone West, depicting the Mac universe at a galactic scale, with application icons floating in space like so much cosmic debris. At first glance, the most prominent icon appears to be some type of window, which might start some noob Mac fanboys dreaming that this is the clue to Apple shipping a Windows virtualization application with Leopard. Except it isn’t. A simple click reveals it to be nothing more than a slightly rotated icon for Apple’s implementation of a workspace manager called Spaces, which they demoed at WWDC 2006, a full year ago. But perhaps that explains the “space” theme.

What is interesting about the image, however, is the relative prominence of some of the well known icons. For example, the icon for Xcode, which is the IDE for Mac OS X, appears prominently to the right of the large Spaces icon. Also note how the Finder icon seems to be about the same size as the Bluetooth Setup Utility and appears to be fading off into the night … most interesting. And what exactly is the icon above and to the left of “Spaces” that appears to be a cleaned up implementation of an old-school window?

Notes on underwater filming …

Saturday, June 9th, 2007

Now that I have a couple of underwater filming sessions under my cap, I feel the need to jot down a few quick notes to self. First note: after filming Ande last time I thought that wearing Fins and kicking along side the subject would be an improvement … unfortunately, holding the camera steady while kicking underwater with fins is harder than it sounds. Second note: setting the camera on the pool bottom pointing straight up seems to work as far as steadiness goes, but the field of view seems limited. Next time I’ll remember to bring a little tripod and try shooting from the bottom, but at an angle.

Enough about filming. To keep things interesting I’ll periodically post some local color commentary. Here’s Brandon taking it easy in between sets of 50 free on :35. Being a busy professional triathlete and coach, he doesn’t grace us with his company much these days, so we have to enjoy what we get. By the way, the facial bling is not actually implanted diamond studs, it’s just the camera flash reflected by water drops.

Sparkly Brandon relaxing

Ande’s new toy

Wednesday, June 6th, 2007

This morning, Ande told me that he thought the waterproof camera I used to film him swimming was so cool that he couldn’t help but to buy one for himself. The camera is very cool, but it does not come with a memory card … so he might want to buy one of those too.