Create a static mirror of your DEV blog

I started using DEV at the suggestion of Perl Weekly, and I was quite pleased with it - until I discovered that links to dev.to are effectively "shadowbanned" on several major platforms (Reddit, Hacker News, etc.). Posts containing DEV URLs would simply not be shown to users, making it impossible to share content effectively.

To work around this, I thought I would need a way to publish my DEV articles on my own domain so I could freely share them. There are some DEV tutorials out there that explain how to consume the API using frontend frameworks like React, however I don't enjoy frontend at all and I did not want to spend much time on that.

My solution was to get a simple Perl script that builds static versions of the articles, along with an index page. A Perl 5 script will run anywhere, including an old shared linux hosting account I still keep on IONOS, and I really like the speed of static sites.

I thought this is an ideal task to start with ChatGPT. Indeed, after 10-15 mins in a few prompts I had a sort-of working solution without having to open up the API documentation, nor writing any CSS. I then spent an hour or two fixing bugs, refactoring some of the ancient-looking code and tweaking / adding features (e.g. tag index pages) - tasks that I enjoy.

Here is the result. You can find the Perl script and assets in this repo.

It will run on pretty much any Perl 5 version (tested down to 5.10) with some basic CPAN modules (LWP::UserAgent, JSON, Path::Tiny).

To use it, check the project out from the repo and specify at least your DEV user name when calling the script:


./dev_to_static.pl -u [username]

# or to also specify a target directory and name your blog:
./dev_to_static.pl -u [username] -t [directory] -title="Blog name"

Try option -h to get more help.

You can run it on your web host, or run locally and copy the resulting directory to your host.

A nightly cron can update the site with new articles.

Weather::OWM released on CPAN

I am in the process of adding OpenWeatherMap support to Xasteria Weather for iOS and the proxy I built is in Perl. Since there was only an old module on CPAN which did not support the current API and was not easily updatable, I released Weather::OWM. It's a very simple module, similar to two other Weather modules I've released in the past (Weather::WeatherKit

Cloud VM performance / price comparison 2024

I gave the talk Maximizing Performance and Cost Efficiency in the Cloud at the Perl and Raku conference this year. Among others, it used data from a benchmarking comparison I did among dozens of VMs on various cloud providers, and I had promised I'd post the full report.

It took me quite a bit longer than expected due to both technical complications and some new releases I wanted to include that enlarged the scope, but here it is now.…

Benchmark::DKbench Perl benchmark suite now supports custom benchmarks.

Although Benchmark::DKbench is a good overall indicator for generic CPU performance for comparing different systems (especially when it comes to Perl software), the best b…

Setting up a free Oracle Database for Perl development

I recently added Oracle Database support to SQL::Inserter (check it out if you'd like simple to use, high-performance inserting to SQL databases). I had not used an Oracle Database since my uni days 20 years ago, so I had to set one up to test it.

Even though Oracle provides a free development DB, the process is not as simple as Postgres/MySQL etc., so I thought I'd document it for future reference.

There are basically two ways you can go, with Oracle providing instructions either for a VirtualBox VM, or Docker. For the purposes of this article, we'll use VirtualBox. If you prefer Docker, you can follow Oracle's instructions and skip the next section.

Setting up the Oracle VM

Oracle provides instructions for setting up a VM with their latest 23c Database.

To sum up, you download and install VirtualBox, as well as the 23c VM image (.ova).

Launch VirtualBox, go to File->Import Appliance and select the .ova file that you just downloaded. You can leave the defaults for the import.

Start the Oracle Linux based VM.

Setting up Perl DBI/DBD::Oracle

Open a terminal on the Oracle VM. You have sudo powers (password is oracle), but first we'll need to set up the ORACLE_SID and ORACLE_HOME environment variables. To determine what they should be do:

> cat /etc/oratab

You are looking for an uncommented line with three parts separated by colons, on this VM it is: FREE:/opt/oracle/product/23c/dbhomeFree:Y, with the first part being the SID, the second being the HOME. We can add these to our .bashrc:

 > echo 'export ORACLE_SID=FREE' >> ~/.bashrc
 > echo 'export ORACLE_HOME=/opt/oracle/product/23c/dbhomeFree' >> ~/.bashrc
 > echo 'export LD_LIBRARY_PATH=$ORACLE_HOME/lib' >> ~/.bashrc
 > source ~/.bashrc

We can now install the required libaio and cpanm - using the latter to install the CPAN packages:

> sudo yum install -y libaio-devel perl-App-cpanminus
> sudo -E bash -c 'cpanm -n DBI DBD::Oracle'

The -E parameter passes the env variables we set up above. We are all set to start development.

Note that this Oracle Linux VM comes with Perl 5.26, if you want a more recent version, you could use use Perlbrew.

Connecting to the DB using Perl/DBI

The html page that opens on the first launch of the Oracle VM gives you the db and user names already set up. Using those, you can connect to the DB through Perl/DBI with the DBD::Oracle driver:


#!/usr/bin/env perl
use strict;
use warnings;

use DBI;

# Connect to the pre-created PDB 'freepdb1'
my $dbname = "freepdb1";
my $user   = "hr";
my $pass   = "oracle";
my $dbh    = DBI->connect("dbi:Oracle:$dbname", $user, $pass);

# Or connect to the CDB 'free'
my $user = "system";
my $pass = "oracle";
my $sid  = "free";
my $dbh  = DBI->connect("dbi:Oracle:host=localhost;sid=$sid", $user, $pass);