Posted wp-markdown-syntaxhighlighter to Wordpress Plugin Directory

I caved. I'm not proud of fine with it. The plugin is now available on the Wordpress Plugin Directory. Fancy.

Sep 13th, 2012

Fantasy Christian Men

I just read a fantastic post over at Parchment and Pen about Fantasy Christian Men that struck a chord with me this morning:

I think there are many men like me. I am going to call us, "Fantasy Christian Men."" We love Jesus. We really do. We want to change our world. We want to advance the kingdom of God. We want to fight injustice. We want to be heroes to our wives and children. Unfortunately, however, we are just as good if not better at fantasy than reality.

If you look at our focus, passion, reading, time, thoughts, conversations and strategy you will find many of us are killing it at: Fantasy Football; Basketball, Baseball; Netflix; and Video Games. We are endlessly engaged in things that are rooted in fantasy. I know you will probably say you are forming powerful relationships with people for Christ through your fantasy draft weekend, the chat room from your favorite video game, etc...

Tim's post is about falling into the world of the TV show "24", which I watched regularly when it aired. I can definitely see myself in some of his words here. There have been other TV shows, other books and other forms of media-related obsessions that have taken me out of the reality that God placed me in. More recently it's been my iPhone. I'm far too into my phone and its ability to connect me with non-present-tense things.1

I think my more regular (and I really hesitate to call it) "fantasy" in this context is work. I spend an incredible amount of mental energy throughout the week on my job, the happenings at my job, the people at my job, the problems/solutions/grips/gossip/etc. at my job. I don't spend nearly enough time praying for the people at work, my tasks at work, advancing his kingdom at work, etc. I think this is a good resolution to start off the week.

  1. It really needs to transition from “mind extension” to “useful tool”…

Sep 10th, 2012

wp-markdown-syntaxhighlighter 0.3



  • Fixed case where both syntaxes could not be used in a single post
  • Added support for the title parameter (default: empty)

Plugin Download Removed.

It feels like there's not much left to do with this plugin until somebody else uses it and needs more. Overall, my first foray into writing a plugin (and not just hacking functions.php) was fun and relatively uneventful.

Sep 6th, 2012

wp-markdown-syntaxhighlighter 0.2.1

It turns out that once I get bothered by something it doesn’t take me very long to work on it. I added an additional syntax to support passing all of the SyntaxHighlighter parameters in as JSON. The first method looks like this:

class Foo < Bar
  def hello
    puts "Hello World!"

This works as before and properly sets the brush type: [ruby]class Foo < Bar def hello puts "Hello World!" end end[/ruby] The second method looks like this:

class Foo < Bar
  def hello
    puts "Hello World!"

This one appends all of the valid parameters as class names so that SyntaxHighlighter can do its business:

class Foo < Bar
  def hello
    puts "Hello World!"

It’s pretty darn nifty, though I discovered that the plugin seems to have a problem with more than one code block in a post, like this one. I guess that's next up in the to-fix list!

Plugin download removed.

Sep 4th, 2012

First Wordpress Plugin: wp-markdown-syntaxhighlighter

I just put the finishing touches on version 0.1 of my very first Wordpress plugin: wp-markdown-syntaxhighliter.

I found a problem that I couldn’t easily solve with existing plugins, and so it made good sense to write one of my own. I have tried to move my blogging to Markdown-formatted content several times, each time running into incompatibilities between WP-Markdown and SyntaxHighlighter Evolved. The problem is that Markdown re-formats code blocks as <pre><code>...</code></pre>. SyntaxHighlighter is looking for bare <pre> sections with class names indicating various formatting options, thus making my code un-pretty when I use Markdown, unless I re-format my posts manually (essentially meaning that I can’t use Markdown as a source format).

In preparation for re-tooling this site, I decided that my first hurdle had to be removing barriers to writing. I like Markdown, I find it easy and less-involved than bare HTML. WP-Markdown now has the option to use Prettify.js to reformat code blocks. It’s simple and looks nice if all you want is syntax highlighting. If you want additional functionality (e.g. line numbers, row highlighting, etc.), you are out of luck.

(Re-)Enter SyntaxHighlighter. Essentially this is a search and replace problem. I have one code format, I want to go to another. Easy-peasy, that’s what preg_replace is for. My plugin simply does this:

return preg_replace( '|<pre><code>#!([^n]+)n(.*?)</code></pre>|se', 'wmsh_add_language('$2','$1');', $text );

That returns the code and its language specified on the first line of a markdown code block to a function that simply changes <pre><code>...</pre></code> to <pre class="brush:language">...</pre>.

I have one big enhancement I’d like to do, which is allowing a user to specify all of the SyntaxHighlighter options in this declarative line, probably in JSON. It’s not urgent, so for now the defaults stand.

I wanted to have this plugin hosted by the Wordpress plugins repository, but I’m not comfortable with the GPLv2 license that they insist on. I’m far more comfortable with Creative Commons-based licensing. I might relent... maybe.

Plugin download removed.

Aug 28th, 2012

Keeping Occupied

John Scalzi, one of my favorite authors, posed a question on his blog:

You have the ability to, for one night, reanimate any two historical personages (“historical” = “not currently alive”) and have them discuss/debate a topic of your own choosing. Which two historical personages do you choose, and what subject do you have them discuss/debate?

There were some great answers in the comments. He was quick to forbid what he considered the obvious choice of “Jesus Christ and Ayn Rand on anything”, which miffed me somewhat as that’s exactly what I’d like to see: Jesus Christ and Ayn Rand on Social Justice.

Thankfully I don’t answer to him, so I’m comfortable going with the “obvious choice”. Were I to be strong-armed, I’d probably go with Ghandi and Patton on direct versus indirect action.

Aug 27th, 2012

Rotating a Portrait-Mode Movie

I always forget how to do this:

ffmpeg -i -b &lt;bitrate-of-source-file&gt;k iphone-portrait-orientation.avi
mencoder -vf rotate=1 -o iphone-landscape-orientation.avi -oac copy -ovc lavc -lavcopts vbitrate=&lt;bitrate-of-source-file&gt; iphone-portrait-orientation.avi
Aug 23rd, 2012

Verizon Customer Service WIN (Round 2)

This summer, my wife and I wanted to stream the Olympics. In previous years we would watch them live or delayed (or DVRd on cable), but we've been firmly against having TV service to the house since our son was born. In the years since we have relied on a DTV converter and an analog antenna to grab OTA HD signals for a few notable events. NBC made the awesomestupid call to require an existing TV subscription in order to use their Live Extras service, so enter the quandary: Here we were, wanting to watch the Olympics, and having no other real-time options. I figured the only way this was going to work was to sign up for FIOS TV for a month and then cancel it, and that the privilege was going to cost me $50 or so.

History should have been a better teacher. Over three years ago, Verizon surprised me by saving me $180 a year by making some very small adjustments to my monthly plan, just for being a good customer. At the time I said:

Maybe luck will strike twice and the FIOS folks will give me a break as well. One can dream, right?

Lucky me. After a quick chat with one of their sales people, I found that I could add FIOS TV, never connect their box, and still qualify for NBC's streaming1. Since now I'm adding a 3rd service, my bundle pricing kicks in and actually saves me $10 a month over what I pay now.

And the icing on the cake: because each service has been upgraded in the last few years, I "have to" select a faster FIOS option and a more feature-filled home phone option.

So I'm now paying Verizon $10 less per month to have an additional service and two enhanced services. That's pretty cool.

It also tells me one very clear thing: We're all getting ripped off.

  1. NBC’s coverage of the 2012 Olympics was insufficient. They paid millions of dollars for the privilege of not showing us what we wanted to see. The events we cared about were all midday local time, which makes sense. However, they could not be replayed until their time-delayed replay time of 8pm that evening, which meant that we had no chance to watch the events until, usually, well after we had heard how they did via other sources. Consequently, on day 3 of the events, I paid for a proxy service that a twitter friend tipped me off to and started watching the BBC feed of the games. The BBC did a fantastic job, and I got to watch the women’s team’s final floor routines which clinched their golds. I watched the NBC replay that night only to find that the routines were split up, and kept switching to other events. I am very glad I was paying less for the privilege of, well, less service.

Aug 23rd, 2012

Infinite Scroll and SyntaxHighlighter Evolved

I like the idea of AJAX pagination whenever it makes sense (e.g. I'm not looking at tabulated data that I want to play with), and so it bugged me that I couldn't get SyntaxHighlighter Evolved and Infinite Scroll to behave nicely here. I tried a few months ago between meetings to force compliance to no avail. There is, what looked like, a simple recommendation here to change the callback after loading the next page from this:

SyntaxHighlighter.highlight(undefined,$('pre',this).get()); //didn't work for me< this:

SyntaxHighlighter.highlight($('pre')); //also didn't work for me

That, however, did nothing. Not even an error in Firebug. I gave up, and way too quickly. Today, 6 months later, it took me all of 5 seconds to find my bug. Wordpress, by default, overwrites the $ function, so to use jQuery's namespace, you have to call it properly with jQuery instead:

SyntaxHighlighter.highlight(jQuery('pre')); //success!

There's taking a step back, and then there's completely forgetting about a problem. Both work, apparently.

Aug 19th, 2012

A Rational Animal

When I get honest, I admit I am a bundle of paradoxes. I believe and I doubt, I hope and I get discouraged, I love and I hate, I feel bad about feeling good, I feel guilty about not feeling guilty, I am trusting and suspicious. I am honest and I still play games. Aristotle said I am a rational animal; I say I am an angel with an incredible capacity for beer.

Feb 9th, 2012