JavaScript is getting array grouping methods

Grouping items in an array is one of those things you've probably done a load of times. Each time you would have written a grouping function by hand or perhaps reached for lodash's groupBy function. The good news is that JavaScript is now getting grouping methods so you won't hav … | Continue reading


@philna.sh | 8 months ago

Node.js includes built-in support for .env files

With the recent release of version 20.6.0, Node.js now has built-in support for .env files. You can now load environment variables from a .env file into process.env in your Node.js application completely dependency-free. Loading an .env file is now as simple as: node --env-file . … | Continue reading


@philna.sh | 8 months ago

Easy and accessible pagination links for your Astro collections

Generating pagination links is not as straightforward as it may seem. So, while rebuilding my own site with Astro, I released a component on npm as @philnash/astro-pagination that anyone can use in their Astro site. Read on to find out more. Pagination Pagination is something th … | Continue reading


@philna.sh | 10 months ago

Build bots on Bluesky with Node.js and GitHub Actions

Bluesky is the new social network in town and it's an exciting place to explore right now. I was fortunate enough to get an invite early on and take part in the early community. But Bluesky is not just a Twitter clone, it's an application on top of The AT Protocol, a (still being … | Continue reading


@philna.sh | 1 year ago

Create a CLI Chatbot with the ChatGPT API and Node.js

ChatGPT has taken the world by storm and this week OpenAI released the ChatGPT API. I've spent some time playing with ChatGPT in the browser, but the best way to really get on board with these new capabilities is to try building something with it. With the API available, now is t … | Continue reading


@philna.sh | 1 year ago

The yaml document from hell — JavaScript edition

I recently came across this blog post from Ruud van Asseldonk titled "The yaml document from hell". I've always heard that yaml has its pitfalls, but hadn't looked into the details and thankfully hadn't been affected, mainly due to my very infrequent and simple use of yaml. If yo … | Continue reading


@philna.sh | 1 year ago

Better two factor authentication experiences with WebOTP

Two factor authentication (2FA) is a great way to improve the security of user accounts in an application. It helps protect against common issues with passwords, like users picking easily guessable passwords or reusing the same password across multiple sites. There are different … | Continue reading


@philna.sh | 1 year ago

Alias your Mastodon username to your own domain with Jekyll

Mastodon is different to most online services. It is a federated network, so when you set up an account you need to choose a server to use. Your username then becomes a combination of your handle and that server you signed up to. For example, I am currently @philnash@mastodon.soc … | Continue reading


@philna.sh | 1 year ago

How to use the Bitly API in Ruby

Link shortening has been around for a long time and Bitly is arguably the king of the link shorteners. It has support for shortening long URLs as well as custom short links, custom domains, and metrics to track how each link is performing. For those of us with the power of code a … | Continue reading


@philna.sh | 1 year ago

Don't ever write your own function to parse URL parameters

Sometimes the platform we are building on provides more functionality than we can keep in our own heads. However, depending on the problem, we often find ourselves trying to write the code to solve the issue rather than finding and using the existing solution provided by the plat … | Continue reading


@philna.sh | 3 years ago

Restart your app and not your tunnel with ngrok and nodemon

When I am developing web applications in Node.js, I like the server to restart when I make changes, so I use nodemon. When I am developing an application that consumes webhooks or that I want to share publicly, I use ngrok. In fact, I like ngrok so much, I volunteered to help mai … | Continue reading


@philna.sh | 3 years ago

How to display dates in your user's time zone with the Intl API

Time zones are hard. Not only are there a lot of them, but they don't fit nicely into whole hour blocks, daylight savings time changes individual zones some of the time, and zones move around and change all the time. In short, it is a hassle.

A map of time zones across the world | Continue reading


@philna.sh | 3 years ago

How to stream file downloads in Node.js with Got

Got is a Node.js library for making HTTP requests. It has both promise and stream based APIs and in this post I want to explore how to use the stream API to download files. Using Got If you use HTTP libraries for making API requests, then the promise method is likely the best for … | Continue reading


@philna.sh | 3 years ago

I built a VSCode extension: ngrok for VSCode

Over the Easter weekend, a four day weekend characterised by lockdowns all over the world, I decided to use the extra time I had at home to start a new project and learn a new skill. By the end of the weekend I was proud to release my first VSCode extension: ngrok for VSCode. Wha … | Continue reading


@philna.sh | 4 years ago

Making a responsive Twitch Embed

I've been trying out streaming live code on Twitch which is a lot of fun. I wanted to share on my own site that I was streaming so I have built a page dedicated to it. The page will evolve, but one of the first things I wanted to include on it was an embed of my Twitch stream and … | Continue reading


@philna.sh | 4 years ago

The story of a mildly popular Ruby gem

The list on GitHub of repositories that depend on your repository is scary. There's something nice about writing and releasing a library, module, Ruby gem, whatever. It is code that you wrote that worked for you. There may be download numbers on the registry, but they are fairly … | Continue reading


@philna.sh | 4 years ago

Mistakes I've made treating file paths as strings

Some things you do as a developer can work for you for years, then turn around and bite you when you were least expecting. These are the things that you wish another developer had told you early in your career so you never had to make the mistakes. This post is about one of those … | Continue reading


@philna.sh | 4 years ago

How to find CFPs for developer conferences

So you've decided to speak at a developer conference? You have a story you want to share with your peers—how you built something, how you learned something new, how you became a better developer and how everyone else can too—but you need to find a stage on which to share this sto … | Continue reading


@philna.sh | 4 years ago

Testing signed and encrypted cookies in Rails

Recently I've been refactoring the tests for a gem I maintain and I needed to test that it sets the right cookies at the right time. But the cookies in use in the gem are signed cookies and that caused a slight hiccup for me. I'd never tested the value in a signed cookie before a … | Continue reading


@philna.sh | 4 years ago

How to Start a Node.js Project

Sometimes I write blog posts to remind myself what I’ve learned and sometimes I write them because someone else shares something and I want to remember that better. This post is one of the latter. | Continue reading


@philna.sh | 4 years ago

How not to sort an array in JavaScript

Array sorting is one of those things you don't spend too long thinking about, until it stops working for you. Recently I was working with array of items in JavaScript that were not sorting at all properly and completely messing up an interface. It took me way too long to work out … | Continue reading


@philna.sh | 4 years ago

2018 in review

I've never been one for writing a review of my year. This year I've found myself not only reading, but comparing myself to others' reviews. I realised that this is not particularly helpful, so decided I'd give myself something to compare myself to at the end of 2019. Thus, here i … | Continue reading


@philna.sh | 5 years ago

Service workers: beware Safari's range request

You’ve implemented a service worker to cache some assets. Everything is working well, your service worker is a success, you’re feeling good. But then… | Continue reading


@philna.sh | 5 years ago

Techniques for animating on the canvas in React

I recently experimented with audio visualisation in React on the Twilio blog. While I meant to teach myself more about the web audio API I found that I picked up a few techniques for animating in c... | Continue reading


@philna.sh | 5 years ago

Implementing one time passwords in Crystal

Crystal is still a young language, there aren't a lot of libraries available yet. For some this could be offputting, but for others this is a chance to learn about a language and provide useful tools for those also starting to use it. I've given a number of talks over time, some … | Continue reading


@philna.sh | 5 years ago

Git commands to keep a fork up to date

I’ve seen the following tweet about git making its way around Twitter recently: | Continue reading


@philna.sh | 5 years ago

Spring clean your dev machine

Development machines can build up such a lot of cruft. Old versions, oudated programs and unused caches litter the hard drive. It's good to take time once in a while to clean all of this up and free up some space. Here are some tips for commands you can run or actions you can tak … | Continue reading


@philna.sh | 5 years ago

Use the web share API easily with web components

I'm a fan of the web share API but I was not happy with my initial implementation of the API. It was all a bit complex for what is a very simple API. I wanted something more declarative and easier to use with a more generic fallback for when the share API was not available. I've … | Continue reading


@philna.sh | 6 years ago

CSS: select first-of-class with the subsequent sibling combinator

There are a whole bunch of CSS selectors available to web developers, but sometimes there's still not enough. I found this recently when building the speaking section of my site and wanted to use the non-existent :first-of-class pseudo class to apply some styles. The problem The … | Continue reading


@philna.sh | 6 years ago

gzip a file in Ruby

At the start of the year I looked into how to better compress the output of a Jekyll site. I'll write up the results to that soon. For now, here's how to gzip a file using Ruby. Enter zlib Contained within the Ruby standard library is the Zlib module which gives access to the und … | Continue reading


@philna.sh | 6 years ago