Guido van Rossum on Maintainable Code and other things

I love Python, so I maybe somewhat biassed about this article on Dropbox’s Blog: Thank You, Guido

Tags: python

Connecting to Public Wifi in MacOS Catalina

After upgrading to MacOS Catalina, I could no longer connect to open WiFI networks, specifically hotel networks and coffee shops. Previously, when connecting to one of these networks, a dialog would appear to ask for confirmation, a username/password combination, etc. No longer with Catalina.

After some extensive searching on the internet, the solution I found is launching the Captive Network Assistant manually. I wrote a small bash script to launch it from the command line on a terminal window:


/System/Library/CoreServices/Captive\ Network\\ Network\ Assistant

(You should always use some kind of VPN when connecting to non-encrypted public networks.)

Tags: catalina, wifi

Hidden Cobra and the worldwide ATM hacks

US-CERT on the August/September 2018 ATM hacks which affected several nations:

(…) all of the compromised switch application servers were running unsupported IBM Advanced Interactive eXecutive (AIX) operating system versions beyond the end of their service pack support dates;

This is the typical example of short-term thinking. Someone/some comittee decides not to spend on a supported version of a particular software, but don’t consider what the downside could be.

Infocom Text Games on MacOs

I played lot of Infocom text games when I was a kid. I remember drawing maps by hand, and inmersing myself in the stories. (There was no internet, so cheats came only from friends.)

Python Whatsapp Client Blues

I had the idea to code a simple script in Python that would notify of the day’s birthdays to a Whatsapp number or a Whatsapp group.

WhatsApp has no public API (that I’m aware of…) I spent some time with YowSup, which didn’t work with the examples of their own page. After applying some changes suggested in the YowSup forums, I was able to register my cel number and obtain a password for the account.

However, I’m dropping the script for now. Using YowSup would imply that every time WhatsApp changes their MD5 hashes and signatures (probably every time they update their client), my script would stop working.

Replacing Your Parrot AR Drone Blades (Propellers)

The Parrot AR Drone has a total of four blades (or propellers…). Note that not all blades are equal. Each blade has a letter printed near the shaft hole. Two blades are labeled “A”, and the other two are labeled “C”.

While replacing the blades is pretty straightforward, the critical step is getting the blades in the right order. Otherwise, your drone won’t take off. (It will roll over one side.)

The image bellow1 shows the correct order.

Parrot AR Drone

I recommend this blade replacement kit from Amazon: Parrot AR Drone 2.0 Propellers. The kit includes 4 propellers (2 ‘A’ and 2 ‘C’), and 8 clips.

Parrot AR Drone Propellers

(You can find a detailed teardown of the Parrot AR Drone on iFixit.)

  1. Image courtesy of iFixit.  

Tags: parrot ar

Migrating from Pelican to Wordpress


I’ve migrated my main blog from Pelican to Wordpress. (Pelican is a static blog generator.)

The main reason for changing is that I to make some changes in my webpage layout, or add some feature like a landing page, but don’t want to make (program) all the changes myself.

Using Wordpress will add complexity to my publishing workflow, but things like implementing landing pages and writing custom page archives can be quickly done in Wordpress by using the appropriate plugin. Also, I don’t have time to make sure my Pelican template/theme/skin stays responsive web-wise each time I need to change something.

My Pelican setup used a combination of Pelican, the program, installed on a Linode server, that generated my blog from a folder in the same server. The folder was kept in sync with my laptop using Dropbox. (More about this setup here.

Every Rose has Its Thorne

Installing Wordpress from scratch in my Linode server, choosing a theme, and installing some basic plugins took around an hour. The most time consuming step, however, was migrating the content to Wordpress.

Markdown Issues

I’ve been writing my posts in Markdown for some years now. The idea is that I can take my content everywhere, because Markdown is close to an universal jargon, so to speak. The idea is to “own” your content so you can take it with you to whatever blogging platform you use, and the content being as close to human writing as possible (which HTML is not).

In reality, however, the Markdown flavor Pelican uses is not 100% compatible with the flavor Wordpress uses (I’m using the one provided with Jetpack). The main difference is how you specify html attributes like classes to your markdown.

For example, my book reviews include a image of the book. It’s format is specified using a class="imagebook" attribute, which in Pelican looks something like this:

~~~ Deep Work{: class=”bookimage” } ~~~

In Wordpress’ Markdown, the same line should look like this:

~~~ Deep Work{.bookimage} ~~~

Also, while I could add attributes like {: target="_blank" } to any link, Wordpress’ Markdown doesn’t provide (as far as I know) anything similar. (This is just a consequence of Markdown extensions not being standardized.)

My solution for this was simple:

Use a text editor (Atom, in my case) and open the folder containing all my content. Then, use Find/Replace project-wise to replace Pelican markup for Wordpress’ flavor. (Forget about `{: target=”_blank” }, just settle down for external links to open in the same browser window.)

Lesson learned:

Disqus Comments

The second pain was migrating Disqus to Wordpress.

Disqus uses your Disqus shortcode (a sort of username) for identifying your account. Then, it uses a unique identifier to identify the comment thread for each of your posts. This identifier is passed as the disqus_identifier variable in the Javascript code that actually load the comments on the web page.

In my Pelican setup, the unique identifiers for each post were created using the one thing that is unique for each post: it’s permalink, without the domain. Like in /2014/02/25/pelican-dropbox-automatic-blog-regeneration/ My idea behind this was, again, to be able to take the comments with me to whatever blogging platform I choose.

Wordpress’ Disqus plugin, however, has another idea of what constitutes a unique identifier. It uses Wordpress’ unique post ID to build it:

~~~ 1119 ~~~

The problem is that the 1119 is unique to Wordpress, and there was no easy way to convert my existing Disqus IDs to that format.

My solution was to hack the Disqus’ plugin code so that it generated the unique identifier in my own format:

~~~ function dsq_identifier_for_post($post) { // return $post->ID . ‘ ‘ . $post->guid; return rtrim(parse_url(get_permalink($post), PHP_URL_PATH),’/’); } ~~~

The problem: I’ll need to patch the code every time the plugin is updated. The benefit: I keep my more logical (to me) identifier structure.

Migrating content itself

I tried several plugins to import my content directly into Wordpress, without success. Pelican is not widely used, so there is no direct way to migrate your content to Wordpress.

Being my posts a bunch of text files with YAML headers residing in a folder on my laptop, at first I thought of writing a Python script that read every file, extracted the post’s metadata from the YAML header, and injected it into Wordpress using the Wordpress API and an appropriate Python library. (Which there are plenty.)

For every post, I would have to check for links to local image files. If found, the image file would be uploaded to Wordpress, and its new URL would replace the original one in the post.

This is not a difficult script to write, but I’m sure it won’t be without it’s pitfalls. And then, knowing myself, I would still want to check every post to see if it rendered OK.

So, I opted for a more manual procedure: copy each post manually. (Yes, I know what you are thinking…) I did this in 30 minutes chunks, for several days. Not the fastest thing, but it did get the work done. The third day, I became tired of this manual procedure and wrote a Pelican exporter. (You can download it from Github.)

Template tweaking

I’m using Genesis as the base theme. I used the Genesis Sample Child theme as a base to customize my blog’s appearance to mimic its previous incarnation. Almost 100% of this was done by adding to the CSS file. Genesis is a good alternative, and not being a CSS specialist, it’s structure is clear and relatively easy to adapt to your needs.

Lessons learned

For me having my content in a format portable enough that allows me to republish it wherever I need is an important requirement. Using Markdown is a good way to do it. Actually migrating the content is not as simple as it sounds, however, but it can be done.

Link: Shawn Blanc interviews John Gruber

This is interview is from 2008, by I’ve just re-read it and thought it was worth linking for my future reference: John Gruber: A Mix of the Technical, the Artful, the Thoughtful, and the Absurd.

Tags: daring fireball

Link: This is GIT

This is GIT

Link: What is Code?

Excellent long article by Paul Ford: What is Code?.

Page 1 / 5 »