WordPress syntax highlighting

I occasionally post code here, and I’ve never been entirely satisfied with the various ways that one can post nicely-formatted code on a blog. This blog has been around for so long that I’ve gone through several approaches. Recently, I’ve been putting all my code snippets in Github Gists, and then embedding those Gists here.

That looks pretty good, and works pretty well, but I’ve discovered a couple of downsides to that method. First, the code itself is not actually in my posts, so it doesn’t show up in searches, either here at the blog or (presumably) in Google or other search engines. I realized this a while back when I tried to search for a past post, using a bit of code that I knew was in the post. When I didn’t find it, I realized that of course the code wasn’t in the post, it was only out on Github. So I wanted to fix that, and get the code itself into my post database.

Second, the company I work for has started blocking the Gist site. I’m not sure why, but I guess maybe it’s occasionally used to post malicious code? Regardless, it’s a problem, since I sometimes want to bring up an old post of mine at work to remind myself of how I solved a problem in the past. When I do that now, the post is visible but the embedded gist is missing. And if my company is blocking gists, other companies are probably doing it too, so other people looking at my blog might be confused when they see a post with missing code.

So there are some good reasons to include actual code in my posts, rather than relying on Github. I could go back to just wrapping the code in <pre> and/or <code> tags, but I wanted to have something that would look at least as good as the embedded gists. So I started looking at syntax-highlighting plugins for WordPress.

I looked at Enlighter and WP-Syntax. Enlighter looks pretty cool, but I decided to go with WP-Syntax in the end. It uses GeSHI, which I’ve used before (in Drupal), and supports a lot of languages, including X++, which is a pretty obscure language. I installed it about a week ago. Today, I decided to spend a little time editing some of my old posts to move code from gists to WP-Syntax. It worked out pretty well. (And I’m still linking to the gists, so if the code gets scrambled, it’ll still be there on Github.)

To some extent, I guess this is just pointless busywork. My old posts don’t really get a lot of hits, and I really don’t refer back to them that often. But it was a nice little way to spend an hour on a cold Sunday afternoon, and it gave me a sense of accomplishment.

a birthday, a parade, and a good book

Tomorrow will be my 50th birthday. I wasn’t sure if I wanted to mention that on the blog, but I’ve previously posted about my 35th and 45th birthdays, so it’s not like it would be hard for anyone to figure out how old I am, if they wanted to know. So here it is: I’ll be 50 tomorrow.

The Somerville St Patrick’s Day parade is going on right now. I’ve been watching a bit from my window; it’s too cold out for me to want to go outside and watch. And I’ve been getting wrapped up in the final chapters of the final book of the His Dark Materials trilogy. I started re-reading it a few weeks ago, and I’m almost done now.

I had been planning to visit a friend yesterday to celebrate my birthday, but that fell through. That will probably happen next weekend now, but that means it’s been a generally uneventful weekend, since I didn’t plan anything else.

I used my Starbucks birthday reward to get a free chicken sandwich for lunch, so that was my big birthday meal. I’ve got a couple of Justin’s peanut butter cups I might eat later, in lieu of birthday cake.

I’m expecting that tomorrow will be a pretty normal, quiet day at work. But we’re supposed to get a lot of snow on Tuesday, so I think it’s going to be a chaotic week overall. I decided this year that I’m no longer going to be the guy who valiantly drives in to work in a snowstorm, so I expect I’ll either be working from home on Tuesday (and possibly Wednesday) or taking a PTO day. And if we get as much snow as expected, the whole week will be a mess. Here’s hoping that something vaguely approximating Spring gets started soon!

Getting master page URL in SharePoint 2013 with JSOM

I’m only just starting to learn JSOM (after previously learning the server-side object model, and CSOM, via C#). There are some slightly weird requirements and limitations that are constantly tripping me up. Here’s today’s waste of time: trying to get the current site’s master page URL.

Here’s what I came up with:

$(document).ready(function () {
            $('#divMain').text('Hello World.');
            getMasterUrl();
        });
        function getMasterUrl() {
            var myCtx = new SP.ClientContext();
            this.site = myCtx.get_site();
            this.web = myCtx.get_web();
            myCtx.load(web);
            myCtx.executeQueryAsync(
                Function.createDelegate(this, this.onSucceededMasterUrl),
                Function.createDelegate(this, this.onFailed)
                );
        }

        function onSucceededMasterUrl() {
            $('#divMain').text('Master URL: ' + web.get_masterUrl());
        }
        function onFailed(sender, args) {
            $('#divMain').text('Failed: ' + args.get_message());
        }

This just kept failing. I tried a bunch of random stuff to get it to work. In the end, I made a fairly minor change that got it to work. But then, I changed the code back, and it still worked. So this was going to be a post about a minor quirk of JSOM, but now it’s more of a “WTF” post. I’m sure I did something to make it work, and I just lost track of what it was. Well, either way, I’m having some fun with JavaScript.

The New Colossus

Not like the brazen giant of Greek fame,
With conquering limbs astride from land to land;
Here at our sea-washed, sunset gates shall stand
A mighty woman with a torch, whose flame
Is the imprisoned lightning, and her name
Mother of Exiles.

Emma Lazarus, The New Colossus

 

Anime

There’s an interesting article on the NewsHour site about anime’s absence from the Oscars this year. It mentions the movie Your Name, which I’ve heard a lot about, but haven’t had a chance to see. (As far as I can tell, it was only released for a short run in 2016 in the US, to qualify for the Oscars and won’t get a “real” release until April.) I don’t know much about the director, Makoto Shinkai, but he seems to be well-regarded, so maybe I should hunt down some of his older movies.

I’ve been getting interested in anime again lately. This week, I watched the first three parts of Ghost in the Shell: Arise on Netflix. It’s not nearly as good as the GITS: Stand Alone Complex series, but it’s not bad. And I really liked the music, some (or all) of which is by Cornelius. There’s even one song which, apparently, is a collaboration between Cornelius and Sean Lennon. It seems like only those first three parts of Arise are available on Netflix, so now I need to decide if I want to buy the rest on Blu-Ray from Amazon, or maybe from iTunes. The series is a bit confusing, just in terms of the way it was released. Wikipedia does a (relatively) good job of explaining it. There are five main episodes, each about an hour long. In the US, they’ve been released on Blu-Ray as Borders 1 & 2 and Borders 3 & 4. (I’m not quite sure about the fifth episode, “Pyrophoric Cult”.) There is also something called The New Movie, which completes the series (I think). Those episodes/movies have also been re-edited into an anime TV series, with typical 30-minute episodes. That TV series is available on iTunes.

All of this leads me to think that I should maybe dive back into my old pile of unwatched anime DVDs.

Pocket acquired by Mozilla

Well, this is interesting. Mozilla has acquired Pocket. I blogged recently about Instapaper, and their acquisition by Pinterest. Now, their one big competitor has been acquired too. That’s a little disappointing, but maybe not unexpected. Though I wouldn’t have guessed that Mozilla would be the one to buy them out.

I’m still using Instapaper. They’ve restored all the data that was lost in their big crash a few weeks ago, and their site has been working fine for me ever since. So I’m hoping that they’re doing OK.

WordPress on .NET

I don’t think I’d ever want to run WordPress on .NET, but it’s interesting to see that it’s (kind of) possible now. This is being done by compiling PHP to .NET, and using Kestrel as the web server. It’s interesting to read about the work that goes into something like this.

Amazon Affiliate Links

Amazon has recently made some changes to their affiliate program that are going to have a negative impact on some bloggers. Here are a couple of articles about the change, from The Verge and The Digital Reader.

I’ve been using Amazon affiliate links here on my blog for a long time. And I’ve never earned a penny from them. And that’s fine. I used to use SiteStripe to generate fancy image links, but I’ve had problems with those since I switched from Blogger to WordPress. So lately I’ve just been using SiteStripe’s short URL links. For me, it’s really just a way to get a short URL that might (but probably won’t) make me a buck or two at some point. But there are some sites that have based their “business model” on Amazon affiliate links, and they’re going to be in a bit of trouble. The Wirecutter and The Sweethome used to be in that category, but since they’ve been acquired by the NY Times, maybe they don’t have to rely so much on Amazon.

Either way, relying on something as fragile as affiliate links for anything other than a little extra coffee money has always seemed a bit daft to me. On the other hand, online advertising is a mess too, with so many people using ad blockers, and getting people to pay for content doesn’t usually work out too well either. I’m glad I have a good day job!

The Book of Dust

I was pretty excited to find out this week that Philip Pullman will be releasing the first volume of his new trilogy in October of this year. The trilogy isn’t exactly a sequel to His Dark Materials, but it’s in the same universe, and features some of the same characters. More details can be found at NPR and The Guardian.

I read His Dark Materials back in 2004, starting in January and finishing in June. I remember it well, since I was reading it when my brother passed away, in February 2004, so those memories are linked together in my head. It was also the first time I read anything substantial in ebook form. (I was reading it with Microsoft Reader on a Toshiba Pocket PC. It wasn’t a horrible experience, but neither was it a good one, and I never did buy anything else to read on that device.)

At some point in 2010, I think, I bought a trade paperback of the trilogy, with the idea that I’d reread it eventually. (Of course, the Pocket PC was long gone by then, along with the DRM’d ebooks that were tied to it.) I still haven’t gotten around to rereading it, but I’m thinking about it again.

I could just go ahead and start into the trade paperback, or I could listen to the audio version of Golden Compass, which I seem to have bought via iTunes in 2007 and forgotten about. Or I could buy the graphic novel version of Golden Compass, which I didn’t know about until I started poking around on Amazon tonight. So, plenty of options.

I’m kind of curious as to how I’d process the books right now. I think I’m a different person than I was in 2004. Am I capable of enjoying them as much as I did the first time through? Would I find new things in them that went over my head the first time? Would reading certain sections trigger specific memories? I don’t know. I’m usually not big on rereading books. There are just so many that I haven’t read yet, and I’m such a slow reader these days. But rereading these books would probably be worth my time.