Category Archives: Tips & Tricks

Convenient Semaphore with DynamoDB

DynamoDB is a non-blocking asynchronous storage, and it is great. Mostly. However, sometimes you just need to ensure that only one instance of script accesses a certain share of information in your table. In my case it was operation or purgin+rebuilding records, which under race conditions would result in a massive data loss.

So, I decided to build a semaphore. Continue reading

RESTful API Tester

For those of us who develop or work with backends with RESTful APIs, I wrote a little tool at http://x2node.com/api-tester/ that allows using a browser to make calls to the backends, mostly for testing. It’s useful when the application’s UI part is not yet ready but you already need to start making calls to the web-service you’re working on. The tool is part of the X2 Framework for Node.js ecosystem, but it’s generic and will work with any RESTful web-service. Enjoy!

A fix for Drupal 8’s broken preview

Drupal 8 is still beta-ish in so many aspects, that “workarounds” is becoming a separate genre of Drupal development tips and tricks. 

The today’s workaround is for the bug in “node preview” functionality. It is not frequently used, but can be rather convenient for large websites with moderation enabled. The bug can be spotted only when CSS styles, applied to the  node/page template rely on the  <body> CSS classes,  namely the core-added  page-node-type-[node bundle] body class. It helps to effectively distinguish different node templates, and therefore are widely relied on by front-end developers. However, in preview mode, this class appears entirely missing, which breaks the styling.

Continue reading

Drupal 8 Migration: Field Updates

By default, the migrate module in Drupal 8 updates existing nodes by completely overwriting all the fields in the target node with the data from the migration. But what if your client has modified content on the target (D8) system, and still wants to update the content with newly-mapped fields? For instance, there is a “description” that has been updated after the first migration, but now the client wants “subtitle” field to be migrated (which was empty or not present during the first pass), without overwriting the description field changes. Continue reading

Critical Above-the-Fold CSS for the rescue

Nowadays site loading time became a very important parameter, especially when it comes to the search engine rankings.

If you’ll test your site with Google Pagespeed tool, it will probably show that your site has some issues with content-blocking stylesheets. This means that the browser won’t paint content to the screen until your CSS has been downloaded. To fix this issue, Google recommends us to split our styles into two parts: critical (above-the-fold) and non-critical. Critical CSS should be inlined in the header meanwhile non-critical needs to be loaded asynchronously, so a user could see styled content as soon as possible. Continue reading