hello.js

var please = require('share');
console.log('thank you');

NEW !!!

Tuesday, 12 January, 2021 UTC

How to use DynamoDB batch write with retrying and exponential backoff

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


Friday, 8 January, 2021 UTC

How to implement an exponential backoff retry strategy in Javascript

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


Friday, 1 January, 2021 UTC

RxJS: How to make an ordered mergeMap operator

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


Friday, 11 December, 2020 UTC

What is the async disposer pattern in Javascript

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


Tuesday, 28 April, 2020 UTC

How to refactor a Promise chain to async functions

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


Tuesday, 21 April, 2020 UTC

Easily run CLI commands as an AWS role with AWSudo

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


Tuesday, 7 April, 2020 UTC

Secure tempfiles in NodeJS without dependencies

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


Tuesday, 31 March, 2020 UTC

Comparing async Javascript functions and callbacks on AWS Lambda

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


Tuesday, 24 March, 2020 UTC

How to use async functions with Array.some and every in Javascript

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


Tuesday, 17 March, 2020 UTC

How to Bash and jq: generate statistics for a REST API

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


Tuesday, 10 March, 2020 UTC

How to use async functions with Array.filter in Javascript

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


Tuesday, 3 March, 2020 UTC

How to use async functions with Array.forEach in Javascript

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


Tuesday, 25 February, 2020 UTC

How to use async functions with Array.map in Javascript

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


Tuesday, 18 February, 2020 UTC

How to use async functions with Array.reduce in Javascript

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


Tuesday, 11 February, 2020 UTC

Asynchronous array functions in Javascript

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


Tuesday, 28 January, 2020 UTC

Automatically schedule emails on MailChimp with RSS and AWS Lambda

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


Tuesday, 31 December, 2019 UTC

How to integrate PlantUML into other software

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


Tuesday, 17 December, 2019 UTC

How to deploy a single-page application with Terraform

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


Tuesday, 10 December, 2019 UTC

How to run a build script with Terraform

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


Tuesday, 3 December, 2019 UTC

How to target subscribers in an SNS topic

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


Tuesday, 3 December, 2019 UTC

How to target subscribers in an SNS topic

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


Wednesday, 13 November, 2019 UTC

Is Access-Control-Allow-Origin: * insecure?

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


Tuesday, 12 November, 2019 UTC

Is Access-Control-Allow-Origin: * insecure?

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


Tuesday, 22 October, 2019 UTC

How to reproduce a Lambda function's environment variables locally

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


Tuesday, 22 October, 2019 UTC

How to reproduce a Lambda function's environment variables locally

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


Tuesday, 15 October, 2019 UTC

How to define Lambda code with Terraform

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


Tuesday, 15 October, 2019 UTC

How to define Lambda code with Terraform

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


Tuesday, 10 September, 2019 UTC

How to route to multiple origins with CloudFront

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


Wednesday, 14 August, 2019 UTC

Adding continuous rendering to the PlantUML server

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


Thursday, 8 August, 2019 UTC

New language features since Java 8

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