Tag: JavaScript
-
Client-side environment variables with Next.js
Next.js does a great job with environment variables. Out of the box, it supports loading up environment variables in next.config.js as well as using a .env file. Both of which are made available inside of server components. For client-side components though, you don’t get direct access to environment variables from both locations. The Next.js config…
-
Convert string to number with JavaScript
Been working through swapping a MySQL library recently to prepare for a major database upgrade. The old library would return the results from function like AVG and SUM as a number. The new library, not so much. MySQL natively returns those values as strings, which I can applaud the library for respecting. Coming from a…
-
Numeronym in JavaScript
Numeronyms are a form of abbreviation. The middle of the word or phrase is swapped out for a number that represents the number of letters that are being replaced. The first and last letters are retained. Some examples are: I’m not really a fan of the word “numeronym”, primarily because I can’t ever seem to…
-
Adding a custom script to an Unbounce landing page
When asked if I knew how to add a custom script to an Unbounce landing page. I have never used Unbounce before, but I’ve worked with enough marketing tools that I figured I could figure it out. Also, figuring out stuff lends itself to new blog content. And here we are. Edit your page If…
-
Stop ESLint from searching up the directory tree
For most projects, I use a monorepo, and nest my scripts in a directory. I’ll npm init each script, and maintain an isolated set of dependencies outside of the main dependency tree. This includes maintaining a separate .eslintrc file as well. Typically, this isn’t a problem, but recently with a new project that was created…
-
Airbnb style guide with Next.js
Starting a fresh Next.js project the other day, I was happy to see that configuring eslint was part of the bootstrapping process. Where things fell short for me, was the lack of a prompt asking me which style guide I’d like to use. I’m sure the out of the box option is sufficient enough, and…
-
Bitcoin price tracking widget for iOS with Scriptable
Of the crypto apps I have used, I’ve yet to find one that provides a Bitcoin price tracking widget to my liking. I’m not interested in the current price of Bitcoin, as I am interested in how my holdings (HODLINGS) are doing. Thus, enter Scriptable, an automation app for Apple devices. It allows you to…
-
Node.js REPL history
Node.js has included a persistent history with it’s REPL (real-eval-print loop) for quite some time now. It’s a fantastic quality of life feature, and it even supports reverse-i-search. The other day, I got to wondering, where the heck does this history even live? Turns out, it’s just living in a…
-
How to convert JSON to CSV in JavaScript
Last week we discussed converting CSV to JSON in JavaScript. This week, we’re going to talk about going in the opposite direction, converting JSON back to CSV. Similar to last week, we’re going to use the immensely popular papaparse library. As it turns out, even though it’s touted as the…
-
How to convert CSV to JSON in JavaScript
Parsing CSV data isn’t as easy as splitting the string up into individual lines, then splitting it by the delimited (in this case commas). Some of the values may have quotes around them, sometimes the values themselves have line breaks. Then there’s the potential that the data itself is malformed….