## Welcome!

Hi there! I'm Julian M Bucknall, a programmer by trade, an actor by ambition, and an algorithms guy by osmosis. I chat here about pretty much everything but those occupations. Unless you're really lucky...

Most recently this is what I've come up with:

## Issues using MathJax 2.5 with Chrome

So yesterday I wrote an article about the conditional support of MathJax in my posts here on the blog. The post required MathJax since I deliberately put an equation in it. Today I noticed that viewing that post in Chrome led to the equation being rendered three times across the page:

Chrome displays three equations. Whut?

Even refreshing the page didn’t solve the issue. A mild bit of panic later – Does it work in FireFox? Yes. In Internet Explorer? Yes. In Safari on the Mac? Yes. On an iPad? Yes. – it was time for a bit more research.

It turns out that MathJax was updated to v2.5 on January 30, 2015 and I’d coded the <script> element to download the latest version:

<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

And there in the PR report about it was the hint:

If you are using the mathjax/latest address you might get a mixture of files in your browser cache, and so may need to clear your browser cache and for some browsers (e.g., Chrome) restart your browser in order to get a consistent version of all files.

I opened Chrome’s History page, clicked the Clear browsing data… button, made sure the Cached images and files option was checked, and cleared the browsing data. I restarted Chrome and everything worked as it should have.

Phew! Saved, at least until the next time…

Now playing:
Aphrodelics - Rollin' on Chrome [Wild Motherf***er Dub]
(from The K&D Sessions)

A couple of years ago I did a series of posts about TVM, the Time Value of Money (1, 2, 3). Because they were mathematical in nature, I had to write a few math expressions and equations. Way back when I’d have written them out in the Equation Editor in Word, and taken screenshots, but this time I decided to go for a browser-based solution: MathJax. In essence, I’d write the expressions in LaTeX format, such as x = \frac {-b \pm \sqrt{b^2 - 4ac}} {2a}, and have it rendered as:

$x = \frac {-b \pm \sqrt{b^2 - 4ac}} {2a}$

Eek, maths on a chalkboard!

This was a great solution, except for one thing: I didn’t really write that many mathematical expressions in my blog posts and MathJax was being loaded and executed for every single page no matter whether there were expressions to be rendered or not. In other words, the specialized infrequent need was dominating the more general use of my blog. The majority of pages were slower to load than they should be. What I wanted was a way for the page renderer to load MathJax only when it was necessary.

The first step was to be able to mark those posts that used MathJax in some way. Enter GraffitiCMS’ Custom Fields. I set up a custom checkbox field called UsesMathJax and then went back over my posts to find those that needed MathJax processing of LaTeX expressions. (It wasn’t as bad as all that: in essence I regex-searched for $, some characters, followed by $ or the equivalent with ordinary parentheses in a loop for each post.) This post has been so marked.

Now that was done, the fun begins. I had to alter the views I use for the site so that the rendering engine (it’s NVelocity) knows to output the <script> element that references the MathJax library. I started off with a simple variable, #NeedsMathJax, that I set false at the beginning of layout.view and then was checked to be true at the end of the <body> element.

<body class="Graffiti-$where"> <div id="wrapper"> #set($NeedsMathJax = false)

$childContent <!-- Other HTML --> </div><!--end of wrapper --> <script type="text/javascript" src="$macros.ThemeFile('minifiedBoyet.js')"></script>

#if($NeedsMathJax == true) <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> #end <!-- Other scripts --> </body> And then, for post.view, which is loaded by $childContent, I had this at the end of the HTML:

#if($post.Custom("UsesMathJax") == "on") #set($NeedsMathJax = true)
#end


(Note the string value that the custom checkbox field uses: “on” . Similarly if it’s unset it defaults to “off”.)

## Installing Yosemite like a pro

Way back when, I bought a black MacBook and an iPod Touch. I was – har, har – going to learn how to write Objective-C and earn millions selling apps. You know the kind of thing: Learn Objective-C … PROFIT!!!! Except Objective-C is a right royal pain in the neck – and this is coming from someone who loves JavaScript. Anyway, after a year or so, I had a better plan: use a Mac as my main laptop and get used to the Mac way. I bought a unibody 13-inch MacBook Pro, mid-2010 version...

# Extras

## Search

I'm Julian M Bucknall, an ex-pat Brit living in Colorado, an atheist, a microbrew enthusiast, a Volvo 1800S owner, a Pet Shop Boys fanboy, a slide rule and HP calculator collector, an amateur photographer, a Altoids muncher.

## DevExpress

I'm Chief Technology Officer at Developer Express, a software company that writes some great controls and tools for .NET and Delphi. I'm responsible for the technology oversight and vision of the company.

March 2015 (2)
SMTWTFS
« Feb
1234567
891011121314
15161718192021
22232425262728
293031