I decided to replay one of my first graphical game series and bought the Sierra classic: Space Quest 1-6 collection from Steam for about £3. I read mixed reviews on that page stating that SQ1 was in VGA for some people and original for others. After installing it I could see that both versions are included but the Sierra launcher loads the original version so you have to do a bit of work to play the VGA edition.

The game installation is funky as it installs two different copies of the collection at the same time!

C:\Program Files (x86)\Steam\SteamApps\common\Space Quest Collection
C:\Program Files (x86)\Steam\SteamApps\common\Space Quest Collection\2016_SpaceQuestCollection

As a tease there is a “sq1vga” directory in the top level collection but it has no .exe to launch the game and no DOSBox setup. The solution is to go to the “sq1” directory from the other collection and copy the “dosbox” directory and “SQ1.bat” file into “sq1vga”. That’s it, you can drag a shortcut to SQ1.bat to your desktop and fire up the game.

Bonus Tip: You can use ALT-Enter to toggle between fullscreen (default) and windowed mode.

Since I was tinkering anyway it seemed like a good time to try the impressive Space Quest I VGA Hacking mod by Spiffythedog which includes 130 bug fixes and tweaks. Keep in mind that using the patch will mean you can’t load any save games from before you applied the patch so make sure you create a backup of the “sq1vga” directory.

Initially the patch didn’t work for me as it uses a couple of programs that are not compatible with Windows 10 x64 but that was easy to solve:

  • Unzip Spiffythedog’s mod files directly into “sq1vga”.
  • Download latest bsdiff-win for x64, for me this was bsdiff-v4.3-win-x64.zip.
  • Copy bspatch.exe to “sq1vga” to replace the version from the mod.
  • Inside “sq1vga”, open “APPLYPAT.BAT” with notepad and remove all the lines starting with “iscrc32” and the line immediately after each of those. For me the final version looked like this:
@echo off
if exist 433.V56 del 433.V56
if exist 533.V56 del 533.V56
mkdir OLD
copy RESOURCE.00? OLD >NUL
copy RESOURCE.MAP OLD >NUL
bspatch OLD\RESOURCE.MAP RESOURCE.MAP DIFF.MAP
bspatch OLD\RESOURCE.000 RESOURCE.000 DIFF.000
bspatch OLD\RESOURCE.001 RESOURCE.001 DIFF.001
bspatch OLD\RESOURCE.002 RESOURCE.002 DIFF.002
bspatch OLD\RESOURCE.003 RESOURCE.003 DIFF.003
bspatch OLD\RESOURCE.004 RESOURCE.004 DIFF.004
del DIFF.*
del ISCRC32.COM
del BSPATCH.EXE
del CWSDPMI.EXE
  • Save the .bat file and run it to start the patch procedure which should take just a few seconds.
  • When it’s done, fire up “SQ1.bat” and enjoy the game in all it’s VGA splendor!

Bonus Tip: There is a PDF containing all the game manuals in the Manuals directory. This is important as you need to use some codes out of it at certain points in SQ1 and SQ5 (Pages 22-24).

I’ve been battling a problem with the new Plesk server I purchased with 1&1 IONOS. Everything in Linux and Plesk looked correct but I could not connect via FTP/FTPS as port 21 remained blocked no matter what I did. It turned out the problem was with the 1&1 IONOS dashboard.

Once you login, select “Servers & Cloud” and then click “Select” on your server. This will take you to the server settings panel. Now select Network->Firewall Policies. At the bottom of the list of ports click the “Add Predefined Values” dropdown and select “FTP Plesk” which will add both the active and passive ports. The final step is to click the green tick icon next to the new rows it added and then wait for the server status to show it has finished setting it up.

That’s it! Because this is a new server it has the latest Plesk which already has both passive and active ports setup so once the IONOS dashboard was sorted out then everything worked. You can check this guide if you need to setup your Plesk firewall.

I’ve been using an app called Greenshot to take screenshots for years. It has a lot of options but I mainly stick to the “Window” and “Full Screen” capture methods. For the last year the “Window” mode has failed to work with Firefox. It takes the screenshot but the image is all black. Not a huge deal on my small 1920×1080 monitor as I can easily switch to “Full Screen” capture but it sucks on my 3840×1080 screen. Today I had enough and decided to either solve the problem or switch to another app. Thankfully the fix was easy and I’m kicking myself that I didn’t do this sooner!

  • Right click the Greenshot icon in the system tray and select Preferences.
  • Select the Capture tab.
  • Under the Window Capture section tick the Window capture mode option and then change the dropdown to “As displayed”.
  • Click OK to save the changes and then give it a go.

Contact Form 7 is a WordPress plugin that allows you to add forms to pages. A downside to using it is that out of the box it adds the Contact Form 7 JavaScript and CSS to every page even if there is no contact form there. It does the same with the reCaptcha assets if you have that enabled. This results in unnecessary page bloat and adds the reCaptcha badge to the bottom right corner of every page. This is the code I have used to hide it:

/**
 * Dequeue the Contact Form 7 and reCaptcha assets on pages without a contact form.
 */
function restrict_contactform7_assets() {
    // Add/edit the page numbers to match your site.
    if(!is_page(10) && !is_page(240)) {
       wp_dequeue_script('contact-form-7');
       wp_dequeue_script('google-recaptcha');
       wp_dequeue_script('wpcf7-recaptcha');
       wp_dequeue_style('contact-form-7');
    }
}
add_action( 'wp_enqueue_scripts', 'restrict_contactform7_assets' );

You can get the page id number from the address bar when you open it for editing in the admin.

Lately I’ve been working on a WordPress Gutenberg plugin. The official WordPress documentation has always been a bit hit and miss due to them changing things so frequently but it’s been good for getting the initial plugin development environment setup. Unfortunately, within an hour of development I stumbled into my first big problem; several of the controls do not seem to exist!

ComboboxControl and the Flex Controls are the two that I wanted to use and despite being covered in the docs they are not actually included with the built in Gutenberg. If you try to use them the block will fail with the dreaded generic error:

"This block has encountered an error and cannot be previewed"

In the browser console you will see the following error:

wordpress react Warning: React.createElement: type is invalid -- expected a string

The solution is quite simple; install the Gutenberg plugin! The one that is bundled with WordPress is an older version. The main Gutenberg plugin project is very active and frequently updated:

That should solve most of your missing component problems. I actually got double unlucky as this latest Gutenberg version still does not include the ComboboxControl but I suspect that is due to some big changes they have been making to it which are covered in this pull request.

Today I was dabbling with the WordPress plugin builder and the first step is to run npx @wordpress/create-block which seems fairly straight forward except on Windows if you have a space in your username. For example, if your Windows username is “David Millington” then you will be blasted with a page of errors that look like this:

Error: EPERM: operation not permitted, mkdir 'C:\Users\David' TypeError: Cannot read property 'get' of undefined at errorHandler (C:\Users\David Millington\AppData\Roaming\npm\node_modules\npx\node_modules\npm\lib\utils\error-handler.js:213:18)
Error: EEXIST: file already exists, mkdir 'C:\Users\David' TypeError: Cannot read property 'get' of undefined at errorHandler (C:\Users\David Millington\AppData\Roaming\npm\node_modules\npx\node_modules\npm\lib\utils\error-handler.js:213:18)

Super intuitive.

The problem is that npx is tripping up when it’s trying to write to the npm cache directory due to it failing to parse the space in the username correctly.

The fix is quite simple.

  • Open a PowerShell window and CD C:\Users
  • cmd /c dir /x
  • You should see the short version of your username directory like DAVIDM~1
  • Make a note of that and then open your npm config file. For me that was C:\Users\David Milligton\.npmrc
  • Duplicate the line similar to this one:
  • ; cache=C:\Users\David Milligton\AppData\Roaming\npm-cache
  • With the new line you made, remove the ; from the start and replace the username with the short version you got earlier on:
  • cache=C:\Users\DAVIDM~1\AppData\Roaming\npm-cache
  • Save the config file

Now if I run npx @wordpress/create-block it works as expected and the real work can begin!

I’ve been using the Members plugin on a client’s WordPress site to define custom roles. It’s been working great except for one thing; the authors dropdown on the Gutenberg document editor does not show anyone who has a custom role.

I had a look around and found several posts that suggested using the the wp_dropdown_users_args filter which worked for the Quick Edit author dropdown but not for the main document editor. In fact I couldn’t find anybody with a solution for that since Gutenberg was introduced. I managed to suss it out for myself and thought I’d share the code for anyone stuck in a similar situation. The following goes inside functions.php. Make sure to replace “custom_role_one” and “custom_role_two” with your actual role names.

// Handles the Quick Edit authors dropdown
function display_custom_roles_in_author_dropdown($query_args, $r)
{
	if (isset($r['name']) && ($r['name'] === 'post_author_override' || $r['name'] === 'post_author')) {
		if (isset($query_args['who'])) {
			unset($query_args['who']);
        }
        $query_args['role__in'] = ['administrator', 'author', 'editor', 'custom_role_one', 'custom_role_two'];
    }
    return $query_args;
}
add_filter('wp_dropdown_users_args', 'display_custom_roles_in_author_dropdown', 10, 2);

// Handles the Gutenberg document editor authors dropdown
function display_custom_roles_in_gutenberg_author_dropdown($prepared_args, $request = null)
{
	if (isset($prepared_args['who']) && $prepared_args['who'] === 'authors') {
		unset($prepared_args['who']);
		$prepared_args['role__in'] = ['administrator', 'author', 'editor', 'custom_role_one', 'custom_role_two'];
	}
    return $prepared_args;
}
add_filter('rest_user_query', 'display_custom_roles_in_gutenberg_author_dropdown', 10, 2);

Recently I’ve been working on a new project as part of a development team. After a recent Git merge I found that I was unable to save any changes on WordPress posts and pages. I logged out of the site and cleared cache but then found I was unable to login. When I entered my details and submitted the form all that would happen is that I would be redirected back to the login page.

I read about several possible reasons for this and tried out several of the fixes but nothing worked. I put my Sherlock cap on and started checking the commits. It turns out the culprit had been hidden away in an old branch that only recently got committed.

It was inside the .htaccess file:

php_value upload_max_filesize 20MB
php_value post_max_size 25MB
php_value memory_limit 30MB
php_value max_execution_time 90

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Did you spot it? Kudos if you did! The culprit was the three PHP values that specify MB. PHP expects those to just say M as specified in the shorthand byte value note. After removing those naughty B’s I was able to login and save updates again. Here’s the working version:

php_value upload_max_filesize 20M
php_value post_max_size 25M
php_value memory_limit 30M
php_value max_execution_time 90

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

When trying to run my Laravel/PHPUnit integration tests I received this error:

ReflectionException: Class config does not exist

It is one of those vague error messages that can be triggered by a lot of different problems and none of the many solutions to these common issues worked for me. In the end the solution came down to some detective work.

I use the setUp() and tearDown() method. What was going wrong was that I did the parent::tearDown() before the rest of the cleanup. So a case of trying to use data after it has been torn down. The following is how it should be setup:

public function setUp(): void
{
   parent::setUp(); // Must be first
   // Your own setup
}
public function tearDown(): void
{
   // Your own teardown MUST come before down the parent::tearDown
   parent::tearDown(); // Must be last
} 

I run Windows 10 with a 3 monitor setup and occasional I get the problem that one of my open program will show up in the taskbar but if I click to focus on nothing will seem to happen. If I do alt-tab I will see it in the list with the thumbnail showing just a title bar and buttons with no visible area below it. Even if I select that then nothing will appear.

What has been happening is that programs have somehow become resized to the point they are not visible!

The trick to get them back to normal is:

  • Select the program in the taskbar so it has focus
  • Press alt-space
  • Select Maximise from the menu that opens
  • The program will appear full screen (you’re not done yet!)
  • Drag the title bar to make it a smaller window
  • It will return to being a floating title bar with no content so now you can drag the bottom right corner of that to expand it again
  • That’s all there is to it

The innocent lie because they don’t want to be blamed for something they didn’t do and the guilty lie because they don’t have any other choice. Find out why they are lying and the rest will reveal itself.

— Commander Jeffrey David Sinclair