Monday, September 30, 2013

Wisdom From A Scribe

Yitzchak the computer programmer and sacred scribe had this to say about some Torah repair work he was doing:

The maftir readings for all Jewish holidays occur in Parshat Pinchas. Most established congregations have at least two Torah scrolls, one for the regular reading and one for the special readings when a second scroll is required. Naturally this second scroll is constantly being rolled to Pinchas and then moved around within the parasha. This leads to the section where Pinchas occurs wearing out a lot faster than the rest of the scroll. This week over sukkot, I noticed several damaged letters and even some whole words rubbed out in or around the maftir reading. Apparently this is very common in scrolls only ever used for maftir. In fact, the original yeriot of that section were replaced years ago and this is the second round of fading.

What's this all mean?

Imagine you have a sacred text, hand written on special parchment. And imagine this text is written without vowels or punctuation, so that when you unroll the scroll, you see blocks and blocks of consonants. Now, imagine, you need to turn a special point in the scroll a few times a year to read from a specific portion of the text. If you've got more than one Torah, it's awfully tempting to just set it in the right spot and leave it alone. That way, you don't have to worry about navigating your way around the scroll, and you won't accidentally damage it in the process.

But, as Yitzchak explains, this good intention actually does harm. You end up wearing out that one part of scroll at a faster rate.

In other words: even something as sacred and seemingly fragile as the Torah, Use It or Lose It.

Another programming myth: if you don't code when you're a kid, you'll never be a pro

For some reason, this Wired story really got me into a tizzy: Forget Foreign Languages and Music. Teach Our Kids to Code. The thesis of the article is that you really can't start teaching kids to code young enough. And heck, rather than teaching them to say, Mandarin, in kindergarten, why not teach them how to program? Both are languages, right?

My first thought was back to my senior year of high school. I took my one and only AP course: AP Computer Science. In it, I learned Pascal (on a Mac no less, had I taken the class a year or two earlier, I would have been learning on a mainframe!). I hardly mastered the world of programming (scoring a whopping 2 out of 5 on the AP, the score you get for basically signing your name to the test), but it was enough to teach me I had a genuine interest in the subject, and to give me the skills to do well enough in CS 113, my first CS course at University at Buffalo. And from there, as they say, the rest was history.

At the same time I was learning For loops in Pascal, I was in my 5th (!) year of German class. As far as I can recall, despite years of instruction, I still had a sub-kindergarten level of German at this point. If I think back, I can still remember the teacher imploring us to learn the Die Der Das Chart, whatever the heck that was.

All this is a fancy way of saying, a programming language and a foreign language are not related in the least. The former, even for all it's initial confusing nomenclature (classes, instances, recursion, etc.) is amazingly tidy compared to the exception and massive-amounts-to-memorize nature of the latter. In other words, it's smart to teach Mandarin to kids when they can just absorb it. That's simply not necessary for learning to program.

I'm absolutely a big believer that programming is really problem solving, and that these skills should be learned by all. But the thought of having a 7 year old program Frogger seems silly; better he should be outside *playing* frogger, than inside coding it. Yes, young kids should experience age-appropriate versions of programming concepts like debugging, building abstractions and modularization. But most importantly, they should be working on that often neglected programming skill: using your imagination.

Now, by the time a kid a teenager, there's no excuse for them not to be coding. The recipe seems simple: for every N hours of game playing time, you should have M hours of coding time. Within a summer, any teenager can master all the skills he or she will need to know if this is a field they want to pursue.

Perhaps what annoys me most about this article is the potential formulation of another programming myth: like violin or Mandarin, if you don't start when you're 5, forget about it. You'll never be a pro. Like the persistent myth that programming requires math (What math? Most programs contain no more math than adding or subtracting 1 to a number), this isn't helping anyone.

Finally Putting an Etrog To Use

For years I've been talking about putting the etrog that I use during the holiday of Sukkot to good use. Finally, thanks mostly to lots of effort by Shira, I was able to do this.

While there are a number of recommended uses for an etrog (including an easy recipe for etrog salt) I was hoping I could twist Shira's arm into making me pie. And to her credit, she did.

This morning for breakfast, I was able to enjoy our Etrog Meringue Pie. Yum!

Along with making the pie, I also salvaged the seeds to see if I could get them to grow. I'm sure I did this all wrong, and I have very low expectations. But who knows, maybe one of the three cups of dirt on our window sill will sprout? For a far more touching tale on the topic of etrog seeds, check out this story.

As proof that all this happened, here are a few photos our little project session last night. If nothing else, I've got more ideas than ever for next year!

The before photo:

Hurray, etrog zest!

Seeds. I'm sure decimated my squeezing what little juice is in an etrog out of it:

Seeds in dirt. Yeah, no way this is going to work.

But who cares, cause we've got pie!!!

Wednesday, September 25, 2013

Half a Do It & Carry It Solution

Carryology has a relatively new category of posts known as: Do It & Carry It, where they suggest small DIY projects for carrying your stuff. For example: combine rope & a towel to make a self contained beach backpack.

It's a clever idea, especially on a site where many of the slickest items are on the costly side.

Anyway, I've got half a Do It & Carry It solution worked out, so I thought I'd share. Maybe someone can suggest an easy to finish it off?

First, a little background. It's just about Fall, which means it's almost time to pack in the cargo shorts and bust out the jeans. This means that I'll have a lot less space to cram all the junk useful tools I usually carry in my pockets. On the bright side, though, it's almost jacket weather. And with jackets, comes pockets!

But what about the in between weather: where a jacket is probably overkill, but shorts are out?

Well, here's a possible solution:

1. Start off by collecting your non-essentials. In this case, I've got a Buff, Altoids Tin filled with goodies, a Bic lighter and a moncular (which I naturally left home on this day).

2. Stash all the stuff in the pockets:

3. Fold the jacket:

4. Roll the jacket:

5. Now things get hazy. In the photo below, I used a couple of reflective bike-pant-holder-thingies to secure the jacket. That's handy if you're outdoors, but not so handy if you don't want to call lots of attention to yourself. And then it needs some sort of strap, so you can actually carry it.

So, how could this be made useful?

Tuesday, September 24, 2013

Bringing PHP Templates to MojoMotor

Recently, one of my clients added a site that leverages MojoMotor (MM) to the list of assets that I now help maintain and improve. MM has an almost Perch like philosophy about being a CMS: it's all about being as lightweight as possible. And to the credit folks behind MM, they have managed to put together a lean system.

MM uses a sort of tag based markup language to power its templates. While handy for simple tasks, I vastly prefer using PHP as a template language, rather than something ad hoc. Luckily, MojoMotor is easily extendable and in about 40 lines of code, I had a full PHP based template engine running within MojoMotor.

Now, a MM layout can contain code like:

 <html>
   <head>
     {mojo:snippet:apply path="assets/js" src="foo.js"}
     ...

Which invokes snippets/assets/js.php and sets $src to the value foo.js. Within that file, I may have:

<?
  /*
   * Render a javascript include
   */
  $xcache = calculate_our_cache_busting_value();
  $should_mini = should_mini_files();
  $src = $should_mini ? "/assets/mini/$src" : "/assets/full/$src";
?>
<script src="<?= $src ?>?xcache=<?=$xcache?>"
           type="text/javascript">

Using this tiny function, it's possible to invoke one snippet (PHP template) from within another, making for easy abstractions.

To implement this in MM, I created the following directory structure:

system/mojomotor/third_party/snippet/index.html   (an empty file)
system/mojomotor/third_party/snippet/libraries/
system/mojomotor/third_party/snippet/libraries/snippet.php

Inside of snippet.php is this hunk of PHP code:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/* CHANGE ME: At the top level of the source tree.  */
define('SNIPPET_BASE_DIR', dirname(__FILE__) . '/../../../../../snippets');

/**
 * Snippets are small chunks of HTML code that are
 * imported and evaluated on the fly.
 */
class Snippet {

  public function apply($template_data) {
    $_path = $template_data['parameters']['path'];
    unset($template_data['parameters']['path']);

    if(!$_path) {
      return "Snippet error: no path param";
    }
    if(!file_exists(SNIPPET_BASE_DIR . "/$_path.php")) {
      return "Snippet error: not found: $_path";
    }

    $body = $template_data['tag_contents'];  
    extract($template_data['parameters']);

    ob_start();
    require(SNIPPET_BASE_DIR . "/$_path.php");
    $content = ob_get_clean();

    return $content;
  }
}
?>

I'm sure there are optimizations to made (add caching of snippets, perhaps?), but as a quick and easy way to add a lot of power (and abstraction) to your templates, this approach is hard to beat.

Monday, September 23, 2013

Signs of Fall

On a walk today, I couldn't help but notice this tree with beautiful red foliage:

Trees, so handy for telling the seasons.

Two Northern VA Birding Resources

I was poking around the Kenilworth Aquatic Gardens website, trying to plan a visit, when I found that they offer two seemingly useful PDFs: Common Kenilworth Aquatic Birds and a Bird Relative Abundance Checklist.

In other words, one document helps you name what you think you saw, and the other document helps you confirm it by telling you how likely (or unlikely) your find is.

Field guides can be tricky: too exhaustive, and you can't find what you're looking for; too terse, and they aren't useful. The 6 page Common Birds list looks like it falls neatly between these two extremes.

Review: Instant, The Story of Polaroid

Instant, The Story of Polaroid, is one of those fun books that seems to encourage you to play Monday Morning Quarterback with a well known brand. In this case, Instant neatly lays out the rise and fall and partial-rise again of the iconic Polaroid company. All the key parts of the story are there: you've got the Harvard drop-out genius founder, the Aha! moment, the technical and aesthetic marvel of a product, the mis-steps in the later years and of course, the ultimate downfall (though not quite, Polaroid still putters along to this day).

Prior to picking up this book, I had two memories of Polaroid. First, my Grandpa had an SX-70, a truly revolutionary and remarkable camera. Of course, I didn't know it at the time, but as a kid watching it spit out prints was absolute magic. Second, I can recall our family owning a big, plastic, boxy Polaroid when I was much older. It too spat out prints, though they weren't great quality and they were awfully expensive. I naturally assumed that's what Polaroid was all about: you traded quality and cost for instant gratification.

After reading this book though, I now realize this only a small part of the story. Polaroid made cameras and film beloved by all sort of photographers and artists, including well known artists like Ansel Adams and Andy Warhol. They made large format cameras, super high sensitivity film and yes, cheap-low-quality cameras for kids. All in all, far more depth than I ever gave them credit for.

But enough about the facts, let's do a little hindsight preaching!

Prior to reading this book, I would have probably gone on and on about how both Kodak and Polaroid missed the digital revolution. See, I'd explain, they mixed up their goals and their methods.

A goal is what the brand is ultimately trying to accomplish: Kodak wanted to make photography accessible to all; Polaroid wanted to deliver instant images.

The method is how you accomplish said goal: for both Kodak and Polaroid, this was a combination of camera and film.

Goals are timeless. If you want to get from New York to Los Angeles, your goals are to do it quickly, safely and cheaply. Methods, on the other hand, change. Depending on the year, you might go across the country by wagon train, railway or airplane. Who knows, maybe one day we'll be beaming ourselves to the West Coast.

The problem, I assumed, was that both Kodak and Polaroid confused goals and methods. More specifically, they latched on to the method (film!) and forgot about the goal (making photography accessible). Digital arrived, print died, and while the goals of both companies were still relevant, they were too focused on film to react.

While I think this more or less describes Kodak, it doesn't actually capture what happened with Polaroid.

See, Polaroid's goal wasn't anything particularly abstract. In fact, it was simple: they wanted to allow photographers have instant prints.

And here's the thing, even with all the digital devices in the world, that goal is still a legitimate one. If I handed a kid an instant print from my cell phone camera, they would be just as wide-eyed today as I was when my grandpa handed me a print from his SX-70.

In other words, Kodak needed to somehow morph from a film company to a digital company. Polaroid, on the other handed, just needed to stay Polaroid. Their method may have changed from using film, to using some other printing technique, but logically speaking, there was no need for them to morph into a digital company.

Sure, Polaroid would have had to shrink as company as demand for digital exploded and film was rightfully killed off. But, they would no doubt have received a resurgence (which they have) as people re-learned the power of a tangible photograph.

Put another way, Polaroid wasn't agile or disciplined enough to weather the storm that was digital, even though it alone shouldn't have hurt them.

I suppose the lesson is simple: know what your goals and methods are; hold tight to the former and be constantly in search of replacing the latter.

Hindsight sure is 20/20, right?

As for the book: if you're a photographer, techie or business owner, it's worthy read.

Sunday, September 22, 2013

A sign of the times

What do you make if these signs? Lawyers at work, or are people really that "creative?"

Wednesday, September 18, 2013

Quick Feet

If only this roach was a little slower, I'd have had an easier time capturing a photo of him. Alas, this was the best I could do; a shot of him scurrying away from me.

Review: Longitude: The True Story of a Lone Genius Who Solved the Greatest Scientific Problem of His Time

Years ago, I noticed the thin volume: Longitude: The True Story of a Lone Genius Who Solved the Greatest Scientific Problem of His Time on my Dad's desk. It looked intriguing, yet I ignored it.

Then I visited Greenwich, England where a docent at the museum heartily recommended the very same book. I continued to ignore it.

Finally, my friend Dawn recommended the very same book, even going so far to let me borrow her copy.

Needless to say, I finally read and enjoyed the book. It held up to all the recommendations.

The book has a simple premise: finding your latitude on Earth in the 1700's wasn't that tricky. Calculating your longitude, on the other hand, was dang near impossible. If one could tackle the problem of deriving one's longitude, then navigating the globe becomes a whole lot easier. And once you can navigate, you can do things like exploring, conquering and shopping with ease.

This all made sense to me. I expected, therefore, that figuring out a method of calculating longitude would be the surprising part of the book. In fact, it wasn't. Even in the 1700's scientists and explorers knew *how* to calculate longitude: you simple compared the time of day at your current location compared with that of the current time of the port you left. From there, you did a little math, and poof, you had longitude. Imagine that, somehow the math geeks of the 1700's figured out a way to use *time* to calculate *location*.

While my visit to Greenwich so many years ago left me with the distinct impression that one calculates longitude using time, I'd never had a clear idea how it was done. In the first chapter of this book however, the author explained it, and to my utter joy, I understood. In many respects, using time to calculate longitude is one of those terrific hacks that everyone should understand and appreciate.

OK, the calculation of longitude wasn't the tricky. So what does that leave? Well, calculating the current time isn't particularly very hard (wait until the sun is directly overhead, bam! you just found noon), either. That leaves only part of the equation: figuring out what time it is back in port.

Easy, set a clock before you leave, glance at it when you want to know what time it is. What could be easier? While clocks certainly existed in the 1700's, they weren't nearly reliable or durable enough to put on a ship and remain accurate. And here's the part that blew my mind: the leading scientists of the day assumed that clocks would *never* be that reliable or durable. In fact, they assumed that it would be easier to calculate longitude from the moons of Jupiter than it would be to expect a clock to reliably keep time.

The story of Longitude, then becomes a pursuit to create perhaps the ultimate clock.

In defense of the scientists of the day, it was probably like looking at ENIAC and trying to imagine Google Glass; not an easy proposition.

It shows that not only do we take technology for granted, but we take the rate of technological advance for granted as well. Of course when I was in college 1Gig was a huge hard drive, and now 1,000 Gigs is considered standard; I'd be silly not to expect that. As the hero of our story shows, that just wasn't always the case.

My only gripe with the book is that now it makes me long to go back to Greenwich where I can properly examine the clocks that originally solved the Longitude problem.

Oh, and one other thought: I'll never take a watch for granted again. Even the $8.00 Timex was once the stuff of pure fantasy.

Tuesday, September 17, 2013

DC Around Sunset

The sun is setting earlier these days, which means that about the time I'm heading out for a run all of DC is bathed in the light of a perfect sunset. While running across the Key Bridge, how could I not stop and snap a few photos?

Here's the best of the lot.

Perfect day for some soaring

Is it possible those two large birds circling above me, apparently with white heads and tails, were bald eagles? It has, happened before in the Arlington area. Unfortunately, all I was able to capture with my camera phone was two dots circling above:

And here's another large bird circling the Air Force memorial. Can't even imagine what this guy is:

As expected, they've got the flags at half staff for the victims of the Navy Yard shooting:

Truly a gorgeous day out. Probably one of our few Fall days before we start kvetching about it being too cold.

Monday, September 16, 2013

Arlington Shelter In Place Order

Shira just called to tell me about the Active Shooter in the DC Navy Yard.

A few moments later, I thought I heard a loudspeaker from outside. I cautiously opened my door and this is what heard:

The message:

Attention...all personnel are directed to shelter in place at this time...go to the nearest building and remain inside until the all clear has been announced...

I can't tell where the loudspeaker is positioned, so it might not be intended for the general population. Maybe I'm hearing a message from the nearby Fort Meyer or the Pentagon.

Either way, very spooky.

Update: with no special activity and no Arlington alert message, this was almost certainly a notification meant for Fort Meyer, the nearby base. Like I said, very spooky, but apparently, nothing to be alarmed about.

Pretty Smile, Nice Legs

Here's a snapshot of Shira in front of the waterfall at the end of Windy Run:

And here's a photo of some creepy crawly thing, also near the waterfall:

Review: The Guerrilla Factory: The making of Special Forces Offices, the Green Berets

I admit it, I picked up The Guerrilla Factory: The Making of Special Forces Officers, the Green Berets for some simple arm chair adventure reading. As a member of an elite unit, surely the author would have some incredible stories to share. And he didn't disappoint. The majority of the book is about the trailing Tony Schwalm, the author, went through to become a Green Beret. Indeed, we're talking grueling and exhausting training, the kind of stuff that makes me tired just reading about it. While Schwalm should have every right to brag, I found that he had a certain humility one might not expect. He admits to making and learning from his mistakes, which removes any preachiness from the book and replaces it with even more respect.

Along with training stories, you get to hear about Schwalm's and the Green Berete's involvement in Operation Uphold Democracy. Taking place in 1994, this mission should have been familiar to me, but wasn't. I was glad to get a first person perspective of the action, which from Schwalm's retelling, was a mostly positive one. Even with a poorly defined mission, the troops were able to provide stability for Haiti, doing far more good than harm while there.

The overarching theme of Guerrilla Factory is that teams like the Green Berets offer a unique way of fighting bad guys. Sure, you've got your traditional fighting force with tanks and bombers, and they'll gladly level everything in sight. And yeah, you've got your commando units that will swoop in and wipe out a single target (think Seal Team 6 and OBL) with lethal precision, but there are times when neither of those approaches work well. The Green Berets and other special forces take an altogether different approach: they partner with rebels on the ground, teach them how to fight, and fight along side them. This method of fighting a war has some serious advantages (the indigenous people are doing the heavy lifting, fewer Americans are involved in far off conflicts, you're less likely to lose the respect of the locals if the locals are doing the fighting) and disadvantages (the process is slow by political standards, there's risk that you could be arming the wrong rebel group), but most importantly it should be a tool in the toolbox.

According to Schwalm, the war in Afghanistan started off using this special forces style approach and was successful. It was only when more traditional soldiers were brought in that things got messy and progress was slowed. I don't have enough information to know if what he's saying here is true, but he certainly brings up a fresh (for me) perspective on Afghanistan.

If you're looking for a definitive book on military strategy for history, you should probably look elsewhere. If you're looking for a fun read with excellent stories and a unique perspective on fighting battles, this is the book for you.

Thursday, September 12, 2013

Two Classic Basketball Stories You Should Know

I'm one of those rare breeds: an American male who doesn't follow football, baseball or basketball. Actually, I don't have any sports team preferences. Sure, I enjoy going to just about any live sporting event, but the thought of watching one on TV? No thank you. I far more prefer to watch the commercials, than the actual Super Bowl.

But I do love me a good sports story. I can always depend on my brother Dave to filter out just the best, and pass them along. Recently he shared two classics with me: Magic & Bird - A Courtship of Rivals and The Dream Team. Both are basketball related and both are probably well known to you. But if you're not familiar with these stories (I was slightly with the latter, and not at all with the former), these documentaries are well worth your time.

It's sports at its best: riveting, heartwarming and inspirational.

Watch: Magic & Bird

Watch: The Dream Team

If you've got a favorite sports story, I'd love to hear it.

Wednesday, September 11, 2013

Perfect Moments

It's that time of year again, when Jews spend hours in temple working on a spiritual tune-up for the soul. It's the perfect time for self reflection. Once concept that I've been rolling around in my head is that of the importance of cherishing special moments as they come. That is, rather than trying to work-work-work to make things perfect, and be disappointed when the stars never align, assume that things never will be perfect. Instead, when those precious moments come, grab them, enjoy them, and know that they will pass.

What can I say, I've got a lot of time to think.

Anyway, along comes a Moth Podcast which explains all this far better than I can. So here it is: Perfect Moments by Brian Finkelstein. You can listen to it on the web by clicking here. It's riveting and definitely worth your time.

So enjoy those moments, they come and go in a flash.

Wheezing on Wilson, Running Routes that start in the Clarendon

Shira (and of late, I!) goes to NOVA MMA, a gym located in Clarendon (and down the street from WoW). Whenever I can, I'll go with her to the gym, and run while she works out. Because of the proximity to DC, I've found that the area has some terrific runs. I was on one of those tonight, and I thought it would be worthwhile sharing them.

My plan is to add to this post as I record the routes I regularly take. They all start and end from the same point in Clarendon. If you find yourself in that area, and want to go for a run, maybe these will be inspirational.

More to come as I map more routes...

Tuesday, September 10, 2013

Coming in for a landing

My friend Dawn tells me that Stand Up Paddling (what the folks are doing in the above photo) isn't as hard as it looks (to me). I remarked that it must take serious courage to do it on the Potomac, but she assures me the boards are stable.

I guess I'll have to give it a try and find out.

Can't Quite Explain These Pictures

1. While walking past the the construction that's been going on for months (and has included some pretty dramatic demolition), I came across this time lapse camera hanging around:

I've never noticed a camera in the area before, so I'm wondering why install one now? They've demolished part of the bridge and put up a new one; seems a little late to add in a timelapse camera. Or maybe it was there all along and I hadn't ever noticed it?

2. I'm running up this short connector trail that leads from Rock Creek Trail to the Dumbarton House and I notice this tree crammed full of rocks.

I can't imagine this trail gets much traffic. So what's up with someone spending the time to do this?

Any explanations for either of these?

Monday, September 09, 2013

emacs function: humanifying URLs

Sometimes I need to share a long URL in an e-mail or document with the purpose of making it clear, rather than making it clickable. When I need to do this, I'll rewrite the URL by add newlines and whitespace to ? and & characters and URL-decode parameter values. That turns this:

http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CCwQFjAA&url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FEditor_war&ei=k9ktUuz2Kvaj4APCmoGIBw&usg=AFQjCNGrgP7q1TYCPmuQnkgcfMIJKpFHOg&sig2=a6GUXFARKXj6r1JyiNkQ8w&bvm=bv.51773540,d.dmg

Into this:

http://www.google.com/url?
  sa=t&
  rct=j&
  q=&
  esrc=s&
  source=web&
  cd=1&
  cad=rja&
  ved=0CCwQFjAA&
  url=http://en.wikipedia.org/wiki/Editor_war&
  ei=k9ktUuz2Kvaj4APCmoGIBw&
  usg=AFQjCNGrgP7q1TYCPmuQnkgcfMIJKpFHOg&
  sig2=a6GUXFARKXj6r1JyiNkQ8w&
  bvm=bv.51773540,d.dmg

This format makes discussing or catching issues with individual URL parameters much easier.

For years I've used a created-on-the-fly emacs macro to help speed up the above conversion. And while I love keyboard macros I was many years overdue in turning this into an elisp function. Last week I finally corrected this oversight. Here's the code:

(defun url-humanify ()
  "Take the URL at point and make it human readable."
  (interactive)
  (let* ((area (bounds-of-thing-at-point 'url))
         (num-params  (count-occurances-in-region "&" (car area) (cdr area)))
         (i 0))
    (beginning-of-thing 'url)
    (when (search-forward "?" (cdr area) t nil)
      (insert "\n  ")
      (while (< i num-params)
        (search-forward "&" nil t nil)
        (insert "\n  ")
        (save-excursion
          (previous-line)
          (beginning-of-line)
          (let ((start (search-forward "="))
                (end (search-forward "&")))
            (url-decode-region start end)))
        (setq i (+ i 1))))))

(defun url-decode-region (start end)
  "Replace a region with the same contents, only URL decoded."
  (interactive "r")
  (let ((text (url-unhex-string (buffer-substring start end))))
    (delete-region start end)
    (insert text)))

(defun count-occurances-in-region (needle start end)
  (save-excursion
    (let ((found 0))
      (goto-char start)
      (while (search-forward needle end t nil)
        (setq found (+ found 1)))
      found)))

(The usual disclaimers apply: url-humanify is not the most efficient elisp implementation, but it should reliably work. That (set i (+ i 1)) code shows I was thinking PHP instead of lisp; but so be it. At least I depend on thing-at-point to do the URL parsing. Oh, and I've included url-decode-region as a bonus. It's another function I use all the time.)

Now, whenever I have an ugly URL, I just need to execute M-x url-humanify and it all becomes clear.

Hope this saves you some typing.

Update: D'oh - forgot to include the count-occurances-in-region. As @anonymous pointed out, I should probably be using count-matches.

Sunday, September 08, 2013

Precious cargo deposited as our adventure comes to an end

I just flew into Boston, and boy are my arms tired! Actually, my everything is tired. That's because Shira and I have just safely deposited our nephew and two nieces into their Mom's arms / mini-van. It's official, our adventure has been a success! And what an adventure it's been.

Since last Tuesday, when we picked up the kids, we've been raspberry and apple picking, to shul 3 times, watched kids do countless laps around our downstairs and even put on a puppet show. I went to bed every night exhausted, and luckily, so did the kids.

The children really were terrific. Generally, they ate, napped, behaved and slept better than I could have hoped.

Tzipora may only be 2.5 but she showed terrific analytical skills picking just the red raspberries and leaving the green ones alone to continue to grow. She did eat quite a few that didn't make it into her bucket. Dovid, 4.5, is train obsessed. After reading him my favorite kids book, "The Little Engine That Could," a few times, he was able to sit with it and go through it himself, pretty much accurately reciting the text from each page. Chana, also 4.5, demonstrated terrific dexterity helping Shira prepare challah by painting on the egg glaze and helping to set the table.

Over the week, the kids fell in love with Shel Silverstein's poetry, requesting their favorites at bedtime. Most of the poetry seems borderline inappropriate for kids, but that's probably what makes it so much fun. At this age, the kids are such sponges, so as you share a poem once, they want to hear it again and again (especially if it's one about a guy who forgets to put on his pants).

On the first evening, as a sort of experiment, I told the kids that if they finished everything on their plates and helped clean up, they could pick out a sticker. They could then apply the sticker to a hastily created chart I put together. Immediately, they wanted to know what happened once they filled up the chart. Not quite sure what to say, I announced that if they did manage to fill up the chart, they'd get a treasure. Chana's eyes lit up and jumped and down yelling, "TREASURE!" Shira turned to me, and nudged me, you better think of some treasure by Sunday.

By Friday night it was pretty clear that the kids were going to fill up all 10 bubbles I had drawn with crayon. We were going to need some treasure. I mentioned the quandary to my brother and sister-in-law who were over for dinner on Friday night, and without asking, they totally saved the day. Saturday afternoon they dropped off a bag little toys and games for the kids, it was the absolute perfect treasure.

Shira even played along, and on Saturday night, after the kids ate their whole dinner and cleaned up, and we applied the last sticker to the chart we went searching for treasure. And where did Shira hide it? In our treasure chest, of course. That is, she stashed the goodies in the chest we have in our front hall. The kids were overjoyed, and I could breathe a sigh of relief knowing that I hadn't gotten their hopes up only to dash them.

So now it's time to get our lives back together. I'll be getting up tomorrow when the alarm says so, not when I hear the pitter-patter of little feet. I already miss them, but like all good adventures, it had to come to an end. If you ask me, I say it's time to start planning our next one!




View Photos

Tuesday, September 03, 2013

The Mystery of the Empty Stroller

Today we headed back to the airport, stroller in hand, but this time it was filled!

After spending a day ooohing and ahhhing over our new baby niece in Boston, we executed the second stage of our plan. We scooped up the older kids and brought them back to DC. We love traveling with our Maclaren stroller so much (it's lightweight, sturdy and goes through an airport x-ray scanner with room to spare), that we brought it along to use for the return trip. As usual, it worked great.

All three kids did great in both the airport and on the plane itself. Dovid loved looking out the window, Chana held it together even though she kept on announcing that she was afraid of heights, and Tzipora was just zonked out (guess that children's Drammamine does work wonders). Nobody got air sick, or caused a riot on the plane.

The kids will be with us until Sunday, at which point we'll fly them back home and make one final trip ourselves to collapse back in DC.

One thing I can promise: it's going to be a memorable rest of the week!

View Photos

And Then There Were 4!

As you probably guessed, we are now in Boston. And we've now met our new niece, Gavriella Esther in person. She's sooooooo precious, and is an absolute angel, only making the occasional squawking noises when she's hungry or needs a change.

I've got about 900 photos to go through, but here are a few as proof that we are in fact here.

But we won't be here for long. That's a whole other story though, so stay tuned.

Monday, September 02, 2013

This will make sense tomorrow

Just give us 24 hours, and this photo of Shira walking through the airport with an empty stroller will make sense.

In the mean time, if anyone asks about the empty stroller, I'm planning to respond: oh, it was definitely worth the bag fee to check the kid under the plane.

Why you can succeed in having a great career

My brother passed me this TED talk: Why you will fail to have a great career by Larry Smith and asked my opinion of it. After watching it, I've got to say it's a wonderful TED talk. It's engaging and got me thinking after the fact. There's only one tiny quibble I have with it, it's fundamentally flawed advice.

See, the video suggests that what's holding you back from greatness is yourself. It's your fear of trying something new, your apathy in searching your passion and your looking for excuses at every turn. And Smith is right, you can certainly be the limiting factor in your own success.

But I think it's disingenuous to suggest that all barriers to greatness are manufactured by yourself. The reality is we all have limitations on our life. We can accept them and work within them, or we can watch TED talks that suggest they don't exist and be disappointed when they do.

Let's consider an example: you decide that your passion is acting. You inform your wife, that she and your two young children will be moving to NY to pursue your dream of being on Broadway. She may say, "terrific, let's do it!" But, more than likely she is going to inform you that this isn't really possible: your children may be in the right school, and she may have a local career she doesn't want to give up. What do you do? Do you lament how you're being held back from greatness?

I think it's at this point that you continue to strive for your dream and greatness, you just do it within the constraints you have. In short, you Live your Best Life. So you join a community theater and act there. If one doesn't exist, maybe you start one up. And maybe in doing so, you show an entire town the power of plays and acting. Maybe you end up getting your kids, and other kids involved, and show a whole generation about the power of the stage over YouTube.

Embracing your limitations doesn't mean giving up. It means tackling your dream with a level of creativity that goes beyond simply facing your fears and searching for your passion. And I think the results can be far more interesting than the path you originally charted when the only thing in your way was a few self-made roadblocks.

You're going to have a great career not because you banished all your limitations, but because you used them to reach it.

Watch the TED talk, and give me your take on it: