Tag name:self.note

Bookmarks to links

24th October 2021

Over time I've collected a fair number of bookmarks and it's time to move some of them to links on this website of mine. Of course the home page is basically a collection of links, but those are, in general, links I regularly use. In this post I'm going to record the more interesting ones that aren't used regularly enough to make it to the home page.


Fan Fiction
Computing

Setting up a ubuntu for my development enviroment

13th May 2021

So I'm experimenting with a new development environment - this one is a ubuntu 20.04 running inside of Oracle VM Virtual Box. The initial installation was done following the cookbook from Abhishek Prakash.

Initial VM setup

  • Download and install VirtualBox
  • Download the ISO for Ubuntu
  • Start Virtual Box and create a new VM - I specified 4GB memory, 4 processor and approx 60GB Hard Disc
  • Start the VM using the ISO image and complete the Ubuntu installation

Development Environment Setup

  • Install fossil using sudo apt install fossil
  • Install ant using sudo apt install ant
  • Install npm using sudo apt install npm
  • Install php 7.4 using sudo apt install php7.4
  • Create directory for the website development mkdir website
  • Clone the website fossil and open it:
    • fossil clone http://david:password@virtual.internal:7780/website website.fossil
    • cd website
    • fossil open ../website.fossil
  • Install prereq npm packages:
    • sudo npm -g install jshint@2.11
    • sudo npm -g install qunit@2.10
    • sudo npm -g install ajv-cli@4.0
  • Test the build by
    • cd build
    • ant rebuild-all

WordPress setup

  • Install prereqs by sudo apt install apache2 mysql-server libapache2-mod-php php-mysql
  • Configure and enable apache2 by
    • sudo systemctl start apache2
    • sudo systemctl enable apache2
    • sudo ufw allow in "Apache Full"
  • Configure mysql and setup a database for wordpress by
    • sudo mysql_secure_installation
    • sudo mysql -u root -p and enter these commands:
      • CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
      • CREATE USER wordpress IDENTIFIED WITH mysql_native_password BY '12345';
      • GRANT ALL ON wordpress.* TO 'wordpress'@'%';
      • quit
  • Install php extensions used by wordpress using sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
  • Restart apache2 using sudo systemctl restart apache2
  • Install curl using sudo apt install curl
  • Download wordpress using curl -O https://wordpress.org/latest.tar.gz
  • Extract the archive and move under apache:
    • tar -xzvf latest.tar.gz
    • sudo mv wordpress /var/www/html
    • sudo chown -R www-data:www-data /var/www/html/wordpress
    • sudo chmod -R 775 /var/www/html/wordpress
  • Setup the wordpress config:
    • cd /var/www/html/wordpress
    • sudo mv wp-config-sample.php wp-config.php
    • Edit wp-config.php to setup the credentials for the database
  • Setup the apache2 config for wordpress:
    • sudo nano /etc/apache2/sites-available/wordpress.conf
    • Make the contents to these lines:
      <Directory /var/www/html>
              Options Indexes FollowSymLinks MultiViews
              AllowOverride All
              Require all granted
      </Directory>
      <VirtualHost *:80>
              ServerName wordpress
              ServerAdmin webmaster@localhost
              DocumentRoot /var/www/html/wordpress
              ErrorLog ${APACHE_LOG_DIR}/error.log
              CustomLog ${APACHE_LOG_DIR}/access.log combined
      </VirtualHost>
      
    • Check the config via: apache2ctl -t
    • Enable it with sudo a2ensite wordpress
    • Disable the default site with sudo a2dissite 000-default
    • Activate the new apache2 configuration with sudo systemctl restart apache2
  • Complete the wordpress install by browsing the image's website

phpMyAdmin installation

  • Install phpmyadmin via sudo apt install phpmyadmin
  • You may need to enable the apache2 conf via:
    • sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
    • sudo a2enconf phpmyadmin
    • udo systemctl reload apache2

Yet more wordpress plugins I've uninstalled but want to keep a record of

7th February 2021

I've recently done another audit of the plugins used on this site. This was in response to the Media Library insisting that it couldn't update the metadata for media in the media library because it already existed in the library. To track this down I ended up doing a review of the media related plugins. The ones I've uninstalled are:

Bulk Change Media Author Plugin
Allowed me to fix up the author field on multiple media items. I'm now less concerned about this and hence no longer need this
Enable Media Replace
Having sorted out the correct directory structure for my plugins and themes I no longer need this plugin
Phoenix Media Rename
As with the previous plugin, sorting out the directory structure means I no longer need this plugin

Enabling updates for self-hosted WordPress themes and updates

30th January 2021

I recently experimented with changing my themes and plugins to support self-hosted updates. For plugins this was relatively straight-forward once I'd found two articles, one by Misha Rudrastyh, which got me to adjust the contents of the zip files down one level (which allows WordPress to understand that the new zip file being uploaded is a replacement/update for a plugin that is already installed) and gave the basics of the self-hosted update process1, including hosting a file that describes the update along side the zip file that is the actual update. The second article by Paul Biron showed what the current version of WordPress is expecting in the php code for plugins

However those articles don't talk about themes that much. To be fair the process for themes is very similar2. However the expection of the WordPress code is different to that for plugins, so as a record here's my code:

function ningxia_check_for_update( $slug ) {
 $info = ningxia_get_remote_update_info( $slug );
 if ( false == $info ) {
  return false;
 }
 if ( version_compare( '@@@VERSION@@@', $info['version'], ' $slug,
    'new_version'   => $info['version'],
    'url'           => $info['homepage'],
    'package'       => $info['download_link'],
    'icons'         => array(),
    'banners'       => array(),
    'banners_rtl'   => array(),
    'tested'        => '',
    'requires_php'  => '',
    'compatability' => new StdClass()
  );
  return $update;
 } else {
  return false;
 }
}

function ningxia_pre_set_site_transient_update_themes( $transient ) {
 // Check for update
 $themeslug = 'Ningxia';
 $update = ningxia_check_for_update( $themeslug );
 if ( $update ) {
  $transient->response[$themeslug] = $update;
 }
 return $transient;
}
add_filter( 'pre_set_site_transient_update_themes', 'ningxia_pre_set_site_transient_update_themes' );

My build process modifies the @@@VERSION@@@ string into the current version number for the build being created (for example, 3.80.1) whereas the $info[['version']] comes from the json that been retrieved from the self-hosting site.


Last updated: May 30, 2021 at 9:36 am

Footnotes

  1. Though I did have to adjust the logic slightly - when you detect that the filter call is not for the current plugin you need to return the current value of first parameter and not just return false
  2. Though the articles I've read suggest that there could be differences for multi-site setups - as this site is not a multi-site setup, I've yet to test how well this description works for that kind of setup

Fixing the Simply Static plugin

18th November 2020

After updating my Ubuntu system to 20.04, I discovered that my method for generating the static version of the site no longer works. It turns out that the Simply Static plugin has a hidden dependency on PHP 7.2 (and upgrading Ubuntu from 18.04 to 20.04 incidently updates the PHP level from 7.2 to 7.4).

After doing some digging I discovered that the Simply Static plugin has an included library called PhpSimpleHtmlDom and the version in the plugin (1.5) is the culprit, I downloaded a more recent version of that library from github and replaced the version of the library with that level and (after a minor hack to change the namespace of the library to match the old namespace being used), Simply Static is now working again.

Hopefully, at some point, the author of the plugin will update it and I won't need the hack. That said the plugin has not been updated for a few years so may now be abandoned. If so I'll probably have to change the infrastructure that builds the static version of the website...

My thanks to Github user caophihung94 for providing a newer version of the PhpSimpleHtmlDom library

WordPress plugins I have used but are now uninstalled (but want to keep a record of)

19th May 2020

I have used (indeed am still using) a number of wordpress plugins. I have actually written quite a few myself as well as several others. There are a few I've used in the past and may well use again, but are currently uninstalled.

They are:

Merge + Minify + Refresh
Used to minimise the size of the css and javascript sent out by wordpress when delivering pages. Not currently simply because it seriously interferes with debugging the javascript!
WP Content Security Policy Plugin
Used to play with the content security policy that allows cautious browsers (and the server) to manage the javascript being used. I did use this to clean up the delivery, but couldn't get to a really clean content policy. I'd still like to do that, but it's not so trivial for the this site (from memory it's mostly the theme that causes trouble).
WP Super Cache
used when the site on dreamhost was an actual wordpress installation to reduce the server load. Since the dreamhost is now just a static version of the site I don't need it there and don't use on the version on my local network since the caching gets in the way of my testing.
WP-DBManager
I have used this to explore the wordpress database. I don't currently need to do this, but would use it if I needed to
WP-RSSImport
Used to query RSS feeds - As I described on the affected page I used to follow a bunch of RSS feeds, but no longer do so (and it's less useful for this static version of the site anyway).

Feeds

26th March 2020

I used to follow a whole bunch of RSS feeds. When Google stopped its RSS reader back in 2013, I converted this very web page on my personal site to gather RSS feeds for me. However my personal usage of that page steadily dropped and in 2019 (which, by then, was based on WordPress) I converted the site to a set of static pages I concluded that maintaining that page was basically infeasible. However I also have a policy of trying to avoid 404 errors for URLs that previously existed. Now, to be fair, I had broken that rule as I've only today noticed that the URL for my 'feeds' page no longer has a page backing it. This is to rectify that error.

As a memoriam, I used to follow RSS feeds from Slashdot, Coding Horror, Cédric Beust's Otaku blog, Igor Ostrovsky Blogging, Bruce Schneier's Blog, Coding Cookies, Cheshire Engineering, The secret barrister, Mark Evanier (Writer of Groo), Patrick Smith (Ask the Pilot), Humble Bundle, Rosemary Kirstein, Sue and Matthew,1 and Syndey Padua. It's interesting to note that most of these haven't been updated in years!

Footnotes

  1. Oxford comma used here to avoid ambiguity.

Automating the static upload

14th February 2020

I've automated some of my static upload process. This post is partially to provide a new post and partially to document/record the automatic part of the process. I created a batch script that generates a winscp script to upload files that changed, and will show the other differences (file adds and deletes) involved in the process. That script is:

@echo off
setlocal ENABLEDELAYEDEXPANSION
fossil extras >%temp%\fossil.out
for /f "delims=" %%a in (%temp%\fossil.out) do (
 fossil add %%a
)

set localdir=%cd%
set remotedir=/home/djvines/blog.tremlas.com

fossil status >%temp%\fossil.out
echo open blog.tremlas.com >%temp%\winscp.txt
for /f "delims=" %%a in (%temp%\fossil.out) do (
 set string=%%a
 for /f "tokens=1,2" %%c in ("!string!") do (
  set dz=%%d
  if "%%c"=="EDITED" echo put %localdir%\!dz:/=\! %remotedir%/%%d >>%temp%\winscp.txt
  if not "%%c"=="EDITED" echo !string!
 )
)
echo exit >>%temp%\winscp.txt
echo to run script execute:
echo "c:\Program Files (x86)\WinSCP\WinSCP.com" /script=%temp%\winscp.txt

Going static

17th December 2018

For a variety of reasons I reckon it's time to convert the public facing version of my website to go to a static version. The reasons include:

  • After the suspension of En Garde there's no dynamic input to the site other than my own (When I restart that campaign I will need to modify the hosting mechanism to provide the form processing - I'll cross that bridge when I get to it)
  • It'll make the site more secure (no WordPress admin on the public version of the site)
  • No more annoying emails from my web host encouraging me to upgrade from a shared host to a VPS due to reaching memory limits (presumably due to the wordfence plugin).

I'm using the Simply Static plugin though I did have to handle some quirks due to the private server sharing the same machine as my fossil repositories and my popmail spam filter.

It should be noted that this post is also part of an experiment to see how the workflow of updating my website is going to go!