Skip to content

Instantly share code, notes, and snippets.

View coolaj86's full-sized avatar
😎
🐹 Go 🦎 Zig 📦 Node 🐧 POSIX 🪟 PowerShell

AJ ONeal coolaj86

😎
🐹 Go 🦎 Zig 📦 Node 🐧 POSIX 🪟 PowerShell
View GitHub Profile

Why is this bad?

const something = (params) => value;

TL;DR Because this ISN'T bad

Pyramids of Doom in JavaScript

  • callbacks
  • promises
  • try/catch

solution: await.catch

async function doLotsOfStuff(params) {
{
"hash": "716dac449e7f7c02a69cb0ec37ea3b905f3f01aac707c1db2dd38bfa9deedb20",
"version": 1,
"inputs": [
{
"prevTxId": "ea5ff9b5bdcce85e3bbdf7c0d84a63681265cf630481bc48e6009d7b5dbad069",
"outputIndex": 1,
"sequenceNumber": 4294967295,
"script": "47304402207a88c7eb79b5307288e73bce404963cb3d8f76db7a3fa3924ab633cfbaf9f49d02204de2d008ce5b38383ad9dbfccaa99bed880fe949166ce2d7ce0c6034b52177070121038081fa1a40e680a1e7ea5be15895669b1a6fb5ea884dabbfa688e7097d0d9011",
"scriptString": "71 0x304402207a88c7eb79b5307288e73bce404963cb3d8f76db7a3fa3924ab633cfbaf9f49d02204de2d008ce5b38383ad9dbfccaa99bed880fe949166ce2d7ce0c6034b521770701 33 0x038081fa1a40e680a1e7ea5be15895669b1a6fb5ea884dabbfa688e7097d0d9011"

(Ab)uses of Reduce

Watch: https://youtu.be/X85QdHe1tDw?t=409 (Starts at 6:50)

reduce is one of the least understood Array methods, and probably the most abused.

Use #0 Actually Reducing

Reducing, as the good functional programmer intended:

Can you convert a Value Object (i.e. JSON) to YAML?

My Expectation

My expectation is that a mid-senior level developer should be able to accomplish this task in under 4 hours:

  • write a basic solution in 30-60 minutes
  • debug / test / fine-tune for another 60-90 minutes
  • document, package, and publish within the remaining time

I could see it reasonable even if a developer takes 2 days to solve this for the first time - possibly because they needed to take a break but didn't, such as feeling pressure and getting brain freeze, taking an initial wrong approach, over-thinking the problem, and then just keeping beating the dead horse, etc - especially if they've never had to work independently before.

@coolaj86
coolaj86 / json-to-yaml-litmus-test.md
Last active March 14, 2022 04:32
"Can you write code?" litmus test.

The Developer Litmus Test

I used to think that fizzbuzz was a stupid way to test if someone is a developer.

Screen Shot 2022-01-24 at 3 06 33 AM

Now I think that it's a good litmus test.

However, I think I've found a better one...

Get that nasty brew out of your system directories!

sudo rm -rf /usr/local/Homebrew/
sudo rm -rf /usr/local/Caskroom/
sudo rm -rf /usr/local/Cellar/

Now remove all broken symlinks from /usr/local/opt/ which, on a typical brew-infected system, will be all of them:

Re: NodeJS vs Go error handling

This is in response to Kai Hendry's NodeJS vs Go error handling

  • 0:00 Storytime: TJ leaves node because it sucks
  • 0:25 Example: A simple service to increment a number
  • 0:40 - 0:51 Node.js: A Naive Route Implementation
@coolaj86
coolaj86 / base62.md
Last active December 16, 2022 18:42
for base62 in javascript / go / pseudocode + github base62 token format