whatishedoing's notebooks

  • CSV Stringify - /whatishedoing/csv-stringify
    Last edited 3 years ago
    Simple, synchronous CSV conversion of a data set, using CSV Stringify https://csv.js.org/stringify/. CSV parsing libraries are great for handling deceiptively awkward issues, such as commas internal to a field, which can affect numeric types that are formatted!
  • CSV Parsing - /whatishedoing/csv-parsing
    Last edited 5 years ago
    A quick demonstration of why a library like Papa Parse - https://www.papaparse.com/ - is far superior to string.split(",")!
  • ISO Validation - /whatishedoing/iso-validation
    Last edited 5 years ago
    Why not use a library to test data that should conform to ISO standards? For example, currencies:
  • ⏲ Millisecond Durations with Luxon - /whatishedoing/millisecond-durations-with-luxon
    Last edited 6 years ago
    Often, configuration data that is represented as a time span will be stored as milliseconds. It's suprising how long it can take to understand a simple calculation, so why not let luxon make the conversion more readable?
  • Converting To and Using js-joda - /whatishedoing/converting-to-and-using-js-joda
    Last edited 6 years ago
    The native JavaScript Date library is very, well, _lightweight_, so libraries such as js-joda can help. Once a native date is converted to a js-joda one, with a little (unnecessary?!) help:
  • URL Parsing - /whatishedoing/url-parsing
    Last edited 6 years ago
    URLs are versatile but easy to generate incorrectly, especially when combined from various sources. Fortunately, there are libraries that not only build URLs from their separate parts - scheme, domain, etc. - but also parse and clean badly-formatted ones. Take this example, with extra forward slashes and an unnecessary WWW subdomain:
  • DOM Fetching and Querying - /whatishedoing/dom-fetching-and-querying
    Last edited 6 years ago
    At some point, you'll need to inspect or scrape web pages for information. Having great libraries makes this process far simpler, so let's see how simple it is to fetch the DOM from a URL using got:
  • Filtering AWS IP Ranges - /whatishedoing/filtering-aws-ip-ranges
    Last edited 6 years ago
    AWS provide IP ranges for their services, in case you'd like to add another layer of security via IP whitelisting. They are available from https://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html, but can be a pain to parse, so let's do that here! First, we'll fetch the data:
  • Reducing Collections - /whatishedoing/reducing-collections
    Last edited 6 years ago
    Functional programming without side-effects is a great way of ensuring your code is deterministic: that it will run the same each time, regardless of environment. Let's look at a simple attempt to aggregate data from the Star Wars API, https://swapi.co/!