Skip to content

Instantly share code, notes, and snippets.

@curtis1000
curtis1000 / upload-recording.ts
Created December 15, 2022 18:15
upload-recording.ts
async function uploadRecording() {
// get a presigned url
let response = await fetch('https://<url to the lambda>?'+ new URLSearchParams({
type: videoFormat()
}));
const { uploadURL } = await (response).json();
response = await fetch(uploadURL, {
method: 'PUT',
mode: 'cors',
@curtis1000
curtis1000 / get-signed-url.js
Created December 15, 2022 18:12
get signed url / lambda js
'use strict'
const AWS = require('aws-sdk')
AWS.config.update({ region: process.env.AWS_REGION || 'us-east-1' })
const s3 = new AWS.S3()
// Main Lambda entry point
exports.handler = async (event) => {
const result = await getUploadURL(event)
return result
@curtis1000
curtis1000 / prom-k8s-request-limits.md
Last active July 13, 2022 15:45 — forked from max-rocket-internet/prom-k8s-request-limits.md
How to display Kubernetes request and limit in Grafana / Prometheus properly

CPU: percentage of limit

A lot of people land when trying to find out how to calculate CPU usage metric correctly in prometheus, myself included! So I'll post what I eventually ended up using as I think it's still a little difficult trying to tie together all the snippets of info here and elsewhere.

This is specific to k8s and containers that have CPU limits set.

To show CPU usage as a percentage of the limit given to the container, this is the Prometheus query we used to create nice graphs in Grafana:

sum(rate(container_cpu_usage_seconds_total{name!~".*prometheus.*", image!="", container!="POD"}[5m])) by (pod, container) /
@curtis1000
curtis1000 / use-terraform.sh
Created November 2, 2020 15:53
Terraform Version Switcher for MacOS
#!/bin/bash
#######################################
# Terraform version switcher for MacOS
# Usage: use-terraform 0.12.29
#######################################
set -e
die () {
@curtis1000
curtis1000 / retries.py
Last active December 5, 2019 16:40
Python Retries
import time
# testing out the retry pattern described here:
# https://stackoverflow.com/questions/2083987/how-to-retry-after-exception/2083996#2083996
tries = 5
sleep = 1
##########################################
@curtis1000
curtis1000 / retries.py
Created December 5, 2019 16:31
Python Retries
import time
# testing out the retry pattern described here:
# https://stackoverflow.com/questions/2083987/how-to-retry-after-exception/2083996#2083996
tries = 5
sleep = 1
def throw_exception():
return '2' + 2
@curtis1000
curtis1000 / switch.sh
Created January 17, 2019 16:49
Git Branch Switcher
#!/usr/bin/env ruby
require 'highline'
# Creates a numbered menu of your most recently committed branches to quickly jump between them
# Prerequisites:
# 1) ruby
# 2) gem install highline
LIMIT = 6
@curtis1000
curtis1000 / wo.sh
Last active August 24, 2018 03:47
Working On
function wo() {
# if there are no arguments
if [ $# -eq 0 ]
then
# output the log
tail ~/.wo
else
# append the log
echo \[$(date +"%Y-%m-%d %T")] "$@" >> ~/.wo
fi
@curtis1000
curtis1000 / DOCKER_RUBY.md
Last active September 29, 2017 02:26
Docker Ruby Env

One-liner to run a ruby script with docker

docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp ruby:latest ruby ./version.rb

Note that the command supplied to the image is everything after the image name "ruby:latest" in the example above.

@curtis1000
curtis1000 / watch.md
Last active June 27, 2017 16:16
Watch Script on MacOS

Watch Script on MacOS

Dependencies

brew install entr

entr is a utility that responds to change, we just need to pipe in a list of files for it to watch

Example Usage: