Skip to content

Instantly share code, notes, and snippets.

@tcodes0
Last active February 7, 2024 16:07
Show Gist options
  • Save tcodes0/fcd1fac083a9c7f792c70fb49a71177c to your computer and use it in GitHub Desktop.
Save tcodes0/fcd1fac083a9c7f792c70fb49a71177c to your computer and use it in GitHub Desktop.
LINKS AND COOL HACKS
@tcodes0
Copy link
Author

tcodes0 commented Oct 25, 2020

x-work

get list from website

// do not use really sucks. need to concat with paragraphs and titles
re = []
sel = ".JobOpeningListItem_JobDescription__1DPoi''
document.querySelectorAll(sel).forEach(x => re.push(x.innerText))
('vaga: ' + re.join('\n\n vaga: ')).replace(/Learn more >>/g, '')
// real dolar
var makeBrlToUsd = rate => brl => Math.round(brl*rate)

@tcodes0
Copy link
Author

tcodes0 commented Mar 13, 2021

High level

speed

In posts talking about how someone made something fast, I see the same idea repeat time after time: it has linear time complexity, has great cache locality, and saturates all available processors.

Interview questions

technical, high-level

How do you handle the diversity of patterns within the JS ecosystem? maybe follow-up: What are some good solutions or patterns you have used that worked for you?
What's your thoughts on JS itself and it's current direction?

execution and team work

Have you worked with designers? what were some highlights there?
We all know it's very hard to give estimates, how to do you approach that? what's your attitude?
What is a big mistake in product process you've seen or committed yourself?
Your favorite meeting and why?
Tell me a good idea for a project that your company should take on, but will not. Explain from both sides, even if they are wrong.
Walk me through a project you enjoyed start to finish. Explain design decisions (why x and not y?)

code review

https://www.michaelagreiler.com/respectful-constructive-code-review-feedback/
https://phauer.com/2018/code-review-guidelines/
https://mtlynch.io/code-review-love/

@tcodes0
Copy link
Author

tcodes0 commented Apr 15, 2022

Datadog

APM traces

query samples

Service:hub-server @url:*drivers-license*
trace_id:2934837843

tricks

search for logs using kubectl, find trace id, then do https://app.datadoghq.com/apm/trace/{id}

if code looks like this

infra.Logger.Info().Str("event", "message.new")

query to find field would be @event:message.new

RUM custom actions

find with @action.target.name:foobar

@tcodes0
Copy link
Author

tcodes0 commented Jul 13, 2022

Cookie cliker

// node
prestigeLvls = Math.cbrt((allTimeCookies + popingWrinklers + sellingBuildings + difference) * 10 ** 18 /* 18 for quintilion cookies*/)/10000
// load cookie monster into cookie clicker
Game.LoadMod('https://cookiemonsterteam.github.io/CookieMonster/dist/CookieMonster.js');

@tcodes0
Copy link
Author

tcodes0 commented Mar 8, 2023

Go

Installing private repos as packages

update ~/.gitconfig with

[url "ssh://git@github.com/"]
      insteadOf = https://github.com/

run go env -w GOPRIVATE=github.com/eleanorhealth/* and add to shell init file export GOPRIVATE=github.com/eleanorhealth/*
run ssh-keyscan github.com > ~/.ssh/known_hosts
try to run go mod download "github.com/eleanorhealth/member-server@<latest commit on main>" and see if you get no errors, if so, run go get "github.com/eleanorhealth/member-server@<latest commit on main>" to add the package

notes

omitting the commit hash doesn't work
ssh-key add may be needed on mac, it will prompt you for password
code must be merged to main

coverage unit

go get golang.org/x/tools/cmd/cover
go test -race -coverprofile .coverage ./svc/server/application/application/...
go tool cover -html=.coverage

@tcodes0
Copy link
Author

tcodes0 commented Jul 30, 2023

/**
 * Maybe captures the result of some operation that may fail.
 * If there is an non null error, attempting to retrieve result will throw.
 */
export class Maybe<T> {
    #result: T | null
    #error: Error | null

    // constructor(data: Data | null, error: Error | null) {
    constructor() {
        this.#result = null
        this.#error = null
    }

    /**
     * throws unless error() returns null.
     */
    result(): T {
        if (this.#error) {
            throw this.#error
        }

        if (this.#result === null) {
            throw new Error("null data")
        }

        return this.#result
    }

    /**
     * if null, result() is safe to call
     */
    error() {
        return this.#error
    }

    /**
     * error must be null for result to be read
     */
    setResult(data: T) {
        this.#result = data
    }

    /**
     * blocks result from being read
     */
    setError(message: string) {
        this.#error = new Error(message)
    }
}

@tcodes0
Copy link
Author

tcodes0 commented Aug 24, 2023

AI

52.7k words on member-server codebase
244 non mock non test files
find . -type f -name *.go | grep -Ev test.go | grep -Ev mock
avg 314 words per file (handlers)
avg 215 word per file (codebase)
say 5k words for a massive conversation context with ai
have 59k words of context to use with ai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment