Typora

Typora

It’s not new. I’m just late to the party.

I love plain text files for documents. They’re future-proof, past-proof, and completely platform agnostic. I’m sure someone has written a text editor in Minecraft or something more outrageous. Text editor for Gameboy Colour? Text editor for a Casio F91W.

But sometimes text files need a little more oomph. Some va-va-voom. And this is where Markdown comes along. It’s still a plain text file, but you can format the text with some markup that ranges from very simple, to slightly less simple.

Like this:

# Heading 1
## Heading 2 - The headening
This is the body text.

1. This is
2. an ordered
3. list

and

- this is
- an unordered
- list

and 

- [ ] these
- [ ] are
- [x] checkboxes

This then ends up looking like this:

when viewed through an interpreter. The themes can be tweaked, but you can tweak individual bits of the style. You can’t suddenly decide that your ordered lists part way through should be twice the size or something.

And it just works. The files don’t bloat. There is image support. Table support. All manner of things.

And because it’s plain text files, it works perfectly with your preferred version control system (git, most likely, right?) in a way that Word Documents don’t.

I recently stumbled upon Typora and it’s just bloody great. You can either type in code, or use the wysiwyg interface, or kinda use both at the same time where the styles update as you type in the code. It’s not free, but why should it be? It’s very well priced at AU$22. It’ll probably never stop working – and if it does, there are dozens of other text editors out there that will pick up your file and open it without any issues.

Start writing in Markdown. You’ll like it. I think.

Migrating Ghost

Migrating Ghost

I found the instructions on how to migrate self-hosted Ghost from one host to another quite lacking. It took a lot of tinkering to get it to work properly. And I still don’t quite understand why just picking up an install folder and database dump on one host and dropping it into the new doesn’t work. But I guess this isn’t LAMP-stack PHP-based simplicity.

So. Here goes.

Caveat

This post is going to assume a lot of knowledge, and doesn’t go into detail about specific steps. More about what steps are required than exactly how to do them. It’s also going to assume that your server is ready for running Ghost – all the prerequisites are there including ghost-cli. This will most likely be taken care of in Step 3 if it isn’t ready for running Ghost, but it’s not going to be covered here.

There will be downtime.

Caveat emptor. YMMV etc.

Step 1 – Export the Ghost data from existing host

Export all members to a CSV.
Export the site details to a JSON – on older installs this is under Settings -> Labs, in the newer ones, it’s under Settings -> Import/Export.
Grab a copy of the config file config.production.json

Step 2 – Update DNS

Point your domain to your new server IP. Don’t forget to do IPv6 too. Wait for propagation to happen. 10 seconds or an hour. Who knows! DNS is magic.

Step 3 – Install Ghost on the new host

This is done with the ghost-cli command ghost install in the directory that you want it to install. Once the installation process is complete, log in to the site, create your user and do all the basics. Delete the default posts and other users.

Step 4 – Migrate images over from the old host to the new

rsync is your friend here. Something like:

rsync -r /var/www/ghostfolder/content/images/ username@host2.example:/var/www/ghostfolder/content/images/

will swiftly move your images over.

Step 5 – Run ghost doctor and fix file permissions

Step 6 – Import members CSV

Step 7 – Import site content JSON

Step 8 – Config file

Add the SMTP settings from config.production.json to your new config file on the new host

Ubuntu Tidyverse Packages

Ubuntu Tidyverse Packages

Mostly a note-to-self.

After you’ve installed r-base on Ubuntu with the default packages, you will have issues installing Tidyverse. It’s because there are a bunch of packages missing.

Install them with:

sudo apt install libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev libharfbuzz-dev libfribidi-dev libfontconfig1-dev libxml2-dev libssl-dev libcurl4-openssl-dev

There might also be the following r packages missing

stringi
ragg

Install them with

sudo su - -c "R -e \"install.packages('stringi', repos='http://cran.rstudio.com/')\""
sudo su - -c "R -e \"install.packages('ragg', repos='http://cran.rstudio.com/')\""
Rocket.Chat – Wrong URI in emails

Rocket.Chat – Wrong URI in emails

I recently spun up a Rocket.Chat server using Linode/Akamai’s pre-rolled scripts, and it mostly worked well. The main issue being that the URI included in all the emails was stuck as the host name of the server rather than the site-url as set in the settings.

The fix is as follows

First of all connect to the server console (be it via LISH or SSH or however). Install the Mongo database client

sudo apt install mongodb-clients

Connect to the database by running

mongo

Select the parties database

use parties

Run a query to find the Site_Url setting and confirm that the correct URI is set in “value” and the incorrect URI is set in “packageValue”

db.rocketchat_settings.find({"_id" : "Site_Url"}).pretty()

Run a query to update “packageValue” to the correct URI (replace <correct URI> with your URI)

db.rocketchat_settings.update({"_id" : "SiteUrl"},{$set:{packageValue:"<correct URI>"}})

Repeat the find query to make sure the change was made. Reboot the server and the problem should be solved.

Password Enterer

Password Enterer

We’re all told to have strong passwords for everything. Long, good, complicated passwords with symbols, numbers, capital letters. Passwords that are a pain to enter without a passwords manager, in essence. Because password managers exist, that’s all good for nearly every situation, except when it comes to logging in to your desktop.

I know this kind of thing exists already, but I don’t think they exist quite as simply (and potentially as un-securely) as this.

What I’ve made, using an old Digispark ATTiny85 arduino board with a built in USB-A plug, is a device that, when plugged in to a USB port, and the button is pressed, will type in a pre-determined string of characters followed by the enter key. There are two use-cases I can think of for this. Logging in to your desktop where there’s no password manager available, and entering your long-winded password into your password manager when setting that up.

There are obviously security issues with this – it’s a single factor authentication system. And you’re keeping the entire password available to anyone who picks up the doodad, plugs it in, and presses the button. There are things that could be done to make that safer – like only keeping part of the long-winded password on the device, requiring user input for to complete the password. But as a little one-hour project, this was fun.

My soldering is a mess, but it works. The button circuit includes a pull-up resistor, to stop any erratic button behaviour when there isn’t a definite high or low signal, as per a tonne of tutorials online. Like this, straight from the Arduino source: https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button

Here’s the completed product:

The code that’s running it is as below. Firstly, import the HID library from Digispark (there are tutorials on how to get that happening on the Digispark website). Initialise the button state, configure the required pin to wait for signal, then repeatedly wait for button press. If there’s a button press, send the defined string to the computer, and to prevent multiple entries, wait for a second before moving on.

#include "DigiKeyboard.h"

int buttonState = 0;

void setup() {
  pinMode(5, INPUT);
}

void loop() {
  buttonState = digitalRead(5);
  if (buttonState == HIGH) {
    DigiKeyboard.sendKeyStroke(0);
    DigiKeyboard.println("notmyactualpassword");
    DigiKeyboard.delay(1000);
  }
}

Self-hosted Evernote Alternative

Self-hosted Evernote Alternative

I think I installed ownCloud in 2014 when v6 was the latest. It’s not perfect, but considering I have access to a virtual machine host for no cost, it’s pretty good value, and I’m willing to overlook the small issues I have with it.

I used Evernote for a while, and quite liked it, but fell further and further out of like with it as the features of the free version were stripped back, and the cost of the basic paid tier increased. $10 a month is pretty steep. I tried Google Keep for a while, but I didn’t like it at all. And do I trust my thoughts with Google? Yeah, kinda, but not completely.

In comes Joplin. A FOSS (free, open source software) note taking application that works with WebDAV (amongst other platforms/protocols).

ownCloud is fully conversant with WebDAV, which means that you can keep your notes safely stowed away on your ownCloud server, which is handy. I created a folder called Joplin in my ownCloud folder, then configured the software with the following settings, consistent across every platform (Android, Windows, and Ubuntu):

Synchronisation target: WebDAV
WebDAV URL: https://yourdomain.example/remote.php/webdav/Joplin (replace Joplin with the name of the folder your chose)
You also need to set your username and password, but they’re self-explanatory.

Installing Joplin on Ubuntu gave me a nice surprise. I ran “sudo snap install joplin” and it went through the motions of installing the software. But I couldn’t find it in the GUI to launch it. So I typed “joplin” at the terminal and a text-only version of Joplin appeared in terminal. Very good! I ran “sudo snap install joplin-desktop” and that installed the graphical version of the software and I was good to go.

Configuring the text only version of Joplin isn’t quite as easy as the graphical one. It’s a bit vi-y, which means that any commands you want to run are preceeded by a semi-colon. So, if you want to see the current configuration, type :config and press enter.

To configure the text version of Joplin to use WebDAV, first run

:config sync.target 6
to set the target to WebDAV, followed by

:config sync.6.path https://yourdomain.example/remote.php/webdav/Joplin
:config sync.6.username yourusername
:config sync.6.password yourpassword

The .6. in the config commands refers to target id of 6, which is what was set in the first command.

Run :sync to manually sync this instance to your server.

Bonus: in the ownCloud desktop application, untick the Joplin folder. This will remove it from your ownCloud folder on your local machine, but it will still exist on the server, which is where the Joplin applications will read it from directly. It will stop you from accidentally making a mess of the folder structure.