Skip to content →

Category: news

iOS: Split a string at case change

I was looking to split a string on case changes today, and googling that problem didn’t turn up much. Here’s my implementation via a category. I hope it helps someone.

@interface NSString (Extensions)

- (NSString*) spacify;

@end

@implementation NSString (Extensions)

- (NSString*) spacify {
    // ignore irrelevant strings
    if (self.length < 1)
        return self;
    
    NSMutableString* result = [NSMutableString stringWithString:self];
    
    // create a range starting after the first character
    NSRange range;
    range.location = 1;
    range.length = self.length - 1;
    
    // match any uppercase character
    NSRegularExpression* r = [NSRegularExpression
        regularExpressionWithPattern: @"[A-Z]"
                             options: 0
                               error: nil];
    
    // replace matches with the match preceded by a space
    [r replaceMatchesInString: result 
                      options: 0 
                        range: range 
                 withTemplate: @" $0"];

    return [NSString stringWithString:result];
}

@end

Leave a Comment

Eat Less, Exercise More

Ever since I finished college and started working desk jobs, my weight has gone up gradually. For the first several years, this was a good thing. 5’10”, 145 lbs was not quite an attractive physique. When I hit 30, I was at 164 and pretty fit – exercising regularly.

By the end of last winter, I was at 187. I didn’t look that good and I didn’t feel that good. When my ultimate league started up in May, I couldn’t keep up with anyone. Shortly after that, I had my annual physical. I know BMI is a rough estimate at best, but the chart on the wall had me square in the middle of the overweight classification. When my blood work came back a week later, my cholesterol was (borderline) high for the first time. I was ashamed. I was also determined to turn it around.

I’ll save the suspense and report that by this weekend I’ve successfully lost 23 lbs. I’m back to 164, and I’m at least as fit as I was 7 years ago. This is how I did it, most of it is pretty basic:

  1. Eat Less – I really think this is the most important. At every meal I would consider what portion size I would have eaten. I then ate 50-75% as much. For example, I love Indian buffets. In the past I would typically take two or three trips. Now, I only take one.
  2. Exercise More – 45 minutes or more of exercise at least 6 days a week.
  3. Eat Better – I cut down on fried foods and sweets. My snacks were almost entirely fruit and nuts. More salads, very few appetizers.
  4. Punishment – Some of my favorite foods are french fries, potato chips, and buffalo wings. I love bacon and cheese on my hamburgers. I was ashamed of how far it had gotten, and I punished myself by vowing to eat absolutely no wings, fries or potato chips until I hit my goal. I could still eat hamburgers, but they were never with bacon and cheese. This also presents a nice little reward for reaching the goal: the punishment can stop.
  5. No Cheating – I stuck to the rules no matter what. It’s easy to say something’s a special occasion or to use a vacation as an excuse to take a break, but I think that’s highly counterproductive. A lot of people use exercise as an excuse to eat more. I didn’t.

I’m really happy with my progress here. Now that I’m at my goal, I intend to maintain the exercise level and better diet, while reducing the punishment as long as I stay under 165. While I don’t think I need to lose any weight, I would like to lower my body fat percentage. I feel a lot better, and I want that to continue.

Leave a Comment

Summer Sailing

I was first introduced to sailing when my father rented a Sunfish on Lake Phalen. My faded memory doesn’t recall a successful afternoon, but who knows? After that, I spent some time on his sailboards, and I always liked that while wanting for more control that my skinny teenaged body could muster.

A couple of summers ago, I took the sailing class offered by the Minneapolis Park & Rec board. That was a lot of fun as well as a good learning experience that I’d recommend to anyone. The same summer, a friend took me out on his catamaran on Mille Lacs Lake. We were cruising along pretty well, but found ourselves turtled in the very middle of the lake. The proper righting gear was not in place, and it seemed we might be stranded there all night. Not a boat was in site, and the middle of Mille Lacs is a long way from shore – not swimmable. We eventually recovered, but I have to admit it was scary.

Recovering from scary adventures is something I evidently enjoy, as I couldn’t wait to join the sailing club. After two and a half years dominated by grad school, I was excited by a summer free from school. Even better, I hired a lawn service. Looking for a fun way to fill that time, I’m really grateful that I found the Twin Cities Sailing Club.

The club is an awesome group for learning to sail and socializing with other like minded sailing enthusiasts. I’ve gone from being pretty green to “Skipper” status in the club: I can take out any of the clubs sixteen boats whenever I’d like. In return, I help other new sailors and join the club in maintenance days on top of a very reasonable membership free. It’s been great, and I look forward to many more summers spent sailing with them.

In the meantime, I’ve been enjoying a few adventures on my own. A couple of Fridays ago, I took a couple friends out on a C-Scow, a larger scow that I hadn’t previously skippered. I’d sailed the smaller MC-Scow many times, and this didn’t seem fundamentally different.

We enjoyed a few passes across the lake in lighter winds. In hopes of squeaking some more speed out of those slower winds, I asked my companions to sit on the leeward side of the boat to help us heel out of the water, reducing drag and letting us move faster. This was the key mistake on my part. An experienced crew would have been fine in that position, but once there it becomes very important to watch for coming gusts and shift weight accordingly.

A large gust came along pretty soon after that, and before they knew what was happening, the boat was on its side. I checked to make sure everyone was OK, and then reassured them that things were fine and that this happens from time to time. I’d done several capsize drills with the club, and I knew what to do in general. Unfortunately, I didn’t know what to do specifically for a scow. The capsize drills were all done on Catalina Capri 16.5s. The C-Scow is a different beast, and after a few attempts to right her, it was clear that I just didn’t know how.

A lot of helpful sailors turned up to give us a hand, but despite their best efforts we ended up swamping the boat. Around this time, I noticed some commotion at the nearby beach. There were, at least, one large firetruck, two police vehicles, and two ambulances waiting on shore along with a crowd. I saw this and said, “Oh man, tell me they’re not here for me.” Someone broke the news that they were. Despite our clear safety and the plenty of boats there to help us, someone on shore called 911, and the entire cavalry showed up. A police boat came out to meet us on the water, and there was another waiting on shore. They didn’t actually help us… just added to my mounting embarrassment.

In the end, a nice family helped us tow the boat to the beach where some club members and I were able to bail it out and get it seaworthy. I’m indebted to them and also to the experience as a whole. I learned a valuable lesson in crew assessment and scow handling in general, and we all walked away from it safely if a bit wetter than intended.

Leave a Comment

Viva Colombia

Today’s IHT Online features this interesting article about the rapid improvements Colombia is making insofar as improving its image as a violent country ravaged by the drug trade. Using my trips to my mother’s homeland as a personal basis for comparison, it certainly seems that the article’s claims are true.

I was amazed by the difference in how much Medellin in particular had improved. When I traveled there in 2003, my lasting impression was how impoverished the area seemed. While the poverty is far from eradicated, I left Colombia this fall impressed by how cosmopolitan Medellin seemed. Improvements were widespread and obvious. Unfortunately, the city seemed much more polluted that during my last trip. That may have been due to the particular air quality during the time of our honeymoon.

The government’s bold stance against violence is illustrated neatly in this square. Botero’s sculpture, “The Bird of Peace” was bombed by guerrillas. Instead of removing the destroyed work, the government annoted the incident on the old installation and built a new one right next to it.

Lastly, writing this reminded me of a funny saying my cousin Nicolas told us over cocktails while were discussing music and fashion trends: “Poor Colombians wish they were Mexicans. Middle-class Colombians wish they were American. The rich wish they were European.”

2 Comments

Mitch Hedberg

I was saddened yesterday to learn that my favorite stand-up comedian, Mitch Heberg had died on Wednesday. This is a real tragedy. I’m grateful that I was lucky enough to see him perform a few times. Mitch’s sense of humor was truly bizarre, and it was largely his nervous, stoner, staring-at-the-floor delivery that made his act so hilarious. One of my favorite Mitch one-liners is “I wish I could play little league now… I’d kick some fucking ass!” Another: “I bought an ant farm… those guys didn’t grow shit! C’mon guys, how ’bout some carrots.” I’ll really miss him.

This news came out yesterday, so I’m guessing this isn’t some sort of demented April Fool’s joke. Mitch wasn’t the publicity stunt type.

Leave a Comment