A Contingency Speech for the First Moon Landing

November 09, 2013

Spoiler Alert: This post contains spoilers for seasons four and five of The West Wing. (Of course, those season are a decade old. So, you're probably safe to proceed at this point regardless.)


A favorite piece from the The West Wing1 is when Toby (a speech writer) is asked to draft two speeches regarding the kidnapping of the President's daughter. When asked, "Why two?" his response is, "One if they find her alive, one if they don't." President Bartlet likes the second one more and uses it (with a few modifications) when his daughter is rescued alive.

A real life example of a presidential contingency speech is found in a July 18, 1969 memo2 from speechwriter William Safire3. It was to be used by President Nixon if a problem with the Apollo 11 mission stranded the astronauts during the first moon landing. A potentially heart-wrenching circumstance where they would still be alive but doomed to die of suffocation as their air ran out.

The speech was written as follows:


IN EVENT OF MOON DISASTER:

Fate has ordained that the men who went to the moon to explore in peace will stay on the moon to rest in peace.

These brave men, Neil Armstrong and Edwin Aldrin, know that there is no hope for their recovery. But they also know that there is hope for mankind in their sacrifice.

These two men are laying down their lies in mankind's most noble goal: the search for truth and understanding.

They will be mourned by their families and friends; they will be mourned by their nation; they will be mourned by the people of the world; they will be mourned by a Mother Earth that dared send two of her sons into the unknown.

In their exploration, they stirred the people of the world to feel as one; in their sacrifice, they bind more tightly the brotherhood of man.

In ancient days, men looked at starts and saw their heroes in the constellations. In modern times, we do much the same, but our heroes are epic men of flesh and blood.

Others will follow, and surely find their way home. Man's search will not be denied. But these men were the first, and they will remain the foremost in our hearts.

For every human being who looks up at the moon in the nights to come will know that there is some corner of another world that is forever mankind.

A beautiful speech that was, thankfully, never heard.

In addition to the text of the speech, the memo also contains these notes:

PRIOR TO THE PRESIDENT'S STATEMENT:

The President should telephone each of the windows-to-be.

AFTER THE PRESIDENT'S STATEMENT, AT THE POINT WHEN NASA ENDS COMMUNICATIONS WITH THE MEN:

A clergyman should adopt the same procedure as a burial at sea, commending their souls to "the deepest of the deep," concluding with the Lord's Prayer.


I heard about this speech from episode 59 of Roderick On The Line4. The mention comes in a section where the hosts (Merlin Mann and John Roderick) are discussing just how amazing NASA's Human Space Flight program is. During the conversation, Merlin makes on of the best statements about humans launching into space that I've ever heard. He says:

You can attach dynamite to anything and send it somewhere, but for it to come back and be able to hug its kids is still, to this day, completely mind blowing.

I couldn't agree more. The fact that way more often then not contingency speeches are only found in archives of undelivered texts is another testament to the amazing things we can make and do.




Footnotes

  1. The West Wing - One of those great shows of the "if you happen to flip past an episode and it's a marathon you're automatically in for the long haul" variety. Also, if you want to get an idea of how important the acting and direction are for a show, check out the script for one of the episodes about having two drafts of the speech. Just reading the words on the page I would not have thought the episode would be as compelling as it is.
  2. The In Event of Moon Disaster page on the National Archives site has a link to the PDF of the scan of the actual memo. This reminds me that there was a time when writers were one of the few set of people who typed on keyboards for a living. It's worth it to take a look at the scan.
  3. William Lewis Safire - Born: December 17, 1929. Died: September 27, 2009. According to Wikipedia: he was an American author, columnist, journalist, and presidential speechwriter. I'll remember him as the first write I saw use the term "widows-to-be" that I hope never to have to hear again.
  4. I listen to a lot of podcasts. Most are either about coding, business or marketing. Roderick on the Line is one of the few outside those genres. It is also one of my overall favorites. It's basically two intelligent people talking about a variety of interesting things while avoiding news headlines. Highly recommended if you're into that type of thing.

Geek Desk Color Change

September 30, 2013

I have two Geek Desks1. One at the house. Another at the office. I'm a huge fan. Using them to get off my ass for at least a bit each day has been nice. The cumulative effect has been profound. I no longer feel like I'm slowly turning into a slug.

My only regret is going with "silver" (i.e. gray) instead of black for the house desk. That choice has bugged me ever since. I picked the better option when I bought the one for the office. Of course, that increased the annoyance with the gray one sitting at home.

While replacing the flooring at the house, I realized I had am opportunity to address this. With everything moved out of the room and not caring about the soon-to-be-removed carpet, a few cans of spray paint were all that was needed.

Initial Geek Desk look with gray legs.

Black is the new gray.

Much better.

It's not quite a "complete solution." The internal sections of the legs that move to do the actual raising and lowering are lubricated. Covering them in paint seemed a poor choice. So, they remain the same old gray.

They've mostly been painted. Mostly.

When the desk is raised, this can be seen from a distance, but it's not noticeable when actually at the desk. That works out just fine.

I highly recommend an automatic, adjustable, sitting/standing desk (a la Geek Desk) for anyone who spends the majority of their workday at a computer. It's a great way to help reverse the slow slide to slugdom. Just make sure to go with the black legs to save yourself some hassle.


Footnotes

  1. Geek Desk - The powered sitting/standing height adjustment desks with a name that speaks to me.

BSoD

September 26, 2013

Looking for some entertainment? Leave a BSoD visual joke up in a conference room.


Jekyll (and GitHub Pages) Liquid Date Formatting Examples

Posted: October 01, 2013 - Updated: September 21, 2013

Note: Since originally posting this, I have learned a better way to remove leading zeros is to use {{ page.date | date: "%-m" }}. Note the dash in front of the "m". The examples haven't been updated yet. Either will work, but the new way is cleaner.

###Summary (tl;dr)

The set of examples below provide tested code snippets for displaying several date formats on a Jekyll blog1. They should also work on GitHub Pages, Shopify or anything else that uses Liquid. An alternate title for this post should be:

Everything you wanted to know about formatting dates in Jekyll but were afraid to ask.


###Overview

Jekyll2 (the simple, blog aware, static website generator) uses Shopify's Liquid Template Engine3. Displaying dates is done using the "{{ page.date }}" supplied Liquid tag4. With no other alteration, the dates produced look something like:

2013-09-21 00:00:00 -0400

If there are designs that use that format, they are few and far between. Creating friendlier looking dates is done by applying Liquid's "date:" filter. For example, the tag/filter combination:

{{ page.date | date: '%B %d, %Y' }}

produces more reader friendly dates like:

September 21, 2013

Much better, but depending on the date, subtle design issues show up. For example, during the first nine days of each month "leading zeros" crop up (e.g. "August 03, 2013" instead of "August 3, 2013"). Other gotchas with the basic Liquid filters include:

  1. Adding a period behind the abbreviated month names has to be adjusted to handle May. For example, "Aug. 16, 2013" is fine. "May. 16, 2013" is not.
  2. September is generally abbreviated "Sept." instead of Liquid's default "Sep."
  3. To comply with the AP style guide the months April, May, June and July should not be abbreviated. Similar alterations are necessary to meet with the guidelines from the Chicago Manual of Style.

Most designs go with the available defaults. Either using a format that doesn't have these issues or, more frequently, letting the details slip. The information still gets across and every web site has a punch list of potential modifications that stretches to the horizon. So, I understand putting off finding a solution, but not having proper date formatting has always bugged me. While solving the issue for myself5, I decided to put together this post as a public reference as well. I don't yet have the Ruby chops to contribute directly to Jekyll, but I can provide this reference to give back a little at least.

This set of Liquid date filters solves the issues listed above and explores a few other formatting options. Each one provides a solution for a specific display format and is provided with four output examples for the following date: 1) May 3, 2013, 2) July 4, 2013, 3) September 23, 2013 and 4) November 26, 2013. These examples demonstrate if/how the various formatting issues are handled. After the examples, a few snippets of code for individual elements are provided. With these samples, just about any date format desired should be within easy reach.


###Liquid Date Formatting Examples for Jekyll

  • ISO 8601 Date5

    {{ page.date | date: "%Y-%m-%d" }}
    

    Output Example 1: 2013-05-03
    Output Example 2: 2013-07-04
    Output Example 3: 2013-09-23
    Output Example 4: 2013-11-26

  • U.S. numeric style with four digit years (With leading zeros.)

    {{ page.date | date: "%m/%d/%Y" }}
    

    Output Example 1: 05/03/2013
    Output Example 2: 07/04/2013
    Output Example 3: 09/23/2013
    Output Example 4: 11/26/2013

  • U.S. numeric style with four digit years (Leading zeros removed.)

    <!-- Whitespace added for code readability -->
    {{ page.date | date: "%m" | plus:'0' }}
    /
    {{ page.date | date: "%d" | plus:'0' }}
    /
    {{ page.date | date: "%Y" }}
    

    Output Example 1: 5/3/2013
    Output Example 2: 7/4/2013
    Output Example 3: 9/23/2013
    Output Example 4: 11/26/2013

  • U.S. numeric style with two digit year (Leading zeros removed.)

    <!-- Whitespace added for code readability -->
    {{ page.date | date: "%m" | plus:'0' }}
    /
    {{ page.date | date: "%d" | plus:'0' }}
    /
    {{ page.date | date: "%y" }}
    

    Output Example 1: 5/3/13
    Output Example 2: 7/4/13
    Output Example 3: 9/23/13
    Output Example 4: 11/26/13

  • Outside U.S. style with full month name (Leading zeros removed.)

    {{ page.date | date: "%d" | plus:'0' }} {{ page.date | date: "%B %Y" }}
    

    Output Example 1: 3 May 2013
    Output Example 2: 4 July 2013
    Output Example 3: 23 September 2013
    Output Example 4: 26 November 2013

  • U.S. style with full month name (Leading zeros removed.)

    {{ page.date | date: "%B" }}
    {{ page.date | date: "%d" | plus:'0' }}, 
    {{ page.date | date: "%Y" }}
    

    Output Example 1: May 3, 2013
    Output Example 2: July 4, 2013
    Output Example 3: September 23, 2013
    Output Example 4: November 26, 2013

  • U.S. style with full month names and ordinalized days (Leading zeros removed.)

    <!-- Whitespace added for code readability -->
    {% assign d = page.date | date: "%d" | plus:'0' %}
    {{ page.date | date: "%B" }} 
    {% case d %}
      {% when 1 or 21 or 31 %}{{ d }}st
      {% when 2 or 22 %}{{ d }}nd
      {% when 3 or 23 %}{{ d }}rd
      {% else %}{{ d }}th
      {% endcase %}, 
    {{ page.date | date: "%Y" }}
    

    Output Example 1: May 3rd, 2013
    Output Example 2: July 4th, 2013
    Output Example 3: September 23rd, 2013
    Output Example 4: November 26th, 2013

  • U.S. style with AP month abbreviations and ordinalized days (Leading zeros removed.)

    <!-- Whitespace added for code readability -->
    {% assign d = page.date | date: "%d" | plus:'0' %} 
    {% assign m = page.date | date: "%B" %} 
    
    {% case m %}
      {% when 'April' or 'May' or 'June' or 'July' %}{{ m }}
      {% when 'September' %}Sept.
      {% else %}{{ page.date | date: "%b" }}.
      {% endcase %}
    {% case d %}
      {% when 1 or 21 or 31 %}{{ d }}st
      {% when 2 or 22 %}{{ d }}nd
      {% when 3 or 23 %}{{ d }}rd
      {% else %}{{ d }}th
      {% endcase %}, 
    {{ page.date | date: "%Y" }}
    

    Output Example 1: May 3rd, 2013
    Output Example 2: July 4th, 2013
    Output Example 3: Sept. 23rd, 2013
    Output Example 4: Nov. 26th, 2013

  • U.S. style full day and full month names (Leading zeros removed.)

    {{ page.date | date: "%A, %B" }} 
    {{ page.date | date: "%d" | plus:'0' }}, 
    {{ page.date | date: "%Y" }}
    

    Output Example 1: Friday, May 3, 2013
    Output Example 2: Thursday, July 4, 2013
    Output Example 3: Monday, September 23, 2013
    Output Example 4: Tuesday, November 26, 2013

  • Chicago Manual of Style day abbreviations and U.S. style date (With "Thurs." and "Tues.")

    <!-- Whitespace added for code readability -->
    {% assign dy = page.date | date: "%a" %}
    {% case dy %}
      {% when "Tue" %}Tues
      {% when "Thu" %}Thurs
      {% else %}{{ dy }}
      {% endcase %}. 
    ~
    {{ page.date | date: "%B" }} 
    {{ page.date | date: "%d" | plus:'0' }}, 
    {{ page.date | date: "%Y" }}
    

    Output Example 1: Fri. ~ May 3, 2013
    Output Example 2: Thurs. ~ July 4, 2013
    Output Example 3: Mon. ~ September 23, 2013
    Output Example 4: Tues. ~ November 26, 2013

###Individual Component Snippets for Liquid Date Formatting

These individual snippets are for a few of the tricker formatting filters. Some that weren't used in the examples above. For those interested in the approach, the hack I'm using to remove leading zeros is to add "0" to the string. This turns the string into an integer. When the integer is rendered back as a string the leading zero disappears. Hurray for dynamic typing.

  • Numeric month with leading zeros removed

    {{ page.date | date: "%m" | plus:'0' }}
    
  • Numeric day with leading zeros removed

    {{ page.date | date: "%d" | plus:'0' }}
    
  • Ordinalized numeric day with leading zeros removed

    {% assign d = page.date | date: "%d" | plus:'0' %}
    {% case d %}
      {% when 1 or 21 or 31 %}{{ d }}st
      {% when 2 or 22 %}{{ d }}nd
      {% when 3 or 23 %}{{ d }}rd
      {% else %}{{ d }}th
      {% endcase %}
    
  • AP Style month abbreviations

    {% assign m = page.date | date: "%B" %}
    {% case m %}
      {% when 'April' or 'May' or 'June' or 'July' %}{{ m }}
      {% when 'September' %}Sept.
      {% else %}{{ page.date | date: "%b" }}.
      {% endcase %}
    

    (Produces: "Jan.", "Feb.", "Mar.", "April", "May", "June", "July", "Aug.", "Sept.", "Oct.", "Nov.", "Dec.")

  • Chicago Manual of Style day abbreviations

    {% assign dy = page.date | date: "%a" %}
    {% case dy %}
      {% when "Tue" %}Tues
      {% when "Thu" %}Thurs
      {% else %}{{ dy }}
      {% endcase %}.
    

    (Produces: "Sun.", "Mon.", "Tues.", "Wed.", "Thurs.", "Fri.", "Sat.")

  • Chicago Manual of Style month abbreviations

    {% assign m = page.date | date: "%B" %}
    {% case m %}
      {% when 'May' or June' or 'July' %}{{ m }}
      {% when 'September' %}Sept.
      {% else %}{{ page.date | date: "%b" }}.
      {% endcase %}
    

    (Produces: "Jan.", "Feb.", "Mar.", "Apr.", "May", "June", "July", "Aug.", "Sept.", "Oct.", "Nov.", "Dec.")

With that, you should be in pretty good shape. If you can't directly create what you need from the above samples or snippets you should at least be able to use a similar approach to piece together what you need.


Notes on the Examples

  1. The hour, minute and second parts of the full date/time stamp aren't being used because Jekyll tends to zero them out.
  2. In some of the examples, the code is split to multiple lines to help readability. If it's a natural break point where white space already exists, this won't effect HTML rendering. In some cases, it will introduce unwanted white space. Simply move everything back to one line to create the desired presentation.

Footnotes

  1. These examples were create on a Mac running OS X 10.8.5 with: Ruby 2.0.0p247 - Jekyll 1.2.1 - liquid 2.5.2. Your mileage may vary.
  2. The main Jekyll website provides a great overview of the software. You can learn even more with a visit to the Jekyll's GitHub Repo.
  3. Shopify's Liquid template engine. "A small and fast template language which is quick to learn but very powerful for full customization."
  4. The Liquid Date Filter offers some basic formatting elements and is the basis of these code snippets. Note that in some cases "post.date" might be required instead of "page.date".
  5. Observant readers will notice that as of the time this post went live, my design still uses a date format with leading zeros. I have the solution, it just hasn't been implement yet. It'll go in with the next set of design changes.
  6. ISO 8601 - "Data elements and interchange formats - Information interchange - Representation of dates and times is an international standard covering the exchange of date and time-related data." A perfect example of how Time really is wibbly wobbly timey wimey… stuff.

Pretty Printing JSON via JavaScript or Extension

August 10, 2013

####Summary

If you're a webdev who uses JSON and you haven't seen JSONView for in-browser pretty printing of JSON, go check it out. Or, take a look at this JS Fiddle if you want to roll your own in JavaScript to do something similar.

####The Problem

Much of my work involves XML and JSON data feeds pulled over a web (HTTP) connection. Most browsers automatically "Pretty Print" XML files and add syntax highlighting and the ability to collapse sections. This makes spot checking data in the XML easy. For example1, this single blob of XML:

<widget><debug>on</debug><window title="Sample Konfabulator Widget"><name>main_window</name><width>500</width><height>500</height></window><image src="Images/Sun.png" name="sun1"><hOffset>250</hOffset><vOffset>250</vOffset><alignment>center</alignment></image><text data="Click Here" size="36" style="bold"><name>text1</name><hOffset>250</hOffset><vOffset>100</vOffset><alignment>center</alignment><onMouseUp>sun1.opacity = (sun1.opacity / 100) * 90;</onMouseUp></text></widget>

is automagically turned into the much friendlier:

Unfortunately, the browsers I use2 haven't caught up with JSON feeds enough to do the same thing. This corresponding JSON example:

{"widget": {"debug": "on","window": {"title": "Sample Konfabulator Widget","name": "main_window","width": 500,"height": 500},"image": { "src": "Images/Sun.png","name": "sun1","hOffset": 250,"vOffset": 250,"alignment": "center"},"text": {"data": "Click Here","size": 36,"style": "bold","name": "text1","hOffset": 250,"vOffset": 100,"alignment": "center","onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"}}}

gets no real help and just shows up like this:

That's not horrible for smaller files, but with larger ones, it gets messy fast.

####Solution 1 - The Hacky Way

I've found two nice solutions for this. The first approach is that of a webdev hacker: Use JavaScript itself to do the formatting. This works great for times when a page is consuming JSON and can be passed a debug flag. The basic approach came from an answer on StackOverflow3. I modified it a little to suite my needs. The first step is to add a <pre> tag with your preferred target ID:

<pre id="pretty_json"></pre>

My version of the JavaScript function looks like this:

function jsonPrettyHighlightToId(jsonobj, id_to_send_to) {
    
    var json = JSON.stringify(jsonobj, undefined, 2);
    
    json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
    json = json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
        var cls = 'color: darkorange;';
        if (/^"/.test(match)) {
            if (/:$/.test(match)) {
                cls = 'color: red;';
            } else {
                cls = 'color: green;';
            }
        } else if (/true|false/.test(match)) {
            cls = 'color: blue;';
        } else if (/null/.test(match)) {
            cls = 'color: magenta;';
        }
        return '<span style="' + cls + '">' + match + '</span>';
    });
    
    document.getElementById(id_to_send_to).innerHTML = json;
}

Just pass the function a JSON object and the ID to update like so:

var pseudo_json_object = {a:1, 'b':'foo', c:[true,false,null,'true','false','null', {d:{e:1.3e5,f:'1.3e5'}}]};

jsonPrettyHighlightToId(pseudo_json_object, 'pretty_json');

Here is a live example of the output (done in an unsafe, hacky way for simplicity that may or may not work with your browser).





Note that the JavaScript function adds the styles inline. Generally a poor practice, it's nice here. Syntax highlighted debugging output is provided without having to alter active CSS files.

####Solution 2 - The JSONView Browser Extension

Of course, most of the time, it's nicer to simply get a human readable version of the JSON directly from the browser. Enter the JSONView4 extension. Originally built for FireFox, there is a Chrome version available as well. It works like a champ, turning the small example JSON from the mess above to this nice, clean output:

Pretty Printing. Syntax Highlighting. Collapsing Nodes. JSONView is great. It even lets you mess with the style sheet and change font sizes. A must have for webdev types who work with JSON.




Foot Notes5

  1. The example XML and JSON files were lifted from the examples on the json.org site.
  2. My main development browsers are Chrome, Firefox and Safari on a Mac. Your mileage may vary with IE.
  3. The initial StackOverflow answer showing how to use regular expressions in JavaScript to stringify a JSON object and add syntax highlighting to it.
  4. JSONView - The extension to make your JSON reading life much nicer.
  5. This really should have been split into a "two-part" set of posts. Alas, other priorities prevent the amount of editing that would take.

Exactly how accurate are the expiration dates on pills?

Posted: July 10, 2013 - Updated: August 01, 2013

Today is August 1st, 2013. This Claritin expired "July 2013."

Probably won't kill me, right?


Bama vs. The Braves (A Logo Comparison)

July 30, 2013

Two quick reference points for those who don't know me:

  1. I'm a fan of the Alabama Crimson Tide.
  2. I'm apathetic towards the Atlanta Braves.

There is generally little confusion to between the two in the sports world. Bama being a college mostly known for football. The Braves, a pro baseball team. Easy enough to tell apart. Unless you're only seeing a monochrome copy of the logos. A True Sports Fan might know which is which in an instant. Me? Not so much.

Whenever I see an "A", I assume Alabama. Since Tuscaloosa (home of the Tide) and Atlanta are just three hours away from each other, this doesn't work out so well. Anywhere a Bama logo might show up is just as likely to have one for the Braves and vice verse. More than once, I've given a "Roll Tide" to someone to get back nothing but a blank stare. To solve this embarrassing issue, here are the two logos side by side.

Atlanta's logo is on the left. Bama's, the right. Viewed together, it's easy to see how to tell them apart. Bama's logo has the serif sticking out of the top. Design geeks will know that there is an imaginary line that runs across the top of letters called the "capline".

Since The University of Alabama is also know as The Capstone, a little mnemonic device is to remember that the logo for The Capstone logo has a serif at the capline. (For non-design-geeks, just remember that the Bama logo has the pointy part sticking out of the top.)

Roll Tide!


Update: A friend, who happens to be an Auburn fan, commented to say, "It's easy to tell them apart. The Bama a has a mullet." While not the way I'd care to think of it, that's too good not to add. (See you at the Iron Bowl, Deason.)


Command Line One-Liner to Compare Files with MD5

July 08, 2013

While working on a tool to eliminate duplicate photos from old hard drives, I wrote this little snippet of code that's worth saving:

if [ $(md5 -q 1.txt) == $(md5 -q 2.txt) ]; then echo "same"; else echo "different"; fi

It's a command line one-liner that generates MD5 hashes for two files, compares them and states if they are the same or different.

For those unfamiliar with MD5, it's a "cryptographic hash function that produces a 128-bit hash value." The useful part for this snippet is that MD5 can be fed a file of any size and the results is a 32 character string. Most importantly, the same input will always produce the same output and any difference (no matter how minor) creates a large difference in the result. For example, any computer can run MD5 on a file with the contents "asdfasdf-1" and it will produce the hash signature:

f3748c05e25ca8cce7795d1ec97749b0

If you change the one to a two (i.e. "asdfasdf-2") the signature changes to:

e9ca151e1882f63c5d05e7958a7527a9

More about this will come in another post, but what this means for a duplicate photo finder is that MD5 hashes can be generated for every photo and then compared. Any two files with the same hash signature are the same* and can be pared down. That is done with a larger program. The little snippet of code is used for verification. It's also useful enough to be broken out to its own.


*Note: For the tech/cryptography minded folks out there, I know that MD5 can have collisions. For what I'm doing, the chances are so small that I'm not worried about it.


Go To Index Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107


© Alan W. Smith
RSS Feed