Setup a Static Site on AWS with S3 and Cloudfront

This is pretty well-trodden territory, but I have recently setup several static sites on AWS, using S3 + Cloudfront, and I thought it would be nice to document the process. The setup isn't hard, but there are lots of steps, and you have to do most them in the right order …

Continue reading »

Using OpenSSL 1.1 with pip

If you are using PostgreSQL or MySQL on a Mac, you might have run into this error when installing libraries via pip.

ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1 …

Continue reading »

pyenv is rad

This isn't news to anybody, but using pyenv to manage virtual environments for Python is great. The python packaging and module system is really annoying, but pyenv makes it tolerable enough that I felt like writing it down.

Setup is pretty simple. You basically need to:

  1. Install pyenv itself
  2. Install …

Continue reading »

Installing Pelican

Today I migrated this blog to use Pelican, a python-based static site generator.

On the whole, the setup was pretty easy, but I hit a few snags setting up the theme.

This is how I installed on a Mac

First, get a clean python environment

brew install pyenv pyenv-virtualenv
pyenv …

Continue reading »

Aspect-oriented Programming in PHP

A very frustrating thing in the legacy system at work is that error logging is badly busted. Because the system is fragile and can't suffer significant downtime, I am disinclined to apply any dramatic fixes. However, I found a pretty cool PHP module that offers a partial solution:

https://github …

Continue reading »

max_input_vars Is Maybe The Most Annoying Bug I Have Tracked Down

Ran into a very interesting bug recently.

In an Order Management System, it was becoming increasingly apparent that certain orders failed to be completely processed, leaving them in a "this should never happen" incomplete state. For awhile there seemed to be no rhyme or reason to it - just absolutely no …

Continue reading »

Gotta Be Careful with parseFloat

Ran into this one today. Somebody forgot to remove the comma from a float:

parseFloat(1000);    // 1000, ok
parseFloat("1000");  // 1000, ok
parseFloat("1,000"); // 1, very bad!!!

The code in question was trying to parse a dollar amount from a popup form field.

It trimmed the "$" (which would cause …

Continue reading »

Using a Different Wordpress Theme on a Subdomain

A situation I've encountered twice now is the need to serve a site's content from a subdomain using a different Wordpress Theme. In the first case, the subdomain was a mobile site and the alternate theme was optimized for mobile with a simplified layout and fewer images. In the second …

Continue reading »

Override rel=canonical in Wordpress

A recent project required cross-posting content between two sites. To avoid duplicate content issues, we're using rel="canonical" to indicate which post is the original and which is the duplicate. While not 100% ideal, evidently cross-domain rel canonical is an okay thing to do.

Oddly, right now, Wordpress does not …

Continue reading »

Custom Sort Orders in Wordpress

Found a neat little piece of MySQL syntax today that I didn't know about. The FIELD() function can be used to define custom sorting in the database, like this:

  WHERE ID IN (1,2,3,4,5)
  ORDER BY FIELD(ID,3,4,5,1,2)

Whether …

Continue reading »