The EC2 user data script can be used to populate the ~/.ssh/authorized_keys file, making it easier to login to the instances via SSH. This is useful if you want to include more than one public key in the file.
The authorized_keys file looks something like this:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMeONV6VCMZJFj8wijLtfkSXHk6hXhw6fQ/1f5l7xD4i email@example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMeONVsdfgjklhdgfkljgHJKhghhXhw6fQ/1f5l7xD4i firstname.lastname@example.org It can be useful to store the contents of this file in an AWS secret so that it can be shared by multiple instances.
The new async/await functionality in Python (available since 3.5) gives a more linear style to asynchronous applications, but requires the programmer to have an understanding of blocking/non-blocking actions. A single call to a blocking function in an otherwise asynchronously application can cause widespread problems. For example, in the case of a web server using AIOHTTP a call to a blocking function prevents any other requests being served.
Sometimes calling slow, blocking functions is unavoidable.
Smaller docker images are quicker to transfer and deploy. What’s more, by only including what is absolutely required you can avoid security vulnerabilities in packages that aren’t even needed.
There are many examples online for applications written in Go, which deploys as a single statically-linked binary. It’s not so obvious how to translate these examples to an application written in Python.
Images based on alpine Linux are the smallest, but are not compatible with manylinux1 wheels due to the use of musl libc instead of glibc.
Shapely provides two ways of testing the equivalence of geometries:
Using the == operator, e.g. a == b Using the .equals method, e.g. a.equals(b) The result of the two methods are not identical, although it may appear that way at first.
For example, take two points:
>>> A = Point([1, 2]) >>> B = Point([1, 2]) >>> A == B True >>> A.equals(B) True So far so good, but what about a more complex example?
CfnCluster is a tool for deploying and managing high performance clusters on AWS. It uses AWS CloudFormation to allow you to quickly configure and deploy a cluster using EC2 instances. The cluster automatically scales the number of workers based on the number of jobs in the task queue, starting new instances as required (to a preconfigured maximum) and shutting down idle nodes. The entire cluster can be shutdown and restarted easily which is great for heavy but intermittent workloads.
The default 9600 baud rate is a little too fast for the 8MHz clock speed of the Pro Mini 3v3 when using a software serial connection. This can result in invalid data being received from the GPS.
NMEA messages include a basic checksum to ensure the message was received correctly. In the example below the checksum for the message is 47 in hexidecimal, preceeded by a * (the last 3 characters).
Back in 2012 XKCD #1043 presented data from Google Trends, predicting that searches for “tumblr” would overtake “blog” on 12th October 2012:
Fast-forward to present (2017) and we can see the prediction was a good, with “tumblr” overtaking “blog” sometime between October and November:
The data is available in CSV format and can be displayed easily using Pandas and Matplotlib. The XKCD extension for Matplotlib even gives it that XKCD-feel.
This post is Part 2 of a series. See Part 1: Sorted Open Data with Shapely and SVG.
D3 has quite a steep learning curve and every time I use it I feel like I’m fumbling around in the dark.
I recently came across the Sorted Cities project by Hans Hack. He uses building footprint data extracted from OpenStreetMap to create beautiful posters, showing all of the buildings in a city sorted by their area.
As soon as I saw this, the hacker in me thought “how would I go about creating this myself?”
Shapely has a fantastic feature that converts geometries into an SVG representation, which is used to display the geometry in Jupyter.
Despite being somewhat late to the party 🎉, this week I’ve been having fun with emoji 😂. Emoji are just unicode characters, which means as well as being easy to send in text messages they can also turn up in places you might not expect.
For example, emoji are correctly displayed in the macOS Terminal app. They’re also valid in filenames provided that the file system supports unicode (which all modern filesystems do).