Rust Nightly or Stable with Rustup and “may not be used” error

When writing one of my pet projects or rather, a very simple automation matter in Rust, I fell into many pits. Usually full of snakes (of my own lack of knowledge of rust), but this one struck me as relatively interesting.

The stable compiler does not allow you to use unstable APIs/features. You have to use the nightly release branch.

If you know node, this is probably the equivalent of having to run V8 with harmony flags.

Rustup easily enables you to install the nightly branch of rust and to use it by default:

Continue reading “Rust Nightly or Stable with Rustup and “may not be used” error”

Upgrading XMR-Stak Miners for the Monero7 Protocol Update

If you’re mining Monero, you might have heard of the currency getting some bad press because several botnets pushed miners out to their clients. This is one of the reasons why the core team decided to upgrade the protocol. You can find their official statement on getmonero.org.

Continue reading “Upgrading XMR-Stak Miners for the Monero7 Protocol Update”

Goroutines, Channels and awaiting Asynchronously Operations in Go

Golang has fantastic support for actions that are supposed to happen concurrently (at the same time) without blocking the thread, they are called goroutines and are used by simply putting go in front of a function.

The functions prefixed with go will run “on their own” and the rest of your code will continue to run.

In order to gather results or returns from the functions, you commonly make use of a channel. Channels are the collecting “buckets” that will receive what your goroutines write to them.

Continue reading “Goroutines, Channels and awaiting Asynchronously Operations in Go”

WordPress Filters Example for Beginners

WordPress comes with a lot of built in amazingness, one of those are filters. You can filter a lot of different things that WordPress outputs into your theme or from your plugin that originate from another place.

That means you can add or remove something to all titles, category names or widgets. That might not seem incredibly useful at first, but if you for example want to add a text at the end of a blog post or page while using an already existing theme, it can be very nifty.

Continue reading “WordPress Filters Example for Beginners”

How To: Detect Ad Blockers (adblock, uBlock, etc)

As a blogger or any other kind of publisher, you might be interested in if the user accessing your page right now is using an ad blocker or not. You might want to do that to display a box that encourages them to disable their ad blocker, because you’re trying to make a living off of blogging or to make more conscious decisions about how you’re going to layout your page.

If a user has an adblocker installed, you don’t have to reserve the space in your layout for the ad units, so you might as well get rid of them, so in this post we’re going to have a look at how we can determine if a user has installed an ad blocker like Adblock, Adblock Plus or uBlock.

Continue reading “How To: Detect Ad Blockers (adblock, uBlock, etc)”

Creating a Chatbot for Slack with Node.js in 17 lines

Creating a chatbot for Slack, the easy to setup group chat for teams was surprisingly easy. In this post we’re going to go over creating a chat bot that can reply to queries and take an action on simple keywords.

We’re going to use a node module called BotKit, which will enable us to connect to Slack easily. Actually Botkit offers a GUI (paid plans) and also connects to Microsoft Teams, Spark, Twilio and even Facebook.

One of the things I like the most about it is that you can kind of build a bot once and then re-use components across different platforms, which is super cool.

This post is written with

  • node 9.3.0

but will probably be up and downwards compatible fairly far since the dependency has been around for a while.

Continue reading “Creating a Chatbot for Slack with Node.js in 17 lines”

Managing Dependencies with Govendor (Heroku, Dokku)

govendor is a dependency manager for Go. Go get gets you pretty far when it comes to installing dependencies at first, but when you want to deploy your project or when you want to pin the right version of your dependency it’s not necessarily appropriate to use.

With govendor you can, like with npm or other tools specify which version of your dependency your project uses, which is a huge benefit for systems that are required to be somewhat stable.

Continue reading “Managing Dependencies with Govendor (Heroku, Dokku)”

Heroku Alternative: Dokku

Dokku is advertising itself as a self hosted Platform as a service and it lives up to its promise. You can fairly easily deploy a range of applications like Ruby, Node.js, Go and so on. Basically everything beyond your standard PHP CMS like WordPress (but also that ;)).

Dokku is easy to install and maintain. Under the hood it uses docker containers to run your apps. Dokku also comes as a pre-built app as a one click installer on Digital Ocean*. Since Dokku is very easy to install, there’s a couple of alternatives for you, for example Linode* or Vultr*.

Note: Dokku recommends at least 1GB or RAM.

Continue reading “Heroku Alternative: Dokku”

WordPress .htaccess and Permalink Cheat Sheet

WordPress is still incredibly popular and sometimes you have a to move a WordPress installation or you want to change your permalink structure. Regardless of your motivation, you probably don’t want to hurt your SEO.

I’ve spent some time writing and testing .htaccess for Apache2 redirects recently, so I thought I’d share a list of commonly needed WordPress redirects using regular expressions or just removing segments.

By default I’ll assume you use a .htaccess file that looks something like this:

Continue reading “WordPress .htaccess and Permalink Cheat Sheet”

Handlebars Custom Helpers and Chaining

Handlebars is a popular templating engine for JavaScript and in this post we’ll have a look at how to write a custom helper. On top of that, we’ll also look at pre-compiling a part of the template and returning the compiled HTML from the helper.

We’ll be using a simple express app with some handlebars views for the setup and we’ll just quickly walk through using handlebars with Express.

Continue reading “Handlebars Custom Helpers and Chaining”