Posted in Uncategorized

After an unfortunate incident involving a crash and a lost save file, I decided to write a batch script to automatically back up my Subnautica 2 saves every x number of minutes. You’ll need 7-Zip and PowerShell installed.

This script will check if Subnautica 2 is running, and if so, will zip the Subnautica save folder to whatever folder the script is located.

@echo off
rem Get HH:MM:SS for log prefix
FOR /F "tokens=* USEBACKQ" %%F IN (`powershell get-date -format ^"{HH:mm:ss}^"`) DO (
	SET logtime=%%F
rem Determine if subnautica is running
tasklist /fi "ImageName eq SubnauticaZero.exe" /fo csv 2>NUL | find /I "SubnauticaZero.exe">NUL
rem If subnautica is running...
if "%ERRORLEVEL%"=="0" (
	rem Get current datetime
	FOR /F "tokens=* USEBACKQ" %%F IN (`powershell get-date -format ^"{yyyy_MM_dd_HH_mm_ss}^"`) DO (
		SET mydatetime=%%F
	rem Set up a folder name for our new backup
	rem Back up with 7zip
	"C:\Program Files\7-Zip\7z.exe" a -tzip "%stamp%" "%USERPROFILE%\AppData\LocalLow\Unknown Worlds\Subnautica Below Zero\SubnauticaZero\SavedGames\slot0000" > NUL
	echo [%logtime%] Backed up to %stamp%
) else (
	echo [%logtime%] Not running...
rem sleep for 30 minutes
powershell -command "Start-Sleep -s 1800"
goto loop

To run the script simply save the above code into a file with a filename like backup.bat and double click it. Run it whenever you’re playing and close it when you’re done.

Read More »

Posted in Uncategorized

For something that should be simple, importing a model from VRoid Studio into Unreal Engine 4 as of the time of writing is extremely convoluted and time consuming – even with the great tools that have been created to speed up the process.

Below I’ll attempt to walk through every step I took to get things looking and working correctly as well as documenting my struggles along the way. Our basic workflow will be VRoid -> Blender -> Unreal.

I should note that as of the time of writing, the latest version of each of the pieces of software I’ll be using are as follows:

Read More »

Posted in Uncategorized

For the longest time now I’ve been having issues with certbot not being able to create a certificate for my domain, returning the error

Attempting to renew cert ( from /home/ubuntu/.certbot/config/renewal/ produced an unexpected error: Failed authorization procedure. (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from [2606:4700:3035::681c:1e6e]: “<!DOCTYPE html>\n<!–[if lt IE 7]> <html class=\”no-js ie6 oldie\” lang=\”en-US\”> <html class=\”no-js “. Skipping.

I think the reason for this is because I’m using Full (Strict) encryption mode in CloudFlare dashboard which requires a valid SSL certificate be present when communicating between my web server and CloudFlare.

Full (strict) SSL/TLS encryption mode with CloudFlare

The solution for this is instead of using certbot’s default authentication method, we instead make use of the certbot-dns-cloudflare plugin that will handle the Lets Encrypt challenge through DNS. This works by automatically creating and deleting our CloudFlare DNS TXT record for us during the certbot renew. Let’s set this up now.

Read More »

Posted (Updated ) in Uncategorized

With the official How to Transfer Data Between microSD Cards for Use on Nintendo Switch documentation being for Windows only, and the Reddit thread on the topic not coming up with anything that works on the latest firmware, I thought I’d write up a quick post on how I moved from a 128GB to 512GB card successfully using OS-X.

  1. Turn off your Switch by holding the power button for 3 seconds and selecting the relevant option.
  2. Remove your old SD card from your Switch
  3. Insert it into your Mac
  4. Run the following in your terminal
    mkdir ~/Desktop/sdcard
    cp -r /Volumes/Untitled/Nintendo ~/Desktop/sdcard
  5. Insert your new SD card into your Switch and turn it on
  6. If an error message about your SD card not being readable pops up, close it
  7. Go to Settings – System – Formatting Options – Format microSD Card and format your card
  8. Once the files have finished copying on your Mac eject your old SD card and store it away for safe keeping
  9. Turn your Switch off, take your new SD Card out and insert it into your Mac
  10. Run the following in your terminal
    cp -r ~/Desktop/sdcard/Nintendo/* /Volumes/Untitled/Nintendo
  11. Once the files have finished copying eject your new SD Card, insert it into your Switch and turn your Switch on
  12. If there is no error message, you’re all done!

Read More »

Posted (Updated ) in Linux, Uncategorized

I have a bunch of sites in /var/www and need individual user logins with access to their respective sites. In this tutorial I’ll go over how to create a user, chroot jail them and allow access to specific folders (in our case web directories).

For reference I’m using a standard LAMP server on Ubuntu:

sudo apt-get install -y tasksel
sudo tasksel install lamp-server

but this tutorial will work for any web server configuration.


1. Create User, Assign Web Group

# Create the user setting group to www-data
sudo useradd -Ng www-data myuser
sudo passwd myuser
# Restrict login to SFTP only
sudo groupadd sftp-only
sudo usermod myuser -G sftp-only


Create their web directory and provide access

With the new user created, make a directory matching their website’s name and mount the real website folder to it:

# Create chroot directory and set permissions
mkdir -p /home/myuser/
chmod 755 /home/myuser/
# Mount the destination directory at the directory we just created
mount --bind /var/www/ /home/myuser/
# Add the above command to /etc/rc.local to mount it on boot
nano /etc/rc.local


Restrict the user to SFTP Only

We only want to allow SFTP access for this user. First open /etc/passwd and make sure the end of the line has /bin/false like so:

tail -n1 /etc/passwd
# myuser:x:1001:33::/home/myuser:/bin/false

Now edit /etc/sshd/sshd_config to allow only SFTP myuser:

Match User myuser
  ChrootDirectory /home/myuser
  ForceCommand internal-sftp
  AllowTcpForwarding no
  X11Forwarding no

Restart the SSHD service:

sudo service sshd restart

Now when you try to SSH in with this user you’ll get the error:

This service allows sftp connections only.


That’s it! They should now be able to SFTP in and will only have a directory with access to their web files.


Further Reading

mihai.ile’s post on Stack Overflow – How can I chroot sftp-only SSH users into their homes?

Read More »

Posted (Updated ) in Uncategorized

Occasionally after running a brew update && brew upgrade I’ll attempt to start apache with sudo apachectl start and get the error

[Thu Jan 25 08:53:02.769633 2018] [core:warn] [pid 41502] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Thu Jan 25 08:53:02.769654 2018] [core:warn] [pid 41502] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00543: httpd: bad user name ${APACHE_RUN_USER}

I also notice OSX’s built in apache is running instead of homebrews. But where should the envvars file go?


The Fix

Firstly disable OSX’s built in apache:

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

Drop your envvars file in /usr/local/Cellar/httpd/2.4.*/bin folder replacing the * with your version number.

You should now be able to sudo apachectl start again.

Read More »

Posted in Uncategorized

For a while now I’ve been having an issue where when I plug my headphones into the headphone jack of my Logitech 5.1 PC speakers, some YouTube and Facebook videos wouldn’t have sound, but most would.

I found this Reddit thread on the topic however the best solution seemed to be:

Hopefully everyone has fixed this by now, however I fixed this by changing my Realtek settings from 7.1 to stereo. – VeryRedChris

I went poking around in my sound settings (Windows 10) and made the following adjustment: Sound – Playback Devices – Speakers (Realtek High Definition Audio) – Properties – Spatial Sound and set Spatial sound format to Windows Sonic for Headphones and made sure Turn on 7.1 virtual surround sound checkbox was checked. This fixed the issue! If you have Chrome open, restart it and any other existing audio apps for the changes to take affect.

Read More »

Posted in Uncategorized

Our firewall at work restricts us to only port 80 and no access to SSH – which as you can imagine for a web developer is a pretty big issue. Below I’ll describe the various methods of routing around this crap.


Create a SOCKS5 Proxy with SSH

If your firewall restricts which sites you can visit but you have access through SSH to a remote server, route your browser and other traffic through that server with a SOCKS5 proxy. This is called Dynamic Port Forwarding:

ssh -f -N -D 1080 remote-server

The above command creates a SOCKS5 proxy server on port 1080 of your machine which sends all traffic through remote-server. 

Use it with you browser:

Now use the server in Firefox:

  • go to Edit -> Preferences -> Advanced -> Network -> Connection -> Settings…
  • check “Manual proxy configuration”
  • make sure “Use this proxy server for all protocols” is cleared
  • clear “HTTP Proxy”, “SSL Proxy”, “FTP Proxy”, and “Gopher Proxy” fields
  • enter “” for “SOCKS Host”
  • enter “1080” (or whatever port you chose) for Port.

Use it with git:

You can also configure SSH git origins to work with your proxy:

Open ~/.ssh/config and add

    User git
    ProxyCommand nc -x localhost:1080 %h %p

Now you can just clone/push/pull as normal. See here for more information.

Read More »

Posted (Updated ) in Uncategorized

Recording a gif on OSX is fairly easy but you’ll need a few tools to make it happen – especially if you want a nice, small filesize for online viewing.


Step 1 – Record a video

You can use anything for this – I was recording a window on my screen so I used Screenium but Quicktime works fine. The output was a 15 second 1.1MB MOV file of resolution 1184×738. I saved the file as on my desktop.


Step 2 – Convert to a Slideshow of PNGs

  • 1
    brew install ffmpeg #if you don't already have it
  • 1
    mkdir output
  • 1
    ffmpeg -i -vf scale=iw:ih -r 10 output/ffout%3d.png
    • ‘scale=iw:ih’ – Don’t change the input scale. You can also set this to specific values or ‘320:-1’ to rescale down for example
    • ‘-r 10’ – Set to 10 FPS
    • ‘output/ffout%3d.png’ output slideshow of pngs in output folder


Step 3 – Convert the Slideshow to a GIF

From our PNG slideshow we can generate a (huge) gif. Don’t worry, we’ll fix the filesize later.

  • 1
    brew install imagemagick #if you don't already have it
  • 1
    convert -delay 8 -loop 0 output/ffout*.png output/demo.gif
    • ‘convert’ is the command-line tool from ImageMagick
    • ‘-dalay’ is the delay of 8, you would get a FPS=100/8=12.5
    • ‘-loop’ adds Netscape loop extension to your GIF animation
    • ‘output/ffout*.png’ is the directory and file names going into the GIF
    • ‘output/animation.gif’ is the final location and GIF output


Step 4 – Optimise your GIF with Photoshop

  • Drag your new gif into Photoshop. Here you can make any changes such as removing frames. Turning on Window – Timeline will help here.
  • File – Save for Web and select GIF from the image type drop down at the top right
  • Tweak your Image Size and Colors values until you get the filesize you want (shown at bottom left). You can preview the GIF in realtime using the media buttons at the bottom right.
  • If the filesize is still too large, return to step 2 and lower your gifs FPS by lowering the r value.
  • Optimising your GIF with Photoshop



Read More »