Create custom style dropdowns on Quill

I’m putting this one up quickly so the info is out there. If you come across this and need more info, just comment on the post.

Set up the editor:

Inject the styles:


Launching renderer functions from the main menu in Electron-Vue

Creating menus is simple enough in Electron, but how in the world do you tell your Renderer process to do something?! I couldn’t find any existing resources on this so hopefully this helps you.

In your menu/index.js  set up your menu:

In your  renderer/main.js  add a listening function:

Tada! You can now successfully run any renderer function you like from your application menus. 🙂

Here’s some other types of ways you can communicate between the two processes:

How to export from Scrivener to Word with correct styles

This is a macro to export from Scrivener to Word with correct Heading and Body styles. This also correctly handles in-paragraph bold and italics. It is based off the excellent work by Félix Chénier.

When I tried his method, it correctly fixed all the heading styles, but it did not update the body text to be ‘Normal’ style. This is of course a bit of a pain if you want to update style of your whole body text at once.

It would be trivial to add a  p.Style = ActiveDocument.Styles(wdStyleNormal)  to his macro assuming that would fix the problem.

However, if you happen to have paragraphs that are comprised solely of italicised or bolded text, then Word will convert those to regular (non italic or bold) text. Apparently if a paragraph is <50% bold or italic, Word assumes those words are for emphasis and keeps them when it does the style conversion. But if it is >50%, then it will turn the whole paragraph just to plain ‘Normal’ style.

So, we have to set as ‘Normal’ and then go through word-by-word and turn the text to its original emphasis.


Luckily I have written the macro for that. It takes your italicised text and temporarily converts it to pink highlighted text. Word does not remove highlights when it converts a paragraph style, so after the conversion the macro knows exactly which words to convert back to the original style. After the conversion it then removes the temporary highlighting. This works for both italic and bold text.

There are two caveats:

  1. If you try and convert your whole document at once, it will simply crash. It’s probably bad coding on my part, maybe someone can suggest a better option. However, if you select 3-4 pages at a time then that seems to work perfectly.
  2. If you happen to have pink or red highlighted text in your document, then you will lose that. Please edit the code to a safe colour!

How to use:

First of all, you need to export from Scrivener with the correct format. Scrivener doesn’t export any special style information, so we will be using a special bit of title suffix text to tell Word which parts of the text are your headings.

The macro can support 6 levels of headingsThe suffixes are in this format:

  1. ~#~ (this corresponds to what you want as Heading 1 in Word)
  2. ~##~ (Heading 2)
  3. ~###~ (Heading 3 …etc…)
  4. ~####~
  5. ~#####~
  6. ~######~

Go to File > Compile, and set up your headings to have a suffix. For Heading 1 it will look like this:

The exported Word document will look something like this:

Title ~#~

Chapter 1 ~##~

It was a dark and stormy night; the rain fell in torrents, except at occasional intervals, when it was checked by a violent gust of wind which swept up the streets (for it is in London that our scene lies), rattling along the house-tops, and fiercely agitating the scanty flame of the lamps that struggled against the darkness.

Chapter 2 – A Story in 3 Parts ~##~

Part 1 ~###~

Through one of the obscurest quarters of London, and among haunts little loved by the gentlemen of the police, a man, evidently of the lowest orders, was wending his solitary way. He stopped twice or thrice at different shops and houses of a description correspondent with the appearance of the quarter in which they were situated, and tended inquiry for some article or another which did not seem easily to be met with.

Part 2 ~###~

All the answers he received were couched in the negative; and as he turned from each door he muttered to himself, in no very elegant phraseology, his disappointment and discontent. At length, at one house, the landlord, a sturdy butcher, after rendering the same reply the inquirer had hitherto received, added, “But if this vill do as vell, Dummie, it is quite at your sarvice!”

You can see how the headings are unstyled, but they have the special suffix added.

Create a macro in your document, and paste this code in:

Set the macro to either a keyboard shortcut, or put a custom button on your toolbar.

Go through your book maybe 3-4 pages at a time. Select the text, then run the macro. Only do a few pages at a time, otherwise the macro will fail.

It shouldn’t take you too long to do the whole book at that speed, and then you’re done!

How to see visitor’s real IP with Cloudways and Cloudflare

If you’re using Cloudflare in front of your Cloudways site, you’ll notice that all the visitors come through with the IP address of It’s easy enough to fix this. Cloudways posted a useful article about it, but it misses one critical thing – the WordPress configuration!

First, head to your server configuration on Cloudways, and choose Settings & Packages > Advanced:

Scroll down until you fine the WAF Module setting, and change that to Cloudflare:

You’ll also need to restart your Apache service.

Then, for each of your WordPress sites, you’ll need to add this code to your wp-config.php :

Once you’ve done that, look in the logs, or post yourself a test comment to verify that the IP address is coming through correctly. Should be all good!

Good password security

Good password security isn’t too hard, it just requires a change in your approach. The biggest factor to increasing password security is password length.

To see this in action, visit this link – – and type in one of your passwords as a test. Look at the last two Attack Scenarios. That’s how quickly it would take to break that current password. Have a look how quickly that changes when you simply increase the length of your password.

If the current strength is in weeks or days, it’s not a matter of “if” you get hacked, it’s a matter of “when”.

There are two good approaches to strong password security:

1. A strong known password scheme
2. A password manager software

#2 is my recommended option, but I’ll describe #1 first:

1. A password scheme

Pick three completely unrelated words. My street – “seaviewrd” – could be one of the words as it is not in any dictionary; this is ideal. Let’s pick the words ‘seaviewrd’, ‘great’, ‘Monday’. We also pick a couple of punctuation characters, perhaps ‘$’ and ‘!’. The reason you pick unrelated words, is that password cracking software tries common phrases, so words that don’t go together in a phrase are critical.

Then to create a password, put together the three words, the punctuation, and what it’s for:

Gmail: seavrewrdgreatMondaygmail!$
Braintree: seaviewrdgreatMondaybraintree!$
Paypal: seaviewrdgreatMondaypaypal!$

Take one of those passwords and type it into to see the difference….

They are easy for you to remember, but effectively impossible to crack. They are also easy to type, as your fingers are used to typing words.

The downside is that if someone ever finds out one of your passwords … it is trivial to guess the rest of them!

2. A password manager

My preferred approach is to use a password manager. The reason for this, is that you can use it to easily generate completely random new passwords, and it can remember them for you – your brain doesn’t have to manage it. It is a little more complicated to get used to though.

KeePass is the best option – (download the Professional Edition).

Create a master password for it using the method above. Write this down on a piece of paper! Keep the piece of paper safe until you’re sure that you remember the master password, and then shred it.

Every time you make a new entry, get it to generate a completely random password, of at least 20 characters length:

When you need to log into a website, you simply double-click on the password, and it copies it to your clipboard. Paste it into the website password field, and you’re done!

IMPORTANT: ​Make sure that you keep a few copies of this file around. If you were to lose it completely, that would be disastrous, as you would have none of your passwords! I keep mine in my Dropbox, and every now and then email myself a copy. That way it’s in three places – on my laptop, in my Dropbox, and in my email.

As long as your KeePass master password is strong, the database is unbreakable.

Cart doesn’t work with Flatsome, WooCommerce, and Varnish

This is a quick and easy one.

If you’re using the Flatsome3 theme with WordPress and you have Varnish cache running, you’ll find the cart doesn’t work. You add an item, and the sidebar pops up but then it disappears again straight away, and the cart is empty.

Turn off Varnish and problem solved… but that’s not good enough.

Flatsome has a mechanism where the DOM is replaced with AJAX after the initial load. It uses cookies to pass the cart information around, and Varnish caches those by default.

Add these two rules and you’re golden:

URL exclude  ^/(cart|my-account|checkout|addons)

Cookies exclude  .*woocommerce.*

My site is running on Cloudways (which I strongly recommend – my review here), and the config looks like this: