Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View LucasRoesler's full-sized avatar

Lucas Roesler LucasRoesler

View GitHub Profile
@LucasRoesler
LucasRoesler / README.md
Last active November 17, 2023 13:07
Find squash-commited branches that can be deleted

Git Branch Audit

  1. It retrieves the name of the default branch from the remote repository using the git ls-remote command.
  2. It checks out the default branch locally.
  3. It lists all local branches using the git for-each-ref command.
  4. For each local branch, it finds the merge base between the default branch and the current branch using the git merge-base command.
  5. It creates a temporary commit tree for the current branch using the git commit-tree command.
  6. It checks if the temporary commit is a descendant of the default branch using the git cherry command.
  7. If the temporary commit is not a descendant (i.e., the branch has been merged into the default branch), it prints a message indicating that the branch can be deleted.
@LucasRoesler
LucasRoesler / create-repo.sh
Last active October 13, 2023 12:31
create-python-repo.sh
#!/bin/bash
# source: https://gist.github.com/LucasRoesler/c7b245bcd9f33bc989e279ba9cdb9828
# usage:
# create-repo [name] [owner]
# create-repo [name] # owner defaults to contiamo
# create-repo # name defaults to the current directory name
# name is the first arg, fallback to the the current directory name
NAME=${1:-$(basename $(pwd))}
OWNER=${2:-contiamo}
@LucasRoesler
LucasRoesler / writer.test.ts
Last active September 20, 2022 09:08
streaming chunked file upload to s3 in typescript
import { S3Client } from "@aws-sdk/client-s3";
import { streamingWrite, Upload } from "./writer";
const sleep = (ms: number) => {
return new Promise(resolve => setTimeout(resolve, ms));
};
// skip because it requires a real s3 bucket, this is still useful for testing locally.
describe.skip("streamingWriter", () => {
@LucasRoesler
LucasRoesler / README.md
Last active February 21, 2024 22:59
Example cloudformation that sets up an s3 bucket and notifications sent to an sqs queue.

Usage

Create a new user in the console, assign it no permissions, but make sure to download the credentials.

Go to the user and copy the user ARN:

arn:aws:iam::<account-id>:user/of-connector-test
@LucasRoesler
LucasRoesler / openfaas-fsgroup.sh
Created March 12, 2020 19:06
Installing openfaas with fsGroup security policy poc
kubectl create namespace openfaas-fn
kubectl create namespace openfaas
kubectl -n openfaas create secret generic basic-auth \
--from-literal=basic-auth-user=admin \
--from-literal=basic-auth-password=localdev
helm upgrade lucas-of openfaas/openfaas \
--install \
--namespace openfaas \
--set basic_auth=true \
--set functionNamespace=openfaas-fn \
@LucasRoesler
LucasRoesler / chrome_HSTS_clear.md
Created December 18, 2019 12:20 — forked from stollcri/chrome_HSTS_clear.md
Clear 307 HSTS redirects in Google Chrome

To clear 307 HSTS redirects in Google Chrome (if you experimenting with SSL -- you probably wouldn't want to do this for a site that you do not opperate, since it is there to protect you), go to the following URL and delete the site.

chrome://net-internals/#hsts

@LucasRoesler
LucasRoesler / kind-faas-netes-certification.md
Created July 28, 2019 09:27
Running OpenFaaS Certifier for faas-netes in KinD
  1. Start the KinD env and disable auth. In the faas-netes project
make start-kind
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"

helm upgrade openfaas --install ./chart/openfaas \
    --namespace openfaas  \
    --set basic_auth=false \
--set openfaasImagePullPolicy=IfNotPresent \
#!/usr/bin/env bash
# reset environment variables that could interfere with normal usage
export GREP_OPTIONS=
# put all utility functions here
# make a temporary file
git_extra_mktemp() {
mktemp -t "$(basename "$0")".XXX
}
@LucasRoesler
LucasRoesler / graceful_servers.go
Last active May 10, 2019 07:30
Two possible call signatures for gracefully starting and ending the health server
// ListenAndServeMonitoring starts up an HTTP server serving /metrics and /health.
//
// When the context is cancelled, the server will be gracefully shutdown.
func ListenAndServeMonitoring(ctx context.Context, addr string, healthHandler http.Handler) error {
srv := monitoringServer(addr, healthHandler)
go func() {
<-ctx.Done()
shutdownContext, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
@LucasRoesler
LucasRoesler / dev-openfaas-env.sh
Last active November 24, 2019 21:57
Create a new dev environment using KinD and immediately forward the Gateway port
#!/bin/bash
DEVENV=${1:-devopenfaas}
kind create cluster --name "$DEVENV"
export KUBECONFIG="$(kind get kubeconfig-path --name="$DEVENV")"
kubectl rollout status deploy coredns --watch -n kube-system
# INSTALLING HELM