Skip to content

Instantly share code, notes, and snippets.

View qoomon's full-sized avatar
🌳
Go for it.

Bengt Brodersen qoomon

🌳
Go for it.
View GitHub Profile
@qoomon
qoomon / Sandbox.md
Created November 1, 2024 08:08
Sandbox

Moin

@qoomon
qoomon / github-for-each-org-repository.ts
Created September 3, 2024 15:47
Script to iterate over all GitHub org repos
import {Octokit} from 'octokit';
import * as process from 'node:process'
import YAML from 'yaml';
const metaDataPath = '.github/metadata.yaml';
const input = {
token: process.env.GITHUB_TOKEN ?? _throw(new Error('environment variable GITHUB_TOKEN is required')),
owner: process.env.GITHUB_OWNER ?? _throw(new Error('environment variable GITHUB_OWNER is required')),
}
@qoomon
qoomon / resultOf.ts
Last active August 27, 2024 11:25
Run functions or await promises in a safe way by return a result object
function resultOf<T>(fn: () => T): SafeResult<T>;
function resultOf<T>(fn: () => Promise<T>): Promise<SafeResult<T>>;
function resultOf<T>(promise: Promise<T>): SafeResult<T>;
function resultOf<T>(input: (() => T | Promise<T>) | Promise<T>): Result<T> | Promise<Result<T>> {
if (typeof input === 'function') {
try {
const result = input()
if (result instanceof Promise) {
return safe(result);
}
@qoomon
qoomon / gist:700f68ca890edd5802fd768652f231cc
Last active February 22, 2024 13:22
GitHub Actions Commit Identity
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
@qoomon
qoomon / AWSParametersAndSecretsLambdaExtension-Utils.ts
Created October 12, 2023 06:08
AWSParametersAndSecretsLambdaExtension
/**
* @param secretId the ARN or name of the secret.
* @param version the version stage or version id
* @see https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieving-secrets_lambda.html
* @see https://docs.aws.amazon.com/systems-manager/latest/userguide/ps-integration-lambda-extensions.html
*/
export async function getSecretString(secretId: string, version?: SecretManagerSecretVersionStage | string) {
const extensionHttpPortPort = process.env["PARAMETERS_SECRETS_EXTENSION_HTTP_PORT"] ? parseInt(process.env["PARAMETERS_SECRETS_EXTENSION_HTTP_PORT"]) : 2773
const secretManagerRequestUrl = new URL(`http://localhost:${extensionHttpPortPort}/secretsmanager/get`)
@qoomon
qoomon / qoomon.md
Last active October 25, 2023 05:40
qoomon styles

"Combining Long Stroke Overlay" (U+0336) and "Combining Short Stroke Overlay" (U+0335).

qoomon

q̴͈̮o̴̱ọm̶͓̥on͒

Q̶̸O̶̴O̶̴M̶̸O̶̴N̶̸


@qoomon
qoomon / bypass safe links.user.js
Last active March 22, 2023 14:45
Userscript to bypass Safe Links
@qoomon
qoomon / Colima-status.2s.zsh
Created February 13, 2023 16:44
xBar - Colima Status
#!/bin/zsh
# <xbar.title>Colima Status</xbar.title>
# <xbar.author>Bengt Brodersen</xbar.author>
# <xbar.author.github>qoomon</xbar.author.github>
# <xbar.desc>Displays Colima Status - https://github.com/abiosoft/colima</xbar.desc>
source ~/.zprofile
DOCKER_RUNNING_ICON='iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAAAXNSR0IArs4c6QAAAIRlWElmTU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAACQAAAAAQAAAJAAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAACqgAwAEAAAAAQAAACoAAAAAxiJEngAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDYuMC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0Y
@qoomon
qoomon / template.plugin.zsh
Created February 7, 2023 08:25
ZSH Plugin File Template
#!/bin/zsh
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
echo "${${0:A}/%.plugin.zsh/.zsh}"
@qoomon
qoomon / script.sh
Last active February 9, 2023 16:13
Google Drive - Hide Symbolic Link in Home Directory
# lock and hide Google Drive link
chflags -h uchg,hidden "$HOME/Google Drive"
# undo by following command
# chflags -h nouchg,nohidden "$HOME/Google Drive"