Drummer | Developer | Drum Tech




JavaScript Set

June 19, 2020

As part of my learning regimen, I've been doing a daily code challenge on Codewars. So far, it's been going very smoothly, and I can often think up an algorithm and get it coded in under an hour--with some solutions coming to me immediately.

Today, however, I had to use my first life line, after racking my brain for over an hour.

The problem, as described in the "Kata", involved finding unique characters in a string. Specifically, checking whether a given string was a "pangram", which is a sentence that contains every letter of the alphabet (e.g. "the quick brown fox jumps over the lazy dog").

Of course, my first naive approach involved all kinds of desperate Regex patterns, and keeping a counter, and then checking whether the total count was at least 26 (one for each letter of the alphabet), but I had to abandon this path when I realized just how lost I had gotten.

Fortunately, it didn't take much time to search online for a hint, and my pal "Google" led me to Set, which immediately got me to my solution:

const isPangram = (string) =>
	[...new Set(string.replace(/\s/g, "").toLowerCase().split(""))].length >= 26;

I know every experienced coder will tell you that the best skill one can have is Googling the solution, and I strongly agree with that, but it also feels nice to be able to think up an algorithm all by myself. However, I won't beat myself up too much, because the next time I need to find unique values in a set, I'll know exactly where to look!


"One Of My Lies"

May 17, 2020

Inspired by all the fun videos that musicians are putting out (particularly the Goldfinger ones, since they're a band that's near and dear to me), I decided to challenge myself to do a similar quasi-live video. Here it is:

Since I'm not the greatest guitar player, I decided to stick to something that I could handle (or at least pass off as "good enough for punk music"). 😎

I went with "One Of My Lies", off the Green Day album "Kerplunk", which has always been one of my favorite songs, even though I didn't know all the lyrics until last week.

In the spirit of capturing a quasi-live band performance, I did these in full takes, without editing. I did about three drum takes before I was happy, maybe a dozen bass takes, and roughly a billion guitar/vocal takes. Haha. I kept fucking up the lyrics (I still did flub a couple tiny things, in the end), but mostly I was just messing up the guitar-playing, which is an impressive feat when you consider that Green Day is not exactly a band covered extensively by Guitar Player magazine.

Anyway, this was a blast to make, and I'm excited to try another one soon! Maybe something even easier on guitar? 😂

Update: Unfortunately, there are open issues with webpack and create-react-app that prevent the usage of symlinks, at least easily or without work that I'm unable to do. Sad times.

For now, I've opted to remove all my Node projects out of iCloud, and instead make a habit of creating remote repos on Github.

If you're not using React, the following solution should still work, and I'd still recommend it!

I've been using the COVID-19 lockdown as an opportunity to learn new skills and expand on the ones I've already got. For the most part, this has been in the realm of coding.

I'm not quite ready to share the projects I've been working on (most of them are really basic little web apps that are more for learning than for a portfolio), but I wanted to share one quick little tip for anyone developing adds with Node.js that uses iCloud.

By default, any new file or directory that you store in iCloud on macOS gets uploaded and synced. In the case of a Node.js project, this means that the monster that is node_modules gets uploaded, as well. This is unnecessary usage of bandwidth and also takes quite a toll on your battery and hard disk.

Fortunately, some smart person made a utility for dealing with exactly this scenario: nosync-icloud.

You can read about it on their site, but the short version is that you can run a command in each of your Node.js project folders, and it will look for a node_modules folder, append .nosync to the folder name (which disables iCloud syncing), symlinks node_modules to the newly un-synced folder, and then adds both to your .gitignore.


Site made by me. Email me or connect on LinkedIn.