Oct 102019
 

(Or, as it’s com­monly known, yak shaving.)

In this case, to be able to use a Dock­er image, the easy way to install soft­ware (I’m told). But, of course, tech­no­logy has a habit of throw­ing curve balls. Or, as here, demand­ing items that you may not have.

Step One: Check­ing the require­ments for Dock­er reveals that, if you’re using Win­dows, you need a Win­dows 10 Pro install­a­tion, not Win­dows 10 Home. There is, how­ever, a Dock­er Tool­box option for Win­dows 10 Home. The require­ment for Dock­er Tool­box includes vir­tu­al­iz­a­tion being enabled. (There’s a link to a tool to check this.) My Win­dows PC, a couple of years old, has that vir­tu­al­iz­a­tion, but it’s disabled.

The word­ing on the Dock­er Tool­box page makes it sound like using the full Dock­er Desktop would be prefer­able, so I decided to check out that option. Microsoft does make it easy to spend the money to upgrade to Win­dows 10 Pro (there’s a link in the Set­tings app under About with the word “Upgrade”), but the require­ments for Dock­er Desktop include sup­port for some­thing called “Second Level Address Trans­la­tion (SLAT)”, which seems to be called some­thing dif­fer­ent any­where you might want to check it. In the Win­dows sys­tem inform­a­tion (sys­teminfo) it’s called Hyper‑V, for example, and check­ing it reveals that in my sys­tem it’s sup­por­ted, but not enabled.

Step two: Enable vir­tu­al­iz­a­tion; this requires a reboot and change to the sys­tem BIOS set­tings. This page on how to access the BIOS on Win­dows 10 was use­ful. Once enabled, everything seems good to go, and from there I decided to try out the tool­box first, and think about the lar­ger upgrade later. I’m not crazy about poten­tially break­ing work­ing sys­tems if I can avoid it, and past Win­dows upgrades have made me cautious.

Step three: Install Dock­er Tool­box, which went smoothly enough. But the pro­gram I was try­ing to run had issues with port map­ping. A pos­sible cause is some­thing in the Dock­er sys­tem not talk­ing to the Win­dows sys­tem in the expec­ted way, so it looks like I will need the full Dock­er Desktop after all. Which means upgrad­ing Windows.

Step four: Delete Dock­er Tool­box from the sys­tem to make sure there are no weird interactions.

Step five: Sign up for a Microsoft account, so that I can buy Win­dows 10 Pro.

Step six: Install Win­dows 10 Pro as an upgrade to Win­dows 10 Home. This went much faster than I expec­ted and appar­ently did­n’t break any­thing either.

Step sev­en: Install Dock­er Desktop and repeat all the soft­ware-depend­ent install­a­tion steps.

Suc­cess! The port map­ping works, and the required soft­ware installed.

Tech­no­logy is great, except when it isn’t. But Win­dows 10 is much bet­ter than pre­vi­ous ver­sions of Windows.

Feb 042018
 

Pos­ted in case it helps someone else.

One of my web­site cli­ents asked for help with one of their Mac OS X laptops, which had sud­denly stopped con­nect­ing to their wifi net­work. The wifi con­nec­tion seemed to be demand­ing a WPA enter­prise user­name and pass­word, des­pite being set up as WPA2 per­son­al, which only needs a password.

In the end, the cause was a com­bin­a­tion of a new modem/router from the cable com­pany, and an old ver­sion of Mac OS X (10.7.5). I had to go to the app store to down­load El Cap­it­an, since you can­’t update from 10.7.5 to High Sierra dir­ectly, but after installing it the laptop could con­nect to the WPA2 per­son­al wifi net­work on the new modem/router. It’s now been updated to High Sierra, and the com­pany reminded to install the updates they get a little more regularly…

Jul 232017
 

For a while there XML.com did­n’t handle tags on sub­mit­ted news items very well. If a tag was included that was in a dif­fer­ent case to an exist­ing tag, the pre­view and pub­lish would res­ult in a 500 serv­er error. For­tu­nately this was some­thing that was­n’t vis­ible to the out­side world, but annoy­ing nonetheless.

Wag­tail allows case-insens­it­ive tags, and I had already turned that on (it would be con­fus­ing to have searches for the tags “XSLT” and “xslt” return dif­fer­ent res­ults, for example). Art­icles and news items sub­mit­ted using the stand­ard inter­face behaved prop­erly, it was just the news items sub­mit­ted by people without logins on the sys­tem that didn’t.

It turns out that the prob­lem lay in the way I called the get_or_create() meth­od, which is used to look up the tags in the data­base and then cre­ate them if they don’t exist. In my code, that looked like this: 

tag, create = Tag.objects.get_or_create(name=tag_name)

By default, this is a case-sens­it­ive meth­od (as it should be, for the gen­er­al case). To make the look­up case-insens­it­ive, you use name__iexact instead of name. The next prob­lem I found was that no tags were being cre­ated if the tag did­n’t already exist in the data­base. To cre­ate the tag, if you’re using name__iexact instead of name for the tag look­up, you also need to give the get_or_create() meth­od a defaults para­met­er to use when cre­at­ing the tag. Now that line looks like this:

tag, create = Tag.objects.get_or_create(defaults={'name': tag_name},
                                        name__iexact=tag_name)

and it all works the way it’s meant to.

Apr 082017
 

If you have Math­ML on your Word­Press site, using the Math­jax sys­tem to show it, then you need to know that Math­jax is shut­ting down the CDN as of April 30, 2017. If, like me, you use the Math­Jax-LaTeX plu­gin, the solu­tion is easy.

Go to the Plu­gins — Set­tings — Math­Jax-LaTeX page. Uncheck the “Use Math­Jax CDN Ser­vice?” check­box, and add https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js to the “Cus­tom Math­Jax loc­a­tion?” text field. You can, of course, also down­load the Math­Jax scripts and install loc­ally, but I prefer to use a CDN.

Save the changes, and you’re all set! Unfor­tu­nately there isn’t an equi­val­ent of the Math­Jax ‘latest’ for the scripts, so every now and then you’ll need to update the loc­a­tion, but oth­er than that there should be no differences.

Mar 262017
 

Let’s Encrypt has made it much easi­er for web sites to use https instead of http, even those on shared host­ing. In my case, all I needed to do was ask my ISP, Cana­dian Web Host­ing, to move my accounts to a serv­er that sup­ports a cPan­el exten­sion (I assume this one). Installing the certs is trivial.

Chan­ging the basic Word­Press set­ting was easy — update the WordPress Address (URL) and Site Address (URL) set­tings in Gen­er­al. This did break a lot of image links, mostly because I’ve had my blog on Word­Press for so long that I still had all my images in a cus­tom image dir­ect­ory and the gal­lery could­n’t find them any more. That took a cer­tain amount of fid­dling, and I haven’t yet got all the images in the old posts back to the way they were.

Anoth­er thing that broke was my spam detec­tion. I used Spam Karma for many years, and even after it was no longer updated it was suit­able for my needs. But it does­n’t work with https for some reas­on. I’ve now switched to Anti­s­pam Bee and find it does what I need. I haven’t noticed any spam slip­ping through, nor real com­ments being marked as spam. Most of the com­pet­it­ors had some fea­ture I did­n’t like, such as by default delet­ing com­ments without my hav­ing a chance to check them. That would be use­ful on sites with lots of spam, but not neces­sary for mine. It has a well-deserved high rat­ing on the Word­Press plu­gin site.

Over­all, switch­ing my sites to https cost me a couple of hours work and the time wait­ing for the new serv­er DNS to propag­ate. Well worth it.

Feb 012017
 

I coded XML.com in Wag­tail, a CMS based on Django. It works well for my needs and I like Python as a pro­gram­ming lan­guage. One of the big reas­ons I like Wag­tail is that it includes a power­ful enough but not overly com­plic­ated work­flow with roles and a built-in mod­er­a­tion and pre­view system.

But, I wanted a sys­tem where people could sub­mit news items that would go into the mod­er­a­tion queue without need­ing to sign up for a login first. For­tu­nately, Wag­tail makes that pos­sible, and there’s a nice art­icle by Erin Mul­laney at Wag­tail: 2 Steps for Adding Pages Out­side of the CMS that details all the steps you need. It all worked nicely in more recent ver­sions of Wag­tail (thanks, Erin!) except for one part, the noti­fic­a­tion that the news item is in the mod­er­a­tion queue. That was­n’t a stop-ship item, so XML.com launched without those emails working.

I’ve now found the source of the prob­lem. It turns out that when you sub­mit a news item in this way, it does­n’t have a login iden­tity attached to it (obvi­ously, since there isn’t one). The send_notification func­tion that sends the email uses tem­plates, and these tem­plates use the login iden­tity of the author in the body of the email. Since that does­n’t exist, the whole func­tion fails. 

That means the solu­tion is easy. The affected tem­plates are wagtailadmin/notifications/submitted.txt and wagtailadmin/notifications/submitted.html, and Wag­tail lets you cus­tom­ize the admin tem­plates. I put my cus­tom­ized admin tem­plates into a utils applic­a­tion, which con­tains all my util­it­ies for the site. My utils/templates/wagtailadmin/notifications/submitted.txt file now has the content

{% extends 'wagtailadmin/notifications/submitted.txt' %}
{% load i18n %}

{% block content %}
{% blocktrans with page=revision.page|safe %}The page "{{ page }}" has been submitted for moderation.{% endblocktrans %}

{% trans "You can preview the page here:" %} {{ settings.BASE_URL }}{% url 'wagtailadmin_pages:preview_for_moderation' revision.id %}
{% trans "You can edit the page here:" %} {{ settings.BASE_URL }}{% url 'wagtailadmin_pages:edit' revision.page.id %}
{% endblock %}

Sim­il­ar changes are neces­sary for the wagtailadmin/notifications/submitted.html file if you want to send HTML emails instead.

/* ]]> */