Skip to content

Instantly share code, notes, and snippets.

View pbrumblay's full-sized avatar

Peter Brumblay pbrumblay

  • Tyr Consulting, LLC
  • Denver, CO
View GitHub Profile
@pbrumblay
pbrumblay / grants.py
Created October 10, 2025 15:39
grants.gov
import xml.etree.ElementTree as ET
from datetime import datetime
from typing import List, Optional, Dict, Any, Union
from pydantic import BaseModel, Field, validator
import os
import pandas as pd
from google.cloud import bigquery, storage
# --- 1. Define the Target Schema using Pydantic ---
# This class defines the structure of our final, clean output object.
resource "google_privateca_ca_pool" "root_ca_pool" {
location = var.region
project = var.target_project_id
name = "root-ca-pool"
tier = "ENTERPRISE"
publishing_options {
publish_ca_cert = true
publish_crl = true
}
package com.tyrconsulting.identityparser;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.concurrent.ExecutionException;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
@pbrumblay
pbrumblay / delete-gcp-tag-bindings-values-keys.md
Last active May 22, 2024 15:17
Delete GCP security tag bindings, values and keys using gcloud

use asset inventory to list bindings

gcloud asset list --organization $ORG_ID --asset-types cloudresourcemanager.googleapis.com/TagBinding

Ouput like the following:

---
ancestors:
- folders/111
@pbrumblay
pbrumblay / cf-edgettl-tfdebug.log
Created November 2, 2022 16:56
Cloudflare provider expects default attribute for edge_ttl mode = "respect_origin". API errors on this.
---[ REQUEST ]---------------------------------------
POST /client/v4/zones/REDACTED/rulesets HTTP/1.1
Host: api.cloudflare.com
User-Agent: terraform/1.3.3 terraform-plugin-sdk/2.10.1 terraform-provider-cloudflare/3.27.0
Content-Length: 389
Content-Type: application/json
X-Auth-Email: REDACTED
X-Auth-Key: REDACTED
Accept-Encoding: gzip
@pbrumblay
pbrumblay / move-messages.js
Created September 20, 2022 21:00
Moves messages from a subscription (aka deadletter subscription) to a topic. Can be used for replay.
import {PubSub, v1} from '@google-cloud/pubsub';
import logger from '#utils/logger';
export async function moveMessages(options) {
const subClient = new v1.SubscriberClient();
const publishClient = new PubSub({projectId: options.topicproject});
const publisher = publishClient.topic(options.targettopic, {
batching: {
maxMessages: 100,
maxMilliseconds: 100,
@pbrumblay
pbrumblay / vietnameseLucky.js
Created June 24, 2022 15:15
Using Vietnamese numerology, is your number lucky?
const myArgs = process.argv.slice(2);
let computedNum = 99999;
let numString = myArgs[0];
while(computedNum > 9) {
let sum = 0;
for (var i = 0; i < numString.length; i++) {
sum += parseInt(numString.charAt(i));
}
@pbrumblay
pbrumblay / pubtestdata.js
Created June 20, 2022 23:22
Publish test data
import {Command} from 'commander';
import 'dotenv/config.js'; // eslint-disable-line import/no-unassigned-import
import {PubSub} from '@google-cloud/pubsub';
const program = new Command();
program
.requiredOption('-t, --targettopic <topic name>', 'Target topic to move messages to.')
.requiredOption('-tp, --topicproject <project>', 'Name of project where topic is defined.')
@pbrumblay
pbrumblay / ctcurl.sh
Last active June 16, 2022 15:09
Curl script to exercise CT API
#!/bin/sh
# Requests manage_project which is full control over project.
# Need to define:
# CT_PROJECT_KEY
# CT_CLIENT_ID
# CT_SECRET
#
# Example queries a product by id.
ctapiurl="https://api.us-central1.gcp.commercetools.com/$CT_PROJECT_KEY"
token=`curl https://$CT_CLIENT_ID:[email protected]/oauth/token -X POST -d "grant_type=client_credentials&scope=manage_project:$CT_PROJECT_KEY" | sed 's/{"access_token":"\([^"]*\).*/\1/'`
import fs from 'fs';
import path from 'path';
import csv from '@fast-csv/parse';
import { Parser } from 'json2csv';
const myArgs = process.argv.slice(2);
const directoryPath = myArgs[0];
const rows = [];