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 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