Skip to main content

Posts

Multiple domain SSL certificates on AWS lightsail...

This one caused some confusion today! I have an AWS lightsail server set up. It handles multiple different domains - essentially the same codebase, but does different things depending on the hostname (domain) being used to access it. I needed to add a new letsencrypt certificate to the system. This would be the second one I've added. After generating the certificate, I found that the new site (called it domain2) was trying to use the certificat of the first site (domain1) ... I thought I'd generated a certificate that supported both domains, but apparently not. After some poking around (lightsail has its own way of setting up the apache configuration files) I finally figured it out. To fix it, I needed to have two different virtual host (port 443) directives. They were essentially alike, except that that I had to add ServerName and ServerAlias settings appropriate for domain1 and domain2, and set the SSLCertificateFile and SSLCertificateKeyFile settings appropriately. Now I j...

Using a vim macro to fix 'mysql_' calls with regex

 I'm working on a largish project, converting it to work from early PHP 5 to PHP 7.3 and I found myself spending a lot of time converting all those various mysql_* to their equivalent procedural mysqli_* function calls. Mostly pretty tedious. Anytime you encounter something tedious that you'll have to do on a ton of files, it's a chance for automation. In this case, I decided come up with a vim macro that would automagically convert the most commonly occurring function calls. Here's the macro, which uses 4 regular expressions to search and replace the four most common ones - then followed by a search for "mysql_" to catch any outliers. :% s/mysql_query(\(.\{-}\),\(.\{-}\))/mysqli_query(\1 , \2)/eg :% s/mysql_fetch/mysqli_fetch/eg :% s/mysql_num/mysqli_num/eg :% s/mysql_close/mysqli_close/ge :/mysql_ The easiest way to use this is to paste into a new document, then select it all and yank it into a buffer. Then just run the buffer as macro. So, I used 'm...

Quickly create a gallery of images from a list in vim

This is something I run into pretty often, so I thought I'd share how I handle it, in case it's helpful. Sometimes you have a list of image files, and you need to create the html formatting to make them into a gallery of some sort. Imagine each file has two versions, a full size and a thumbnail image. Pretty common scenario. The URL for the files will look like /images/gallery/full/[filename] and /images/gallery/thumb/[filename] There's lots of ways to do this, here's what works well for me. First I grab a list of the files from the command line, ending up with something like this ls -l -rwxrwxrwx 1 user group 388044 May 25 11:16 IMG_20161205_120541.jpg -rwxrwxrwx 1 user group 451788 May 25 11:16 IMG_20161215_114201.jpg -rwxrwxrwx 1 user group 298125 May 25 11:16 IMG_20161216_121618.jpg -rwxrwxrwx 1 user group 369981 May 25 11:16 IMG_20161216_125940.jpg -rwxrwxrwx 1 user group 479464 May 25 11:16 IMG_20161216_131010.jpg -rwxrwxrwx 1 user group 664528 May 25 11:16 IMG_20...