RSSAmplifier

Blog

Robert Pearce's blog

Posts on JavaScript, Nix, Haskell, Ruby, Bash, and more.

robertwpearce.comRSS feed ↗51 posts

Latest posts

Neovim: All In

This is an accounting of how I recently went all-in on Neovim with its Lua-based configuration ecosystem. Here is my nvim config at time of writing . This folder just needs to live in $XDG_CONFIG_HOME (typically, ~/.config ), and in my case, I symlink it from my dotfiles to there . In this short post, I’ll share about the switch, some screenshots, and list the tools I’m using at the time of…

Content hashing static assets to break caches with md5sum and bash

The Problem When I make something for the web, I have plenty of “static assets”: CSS files, JS files, and images. In my HTML files, I reference their sources as you might expect: < link rel = "stylesheet" href = "./styles.css" /> < script async src = "./scripts.js" ></ script > < img src = "./cool-image.avif" /> But when a browser downloads these, it will note the source URLs and cache the static…

Theming static sites

In this post, we’re going to dive into some useful patterns for theming static websites that we can start using today to respect users’ system preferences and provide them with custom ways of viewing our content. This post is sponsored by Flavio Corpa (kutyel) , and if you’re curious about Elm, Haskell, or functional JS, check out his work! If you’d like to sponsor me writing about a topic, check…

People are so much more than cogs

I’m re-reading the Dune series for the nth time, and this time, I’m doing it with a group via the excellent Gom Jabbar podcast . There are some seriously problematic themes in God Emperor of Dune , but the quote below has stuck with me for weeks and has illuminated life for me in a way I haven’t experienced in years. "I point out to you […] a lesson learned from past over-machined societies which…

One does not simply use GHCup on macOS M1

Intro The GHCup tool is the official installer for core Haskell tools: cabal , stack , haskell-language-server , and ghc . I usually use Haskell through Nix (I’m liking devenv.sh , too), and I’ve also used it through Docker, but I was frustrated with build times and wanted to try the official Haskell way. Unfortunately, I had a rough time trying to use GHCup on a macOS M1 (Ventura 13.2.1), so I…

The hakyll-nix-template Tutorial

If you’re looking to use hakyll with nix to build static sites, this reference article was made for you! We will be working with the hakyll-nix-template , so go ahead and pull that up in a new browser tab. Its README also contains info on all the features that are provided. Update, July 2026: I’ve given the template a solid overhaul since I first wrote this, so I’ve gone back through the article…

How To Lose Functional Programming At Work

Hi! If you’re looking to lose functional programming at work, here are a bunch of mistakes I’ve made on JS-heavy web teams over the years that can help you do the same. Enjoy! Note: if sarcasm and self-deprecation aren’t your thing, you can skip to the real-talk takeaways . PDF version Here is the much prettier PDF version that is also useful for sending to your teammates or using in your own…

Hakyll Pt. 6 – Pure Builds With Nix

Special thanks to Utku Demir for review and constant inspiration. This is part 6 of a multipart series where we will look at getting a website / blog set up with hakyll and customized a fair bit. Pt. 1 – Setup & Initial Customization Pt. 2 – Generating a Sitemap XML File Pt. 3 – Generating RSS and Atom XML Feeds Pt. 4 – Copying Static Files For Your Build Pt. 5 – Generating Custom Post Filenames…

Build Your Team an Accessible, Shareable Component Library

Today we’re going to dive into building a frontend component library from start to finish that you can share privately with your team or publicly with everyone! By the end of this post, you will be able to use TypeScript , React , Storybook , and more to provide a simple way to create accessible components that can be included in all of your projects. If you’d like to skip to the code, here is the…

Catch Low-Hanging Accessibility Fruit with axe-core

Deque Systems , in addition to having an accessibility-testing browser plugin , has an open source package, axe-core , that can help you determine if HTML contains obvious accessibility issues. That tool can be used on its own in your tests, or you can turn it into a Promise and use it like this! import axe from 'axe-core' const isA11y = html => new Promise (( resolve , reject ) => { axe . run (…

JavaScript: Writing a Functional Programming-Style map Function

Many thanks to Helen Durrant for reviewing this post and offering stellar suggestions. In this post, we will write a functional programming-style implementation of JavaScript’s map function that not only works with Array but any data structure that implements a map method. Such data structures are known as Functors . Some examples of Functors are the algebraic data types 1 Maybe and Async (prior…

JavaScript: Understand Array.prototype.map by Reimplementing It

In this post, we will reimplement JavaScript’s Array.prototype.map function in order to not only understand map better but also to get an idea of how to implement instance methods on Array.prototype . If you’d prefer to see a ~5 minute recording of what we’ll do in this post, you can watch the video below; otherwise, carry on! Initial Example: Use map to Convert Film Data to HTML Strings First, we…

Announcing react-medium-image-zoom v4

2023-02-12 update: this article’s content is valid for the v4, but it isn’t really for the v5 version. tl;dr => I’ve release v4 of react-medium-image-zoom , and you should consider using it for zooming images. Check out the Storybook Examples to see it in action. History of react-medium-image-zoom I wrote the first version of react-medium-image-zoom in 2016 in a 6m x 6m flat in London that my…

Hakyll Pt. 5 – Generating Custom Post Filenames From a Title Slug

2023-02-03 update: I published the slugger package on Hackage back on 2021-07-28, so that is available for use if you’d rather use a package. This is part 5 of a multipart series where we will look at getting a website / blog set up with hakyll and customized a fair bit. Pt. 1 – Setup & Initial Customization Pt. 2 – Generating a Sitemap XML File Pt. 3 – Generating RSS and Atom XML Feeds Pt. 4 –…

Hakyll Pt. 4 – Copying Static Files For Your Build

This is part 4 of a multipart series where we will look at getting a website / blog set up with hakyll and customized a fair bit. Pt. 1 – Setup & Initial Customization Pt. 2 – Generating a Sitemap XML File Pt. 3 – Generating RSS and Atom XML Feeds Pt. 4 – Copying Static Files For Your Build Pt. 5 – Generating Custom Post Filenames From a Title Slug Pt. 6 – Pure Builds With Nix The…

Hakyll Pt. 3 – Generating RSS and Atom XML Feeds

This is part 3 of a multipart series where we will look at getting a website / blog set up with hakyll and customized a fair bit. Pt. 1 – Setup & Initial Customization Pt. 2 – Generating a Sitemap XML File Pt. 3 – Generating RSS and Atom XML Feeds Pt. 4 – Copying Static Files For Your Build Pt. 5 – Generating Custom Post Filenames From a Title Slug Pt. 6 – Pure Builds With Nix The…

Hakyll Pt. 2 – Generating a Sitemap XML File

This is part 2 of a multipart series where we will look at getting a website / blog set up with hakyll and customized a fair bit. Pt. 1 – Setup & Initial Customization Pt. 2 – Generating a Sitemap XML File Pt. 3 – Generating RSS and Atom XML Feeds Pt. 4 – Copying Static Files For Your Build Pt. 5 – Generating Custom Post Filenames From a Title Slug Pt. 6 – Pure Builds With Nix The…

Hakyll Pt. 1 – Setup & Initial Customization

This is part 1 of a multipart series where we will look at getting a website / blog set up with hakyll and customized a fair bit. Pt. 1 – Setup & Initial Customization Pt. 2 – Generating a Sitemap XML File Pt. 3 – Generating RSS and Atom XML Feeds Pt. 4 – Copying Static Files For Your Build Pt. 5 – Generating Custom Post Filenames From a Title Slug Pt. 6 – Pure Builds With Nix The…

Ramda Chops: Map, Filter & Reduce

Thanks to Jillian Silver , Patrick Eakin and @zerkms for their review of this post. The map , filter and reduce methods on Array.prototype are essential to adopting a functional programming style in JavaScript, and in this post we’re going to examine how to use these three concepts with ramda.js . If you are unfamiliar with these three concepts, then be sure to first read the MDN documentation on…

Ramda Chops: Safely Accessing Properties

Thanks to @joshsloat and @zerkms for their review of this post. One of the most prevalent causes of bugs I’ve seen in latter-day JavaScript revolves around expectations with regard to data modeling. With the rise of react , redux , et al, many of us store our application state in an object whose keys and hierarchy can easily change, leaving us sometimes with or without values that were in fact…

Ramda Chops: Function Composition

Thanks to @evilsoft and @zerkms for their review of this post. Composition is defined as “the combining of distinct parts or elements to form a whole.” source If we apply this thinking to functions in programming, then function composition can be seen as the combining of functions to form a new function that is composed of said functions. Now that that word salad is over, let’s get to work. We…

Ramda Chops: Function Currying

Thanks to Jillian Silver and @evilsoft for their review of this post. Functional Programming concepts have been pouring into the JavaScript community for a number of years now, and many of us struggle to keep up. I’ve been lucky enough to be able to work with some mentors and functional tools that have helped me along the way. One of these tools is ramda.js , and it was my gateway to the larger…

Elm, Geocoding & DarkSky: Pt. 4 – Extracting our Elm Code

This is part 4 of a multipart series where we will be building a small weather forecast app using Elm , Google’s Geocoding API and the DarkSky API . Instead of doing everything in one massive post, I’ve broken the steps down into parts of a series. Here is the series plan: Pt. 1 – Setup Elm & Proxy Servers Pt. 2 – Geocoding an Address Pt. 3 – Fetching the Current Weather Pt. 4 – Extracting our Elm…

Elm, Geocoding & DarkSky: Pt. 3 – Fetching the Current Weather

This is part 3 of a multipart series where we will be building a small weather forecast app using Elm , Google’s Geocoding API and the DarkSky API . Instead of doing everything in one massive post, I’ve broken the steps down into parts of a series. Here is the series plan: Pt. 1 – Setup Elm & Proxy Servers Pt. 2 – Geocoding an Address Pt. 3 – Fetching the Current Weather Pt. 4 – Extracting Our Elm…

Elm, Geocoding & DarkSky: Pt. 2 – Geocoding an Address

This is part 2 of a multipart series where we will be building a small weather forecast app using Elm , Google’s Geocoding API and the DarkSky API . Instead of doing everything in one massive post, I’ve broken the steps down into parts of a series. Here is the series plan: Pt. 1 – Setup Elm & Proxy Servers Pt. 2 – Geocoding an Address Pt. 3 – Fetching the Current Weather Pt. 4 – Extracting Our Elm…

Elm, Geocoding & DarkSky: Pt. 1 – Setup Elm & Proxy Servers

This is part 1 of a multipart series where we will be building a small weather forecast app using Elm , Google’s Geocoding API and the DarkSky API . Instead of doing everything in one massive post, I’ve broken the steps down into parts of a series. Here is the series plan: Pt. 1 – Setup Elm & Proxy Servers Pt. 2 – Geocoding an Address Pt. 3 – Fetching the Current Weather Pt. 4 – Extracting Our Elm…

Node.js Geocoding Proxy with Paperplane

tl;dr => use a proxy server when private API keys are involved; paperplane is a great functional server framework. Converting addresses, cities and other locations to latitude and logitude and back again is something that is expected in the software application world today. Whether someone is asking for directions, plotting optimal beer delivery routes or tagging a photo of their cronut in a local…

Behaviour & Your Team

This is a talk I gave back in February at the New Zealand JavaScript Conference on Behaviour & Your Team .

Travel Ruminations

Travel is a way of discarding what you know and embracing that which is strange; a way of unburdening the comforts of life in search of a truth about which you cannot quite say, but you know it exists. But it is as important to remember yourself and your values as you explore strange new lands. Frodo quoted Bilbo in The Lord of the Rings , It’s a dangerous business, Frodo, going out your door. You…

Turning A New Leaf

Two weeks ago today, I quit a rewarding and lucrative job without having another gig lined up. Oh, sh*t. The Immediate Aftermath The following day consisted of my mind completely shutting down after being unable to answer the following questions: What do I do about health & dental insurance? How am I going to pay for life? rent (in London) food/house supplies transportation what if I break my leg?…

Missing Those We Love

Perspective is a strange thing. It rips us out of our frame of thought, showing us our lives from a different point of view, forcing an evolution of ourselves for which we may not have asked. One such perspective I’ve encountered numerous times and resisted is the fact that those whom I care about will not always be around; they won’t always be back home; they won’t always be alive; they won’t…

Freelancing

Sandy beaches; downhill skiing; coffee shop Hugh Grant-esque romance. When people imagine themselves leaving their corporate jobs and becoming their own boss, moving from project to project as a knife through butter, they envision themselves living the good life and doing so on their terms . This is absolutely possible to achieve, but as with anything, freelancing isn’t all rainbows and unicorns!…

Simple Variadic Behavior

Recently, I have started working on my own static site generator, react-static , to accomodate my markdown blog posting & static site needs. Another benefit is that I get to work on my Node.js and ES2015+ JavaScript skills. While I am reinventing the wheel on some levels, it is good practice. Update : I made a library, parse-md , out of some of this behavior in order to address the need of parsing…

Immediate Functions

This article is intended for JavaScript beginners. The browser environment is one big JavaScript closure that will encapsulate in its scope all of the code that is to be run. Because of this, any functions or variables that are created in <script> tags or external .js files that are not defined within a function will end up as global variables! And we all know that global varibles are bad. Let’s…

Asynchronously Loading Scripts

This article is intended for HTML & JavaScript beginners. 2023 update: This article, while still good, doesn’t take into account the defer , attribute. Here is a great javascript.info article on async vs. defer . Where do you place your <script> tags to load your JavaScript for your website? If you’re doing this within the <head> element, you might want to consider whether or not this is the best…

Long-Distance Movie Night

In a long-distance relationship? I currently am, and it sucks, but that will change someday. My SO (significant other), who is an ocean away and five hours ahead, and I were recently celebrating the passing of time and wanted to share a movie night. How were we to do this? There are many options out there that we explored, such as Gaze , which has a great design (though a questionably shaky…

Delegate; Don't Dump

A fellow employee, Margaret, contacts you and asks, "Do you know anything about [problem] and how I might be able to solve it?" You respond, "Oh, yeah, Jane is handling that now." You are a busy person being crushed under the weight of your duties, and you have just helped someone. Having now pushed something off of your plate, it is time to address the next thing! But then Margaret comes back to…

Switching Jobs

Self-discipline can take you places you’ve never dreamed you would go. I have recently switched from one dream job to another one. For the past 1.5 years, Articulate has allowed me to roam from Washington, DC to Charlotte to Charleston to Atlanta to Greenville to Miami to Utah to London to Edinburgh to Berlin to northwest Spain to Denver and beyond. Without such an opportunity, I would never have…

Stop Saying Silicon Harbor

Ever since Nate DaPore allegedly coined the phrase “Silicon Harbor” for Charleston, South Carolina (even though other cities around the world already used this term, such as Hamburg, Germany ), folks wanting to look like they know what they’re talking about have continued to use the phrase “Silicon Harbor” ad nauseam . If Charleston tech companies would like to move forward and be taken seriously…

Mobile Device Etiquette

A friend and colleague of mine, Jason Vanderslice , and I recently discussed the state of mobile devices with regard to their place in various settings and within our interpersonal relationships. While I would not presume to speak for Jason on most subjects, we agree that mobile device etiquette is something that needs to be taught, spread to others and repeated. With the evolution of digital,…

Life in Colorado

One month ago, with an entire world to travel at my fingertips, I chose to temporarily move to Denver, Colorado. For years I have heard great things about the people, hiking, skiing and beer, so I decided to give them a try. The People The following statement may cause me a bit of flack in the South, but "Denver has the most welcoming population I’ve ever come across in my travels." Never in my…

RiotJS Example

When I look at any of the myriad JavaScript UI libraries out there, I now ask two questions: Does data flow in one direction? Do updates to the UI happen intelligently? I am a fan of Facebook’s ReactJS library because of its DOM diffing (via the “virtual DOM”) and one-way data binding. React is a tool I use every day and have come to enjoy (sans-JSX), but I am always on the lookout for way to do…

Use Bcc

I have a new feature request for email applications: if there are a multitutde of addresses in the “To:” field, recommend the author use Bcc (and give a checkbox with the option to never ask this question again). Let us begin with this sage tweet from Marty Bauer : Sending a mass email and not bcc-ing everyone is like a kicker missing an extra point. You had one job. What is Bcc? For those of you…

Be Better

We are not always the people we strive to be. Many of us want to be better versions of ourselves: wiser, kinder, stronger, skinnier. However, we often find it is ourselves that get in the way of this. Some time ago, I began removing things from my life that did not help me on the path to being the person I desired to be. This is a very painful yet effective attempt at a remedy. Unfortunately, it…

On Working Remotely

Do you have a remote/virtual/telecommute job? I do. And it rocks. A vast majority of the people in the States who inquire as to the nature of my job share with me that they feel working remotely would make them feel isolated; that they would lose their sense of team; that they would get bored. Boredom? Nope Someone once said to me, "Only boring people get bored." Let that sink in for a second. Let…

Exercising In Transit

Many folks who travel are no strangers to a general decline in health (and bank account funds!) while on their adventures. Apart from being less likely to cook their own meals, the general lack of exercise people also experience while on the move in new, unfamiliar places, creates a cycle of unhealthiness that is difficult to break. Since I’ve moved to London, I have had to consider my options and…

Chief

Tonight, I lost a dear friend. On this day, 23 September 2014, my family lost a constant. Chief, a member of our family, passed — by our hand — on account of aggressive cancer. Chief made me better. Or, Chief made me make myself better. I will never forget one moment, one line of his life, I swear. He will always be my brother, my son, my guide. I love you, man.

Berlin

Traveling to Berlin for the first time, one cannot help but marvel at a city and people so steeped in painful history. All Americans learn of the Berlin where Hitler ruled, where the Russians paraded down the streets after they reached the city before the other Allies could and where the Berlin Wall was erected and felled. While this is not the city that exists today, there are bold, powerful…

Working In London

I spend the majority of my time writing software for Articulate . This isn’t the offical mantra, but it is how I think of the company: "Work when you want, where you want; just don’t be a jerk." Sound too good to be true? It is true. Articulate is a “remote” or “virtual” company, meaning it has no physical offices anywhere in the world, and everyone works wherever they like. Many of my colleagues…

Moving To London

2 months ago I decided I wanted to go to London for an indefinite amount of time. There were no external driving factors behind this decision; no significant other, no new job, no criminal charges, no desire to leave my home in Charleston, SC. I love my family, friends, beaches, the spartina grass (marshes), the plough mud, and the odd—yet wonderful—assortment of personalities that exist in…