Skip to content

Instantly share code, notes, and snippets.

View looselycoupled's full-sized avatar

Allen Leis looselycoupled

  • United States
View GitHub Profile
@looselycoupled
looselycoupled / proof-of-concept.py
Created February 29, 2024 21:37
Proof of concept for rewriting weighted random choice but with Spanner so cannot do entirely in query
import random
from pprint import pprint
from google.cloud import spanner
# Initialize Spanner client
spanner_client = spanner.Client(project='test-project')
instance = spanner_client.instance('test-instance')
database = instance.database('test-database')
@looselycoupled
looselycoupled / jwt_example.go
Last active February 29, 2024 21:28
Quick demonstration to create a JWKS, sign a token, and then validate it
package main
import (
"crypto/ed25519"
"crypto/rand"
"encoding/json"
"fmt"
"time"
"github.com/lestrrat-go/jwx/v2/jwa"
@looselycoupled
looselycoupled / README.md
Created October 25, 2023 15:50 — forked from palewire/README.md
How to push tagged Docker releases to Google Artifact Registry with a GitHub Action

How to push tagged Docker releases to Google Artifact Registry with a GitHub Action

Here's how I configured a GitHub Action so that a new version issued by GitHub's release interface will build a Dockerfile, tag it with the version number and upload it to Google Artifact Registry.

Before you attempt the steps below, you need the following:

  • A GitHub repository that contains a working Dockerfile
  • The Google Cloud SDK tool gcloud installed and authenticated

Create a Workload Identity Federation

#!/usr/bin/env python
"""
Template for RSS exercise
"""
##########################################################################
## Imports
##########################################################################
import os
import re
@looselycoupled
looselycoupled / test.go
Last active February 9, 2023 04:13
Simple example of using the ProtonMail/gopenpgp package to quickly create ed25519 keys and then encrypt/decrypt some data.
package foo
import (
"github.com/ProtonMail/gopenpgp/v2/crypto"
"github.com/ProtonMail/gopenpgp/v2/helper"
"github.com/stretchr/testify/require"
"testing"
)
func TestGenerateGPGKeys(t *testing.T) {
package main
import (
"crypto/sha256"
"encoding/hex"
"fmt"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
"io"
"os"
# vim:ft=zsh ts=2 sw=2 sts=2
#
# Based on agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
# Make sure you have a recent version: the code points that Powerline
@looselycoupled
looselycoupled / demo.py
Created April 16, 2020 23:11
Simple Ray demo
import ray
from collections import Counter
import socket
from pprint import pprint
ray.init("auto")
@ray.remote
def f(x):
return x + (socket.gethostname(), )
@looselycoupled
looselycoupled / 6 - Water Plate Image Exploration 7-14.ipynb
Created August 15, 2019 15:00
Water IR Test w/ Updated Camera App
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@looselycoupled
looselycoupled / cluster_capacity.py
Last active June 5, 2019 15:33
k8s node capacity
import re
import subprocess
from tabulate import tabulate
def get_nodes():
output = subprocess.run("kubectl get nodes".split(), stdout=subprocess.PIPE)
text = output.stdout.decode("utf-8").split("\n")
return [(re.split("\s+", line)[0],re.split("\s+", line)[2]) for line in text[1:] if line]
def cluster_capacity():