The nature of the input data, files consisting of lines of text, means that regex often seems the perfect tool to accomplish subtasks needed for puzzle solutions. As I'm learning more about regular expressions this year I've found these resources helpful:
// in package.json need to set type field to module { "type": "module" } | |
import { open } from 'node:fs/promises'; | |
import path from 'node:path'; | |
import { fileURLToPath } from 'node:url'; | |
// recreate Node globals for ESM modules | |
const __filename = fileURLToPath(import.meta.url); | |
const __dirname = path.dirname(__filename); | |
(async () => { |
Regular dependency updates are important for long-lasting codebases. For short-term projects and one-off scripts nothing might ever have to change, but for software that is in use for a long enough period of time everything will likely have to change, eventually. Regular dependency updates are a good practice because they chunk the amount of changes we have to review and navigate into a managable amount and save us from problematic version migrations. They keep our systems in tip-top shape and help us avoid technical debt.
Make them regular because:
- You want to keep the number of changes you have to review for any dependency at any one time minimal.
- You want to avoid deferring breaking changes and gathering them all up into a problematic, complex, and hard to understand series of version migrations.
- You want to resolve security vulernabilites promptly.
- You want new improvements and fixes to flow into your project regularly.
var countryList = ['Mexico', 'United States', 'Canada']; | |
// prefer not to use the Oxford comma so use locale 'en-GB' | |
var phraseFormatter = new Intl.ListFormat('en-GB', {type: 'conjunction'}); | |
phraseFormatter.default = 'North America'; | |
// see http://exploringjs.com/es6/ch_proxies.html#_intercepting-method-calls | |
const handler = { | |
get(target, key) { |
Pursuit is a social impact organization that creates transformation where it’s needed most.
Through our four-year intensive program, we train adults with the most need and potential to get their first tech jobs, advance in their careers, and become the next generation of leaders in tech. Our graduates are hired by leading companies like Pinterest, Kickstarter, LinkedIn, BlackRock, and JPMorgan Chase, and increase their average annual salaries from $18,000 to over $85,000.
I volunteer at Pursuit and I recommend you do too!
§ 5 — 'Your Knowledge Portfolio'
The authors of The Pragmatic Programmer talk about the importance of diversifying your knowledge base specifically in terms of guaranteeing your long-term success in a field that is always changing. I want to talk about the power diversification has to jump start your understanding even of those areas you already think you know well.
Probably those of you in class are desperately praying for a learning plateau and a chance to catch your breath. But after your program ends and when you are working you are going to experience some learning plateaus. When you feel this way, "I have a body of stuff I know and am competent with but I'm not learning how to do more", then you've hit a learning plateau. It's pretty common.
I've learned that diversifying your knowledge by learning something completely new is a great way to get your learning momentum moving again. And surprisingly learning something new always seems to shed light on the bundle
const getCommand = commands => word => key => key in commands ? commands[key](word) : null;
Wow! What is that? It sure looks cool but what is actually going on there?
That is a curried function and I hope to explain to you over the next page or two what that is and why you might prefer to write this function in that way rather than this:
function getCommand(commands, word, key) {
One line of grep
explained:
grep 'TODO' -r -n --exclude-dir={node_modules,.git,lib} --exclude={"*bundle.js","*.map","*.min.js","*.csv",todos.txt} . > todos.txt
This command searches through a directory and its subdirectories for TODO comments and writes them to a text file.
grep
is a file pattern searcher and 'TODO' is the pattern we are searching our directories and files for
-r
– search recursively through a directory and its subdirectories
'use strict'; | |
const d3 = require('./d3.min.js'); | |
export class Legend { | |
constructor(el, d, r, rm, m, w, h) { | |
this.mount = el; | |
this.data = d; | |
this.regions = r; | |
this.regionsMap = rm; | |
this.margin = m; |