Exporting from CSV format into Markdown - the long way.

{… or how to export from the texpattern cms the hard way}

Kraxn.io recently migrated from textpattern to a static site generator. *

This was a journey, that didn’t happen overnight. In fact, as I couldn’t find any out of the box solutions, it took a couple of weeks before I took a stab at it again. I had over 350 posts, so I could do it manually, or figure out a more automated way to do it. Here are the steps I took to do this:

  • Export a csv from mysql (you can use mysql command line, but used phpMyAdmin export function since I had it installed).
  • Convert each row in of csv into an markdown (.md) file. Each row represents a blog entry.
Read more →
Fri, 03 April, 2020

Swift, Nginx, Perfect, & PerfectMustache

This is a quick start guide on getting started with Swift and the Perfect framework. In a previous guide, we showed how to run Swift Perfect and Nginx together: Perfect handles the dynamic code, and Nginx handles the static files.

Today we are going to use the templating system within Perfect, called PerfectMustache. This is a more involved guide that has a lot of moving parts. If unfamiliar with templating systems, watch [Ray Wenderlich’s excellent introduction to PerfectMustache][1]). Its a great back up if you are ever stuck on anything here! Also check out [Perfect’s perfect blog template][2]).

One thing to note – I mostly just show the code, which very little explanation. I encourage you to fill in the gaps. This is mostly to try to keep things moving along. Check out Swift’s documentation on sections you don’t understand.

Read more →
Sat, 07 March, 2020

ssh prompts for passwords despite authorised keys

Really short post, on a something that cost me more than 2 hours. I had a hard drive fail, so I had reset servers ssh key to my machine. No matter what, I kept getting prompted for my password.

solution was going through this here: https://unix.stackexchange.com/questions/26371/ssh-prompts-for-password-despite-ssh-authorized-keys

Check ~/ssh folder permissions in client and server machine.
Check /etc/ssh/sshd_config in the server to ensure that RSAAuthentication, 
PubkeyAuthentication and UsePAM options aren't disabled, 
as they are enabled by default with yes. 

I had PubkeyAuthentication turned off, simple as that.

Thu, 05 March, 2020

FastCGI Perl, NGNIX, insserv and “This account is currently not available.”

I have local perl script that runs on FastCGI. Recently my Ubuntu machine died and I have been systematically reinstalling the old scripts. This script came from the following tuturial: https://nginxlibrary.com/perl-fastcgi/

Unfortunately, I got stuck when it got to this part:

insserv perl-fcgi

There do not seem to be any more packages for insserv:

sudo apt-get install insserv
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package insserv

by jumping heading and trying to start init.d without it, it got this error:

sudo /etc/init.d/perl-fcgi start
This account is currently not available.

Looking around I found the solution was modifiying the etc/passwd file. While I am not sure if this kosher for live production website, it worked for me:

Unfortunately when I got to the "/etc/init.d/perl-fcgi start" step, I ran into 
the same problem, i.e. "This account is currently not available.". I temporarily 
worked around it by changing the www-data's shell in /etc/passwd from 
"/usr/sbin/nologin" to "/usr/bash", and although that allowed me to serve 
Perl webpages..

In my case I commented out the www-data user like so and everything worked.

# added this as to get local fcgi to work with nginx

FastCGI Perl, NGNIX, insserv and "This account is currently not available."

Thu, 05 March, 2020

Quick guide to Nginx and Swift Perfect server on your local linux machine.

The goal is a to use the Swift Perfect server to use the default “hello world” template, but let Nginx serve static files

I am currently testing out the Swift Perfect Server (eg from [Perfect.org][1]) and Nginx. The idea here is to let Swift Perfect to serve dynamic stuff, and Nginx to serve static stuff (like images, css etc).

This quick & dirty guide assumes the following:

  • You’ve got [Nginx][2] installed and running.
  • You’ve got [Swift][3] installed and working.
  • You’ve got [Perfect Server][4] installed and running
Read more →
Mon, 02 March, 2020

Modern Perl - Getting Starman, Nginx, and Plack on your website with Ubuntu Server.

The goal of this guide is to get Perl working on live domain running with Plack.

This is a very basic set up on how to get Plack, Nginx, and Starman aligned if you want to set up a more modern web application in Perl. This means moving away from ye olde CGI.pm and mod_perl. If you see a better way of doing this, then don’t be silent, comment below!

Like many, I was a php developer for years, so getting LAMP stack going was easy. It also not too hard to use CGI and mod_perl, and if this works for you, then please use them. The Perl community can get a bit ornery about their use, and I think they are fine too. However, there is a modern way of doing things that most recommend which is PSGI.

PSGI is a protocol that many PERL frameworks use (Dancer, Mojolicious, Catalyst); however, I wanted to figure how to get it running without framework, because by doing things the hard way, I tend to learn things a lot deeper!

It sounds complicated, and it took weeks for me to set in and figure out. I also nearly crashed my server with trying to set things up. For reference, if my guide doesn’t help see if you can follow these tutorials - they got me on the path to success:

  • Why use Plack? If you need a deep read, check out the inventors slide deck: [http://slideshare.net/miyagawa/plack-at-oscon-2010][1]
  • This gives you a easy start into learning how to use Plack, our example here is just using hello world example. https://advent.plackperl.org/ (note if you like it, just donate $5 to get the epub)
  • You can follow this pretty closely and get your first web app working with Plack instead of Dancer: [https://stackoverflow.com/questions/12127566/an-explanation-of-the-nginx-starman-dancer-web-stack][2]
  • Here is the original tutorial I found for Dancer. They used perlbrew, which my system didn’t like. [https://perlmaven.com/getting-started-with-perl-dancer-on-digital-ocean][3]

In truth - after I saw how everything worked - it was a bit of an ‘Ah ha’ moment. Its not particularly complicated, just a new way of thinking.

Part One - Don’t use System Perl

The cool thing about Perl - its likely on your system already. This is how I got back into Perl, because it was already there. However, using your system Perl is probably not a good idea when you are doing active development. Before we install all the Plack goodies, it a good idea to get separate installation of Perl just for our web projects.

There are two Perl install managers that you can have a look at, PerlBrew and Plenv. The Dancer tutorial above used PerlBrew, but my installation was not happy with it, and suffered from constant failed installations, even when force flag was used. So I used Plenv - which worked like a charm. You can try PerlBrew if Plenv doesn’t work.

Note - before you get started, you probably want to set this up as a brand new user, and not root (for security reasons). I’ll leave this up to you, [here is how to create a new user][4]. Once you’ve done that here are steps to install plenv:

The detailed Plenv instructions are on [GitHub][5], here is shorter version for Ubuntu:

Setup plenv into your home directory ~/.plenv (eg /home/.plenv)

  1. Clone from Github

    $ git clone https://github.com/tokuhirom/plenv.git ~/.plenv
  2. Add ~/.plenv/bin to your $PATH for access to the plenv command-line utility.

       $ echo 'export PATH="$HOME/.plenv/bin:$PATH"' >> ~/.profile
  3. Add plenv to your shell to enable shims and autocompletion

    $ echo 'eval "$(plenv init -)"' >> ~/.profile
  4. Restart your shell as a login shell so the path changes take effect

    $ exec $SHELL -l
  1. Install perl-build, which provides an plenv install command that simplifies the process of installing new Perl versions.

    $ git clone https://github.com/tokuhirom/Perl-Build.git ~/.plenv/plugins/perl-build/
  2. Almost there - your plenv command should be working now so have look at all the fine versions of Perl it has to offer

    $ plenv install --list

A couple of quick tips on deciding. If you choose an odd numbered release its considered unstable You find an install fails, just try another. My system was finicky, but I eventually got there. The install is the longest process.

To install Perl choose a version number form the list and run. Below is the version i used:

$ plenv install 5.30.1

This is potentially a good time to take the dog for a walk! Finally when its done, or whenever you install a cpan module, you have to run this command:

$ plenv rehash

Of you can install this module and it will take care of it for you.

$ plenv install-cpanm

Now check out what versions of Perl you have installed by running “plenv versions” like this:

*system (set by /home/username/.perl-version)

You’ll see the the asterisk by the default system, so you can change this: Set your default developer Perl by

$ plenv local 5.30.1

by doing so you should see that it now goes to your new Perl, note asterisk

system (set by /home/username/.perl-version)

You are now ready to install Plack! Quick note - I sometimes noticed that my ‘plenv’ command is not recognised. I run step 5 ($ exec $SHELL -l) and it returns. This was the long part of the set up.

Part 2: Install Plack!

This is pretty easy:

$ cpanm Plack

This took a while to install as well. In addition, it runs a series of test, which some my fail and your install will fail. If that happens try doing a force install (it will explain it should it fail).

Part 3: Install Nginx

I actually made the decision to uninstall my Apache server. I have fond memories of Apache, but wanted a fresh break. If you want to remove [Apache follow this][6]:

$ sudo apt-get remove --auto-remove apache2

if you want to get rid of everything (including local config files)

$ sudo apt-get purge apache2

For installing Nginx here’s a great [blow by blow guide][7] which I’ve whittled down. Refer to the tutorial above for fine tuning.

    sudo apt install nginx #install nginx
    sudo ufw allow 'Nginx FULL' 

We’ll do some more configuration later on.

Part 4: Write your first Plack App

This will be super simple, write of of the Plack Advent Calendar. A simple Hello world. Go to any directory on your server where you will keep your code. Note - you don’t have to keep this in the web document root, in fact, its better if you didn’t (think about the way good old CGI works).

Create this code and save it as hello.psgi (for reference I saved it in /home/perlapps/hello.psgi)

my $app = sub {
    return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello, is it me you're looking for?' ] ];

now see it in action:

    ? plackup hello.psgi
    HTTP::Server::PSGI: Accepting connections at http://0:5000/

If you are on your local server go to, if your remote server go to :5000 and you should see your message:

**‘Hello, is it me you’re looking for?’**

That’s your first Perl plack script app. But as you can see its not tied to your domain. That’s what where are going to get to!

Part 6: Starman & Nginx

This is the final part. We want Starman to serve our dynamic psgi script and Nginx to serve any static content (think css and images).

Lets do Starman first:

sudo plackup -s Starman -p 5001 -E deployment --workers=10 -a /home/perlapps/hello.psgi

Notice the path to the psgi file we just created above. Next we will configure our website.conf file for nginx. Note if you need to know how to set up set sites in nginx, follow this [tutorial on digital ocean][8]. Here is a mock configuration which sets everthing up:

server {
listen 80;
listen [::]:80;

  root /var/www/gurdyhurdyman.org/html;<br />
  index index.html index.htm index.nginx-debian.html;

  server_name gurdyhurdyman.org www.gurdyhurdyman.org;

  location /css/ {
    alias /var/www/gurdyhurdyman.org/html/files/css/;
    expires 30d;
    access_log off;<br />

  location / {
   proxy_pass        http://localhost:5001;
   proxy_set_header  X-Real-IP  $remote_addr;
   try_files $uri $uri/ =404;<br />


The “location /” bits are the magic parts: nginx will serve all the css files through port 80, while starman gets served via proxy at port 5001.

If you visit your domain (note that gurdyhurdyman.org does not exist), you should see your .psgi file shining through some lyrics from Lionel Richie :)

Sun, 02 February, 2020

Installing a ‘stubborn’ Perl Mod that is not recognised in @inc: HTTP::BrowserDetect

I have an old ‘beater’ laptop which I use to try Perl scripts among other things. I had just installed a very cool mod called HTTP::BrowserDetect. After installing it, I ran this to check and see if was installed:

perldoc -l HTTP::BrowserDetect 

Looks good, BrowserDetect.pm is installed. However when I ran the script, it was an internal server error. So I used tail

tail /var/log/apache2/error.log [pid 25664] Can&#39;t locate HTTP/BrowserDetect.pm in @INC 
(you may need to install the HTTP::BrowserDetect module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 
/usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 
/usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 
/usr/share/perl/5.26 /usr/local/lib/site_perl /etc/apache2) at 
/var/www/testwebsite/public_html/BrowserDetect.pl line 9.
\nBEGIN failed--compilation aborted at /var/www/testwebsite/public_html/BrowserDetect.pl line 9.\n

Notice that it didn’t find “/home/myusername/perl5/lib/perl5/HTTP/BrowserDetect.pm” from my previous command. During the install, it probably recognised wisely that the Perl is used by my OS, and installed BrowserDetect in my home directory instead. How to fix?

In my perl script, I placed this line to the folder, at the top with my other ‘use’ lines. This worked! I am sure there are better ways, but this seemed simple and functional:

use lib qw(/home/myusername/perl5/lib/perl5/);
Tue, 21 January, 2020

Installing mod_perl on Apache 24 Ubuntu 18.04

This is quite old school, but if you want to try mod_perl on Apache2.4 on Ubuntu, here’s how I did it:

First get the modules for Ubuntu server. If you were like me and trying to read the [installation process on the mod_perl website][1] , you probably were scratching your head. Luckily its trivial to install with just a couple of commands:

sudo apt-get update -y
sudo apt-get install -y libapache2-mod-perl2

Once that is done, just set up the virtual hosts, here is an example, just replace <yoursite.com> with your domain as well as any other directives. For the below, you can easily search and find the meanings of the directives:

<VirtualHost *:80>
         ServerAdmin webmaster@<yoursite.com>
         DocumentRoot /var/www/<yoursite.com>/public_html
        Servername <yoursite.com>
        Serveralias www.<yoursite.com>
       <Directory /var/www/<yoursite.com/public_html>
               AddHandler perl-script .pl .cgi
                PerlResponseHandler ModPerl::Registry
                Options +ExecCGI +FollowSymLinks +MultiViews
                 PerlOptions +ParseHeaders
                 AllowOverride All
               Order allow,deny
                Allow from all 
        ErrorLog ${APACHE_LOG_DIR}/error.log
         CustomLog ${APACHE_LOG_DIR}/access.log combined

As for why, I happen to like Perl. I know there is doom and gloom about the future of this language. I first heard of Perl’s demise in 2002, when I wanted to try to learn a scripting language outside of ASP. My Java programming mates thought it was horrible decision: Perl was considered old even then! However, not long after I started digging into Perl when I learned about PHP, and that became what I used for years. So I revisited Perl again, and wow, there is a very, very deep community. A google site:cpan.org yields over 400,000 pages, though I suspect more. Even that archaic [mod_perl][2] was updated just a few months ago.

The Java guys? Not sure what happened to them. But its certainly fun to horse around with “Perl again before it disappears completely :)


Mon, 20 January, 2020

Sketch of the Day Theme: Lock - the 365th sketch of day; 1 year of sketches.

This is a brotherly orangutan headlock. So this is my final sketch of the day – at least for a little while. Its hard to believe that I have been doing this for a whole year ! I am not sure how my artistic skills have improved, but the challenge was trying to find something creative for each prompt. Looking back, I did some really poor, inane sketches. I also felt the last 2 weeks, the final stretch, was the hardest part. But I’ve also done some sketches that I’ve really loved, particularly those done in Charcoal – which has been been my favourite medium. I’ve learned that the mediums I enjoyed most, in order, where: charcoal, pen, digital, pencil, and coloured pencil. Perhaps the next step for me is painting, but I still think I have a long way to go for getting more realistic drawings.

The most wonderful part was creative process; some things that helped me with the creative process:

  • us juxtaposition: the act or an instance of placing two or more things side by side often to compare or contrast or to create an interesting effect.
  • If you doing this for a popularity contest, it will stifle you. I see this a sometimes in younger folks who really want likes on Sketch a day app. If you are in for approval, you probably aren’t expressing your true creativity.
  • Its ok to have a some terrible attempts. I’ve had plenty. Just move on, no big deal.
  • Downplay your ego. My very worst attempts were usually centred around myself, rather than the art itself. Perhaps I was trying to do something really clever to impress somebody, or prove a point. The results were often contrived.
  • If you find exactly what you want to draw on your first google image search, its probably not creative enough!
  • Crude mock ups help: I would images and put them together in photoshop (In my case PhotoShop 5.5 running on Linux Mint with Wine!) .
  • One your prompt – what are all the alternative meanings of the word? Are the homonyms? Is there similarly spelled or sounding word in another language? Dictionaries, thesaurus, and translations can all open up new world of possibilities.
  • Don’t be afraid to express your humour.
  • Don’t be afraid to express your sadness.
  • Don’t be afraid to be fucking weird. It’s really ok. It’s 2019, not 1919.
  • Learn from everyone. Its not just the amazing artists. There absolute gems in the rough on sketch a day, so they are not Picassos or Rembrandts, but they made incredible expressions of creativity. If you see something you like, a kind word goes a long way.

  • Kraxn

Sketch of the Day Theme: Lock - the 365th sketch of day; 1 year of sketches.

Fri, 27 December, 2019

Sketch of the Day Theme: Volcano

Chthamalus vulcanus, or volcano barnacle, emits hydrogen sulfide to kill its prey in the cold waters of the Arctic Ocean.

Sketch of the Day Theme: Volcano

Thu, 26 December, 2019

Sketch of the Day Theme: drive

This is from a video still of R.E.M.‘s “Drive”. A bit incomplete. Done in charcoal.

Sketch of the Day Theme: drive

Wed, 25 December, 2019

Sketch of the Day Theme: Happy

Santa is very happy to see you, but how is he holding that wreath up? Yes, I know, juvenile humour, but its the best I can do today!

Sketch of the Day Theme: Happy

Tue, 24 December, 2019

Sketch of the Day Theme: Wrap

Arms wrapped around the one you love (you can never have enough arms).

Sketch of the Day Theme: Wrap

Mon, 23 December, 2019

Sketch of the Day Theme: Strange

A Salvador Dali snail. It is kind of strange.

Sketch of the Day Theme: Strange

Sun, 22 December, 2019

Sketch of the Day Theme: Look

Seldom do look behind the scenes of how technology works. The Google reCaptcha asks us to confirm we are not robots. Do we get the chance to ask if Google is human? Data that reCaptcha collects, Clockwise from top : An entire screenshot of the page viewed, mouseclicks on the screen (shown here as heatmap), the language your browser is set in, your browsers plugins, all your google cookies, and javascript/css on the page you visit. All the information combined can give Google a unique profile of who you are. Finally, I had to actually do a sketch, instead of just screenshots: A little Googlebot vacuuming the data from the internet.

Sketch of the Day Theme: Look

Sat, 21 December, 2019
Next Page →