Invite-only microsites with Next.js and AirTable
I recently needed to create an invite-only Next.js-powered microsite (for my wedding 🌸) and in this article I’m going to show you how I went about creating invite codes and how I implemented code validation in the app, using Next.js API endpoints and AirTable as a lightweight backend. The use case and the tech stack 24 June 2022 was the best day of my life. Seriously, I got married with the human being I love the most and everything was just perfect. But we are not here to talk about my wedding, right…
Create resources conditionally with CDK
Did you ever need to create a resource based on a condition in CDK? I recently needed to do that and finding a viable solution for this problem took me longer than I originally anticipated. In this article I will try to summarise what I learned and present my solution. In short, we will learn about the CfnCondition construct and how it can be used to create CloudFormation conditions. Then we will see how to attach condition to low level construct. Throughout this article, we will discuss these concepts with…
Provision an Ubuntu-based EC2 instance with CDK
You are using CDK and you need to provision an EC2 instance. What if you prefer to use Ubuntu over Amazon Linux? In this article, we will see exactly how to do that, and, hopefully, we will learn a bunch of interesting things in the process! I have to be honest, I am more on the Ubuntu camp than I am in the Amazon Linux one… It’s a subjective preference. I find myself more comfortable with apt, snap, systemd and other Ubuntu nuances than I am with yum and other things in Amazon Linux. Plus, I find easier to…
Middy 1.0.0 is here
Middy, the Node.js middleware framework for AWS Lambda, has finally graduated to 1.0.0! A long awaited milestone for the project. In this post we will discuss what middy is and what are the main features of this first stable release. What is middy If you are hearing about middy for the first time, middy is a middleware framework for AWS Lambda written in Node.js. Middy has the goal to simplify the way you write Lambda code, essentially by providing a convenient middleware abstraction (similar to the ones…
Lean NPM packages
Every developer on the planet knows how modular Node.js and the JavaScript ecosystem have become. This is probably due to the great job that package management systems and registries like bower (discontinued) and npm carried over in the last few years. I personally believe that this is also a consequence of the “many small modules” philosophy that has been popularised within the JavaScript ecosystem. This is great, but all that glitters is not gold… Look, for instance, at this picture for a second: Yeah…
Fastify and Preact for quick web app prototyping
In this article I will show my setup to build and share web apps prototypes using Fastify and Preact, two technologies that I love. I will also use htm, a library that can be easily integrated with Preact to define DOM elements in a very expressive and react-like way (like JSX), without having to use transpilers like Babel. Finally we will see how to dockerize a sample app built with this setup. This will make the app easy to share with co-workers and friends. I came up with this stack, few weeks ago when I…
JavaScript iterator patterns
In this article we will explore different ways to create iterators and iterable values in Javascript, specifically functions, iterators, iterables and generators. JavaScript is a very flexible language and most often you can achieve the same goals in many different ways, iterators are no exception! Wikipedia defines iterators as follows: In computer programming, an iterator is an object that enables a programmer to traverse a container, particularly lists. Various types of iterators are often provided via a…
Emerging JavaScript pattern: multiple return values
In this article, I want to explore an interesting pattern that I am seeing more and more in JavaScript code which allows you to return multiple values from a function. You probably know already that JavaScript does not support multiple return values natively, so this article will actually explore some ways to “simulate” this behavior. One of the most famous usages of this pattern I have seen recently is within React Hooks, but before delving into that, let’s see what I mean with “multiple return values” by…
My Serverless talk at Shift conference in Split
This June, I had an amazing experience talking again about Serverless and how we use it at Planet 9 Energy at the recent Shift Conference in Split, Croatia. In my talk titled ”Serverless: The pros and cons of building a company without infrastructure”, I tried to address what Serverless is and why is becoming such a big thing, also exploring what I believe are the pros and cons of this new paradigm. The experience was great and I was super happy to have a chance to share the stage with extraordinary people…
My Universal JavaScript Web Applications talk at Codemotion Rome 2017
Last month (March 25th) I had the pleasure of delivering again my Universal JavaScript talk in a Codemotion Event, this time in Rome. As expected it was a super interesting event and it gave me the chance to meet fantastic people, attend inspiring talks and refine my presentation. Judo Heroes Version 2 For this occasion, I updated my common Universal JavaScript Judo Heroes to ”Version 2“. I believe this new version looks a bit more polished and easy to understand, plus it features a number of other relevant…
Unshorten (expand) short URLs with Node.js
Short URLs have been an invaluable tool for social media marketing for so many years and we are now used to seeing them everywhere. Most of the credit probably goes to URL shorteners services like Bit.ly, Goo.gl, YOURLS and Rebrandly that popularised the concept and made easy for everyone to start creating short URLs. When working with URLs in some automation scenarios like analytics, information crawling, data retrieval, etc. it can be important to resolve (or ”unshorten” or ”expand”) short URLs, which…
My Serverless & AWS Lambda talk at Node.js Dublin January 2017
Last January I had the pleasure to share the stage with the great Padraig O’Brien to talk about how we use Node.js, AWS Lambda and the Serverless framework at Planet9 Energy. The talk was hosted by the monthly Node.js Dublin Meetup at Intercom Dublin office, as usual, a very cool location for this kind of tech talks. Apart from having a great chance to show off my über cool Super Mario T-shirt for about 45 minutes, Podge and I had some good time discussing the following topics: What does ”Serverless” mean…
My Universal JavaScript Web Applications talk at Codemotion Milan 2016
Yesterday (25/11/2016) I had the pleasure of delivering a talk about Universal JavaScript at Codemotion Milan 2016. It was a great fun and I was very happy to meet such a big pool of technology enthusiasts and professionals all in one places. I’m already looking forward for the next edition! Video Update (12-12-2016): a video recording of the talk has been published by the folks at Codemotion: Slides deck If you are interested in my talk you can find the slides on Slides.com: Commentary Here follows also a…
How to crack a JWT token: two articles about distributed computing, ZeroMQ & Node.js
In the last 2 weeks I add the pleasure to release an article (in two parts) in collaboration with RisingStack, one of the most famous companies in the Node.js ecosystem. The article explains how to build a distributed application using Node.js and ZeroMQ and provides an example that I believe it’s very actual and interesting: a JWT token cracker. If you are into Node.js, ZeroMQ, security or distributed application you can read the two articles in the community section of RisingStack. ZeroMQ & Node.js…
Two Interviews about Node.js, JavaScript and being a book author
In the last month I had the pleasure to seeing published two interviews regarding my life as developer with Node.js and JavaScript and about being a book author with Node.Js design patterns second edition. The first interview was made with the Packt Publishing team and it was published in their own website: With Node.js, it’s easy to get things done The second interview was made by Thomas Peham, marketing manager at UserSnap: Meet the community: Luciano Mammino, software developer from Sicily I think both…
To promise or to callback? That is the question...
You are building the next cool JavaScript or Node.js module with a lot of asynchronous functions and you are very happy about it. At some point a terrible doubt assaults you: Should my API offer support for callbacks or should it be promise based? In this article we are going to show a very simple way to add support for both promises and callbacks in our asynchronous modules, this way we can make everyone happy and our libraries much more flexible. The problem Promises can be used as a nice replacement for…
Introducing Gulp cozy - Manage your gulp tasks in a cozier way
Gulp-cozy is an experimental NPM package that allows you to organize your Gulp tasks in a more modular way with simplicity and “cozyness” in mind. Rationale Ever found yourself digging into a gigantic monstrous Gulpfile with hundreds of functions and tasks scattered all around? If it happened to you I am sure you can tell that it’s not a great feeling… That’s the reason why I created this small module as an attempt to help with keeping yourself cozier (and happier!) when working with Gulp. In a way it…
Gulp and FTP: update a website "on the fly"
In this post I will explain you how to use Gulp to interact with the files on your server through FTP. You will learn how to watch the files you are editing on your local machine and automatically synchronize them with your server as they change and how to setup a task to launch an FTP deploy on demand. Premise Few days ago I was assigned to take care of updating few sections on a legacy website which development environment is currently accessible only through FTP. So no local virtualized development…
Versioning and deploying a static website with Git, Flightplan and Nginx
Do you ever wondered how to manage the versioning and deployment process of a website? It seems to be a very interesting yet complex topic for which there are already thousands of different solutions. In a recent collaboration with Usersnap I had the pleasure to write a very detailed article for their blog that proposes a solution based on Flightplan.js, Git and Nginx. My solution is very simple, it requires very few dependencies on your system (Git and Node.js) and it has been thought to give you the…
Introducing flickr-set-get a command line app to download photos
I recently developed a small command line app that allows you to download an entire gallery from Flickr, it’s called flickr-set-get and you can find it on NPM and GitHub. Why? To be honest I had myself the need to download a large set of photos (more than 400 photos) from Flickr and I didn’t wanted to do it manually. I also wasn’t able, after a quick search, to find something simple to solve this task. Given that I am currently getting into deep of Node.js this was the perfect chance to develop something…
Integrating Twig.js and BazingaJsTranslationBundle
Recently I had the need to run a twig template that uses the trans filter on my frontend using twig.js, a pure JavaScript port of twig written by the good Johannes Schmitt. The JavaScript version does not handle all the functionalities offered by the original PHP version (even if it goes pretty close) and in particular it does not natively handle the trans filter. So, at first, I got a JavaScript runtime exception on my page when trying to use the template. Luckily enough the JavaScript version of twig is…