These are some handy snippets to get common metrics for checking how active a software engineer is.
- How many pushes are made by the IC?
- How many reviews are made by the IC?
- How many comments are made by the IC?
// UTILS | |
export const getPaddingFromPrecision = ( | |
floatingPointPrecision: number, | |
): number => { | |
return Math.ceil(Math.log2(360 * floatingPointPrecision)); | |
}; | |
export const convertToBinary = ( | |
num: number, |
import assert from 'node:assert/strict'; | |
// Extended RegExp mode (flag /x) [1] via a template tag | |
// | |
// Quote: “While the x-mode flag can be used in a RegularExpressionLiteral, | |
// it does not permit the use of LineTerminator in RegularExpressonLiteral. | |
// For multi-line regular expressions you would need to use the RegExp | |
// constructor.” | |
// | |
// The plan is to include this functionality in re-template-tag [2]. Then |
/*******************************************/ | |
/* Version 1.0.0 */ | |
/* License MIT */ | |
/* Copyright (C) 2022 Devin Weaver */ | |
/* https://tritarget.org/cdn/simple-dom.js */ | |
/*******************************************/ | |
/** | |
* This micro lib is a compact and simple method to interact with the DOM. It | |
* facilitates the query mechanisms that querySelector and querySelectorAll use |
This is a proposal to adopt the use of // ENTRYPOINT
comments next to a program's top-level entrypoints, such as the main
function, event handlers, and network listeners.
The idea is to allow new contributors and curious readers to quickly gain an overview of the project's main functions in a way that's easy to understand, and for the entrypoints to act as sensible starting points (and helpful mental anchor points) for further exploration.
The presence of ENTRYPOINT comments should allow the reader to quickly begin to answer questions like what does this program do? (provided the main
function is sufficiently readable); what happens when I press a key?; and how does this program respond to network requests?.
Tooling
import glob from 'fast-glob' | |
import { build } from 'esbuild' | |
import { Project } from 'ts-morph' | |
const project = new Project({ | |
compilerOptions: { | |
outDir: 'dist', | |
emitDeclarationOnly: true, | |
}, | |
tsConfigFilePath: './tsconfig.json', |
// Regular expression patterns for testing content-type response headers. | |
var RE_CONTENT_TYPE_JSON = new RegExp( "^application/(x-)?json", "i" ); | |
var RE_CONTENT_TYPE_TEXT = new RegExp( "^text/", "i" ); | |
// Static strings. | |
var UNEXPECTED_ERROR_MESSAGE = "An unexpected error occurred while processing your request."; | |
export class ApiClient { | |
/** | |
* I initialize the API client. |
import { useLoaderData, Link, useSearchParams } from 'remix'; | |
import { parseISO, format } from 'date-fns'; | |
import groupBy from 'lodash/groupBy'; | |
let PAGE_SIZE = 5; | |
function safeParseInt(str) { | |
let parsed = parseInt(str); | |
return isNaN(parsed) ? 0 : parsed; | |
} |
import type { Stripe } from 'stripe' | |
export type StripeWebhookEventTypes = | |
Stripe.WebhookEndpointCreateParams.EnabledEvent | |
export type StripeWebhookEvent< | |
EventType extends StripeWebhookEventTypes, | |
Payload | |
> = { | |
eventType: EventType |