Skip to content

Instantly share code, notes, and snippets.

View enriched's full-sized avatar

Rich Adams enriched

  • CIQ
  • Seattle, WA
View GitHub Profile
@enriched
enriched / get_rpm_metadata.py
Created January 19, 2024 00:39
Get rpm metadata files for repository
import os
from urllib.parse import urljoin
import urllib
import gzip
from pathlib import Path, PurePath
import requests
from bs4 import BeautifulSoup
NOTEBOOK_DIR = os.getcwd()
REPODATA_DIR = Path(NOTEBOOK_DIR) / "repodata"
@enriched
enriched / gist:cf71e0e0057d34ab9ecf52c39a6c0f95
Created January 19, 2022 21:51
AWS SSO Login with profile selection
#!/usr/bin/env bash
set -eo pipefail
PATTERN=${1}
SELECTED_PROFILE=$(cat ~/.aws/config | awk '/\[.+\]/{ gsub(/(\[profile[ ]+|\])/, ""); print }' \
| fzf-tmux --height 30% --reverse -1 -0 --header 'Select AWS profile' --query "$PATTERN")
aws sso login --profile "$SELECTED_PROFILE"
@enriched
enriched / in-pod-kubeconfig.sh
Last active February 24, 2024 00:10
Create kubeconfig inside pod
SERVICE_ACCOUNT_DIR="/var/run/secrets/kubernetes.io/serviceaccount"
KUBERNETES_SERVICE_SCHEME=$(case $KUBERNETES_SERVICE_PORT in 80|8080|8081) echo "http";; *) echo "https"; esac)
KUBERNETES_SERVER_URL="$KUBERNETES_SERVICE_SCHEME"://"$KUBERNETES_SERVICE_HOST":"$KUBERNETES_SERVICE_PORT"
KUBERNETES_CLUSTER_CA_FILE="$SERVICE_ACCOUNT_DIR"/ca.crt
KUBERNETES_NAMESPACE=$(cat "$SERVICE_ACCOUNT_DIR"/namespace)
KUBERNETES_USER_TOKEN=$(cat "$SERVICE_ACCOUNT_DIR"/token)
KUBERNETES_CONTEXT="inCluster"
mkdir -p "$HOME"/.kube
cat << EOF > "$HOME"/.kube/config
@enriched
enriched / bazel-generate-eclipse-project.sh
Last active November 3, 2020 14:16
Generate Eclipse project for Bazel workspace (works with vscode-java)
#!/usr/bin/env bash
set -euo pipefail
cd $(bazel info workspace)
WORKSPACE_NAME=$(basename $PWD)
cat << EOF > ./.project
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
@enriched
enriched / copy_to_workspace.bzl
Last active May 24, 2019 20:46
Copy Bazel Output to Workspace
COPY_TEMPLATE = """\
#!/bin/bash
FROM_PATH="$PWD/{copy_from}"
TO_PATH="$BUILD_WORKSPACE_DIRECTORY/{to}/"
echo "Copying from $FROM_PATH to $TO_PATH"
cp -f $FROM_PATH $TO_PATH
"""
@enriched
enriched / extract_npm_token.sh
Created September 12, 2017 19:57
Get NPM Token from .npmrc
if [ -z "$NPM_TOKEN" ]; then
NPM_TOKEN=$(sed -En 's|^//registry\.npmjs\.org/:_authToken=(.*)|\1|p' ~/.npmrc);
fi
@enriched
enriched / run-in-folder.sh
Created August 2, 2017 00:50
Run Bash command in another folder
run-in-folder ()
{
CUR_PWD=$PWD;
cd $1;
eval "${@:2}";
cd $CUR_PWD;
}
@enriched
enriched / keybase.md
Created July 29, 2016 03:56
keybase.md

Keybase proof

I hereby claim:

  • I am enriched on github.
  • I am enriched (https://keybase.io/enriched) on keybase.
  • I have a public key whose fingerprint is 4647 E8D8 7A94 3EE9 14D1 3A29 C0F0 DA43 480F 6E04

To claim this, I am signing this object:

@enriched
enriched / durable.ts
Created May 23, 2016 18:07
Typescript definitions for durable
var durable: DurableStatic = require('durable');
export {durable};
export interface DurableStatic {
state: <M extends EventBase, S extends StateBase>(name: string) => State<M, S>;
statechart: <M extends EventBase, S extends StateBase>(name: string) => Statechart<M, S>;
stage: <M extends EventBase, S extends StateBase>(name: string) => Stage<M, S>;
flowchart: <M extends EventBase, S extends StateBase>(name: string) => Flowchart<M, S>;
ruleset: <M extends EventBase, S extends StateBase>(name: string) => Ruleset<M, S>;
@enriched
enriched / jsonSchemaInterface.ts
Last active December 8, 2023 07:28
TypeScript interface for Json-Schema V4
/**
* MIT License
*
* Copyright (c) 2016 Richard Adams (https://github.com/enriched)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is