Skip to content

Instantly share code, notes, and snippets.

View lox's full-sized avatar

Lachlan Donald lox

View GitHub Profile
@lox
lox / pipeline.yml
Created November 11, 2024 04:37
Example Buildkite Pipeline to Print OIDC Token
steps:
- label: ":key: Test OIDC Token"
command: |
# Request an OIDC token
echo "--- :buildkite: Requesting OIDC token"
BUILDKITE_OIDC_TOKEN="$(buildkite-agent oidc request-token)"
echo "--- :mag: Token details"
# Print token (redacted in logs for security)
echo "Token: \$BUILDKITE_OIDC_TOKEN"
@lox
lox / README.md
Created August 24, 2024 23:26
Buildkite Pipeline w/ step_template

Step Templates

As there get to be more Buildkite plugins that are useful, the challenge is they clutter up pipelines and it's hard to make cross-cutting changes to the plugin configuration.

What if there was top-level block for creating templates for steps that was basically just top-level properties that would be copied to the steps?

It's an incremental solution vs a redesign of plugins, but it would allow for much cleaner templates.

The attached example is a very simple pipeline, but I've seen long pipelines with lots and lots of plugins, it's a mess!

@lox
lox / groq-whisper.py
Created May 3, 2024 02:12
Experimental client to test Whisper on GroqCloud
import os
import argparse
import requests
from datetime import datetime
# Define the parser for command line arguments
parser = argparse.ArgumentParser(description='Groq Whisper transcribe')
parser.add_argument('file', type=str, help='Audio file to transcribe')
parser.add_argument('--output_file', type=str, help='File to write output', default="transcription.txt")
args = parser.parse_args()
@lox
lox / Setup.md
Last active March 27, 2024 01:35
Setup Ubuntu 22.04 for Deep Learning
# Check for Nvidia Hardware
lspci | grep -i nvidia

# Update
apt update
apt upgrade

# Install Nvidia drivers
apt install nvidia-driver-535 nvtop
@lox
lox / main.tf
Last active September 14, 2023 11:28
Drata Integration for GCP in Terraform
# https://help.drata.com/en/articles/4994112-gcp-connection-details
# Create a new project for Drata Integration
resource "google_project" "drata" {
name = var.project_name
project_id = var.project_id
org_id = var.org_id
billing_account = var.billing_account_id
auto_create_network = false
}
@lox
lox / intercept.js
Created September 10, 2023 04:42
Example of using mswjs interceptors
import { BatchInterceptor } from '@mswjs/interceptors'
import { ClientRequestInterceptor } from '@mswjs/interceptors/ClientRequest'
import { FetchInterceptor } from '@mswjs/interceptors/fetch'
import http from 'http'
const interceptor = new BatchInterceptor({
name: 'my-interceptor',
interceptors: [new ClientRequestInterceptor(), new FetchInterceptor()],
})
@lox
lox / main.tf
Last active September 5, 2023 23:45
Terraform for setting up Identity Federation with GCP for Namespace workloads
// See https://cloud.namespace.so/docs/federation/gcp
locals {
roles = [
"roles/resourcemanager.projectIamAdmin", # allow managing identity
"roles/editor", # allow to manage all resources
"roles/iam.serviceAccountAdmin", # allow to manage service accounts
]
}
@lox
lox / Worker.js
Last active August 31, 2023 09:58
Cloudflare worker for rewriting a custom domain to work with Firebase SDK
addEventListener('fetch', (event) => {
event.respondWith(handleRequest(event.request))
})
/**
* Intercept requests and redirect to Firestore API
* @param {Request} request
*/
async function handleRequest(request) {
const url = new URL(request.url)
@lox
lox / stream-to-cw-logs
Created May 24, 2023 02:35
Stream stdin to cloudwatch logs
#!/bin/bash
# Enable bash strict mode
set -euo pipefail
IFS=$'\n\t'
# Disable the pager for aws commands (no less on the host)
export AWS_PAGER=""
# Get the log group arn as a parameter and cut the group name out of it
@lox
lox / gist:c7a3b44970201b716e600f3538a6e351
Last active March 14, 2023 22:20
A Buildkite pre-bootstrap hook that protects against attacks via known dangerous environment variables
#!/bin/bash
set -euo pipefail
# Buildkite pre-bootstrap hook that fails a build if there are any
# dangerous environment variables set.
blocklist=(
# General Linux
"PATH" # Executable search path
"LD_PRELOAD" # Preloaded shared libraries