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?
| // Configuration | |
| const owner = "your-github-username"; | |
| const repo = "your-repository-name"; | |
| interface PullRequest { | |
| created_at: string; | |
| merged_at: string; | |
| } | |
| interface Deployment { |
| = {"Destructure issues into separate items"; ArrayFormula(TRANSPOSE( {SPLIT( {JOIN("",{REGEXREPLACE('YOUR SHEET NAME'!W2:W,"\(.*\)","")})}, ";", FALSE, TRUE)}))} |
| /** | |
| * @description This is the entry point for the Cloudflare Worker. | |
| * Call it with `http://0.0.0.0:8787?endpoint=gh` or `http://0.0.0.0:8787?endpoint=swapi` | |
| */ | |
| export default { | |
| async fetch(request: Request): Promise<Response> { | |
| const { searchParams } = new URL(request.url); | |
| let endpoint = searchParams.get("endpoint"); | |
| const result = await (async () => { |
| import { randomBytes } from 'crypto'; | |
| /** | |
| * @description Simple demo of tracing in a manual way. | |
| * | |
| * Note that this demo does not actually set the duration of traces | |
| * given that you provide them manually here. | |
| * | |
| * Another thing obviously missing is therefore, by logical extension, | |
| * any way of "ending" a span. |
| #!bin/bash | |
| set -o pipefail | |
| # Assign first value to a named global variable | |
| NAME="${1}" | |
| # Exit with an error if not set | |
| if [[ -z $NAME ]]; then echo "You need to call this with a value!" && exit 1; fi | |
| # Echo first value coming into function |
| import { simpleGit } from 'simple-git'; | |
| diff(github.context.payload.after, github.context.payload.before); | |
| async function diff(after: string, before: string) { | |
| const git = simpleGit(); | |
| const diff = await git.diffSummary([after, before]); | |
| console.log(diff); | |
| } |
| #!/bin/bash | |
| # Requires pandoc | |
| # @see https://pandoc.org | |
| mkdir -p pdf | |
| for file in *.md; do | |
| pandoc $file -s -o pdf/$file.pdf --pdf-engine=xelatex | |
| done |
| import { createHmac, timingSafeEqual } from 'crypto'; | |
| const TOKEN = 'SOME_SECRET_VALUE'; | |
| /** | |
| * @description Verify GitHub secret from signature. | |
| * | |
| * There are a ton of these examples out there but some are really messy and this one tidies them up a bit. | |
| * | |
| * @param {string} headerValue - Pass in `headers['X-Hub-Signature-256']`. Looks something like 'sha256=3fead968c...' |
| /** | |
| * @description Create and return 10-digit Unix-formatted expiration time for a DynamoDB item. | |
| */ | |
| export function getExpiryTime(expirationInMinutes = 10): string { | |
| const date = new Date(); | |
| return date | |
| .setMinutes(date.getMinutes() + expirationInMinutes) | |
| .toString() | |
| .substring(0, 10); | |
| } |