Jun 242014
 

I’ve been work­ing at Design Sci­ence for a couple of months now, as Seni­or Product Man­ager con­cen­trat­ing on the Math­Flow products. So I figured I should enable Math­ML sup­port on my blog. It’s not hard, but like everything in tech there are a few nig­gly details. Many of those issues are caused by Word­Press’s over-eager help­ful­ness, which has to be reined in on a reg­u­lar basis if you’re doing any­thing at all out of the ordin­ary. Like edit­ing your posts dir­ectly in HTML rather than using some pseudo-WYSI­WYG editor.

The­or­et­ic­ally, show­ing Math­ML in a browser is easy, at least for the sort of equa­tions that most people put in blog posts, even though not all browsers sup­port Math­ML dir­ectly. You just use the Math­Jax JavaS­cript lib­rary. On Word­Press there is even a plu­gin that adds the right script ele­ment, the Math­Jax-Latex plu­gin. You can make every page load Math­Jax, or use the [math­jax] short­code to tell it when to load.

The wrinkle comes with Word­Press’ tend­ency to “cor­rect” the markup. When you add the Math­ML, Word­Press sprinkles it with <br/> tags. Math­Jax chokes on those and shows noth­ing. Since the tags don’t show up in the edit­or view, you need some way of stop­ping Word­Press from adding them. The best way I’ve found is with the Raw HTML plugin.

But there’s a wrinkle with that too. For some reas­on if you use the short­code ver­sion of the begin and end mark­ers ([raw]) the edit­or decides that the XML char­ac­ters between those mark­ers has to be turned into the char­ac­ter entit­ies, so for example the < char­ac­ters are turned into &lt;. To stop that, you need to a) check all the check­boxes in the Raw HTML set­tings on the post, and b) use the com­ment ver­sion (<– raw –> and <– /raw –>) to mark the begin­ning and end of the sec­tion instead of the short­code version.

Once it’s done it’s easy to add equa­tions to your pages, so it’s worth the extra few minutes to set it all up.

A couple of examples taken from the Math­Jax samples page

Curl of a Vec­tor Field
×F=(FzyFyz)i+(FxzFzx)j+(FyxFxy)k
Stand­ard Deviation
σ=1Ni=1N(xiμ)2

and one from my thes­is from way back when

fλ=n!i<k(li-lk)l1!l2!lr!
Mar 072014
 

Langara is a loc­al col­lege offer­ing degrees in a num­ber of sub­jects, includ­ing Com­puter Stud­ies. I know one of the instruct­ors there, and he asked me to give a talk at their monthly Com­puter Tech meetup. As a top­ic, I picked Simple Prin­ciples for Web­site Secur­ity, a short­er ver­sion of talks I’ve giv­en at the XML Sum­mer School.

Apart from the fact that I was recov­er­ing from a bout with the vir­u­lent stom­ach bug that seemed to be going round Van­couver at the time, it was fun. A good bunch of people, decent ques­tions, and the stu­dent news­pa­per took advant­age of the oppor­tun­ity to write a column and make a video about basic inter­net secur­ity. One of my aims in this talk is to make the audi­ence para­noid, point­ing out some­times the bad guys really are out to get you, and talk­ing a bit about risk ana­lys­is and the trade-offs involved in writ­ing down strong pass­words (using a pass­word man­ager is bet­ter, of course). And the door prizes for Langara stu­dents were quite impressive!

Thanks to Ray­mond for invit­ing me, and Gail and Holly for organ­ising everything. I put the slides up at slide­share if you’re interested.

Jan 252014
 

If you’ve ever browsed through, or read, one of those self-help books that prom­ises life will be per­fect if only you think good thoughts, or that suc­cess in a busi­ness comes from set­ting goals and striv­ing to meet them, you may have had the nig­gling thought that there might be some­thing miss­ing in the rosy pic­tures these books paint. If so, The Anti­dote: Hap­pi­ness for People Who Can­’t Stand Pos­it­ive Think­ing might be the right book for you. I haven’t reviewed many of the books I’ve read recently, but this struck me as import­ant enough to do so.

The book talks about how always try­ing to be happy, think­ing only pos­it­ive thoughts, and try­ing to pre­tend bad things nev­er hap­pen to people does­n’t work to make us happy; there is real value in con­front­ing our fears and wor­ries and work­ing through the worst-case scen­ari­os as well as the best-case dreams. The author points out that fear of fail­ure makes busi­nesses blind to the real­ity that set­ting goals and doing things in the same way as a suc­cess­ful com­pany does­n’t bring suc­cess in and of itself.

The chapter called ‘Goal Crazy’ got me adding book­marks: it’s about how goals often don’t work, and it’s not just because com­pan­ies and people set the wrong ones, but because set­ting goals at all often means neg­lect­ing oth­er import­ant aspects. Examples include people determ­ined to suc­ceed in busi­ness who end up divorced and with health prob­lems, or com­pan­ies who focus on sales and starve the research depart­ment of neces­sary funds. Inter­est­ing stuff indeed, and lots to think about.

The author dis­cusses vari­ous philo­sophies and meth­ods to accept life without the ‘think pos­it­ive at all times’ man­tra, includ­ing stoicism, med­it­a­tion, Eck­hart Tolle’s teach­ings, and the Mex­ic­an tra­di­tion of memento mori, and teases out the sim­il­ar­it­ies between these. In the final chapter, entitled ‘Neg­at­ive Cap­ab­il­ity’, he comes to the con­clu­sion that hap­pi­ness includes neg­at­ive thoughts and emo­tions as well as pos­it­ive ones. This is a groun­ded hap­pi­ness, rather than some­thing fleet­ing that depends on one’s mood. This, to me, sounds like some­thing worth­while (and achievable).

Jan 212014
 

In prin­ciple I’m in favour of the ‘log in with X’ way of doing things (mod­ulo user exper­i­ence issues such as try­ing to remem­ber which ser­vice you picked to sign up with in the first place). There is, how­ever, more to it than that in some cases. Example: using the online repos­it­ory ser­vice bit­buck­et.

Sign­ing up in the first place with one of my Google accounts worked as expec­ted. The next step, of adding a git repos­it­ory and push­ing files to it, was a little more com­plic­ated. You need to use a reg­u­lar pass­word for git push and, of course, bit­buck­et does­n’t have the pass­word for my Google account. And I did­n’t have a reg­u­lar pass­word for the account, hav­ing set it up using my Google account, so I had to go through the pass­word-reset dance to cre­ate a new pass­word that bit­buck­et is allowed to know.

In oth­er words, for these sorts of ser­vices I need a pass­word that the ser­vice is allowed to know; log­ging in with oth­er ser­vices is an add-on but not a replace­ment. This isn’t hard to under­stand when you stop and think about what’s going on (in the browser the ser­vice relies on a lot of browser redir­ects which aren’t avail­able in the com­mand line), but it did take me a minute or two to fig­ure out that I would have to reset my here­to­fore blank pass­word to get one that I could use. (Bit­buck­et also sup­ports SSH iden­tit­ies and I’ll prob­ably set that up instead of the password.)

Dec 112013
 

My Mum used to make ginger beer on the farm. We would seal it in the glass bottles with bottle caps that you tapped on with a ham­mer, try­ing hard not to break the glass. A bottle or two would occa­sion­ally explode dur­ing the fer­ment­a­tion pro­cess, which was excit­ing, and messy.

I’ve taken to mak­ing it. Home-made ginger beer is a refresh­ing, fizzy drink, much less sweet than com­mer­cial soft drinks, with a pleas­ing zing. There is a small amount of alco­hol in it due to the yeast-mak­ing-bubbles fer­ment­a­tion step, but it’s min­im­al. The pro­cess of mak­ing it is fun, teaches the kids some­thing about chem­istry, and is much less messy with the advent of PET bottles.

The pro­cess is reas­on­ably simple. You start with a ginger beer plant (actu­ally a fungus yeast and a bac­teri­um; more details here). You feed it ginger and sug­ar every day until it’s ready, then add the liquid to a mix­ture of water, sug­ar, and lem­on juice. Bottle, store for a few days, and enjoy!

There are a num­ber of places on the inter­net you can get a ginger beer plant. I made my own; as a con­sequence it may not be a ‘real’ ginger beer plant, but giv­en the ginger beer it pro­duces is good, I’m not bothered by that fact. There are lots of vari­ations; this is the recipe I follow.

To make the plant, put the fol­low­ing ingredi­ents in a jug or jar.

  • 8 organ­ic sul­tanas (golden rais­ins). You need organ­ic (or oth­er unpro­cessed, if you’re lucky enough to be able to get them) to get access to the nat­ur­al yeasts that live on the sul­tana skins. Mod­ern pro­cessed sul­tanas are too clean and don’t have those yeasts on them, so the ginger beer won’t fer­ment properly.
  • ¼ cup lem­on juice. Use real lem­ons to get the juice, not some­thing that comes in a bottle. Organ­ic is nice, but not necessary.
  • 1 tea­spoon grated lem­on zest. Make sure you wash the lem­on first to get rid of any coat­ing that might inter­fere with the yeast.
  • 1 table­spoon sug­ar. I use white sug­ar, but you can use any type.
  • 2 tea­spoons ground ginger. You can also grate fresh ginger if you like, but I find that’s too much work. 
  • 2 cups water. I usu­ally use ordin­ary water, since our tap water isn’t too heav­ily chlor­in­ated. If you would­n’t drink your tap water, use bottled or filtered (but not distilled).

Stir, and cov­er the jar loosely with a cloth. You want air to get in (for the nat­ur­al yeasts) but not bugs (in sum­mer this is a mag­net in my kit­chen for fruit flies). Keep at nor­mal room tem­per­at­ure. Feed every day with 2 tea­spoons ground ginger and 2 — 4 tea­spoons of sug­ar (I use 4, you may like it slightly sweeter or less sweet). After a couple of days, you should notice some bubbles in the mix, and even a slight smell of fer­ment­a­tion as the nat­ur­al yeasts go to work on the sug­ar and ginger. The plant will be more act­ive in sum­mer, when the kit­chen is warmer.

After a week or three (the peri­od depend­ing on how much time I have in any giv­en week), make the ginger beer. You will need around 12 one-litre PET bottles. If you don’t have those at home, a loc­al beer-brew­ing shop will be happy to sell some to you, com­plete with the caps. Wash in soapy water, and rinse to get the bubbles out. You don’t need to ster­il­ise the bottles, I find the usu­al deter­gents to be adequate.

In a large pot, boil 5 cups of water with 3 cups of sug­ar. Stir to make sure the sug­ar is all dis­solved, then take the pot off the heat. Add the juice of three fresh lem­ons (yes, the pro­hib­i­tion against bottled lem­on juice applies here too). If you have small lem­ons, make that the juice of four lem­ons. Place a clean cloth (an old lin­en tea tow­el, for example) over a sieve or colan­der and pour the ginger beer plant through the cloth into the pot. Squeeze the cloth to get as much liquid out of the plant and into the pot as pos­sible. Add 7 litres of water to the pot (same com­ments on the water as above; I use tap water). Bottle the ginger beer, leav­ing some space at the top of the bottle for expansion.

The con­tents of the cloth are the ginger beer plant itself. Take approx­im­ately half of it, put in a clean jar with two cups of water, and feed. I also put anoth­er couple of sul­tanas in at this stage. This is the basis for the next batch of ginger beer, so feed every day as before. Give the oth­er half of the plant to someone, or add to your com­post bin. The plant gets bet­ter as it ages, so it’s worth­while keep­ing it going rather than start­ing new each time.

After a couple of days, you should see some small bubbles in the bottles, and the bottles should be firmer. This stage may take a couple of days longer in winter than sum­mer. You can drink the ginger beer at this stage, but it tastes bet­ter if you can leave it at least a week.

Oct 222013
 

I see the dis­cus­sion about how best to struc­ture your HTML+CSS to be both appeal­ing to the read­er and easy to main­tain is con­tinu­ing; see The Semant­ic CSS Debate for some of it and links to more. What par­tic­u­larly struck me was this sentence: 

I now find myself act­ively advoc­at­ing against lib­rar­ies like boot­strap due to the long term main­tain­ab­il­ity issues their approach to CSS causes.

On the sur­face, this appears to be one issue that tem­plat­ing sys­tems can help solve. Wheth­er you use XSLT to gen­er­ate a web site from Word doc­u­ments or XML, or some­thing like Jekyll (which I use for the Tex­tu­al­ity web site), or a data­base-driv­en sys­tem, to gen­er­ate the site, you should be able use both a frame­work such as boot­strap and your semant­ic con­tent. You do have to be pre­pared to put in an inter­me­di­ate step, that of gen­er­at­ing the out­put from the input and plan in advance for the fact that you may wish to switch from format a to format b.

This seems to me to be a logic­al way of doing things, or maybe it’s simply because I’m steeped in the idea of cre­at­ing the data in a format that can be trans­formed to an appro­pri­ate out­put format. This idea does make the choice of out­put format (in this case pre­cisely which HTML + CSS frame­work to use) some­what less daunt­ing, or rather, the cost of chan­ging it later some­what less (although not neg­li­gible since the trans­form­a­tion sys­tem needs to be changed).

Dis­claim­er: yes, I do write my blog posts using pointy brack­ets. Word­Press provides a tem­plat­ing sys­tem which enables chan­ging styles fairly read­ily; all I write by hand is the con­tent with­in the main con­tent block.

/* ]]> */