Skip to content

Instantly share code, notes, and snippets.

@tinfoil-knight
Last active August 11, 2022 11:10
Show Gist options
  • Save tinfoil-knight/49dcf7a5182472129f9a119fab9de79f to your computer and use it in GitHub Desktop.
Save tinfoil-knight/49dcf7a5182472129f9a119fab9de79f to your computer and use it in GitHub Desktop.

OSS Log

  • be a bit more patient with what you claim, always double-check, mistakes will forever be out there in the public forum
  • there's a deprecated tag in JSDoc that can be used to mark things that are outdated.
  • sometimes you can avoid using a mock by making a wrapper and only testing the responses from the core function's response instead of checking if the wrapping function throws an error, exits the process etc.
  • don't just remove dead code without asking the original author
  • don't club changes you find while working on a PR, always create a separate PR for unrelated changes
  • switch(true) pattern with statements that evaluate to boolean as cases. (Feels like using guards in Haskell)
  • do not write PRs with excessively large changes as I did in this one, eventually I had to break it up to allow the reviewer to properly test everything since the changes are all across the codebase
  • naming is hard, naming branches with limited characters is harder
  • sometimes it's not possible to just refactor a codebase to fix a bug the right way and you've to succumb to using a tempfix (which is very permanent)
  • the Proxy object in JS (I don't completely get this yet)
  • colorless instance in chalk (for logging to files?)
  • used the chalk package for styling text
  • came across ci-info
  • maintainers have other work too (I'm holding the urge to @ people constantly in my PRs)
  • decided to read up more about the oclif cli framework that the repo uses
  • npm link to use the repo cli directly (through symlinks) instead of doing a global install
  • for loops are easier to understand over using confusing recursive approaches or functional array methods (easy to realise but hard to accept as an FP fan)
  • used Promise.all, Promise.allSettled, Promise.any (N.B. Promise.allSetlled doesn't make the async call in order unlike a for loop)
  • installed and tried out nvm to debug an issue caused due to Node.js 10 not supporting the ?. operator
  • for...of, for...in (knew these but didn't use them due to pref for functional methods)
  • running tests serially to avoid burning my Mac (also had to force shutdown my Mac for the first time since everything hanged)
  • more ava stuff and some useful flags: fail-fast, verbose, serial
  • found a eslint plugin to enforce fp rules
  • wrote a recursive way to retry (this was rejected since a loop is actually more intuitive)
    const retry = async (retriesLeft) => {
      try {
        return await asyncCall()
      } catch (error) {
        if (retriesLeft === 0) {
          throw error
        }
        return retry(retriesLeft - 1)
      }
    }
    
  • Object.entries(a).map([key, value]) => {}) is a pretty neat way to use key-value pairs from an object.
  • learnt more about static methods in JS classes (in most cases, separating these methods from classes is better)
  • came across the ascii-table package, output data as tables easily on terminal
      .------------------------------------.
      | a | apple     | Some longer string |
      | b | banana    | hi                 |
      | c | carrot    | meow               |
      | e | elephants |                    |
      '------------------------------------'
    
  • the ava testing library (it even supports snapshots for cli output)
  • to avoid losing work while using git stash set this as a git alias: git add --all && git stash
  • pattern matching through * in npm scripts, useful for separation e.g. test:dev:* will run all scripts that start with the word test:dev:
  • came across git lfs (could use these for my figma design files)
  • using objects to pass arguments so when one is removed, you don't need to care about the positioning (not sure about using this for other langs but seems good for js due to the spread operator and object property shorthand)
  • the pain of flaky tests; can't debug code if it's not wrong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment