Mandelbrot

Perhaps the best known fractal of all: the Mandelbrot set.

Since I was already working on Python code that would render an image given a function (for a future post), I figured that I might as well render fractals with it.

read more...


Backing up GitHub repositories

The newest chapter in my quest to collect entirely too much data / back up All The Things!: GitHub.

Basically, I want to back up all of my own personal GitHub repositories along with any from organizations that I am involved with. Strictly speaking, this is a little strange, since it’s unlikely that GitHub is going anywhere soon and, if it does, we are likely to have fair warning. But still, it’s nice to have a local copy just in case GitHub is down.

read more...


Configuring Websockets behind an AWS ELB

Recently at work, we were trying to get an application that uses websockets working on an AWS instance behind an ELB (load balancer) and nginx on the instance.

If you’re either not using a secure connection or handling the cryptography on the instance (either in nginx or Flask), it works right out of the box. But if you want the ELB to handle TLS termination it doesn’t work nearly as well… Luckily, after a bit of fiddling, I got it working.

Update 2018-05-31: A much easier solution, [https://aws.amazon.com/blogs/aws/new-aws-application-load-balancer/](just use an ALB):

WebSocket allows you to set up long-standing TCP connections between your client and your server. This is a more efficient alternative to the old-school method which involved HTTP connections that were held open with a “heartbeat” for very long periods of time. WebSocket is great for mobile devices and can be used to deliver stock quotes, sports scores, and other dynamic data while minimizing power consumption. ALB provides native support for WebSocket via the ws:// and wss:// protocols.

read more...


Automagically storing Python objects in Redis

When you’re starting out on a simple web application, eventually1 you will reach the point where you need to store some form of persistant data. Basically, you have three options2:

  • Store the information in flat files on the file system
  • Store the information in a database (MySQL, SQLite etc)
  • Store the information in a key/value store (mongoDB, reddis)

There are all manner of pros and cons to each, in particular how easy they are to get started in, how well they fit the data you are using, and how well they will scale horizontally (adding more machines rather than bigger ones).

read more...


Backing up Moves Data

Another backup post, this time I’m going to back up my data from the Moves App (step counter + GPS tracker). Theoretically, it should be possible to get this same data from the app as part of my iOS Backup series, but the data there is in a strange binary format. Much easier to use their API.

read more...


Scraping Kindle Highlights

Edit March 2020: It seems the page ‘your highlights’ page on Amazon no longer exists, so this script no longer works. I’ll probably see if I can pull them from Goodreads instead now that the integration is there or directly from my Kindle, but for the moment, this script does not work.

As part of an ongoing effort to backup all the things, combined with a rather agressive 2015 Reading List, I wanted to the ability to back up any sections that I’ve highlighted on my Kindle. Unfortunately, Amazon doesn’t seem to have an API to do that, but why should that stop me?

Using a combination of Python and the Python libraries Requests and BeautifulSoup1, it’s entirely possible to write a Python script that will log into Amazon, get a list of all of the books on your account, and download the highlights for each.

Let’s do it!

read more...


Generating YouTube user RSS feeds

On 4 March 2014, YouTube deprecated the v2.0 API for YouTube (source). One of the unfortunate side effects was that RSS feeds for user uploads were included in what was deprecated.

Previously, you could get an RSS feed with a link of the form: https://gdata.youtube.com/feeds/base/users/{user}/uploads For the longest time, even after the deprecation, those links still worked, but a couple weeks ago, more and more of the video feeds I was subscribed to started redirecting to YouTube Help account. As thrilling as that channel is, it’s not what I’m looking for.

Let’s fix it.

read more...