Find and block unsafe content on your wordpress installation

For some reason, my WP installation decided to load some files via http instead of https

Screen Shot 2018-11-12 at 3.28.59 PM.png

To find out which file it is, I used the Javascript consoleScreen Shot 2018-11-12 at 3.29.39 PM.png

It’s wp-emoji in this case, and I don’t use emojis on my site, so I decided to block it by adding this to my theme’s functions.php


remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );


About mongo’s useNewUrlParser warning

Recently I got this warning when trying to create a new MongoDB application

(node:28962) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.

Turns out I’m the first few to use the new MongoDB driver released on npm over the weekend.

The new URL parser has no big changes (yet). Currently it only forces you to put the port into the URL

You can resolve the above warning by changing from



MongoClient.connect("mongodb://localhost:27017", { useNewUrlParser: true })

Solving MongoDB timeout

Sometimes you may encounter an error like this

While it’s easy to blame it on an overloaded server, there may be other reasons like

  • You changed something in your database access code
  • You are using a specific version of Mongoose (4.7.1 is known to have problems)
  • Your network condition isn’t good

You can try to set connectionTimeoutMS and socketTimeoutMS to ‘0’, hoping it to never time out, but ‘0’ doesn’t mean never with Mongo (from the FAQ)

The special meaning of 0

Setting connectTimeoutMS and socketTimeoutMS to the value 0 has a special meaning. On the face of it, it means never timeout. However this is a truth with some modifications. Setting it to 0 actually means apply the operating system default socket timeout value.

maxTimeMS is the option you are looking for

Most people try to set a low socketTimeoutMS value to abort server operations. As we have proved above this does not work. To work correctly you want to use the maxTimeMS setting on server operations. This will make MongoDB itself abort the operation if it runs for more than maxTimeMS milliseconds. A simple example is below performing a find operation.

// Execute a find command
col.find({“$where”: “sleep(100) || true”})
 .count(function(err, count) {

So what you can do is:

Increase the timeout value (connectTimeoutMS, socketTimeoutMS)

server: {
socketOptions: {
connectTimeoutMS: 60000,
socketTimeoutMS: 60000,
keepAlive: 1

Note that those two values’ meaning are

  • 0: default socket timeout (20 secs for Linux)
  • 30s: default for Mongo DB
  • 60s: longer timeout for our case

Add keep alive to the connection

It’s a safeguard against timeout. From Mongoose docs

A note about keepAlive

For long running applications, it is often prudent to enable keepAlive with a number of milliseconds. Without it, after some period of time you may start to see “connection closed” errors for what seems like no reason. If so, after reading this, you may decide to enable keepAlive:

options.server.socketOptions = options.replset.socketOptions = { keepAlive: 120 };
mongoose.connect(uri, options);

Hope this can help someone with the same question 🙂

The NPF driver isn’t running

If you installed Wireshark and, in fear of installing another service that might slow down your computer’s start-up time, you choose to have that service start on demand, but then when you start Wireshark you see the message ‘The NPF driver isn’t running’

This is simply because it isn’t running! To start it, open an administrator command prompt and type in ‘sc start npf’

That’s all!