String translations are always a bit a pain in the ass for drupal. Luckily, in drupal 8 the function is rather easy.
Snippet on how to remove all users with a certain role in drupal.
I play a lot with importing and exporting content lately. When I remove content, the created menu items need to be removed automatically. Here's a snippet on how to delete all links in a menu.
Goodbye preprocess functions! Welcome to drupal 8. We use a nice plug-in to get control over our menu item and to show html inside the title. In this case we show a counter of the amount of messages a user has.
Some parts of custom entities seem different from nodes, but mostly they aren't. Small snippet for showing a created date of a custom entity in a controller
Quick tutorial on how to serve a PDF that downloads automatically in your browser in drupal 8.
Sometimes simple tasks like changing a page title of a system page can be hard. Luckily, drupal 8 provides clean ways to do that. In this tutorial some info about RouteSubscribers.
When creating seed data, for example in your modules hook_install() script, creating a menulink can be necessary. This snippet shows how.
Getting the output like you want it to be an be quite a challenge in drupal. This snippet shows you how you can add markup to your form labels in drupal 8.
In drupal 8, each entity will get a UUID assigned automatically. With this snippet you can check if it is a valid one.
In drupal 7 we had some contrib modules using a tag to make subtitles in our menu. In drupal 8 I try to avoid contrib modules on my menu items. Here's a hint on how to get it to work.
The chosen widget is my default option for select widget. This snippet shows you how to add the placeholder in a form alter.
For a few months I'm working in my spare time on a module that can import instagram feeds and turn it into nodes. And on top of that, a nice javascript extension to make it look beautiful out-of-the box.
A thing developers can forget while testing, is to make sure all functionality of your module is stable when used in the context of ajax. Some plugins might stop working after an ajax call on the page. This is how to prevent such thing.
It is a bit strange that the name field (which functions like the node's title field) can be only 50 characters long. The snippet I'd like to share with you, makes it 255 long.
Drupal ships with an ugly 404 page by default. in this tutorial I learn you how to add markup to it.
There is a great shortcut I use a lot when dealing with entity references (the're great, right). I thought I'd share the snippet here.
We all well know the functions to check if a node is published or not, but what about a custom entity?
You create a custom controller and want to show a table that resembles the core back-end tables. This snippet shows you how to do it.
A very recurring thing you would do is to get the current node id of the visited page. Here are two ways of doing it programmatically.
Where in drupal 7 you would typically use something like drupal_get_path_alias(), this is different in drupal 8.
Short snippet that shows how to get url parameters in drupal 8. Where in drupal 7 you would have to do some $_GET or work with args(0), you now have a clean function to do this.
I had to loop over some images in Twig and dynamically adding image styles to them. Without using contrib this seemed a bit hard to do. I found a fix and I share it here with you.
A common issue you would have when using javascript plug-ins is that you do not want them to be added to your version control. You would want to add it to the main composer.json file that has to donwload the library for you. Here is how the solution works.
One thing that bothers me quite a lot is the error when you try to import existing configuration into a new drupal 8 website. I resolved this by adding a custom drush command that gets fired right before config import.
Saving a link field is quite different from saving a text value in drupal 8. here's how its done.
Populating geolocation field programmatically in drupal 8 is different from normal field values. This snippet does the trick:
When using content moderation, the view_unpblished module does not work. But I really needed to get a user role to see all nodes created of this type and have access to it. With the following snippet, I fixed this. 
Sometimes you forgot to uninstall a module when you removed it. To keep thing clean, uninstall the module using the following drush script.
A thing that is very nice about drupal 8 is the flexibility of views In this tutorial, a snippet about how to show a 'total' count of results of some number fields of a table.
I encountered a problem while working on a big migration. The client wanted to reuse files and images, so I added entity browser functionality. The problem however was that views does not provide a preview image for files. Therefore I created a small module.
When importing tags, or when in development, you would sometimes need to delete all terms from a vocabulary. This snippet does the trick for you.
Twig is the theme engine in drupal 8 sites. This snippet how to link to nodes correctly, without using preprocess functions to do it.
Twig comes with quite some handy functionalities. Date formatting is an example. In this snippet an example of how to show the created date in a drupal 8 time format. 
Sometimes you need a body text that is trimmed. No need to install contrib modules.
Use global theme javascript only in a few occasions. You should make sure javascript is only used on the right places. This snippet shows you how to load javascript when a specific view is loaded only.
Batch processes give you a hard time when using them for the first time. This module example will handle every aspect of it!
A much needed functionality is how you get the url of an image style form the uri (f.e. in a node object). This snippets helps you accomplish this.
When importing content, it is really important you also think about meta tags on your import. Here's how to save them to nodes.
Drupal 8 is becoming more and more API-first based. This means a lot of imports and exports of data will be done. A thing you might face here, is that the updating of entity reference fields is a bit tricky. Here I'll show you how it is done.
Paragraphs give great power to drupal 8. This code will show you how you can add them programmatically, for example when importing stuff.
Sending files attached in e-mails is a necessary feature for a lot of applications. This snippet shows you how to attach a managed file f.e. an invoice to your custom e-mail.
I'll share with you some code on how to cache blocks per user. The secret lies in using the right cache context on the build() function of your block.
Here's a html e-mail template example for sending html e-mails.
Configuration management is great. But you'll encounter some difficulties at first when importing existing config to a new site. A typical error is the "Entities exist of type" error. Here's how to fix them.