With my ever growing list of things that I need to catch up (like wiring my home network and managing Rookeries), I needed a small fun project that I can work on. Ever since I learned enough Rust to be able to convert Rookeries, I wanted to play around with being able to speed up my code with a Rust library. I am especially interested in figuring how to call Rust code from Python or from JS with Web Assembly.
As a test bed (and a reason) for me to learn this, I created a small little library for
getting the uptime of a local server (Linux only): embedded-uptime converting between different measurement units like Celsius and Fahrenheit: embedded-unit-converter. If you’d like to follow along, feel free to check it out. I will be posting updates on the blog, and on the Rookeries mailing list.
Updated on 2019 February 4: When I setup the project, I forgot that server uptimes that rely on accessing a server’s
/proc/uptime can not possibly work in Web Assembly in browser environment. After some consideration I decided to go with something simple that accessible from any platform, namely conversion between different units of measure.
This week as I had some downtime after PyCon Canada, I started working on resolving all the issues that I postponed. One of these issues involved applying security updates to my Linode server and rebooting the server. However when I did so… I noticed that the Rookeries site went down. When I logged into the server, I quickly found the problem: Docker refused to start after the kernel updates.
As this bug report on Docker for Linux says, there is an issue with the latest Linode kernel when it comes to OverlayFS.
This causes the
docker-ce is dependent on to not start. When looking at the logs (using
sudo journalctl -xe), you’ll see an error along the lines of:
modprobe: ERROR: ../libkmod/libkmod.c:514 lookup_builtin_file() could not open builtin file '/lib/modules/4.18.16-x86_64-linode118/modules.builtin.bin'
modprobe: FATAL: Module overlay not found in directory /lib/modules/4.18.16-x86_64-linode118)
Thankfully there is a workaround to resolve this problem. From the instructions you need to an override configuration for the
$ mkdir -p /etc/systemd/system/containerd.service.d/
$ cat << EOF > /etc/systemd/system/containerd.service.d/override.conf [Service]
$ systemctl reload
$ systemctl restart docker
Anyways, I hope this helps if you run into the same situation.
Apologies for the late post but it has been a busy day. As of today you can buy the early edition of Juggling JSON with jq on Gumroad. I am very excited since this is my first attempt at self publishing a book. Naturally the journey is still continuing as I work towards the final release of the book. All buyers of the book will get updates including the final version when it comes out.
I plan sending out an update on the book and the companion site/API that I am working on.
The early release of my ebook Juggling JSON with jq comes out tomorrow! However this post is more about the process of writing the book itself.
Getting started on an technical ebook, (such as Juggling JSON with jq), requires a bit of upfront setup. On the ebook side, I decided to go the route of writing the book in Markdown, and generating the various formats using Sphinx. While I feel most comfortable using Markdown, and yet Sphinx uses reStructedText by default. So I had to coax Sphinx to accept Markdown by using a project called m2r. Generating the PDF version of the ebook took a bit to get working. Sphinx uses LaTeX to generate PDFs, and LaTeX while powerful can be clunky to work with. I wrapped everything up with an invoke script, and now I can quickly generating new versions of ebook in the various formats I want to support.
Something unique to writing technical books, is the need to have actual working examples. You can learn by reading, but working through exercises and examples re-enforces that learning. In the case of Unjumbling JSON with jq, I needed an example REST API that readers play with. I searched for some nice open APIs, but nothing seemed very compelling. Many of the open APIs require some form of user registration and non-trivial authentication method that would complicate the examples in the book. So I setup a simple demo API for the book. Thankfully with Docker and Flask, that isn’t a particularly daunting task. (Dockerizing most of my webapps definitely made my live easier overall.)
Finally using Gumroad made marketing and selling the book a lot more approachable. Getting everything setup for e-commerce is a daunting job, if you plan on doing it yourself. Thankfully for ebooks, and similar digital products, Gumroad solves most of the problems one can encounter. I definitely recommend using them if you are planning to do something similar.
jq is an amazing tool for querying and manipulating JSON in command-line, that I learned about from one of my good colleagues, Eric Olsen. And I feel that jq deserves a good book describing how to use this tool. Hence I am writing a book called Unjumbling JSON with jq on the topic.
As mentioned in a previous post, I originally planned on writing a single book on both jq and httpie. I divided the original book in two, because there is only a small overlap between the two. I wanted to show examples of grabbing a REST API response via httpie, and parsing the JSON output with jq. However basic querying a REST API is something that could be covered in a short section. By writing the books separately, I will be able to release them faster, and the books will be much more focused.
I plan on selling early drafts of the ebook on August 10th. Buyers of the ebook will get regular versions of the evolving drafts of the ebook, and a free upgrade to the final version of the book. I want to release the early drafts to get early reader feedback. In addition readers of the book will have access to the REST API that accompanies the book.
You can order the early version of Unjumbling JSON with jq from here].
I have not completed the switch away from WordPress completely, (as this site and the justCheckers site show). I might switch to using something like Django CMS or Wagtail. Unfortunately I have not had as much time as I’d like to, to work on Rookeries, my own Flask based CMS
Still in the meantime, I managed to accidentally lock myself out of my own WordPress sites. Thankfully there are a few ways to reset passwords in WordPress. The most surefire way I found was to reset the password using MySQL. (Using the wp-cli tools looks interesting, but I didn’t feel like setting up get another PHP tool.) Most of the time you don’t need to do this. However if you’ve managed to forget your only admin password… well this will get you out of that problem. So what does resetting a WordPress password via MySQL, you ask?
- Log into your server via SSH (or to MySQL via a SSH tunnel if you have that enabled)
- Login into MySQL:
mysql -u $MY_DB_USER -p
- Get the username if you have not already. You can look those up in the
- Finally reset the password, using the MD5() function and an update SQL statement:
UPDATE "wp_users" SET "user_pass" = MD5('new_password') WHERE "wp_users"."user_login"= "username";
- Log in with the user using the regular WordPress login (e.g. https://my-wordpress.example.com/wp-login.php). Remember to change the password, as that will use a stronger hash than MD5 internally and is more secure.
And there you go!
One of the few Java webapps I work on at work, has a very long startup time. Unfortunately since the server startup code is proprietary and owned by the vendor, there is not much I can do about that. However it is easy to forget to check if the server has started up, I decided to that I needed a way for my computer to notify me that the webapp was up. Here is how I came up with a simple and quick way to do just that in KDE.
So my webapp has an health endpoint that can be easily queried via HTTP. With httpie the HTTP query was very easy, however to script httpie to keep querying until the result came back, meaning the server was up. At first I tried do a
while with negation of the return code, and then I found on StackOverflow that the bash
until command will do just that. (Without needing to figure out the appropriate negation).
The second part was figuring how to create notifications in KDE via the console. Turns out that
kdialog will create both notifications and general popup alerts.
Putting the two together I came up:
until http :8080/my_health_endpoint; do echo 'Waiting...'; sleep 10; done; kdialog --passivepopup "Ready to go!" 10`
I added a sleep in there, to throttle the number of times that httpie would run. The second parameter on the kdialog dictates how long the notification popup will be around. Alternatively I could of used
--msgbox if I wanted a dialog that I had to press ‘OK’ on.
Earlier this year (yes I meant to send this out much earlier) I went to a meetup hosted by my local PyLadies group. There Tracy Osborn of Wedding Lovely and Hello Web App fame gave an amazing talk about marketing for developers. I was truly inspired by the talk, and I feel it was very relevant for me, especially as I try to launch my first product and startup Amber Penguin Software. I could write a series of blog posts just on the content from this one meetup alone, and I probably will over time. But today I’ll focus on one thing in particular that I’ve learned from Tracy.
Getting to Inbox Zero
Nowadays I try to not organize my day to day tasks, by either my inbox or even one of my many, many Trello boards. Rather I try to bite off a few urgent and important tasks each day. Still I end up spending time on tasks initiated from emails in my email inbox. Unfortunately my inboxes seems to fill up faster than I can manage them at times. I would love to have a clean inbox as in Inbox Zero technique but more importantly I want to be much more responsive to the emails I get. Also opening up my email can be overwhelming when I see the number of emails in my inbox.
Using Multiple Inboxes in Gmail
One of the things I learned after the meetup, while browsing Tracy’s site was a technique to get my inbox under control at least in Gmail. In essence, you need to enable the “Multiple Inboxes” lab experiment in the Gmail Labs settings. Then you need to write a few filters such as
is:drafts || label:follow-up (which happens to be my filter for follow-up emails) for each particular inbox. Et voilà! You have a much more manageable inbox that is subdivided into categories, and the actions you need to take.
Where it works and where it doesn’t work
Unfortunate this technique only works in Gmail at the moment. Some other webmail providers maybe have a similar multiple inbox solution, but unfortunately ProtonMail does not but it is a suggested feature. So my ProtonMail will probably lag behind in terms of how quickly I respond, unless I or someone else implements the multiple inbox feature in ProtonMail.
However where I can use multiple inboxes like in my Amber Penguin Software email (managed by Gmail) it has drastically improved my email experience and my own responsiveness. My Gmail still needs some love to get everything under control, but once I do I will be much better at replying to emails. Ultimately this technique helps you become more confident in categorizing your email, and then acting up on it when the time comes.
This week has been a rough one for me, so I’ll keep this blog entry short.
However I am pleased to announce that after a bit of struggle, I have setup HTTPS on all my sites, including this one. Thanks to Let’s Encrypt and specifically the acme-nginx project to making that possible. Getting everything setup, and automated using Ansible took a bit of work, but in the end it was worth it.
In the future I am looking forward to using the new more secure TLS 1.3 standard once it is supported more widely by NGINX and various browsers.
This week’s entry will be a short one, since I am in the middle of getting things organized, and preparing for launching my first ever product. (More about that on a later post.)
One of the things that bite my recently, is that I was unable to login into one of my WordPress sites. For the life of me I could not figure out why. At first I thought that I had forgot my password. Then I noticed that I couldn’t even reset it via email.
Well it turns out that I had changed the domain name for that site, and apparently WordPress is very temperamental when moving between domains. So any action that I took that involved a redirect caused breakage. Thankfully a small temporary edit in a wp-config file fixed that. Basically after I added this to my wp-config.php file:
I was able to login into my site. I updated the site URL in the
Settings > General section, which fixed the underlying issue. I removed the above line since it is a security liability, after the fix was in place.
What can I say… sigh… WordPress. That is why I’m developing Rookeries, to avoid WordPress’ finky nature. Rookeries is still in early development mode, but hopefully sometime in Q1 of this year, it’ll be ready for general developer preview.