Skip to content

Instantly share code, notes, and snippets.

View sandrom's full-sized avatar

Sandro Manke sandrom

View GitHub Profile
@FeepingCreature
FeepingCreature / youre_doing_json_apis_wrong.md
Last active January 7, 2024 19:33
You Are Doing JSON APIs Wrong

You are doing JSON APIs wrong.

When you use JSON to call an API - not a REST API, but something like JSON-RPC - you will usually want to encode one of several possible messages.

Your request body looks like this:

{
 "type": "MessageWithA",
@mikesparr
mikesparr / gke-config-connector-storage-bucket-demo.sh
Last active January 13, 2022 16:28
Google Cloud Kubernetes Config Connector Test (working)
#!/usr/bin/env bash
# ref: https://cloud.google.com/config-connector/docs/how-to/getting-started
export PROJECT_ID=$(gcloud config get-value project)
export PROJECT_USER=$(gcloud config get-value core/account) # set current user
export PROJECT_NUMBER=$(gcloud projects describe $PROJECT_ID --format="value(projectNumber)")
export IDNS=${PROJECT_ID}.svc.id.goog # workload identity domain
export GCP_REGION="us-central1"
from math import *
# a performant solution would store a prefix sum of line lengths to
# a sidechannel and then use that to do a bsearch; on the GPU,
# you'd do a sum tree / histopyramid as a preprocessing step
def find_point(points, d):
d = d
for i in range(1, len(points)):
x0,y0 = points[i-1]
x1,y1 = points[i]