As a programmer1 I frequently need to convert numbers to or from their hexadecimal representations. Today I added the following functions to my zshrc:
These aliases allow me to do conversions like
$ to_hex 42
$ from_hex 09f91102
right from the command line. The code above works with GNU bash and with zsh.
(These functions inject unsanitized text into Python expressions, so they’re not very robust. Caveat emptor. I’m sure this is possible with shell built-ins too, but after a decade of not quite consciously realizing that I didn’t have a quick way to do these conversions, it felt good to fix the problem with a pair of one-liners that I could just type off the top of my head.)
Honestly, I mostly encounter hexadecimal in CSS colors. I don’t do any numerical programming. ↩︎
1.3 billion years ago, two black holes were locked together in a death spiral. Rotating around each other at two thirds the speed of light, separated only by the distance between London and Paris, they quickly and violently merged into a single black hole. Its mass was less than the combined mass of the original ones; the leftover energy was blasted out in all directions in the form of a gravitational wave.
Meanwhile, on Earth, the Rodinia supercontinent was home to nothing more than single-celled organisms. Life slowly grew in complexity; the continents separated; the dinosaurs arose; the continents recombined; the dinosaurs died out. When the gravitational waves had traveled 99.985% of the way to Earth humans appeared. Over hundreds of millenia we developed language, agriculture, philosophy, mathematics, and science.
Mystical explanations for the natural world slowly gave ground to empiricism. Newton developed a theory of gravity and Einstein later refined it, predicting that some moving objects would radiate waves of gravitational energy. Almost a century later, the LIGO experiment began to look for these waves. After seeing nothing for five years the detectors were taken offline and upgraded; they saw nothing again and were taken offline and upgraded again.
They were brought back online last February and in September they detected the gravitational waves from the merging black holes. The waves had been traveling for 1,300,000,000 years — since before humans existed — and they passed through our detector seven months after we turned it on.
Thanks to a free certificate from Let’s Encrypt, this site is now accessible over SSL.1 Instead of using the official Let’s Encrypt client to obtain the certificate I used letsencrypt-nosudo. This client has a number of advantages: it doesn’t need to run as root, it doesn’t take over port 80 on your server, it doesn’t run continuously in the background, and it doesn’t touch your server configuration. The only thing I missed from the official client was setting up OCSP stapling, which the official client will do but letsencrypt-nosudo won’t. Through some trial and error I figured out which certificates need to go where in order to get stapling working from nginx.
These commands assume that you’re working in the directory that contains your nginx configuration (usually /etc/nginx) and that there’s already a directory there called “ssl”.
Figure out which of the Let’s Encrypt certificates was used to sign your certificate.
replacing “ssl/signed.crt” with the path to the certificate you just obtained. (The openssl command prints a bunch of somewhat-human-readable information about the certificate; the grep command extracts the line we care about.) The output will be something like
That last bit (“Let's Encrypt Authority X3”) is the name of the Let’s Encrypt certificate that was used to sign your new certificate.
Download that certificate in PEM format.
You need to download the PEM version of this certificate. You can find all of the Let’s Encrypt intermediate certificates on the Let’s Encrypt site; click on the “PEM” link for the appropriate certificate to get the file you need. Or, from the command line,
Make sure you verify your setup using sudo nginx -t. If the test is successful, restart nginx (e.g. using sudo nginx -s reload) and you should be up and running with OCSP stapling! You can test your server using the instructions in this guide from DigitalOcean.
It’s actually no longer available over unencrypted HTTP. I share Brent Simmons’s ambivalence (see the “http deprecation” section) about the shift toward HTTPS, but I also can’t deny that the shift is happening more and more quickly (due in no small part to Let’s Encrypt). ↩︎