From time to time it comes in quite handy to import configuration from other websites into yours. You site uuid is unique though, with the following snippet you get yours.

drush config-get "system.site" uuid

 

A typical setup is one where you would redirect all non www and http requests to https://www.domainname.com. I prefer to keep my .htaccess file in version control also. With the following snippet, I get it the way I want it.

Easy snippet to get your current language:

// Get current language code
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();

 

I started using an automated script for my drupal installation, which will generate an admin user. But, after installation I have to edit the password.
I like a good user interface for webmasters, so a clear menu path is necessary. For the admin toolbar dropdowns, I usually create subitems programmatically. 
While there are many ways to debug your errors, sometimes just seeing the full errors in your screen works best.
I recently had an issue with ckeditor inside pop-ups (modals) in drupal 8. This snippet is the solution to it.
I recently found out a bug I wasn't aware of. My default text format wasn't saved on a body field. I attached a snippet to fix this.
I've had some difficulties loading a list of translated terms. More in particular I didn't want to show the untranslated terms, but ONLY the ones that were already translated in the current language
A snippet with submitForm to redirect your form to another page and pass a variable.
With this snippet, you will be able to render a list of tags in drupal 8.
By default, users with the permission of 'administer users' cannot assign roles on the user registration form. With this snippet you can, but make sure to hide the 'administrator'-role for your users.
I encountered this bug in a Display suite 2-column lay-out where I wanted the left region to disappear when empty. 
If you like to use the search api or a custom Views page for your search result I personally like to use the default search block and redirect it to my results page.
When creating custom blocks, sometimes you need to make sure the block is never cached f.e. when including dynamic links. 

In this case I created a custom entity called 'submenu'. In my custom module a used HOOK_LINK_ALTER to make the submenu (which contains a textfield) visible on hover. I used the code below to render my custom entity content:

In some cases you want to embed a view inside your custom module. The views_embed_view() function is the way to go. With this little snippet, you can render any view.
With this simple snippet, menu items are saved as expanded when you save your node. In some cases, this is a necessary functionality.
When using lazy loading of images, I encountered an important issue. Social sharing engines like Facebook can't read placeholder images. In this drupal 8 tutorial we'll fix this issue by creating a small custom module handling image tokens.
Ever looked at Pinterest or Google images and wondered how to achieve this nice effect of loading in images? One of the things that frustrated me building drupal websites is the lack of nice front-end libraries. Fancyload solves the problem!