The batchWriteItem operation DynamoDB supports the batchWriteItem function that consolidates multiple item writes in a single request . It’s a great performance improvement as network overhead is a significant factor with DynamoDB and sending fewer requests ... more
Backoff algorithm A Javascript application made a fetch call to a remote server and it failed. How should it retry the request so that it eventually succeeds while also minimizing the calls made? A backoff algorithm makes sure that when a target system ... more
The problem to solve In one of my projects, I needed to assemble a PDF document where different pages came from different sources and the result document had to contain all of them in order . I used the pdf-lib for everything related to documents. With ... more
Try-with-resources A recurring pattern is to run some initialization code to set up some resource or configuration, then use the thing, and finally do some cleanup . It can be a global property, such as freezing the time with timekeeper, starting a Chrome ... more
Refactoring to async/await Javascript Promises are kind of a legacy things now that async/await has widespread support, but they are still the engine that drives everything asynchronous. But constructing one and using the then functions for chaining is ... more
Run commands as an AWS role with AWSudo AWSudo is an easy-to-use CLI utility to run a command as an AWS role. It works similar to the traditional sudo used widely in most Linux-based systems, which provides an easy way to run something as the root user. ... more
Tempfiles use-cases Recently, I’ve been working on a static site generator, and I needed to implement how the sitemap.xml is generated. The whole project was a Node HTTP server, generating the whole site on-the-fly, no files are written to the disk. To ... more
Initially, Lambda only supported callbacks with Javascript handlers. Back then in 2014 it was the common way to handle asynchronicity as async/await was nowhere near as mainstream as it is today. Moreover, the SDK functions also used callbacks so it ... more
In the first article, we’ve covered how async/await helps with async commands but it offers little help when it comes to asynchronously processing collections . In this post, we’ll look into the some and the every functions that are used for a more efficient ... more
Bash scripts are infamous for their maintainability, but with pipes and small functions, the result can be terse, readable code. And it’s not only code quality: writing concurrent applications is a hard task, but it’s easy to achieve in Bash by relying ... more
In the first article, we’ve covered how async/await helps with async commands but it offers little help when it comes to asynchronously processing collections . In this post, we’ll look into the filter function, that has probably the most unintuitive ... more
In the first article, we’ve covered how async/await helps with async commands but it offers little help when it comes to asynchronously processing collections . In this post, we’ll look into the forEach function, which is helpful when you need to run ... more
In the first article, we’ve covered how async/await helps with async commands but it offers little help when it comes to asynchronously processing collections . In this post, we’ll look into the map function, which is the most commonly used as it transforms ... more
In the first article, we’ve covered how async/await helps with async commands but it offers little help when it comes to asynchronously processing collections . In this post, we’ll look into the reduce function, which is the most versatile collection ... more
Asynchronicity in Javascript The new async/await is an immensely useful language feature that hides the complexity of asynchronous code and makes it look like it’s working in a synchronous way. The code example below does not look complicated at all, ... more
Automatic newsletter For quite some time now, I’ve been writing the JS Tips newsletter, which is a WebDev-related tip sent out every week. Initially, I scheduled the tips manually, creating an email campaign on MailChimp every week. The emails are in ... more
Why PlantUML? I like text-based image generation for illustrating a point in an article. And I’ve found that putting images, any type of image, to break the text flow helps a lot with understanding. Even when I see some cat pictures strewn over it helps ... more
SPA with Terraform As covered in the previous article, Terraform can run a build script as part of the state refresh process, i.e. during terraform plan and terraform apply . This capability opens the way to automatically compile a project in a way that ... more
Terraform build Terraform is to deploy infrastructure, and as a consequence, it can copy code that does not require compilation. As an illustration, a Lambda function does not even need to be in a separate directory but it can be embedded in the Terraform ... more
SNS notifications to users Let’s say you have a monitoring app that pings customers’ pages and sends a notification when there is a problem. In AWS, the service for notifications is SNS, where you create a topic, customers subscribe to it, then you can ... more
SNS notifications to users Let’s say you have a monitoring app that pings customers’ pages and sends a notification when there is a problem. In AWS, the service for notifications is SNS, where you create a topic, customers subscribe to it, then you can ... more
CORS headers CORS headers come into play when a client makes a cross-origin request. In that case, the server must indicate that it allows the cross-origin operation otherwise the browser will reject the request. The two important points are that the ... more
CORS headers CORS headers come into play when a client makes a cross-origin request. In that case, the server must indicate that it allows the cross-origin operation otherwise the browser will reject the request. The two important points are that the ... more
Develop Lambdas locally Getting started with Lambdas usually involves a lot of trial-and-error which means a lot of redeploys. Change something, deploy, refresh in the browser. While the deployment can be fast, it still takes multiple seconds, not to ... more
Develop Lambdas locally Getting started with Lambdas usually involves a lot of trial-and-error which means a lot of redeploys. Change something, deploy, refresh in the browser. While the deployment can be fast, it still takes multiple seconds, not to ... more
Background Terraform’s archive_file is a versatile data source that can be used to create a zip file that can be feed into Lambda. It offers several ways to define the files inside the archive and also several attributes to consume the archive. It’s API ... more
Background Terraform’s archive_file is a versatile data source that can be used to create a zip file that can be feed into Lambda. It offers several ways to define the files inside the archive and also several attributes to consume the archive. It’s API ... more
Routing with CloudFront Recently I got a question about Cloudfront where there were multiple backends and the asker wanted to bring everything under a single distribution. I then realized that AWS’s naming does not help much in this case. The different ... more
The problem with the PlantUML server As of late, I’ve re-discovered PlantUML and how much easier it is to generate diagrams with text instead of clicking around with the mouse. I haven’t been following its development for quite some years now, and I’m ... more
When Java 8 introduced Streams and Lambdas it was a big change, enabling functional programming style to be expressed with much less boilerplate. While recent versions did not add such impactful features, lots of smaller improvements were made to the ... more