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 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 / 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 / middleware.py
Last active June 27, 2023 17:01
A Django middleware that process JSON data into the appropriate GET or POST variable. I use this with AngularJS, by default POST requests are sent as JSON instead of the urlencoded data expected by Django.
class JSONMiddleware(object):
"""
Process application/json requests data from GET and POST requests.
"""
def process_request(self, request):
if 'application/json' in request.META['CONTENT_TYPE']:
# load the json data
data = json.loads(request.body)
# for consistency sake, we want to return
# a Django QueryDict and not a plain Dict.
@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 / rqperiodic.py
Created March 15, 2014 22:08
Demonstration of how to create cron like periodic tasks using python RQ (http://python-rq.org/), django_rq (https://github.com/ui/django-rq), rq_scheduler (https://github.com/ui/rq-scheduler)
# put in app/management/commands
from datetime import datetime
import importlib
import logging
from optparse import make_option
from django.conf import settings
from django.core.management.base import BaseCommand
import django_rq
@LucasRoesler
LucasRoesler / scim.yaml
Last active July 7, 2020 22:06
EB SCIM
swagger: '2.0'
info:
title: Teem User Provisioning API
version: "1.0.0"
contact:
url: https://teem.com/developers/
email: support@teem.com
# the domain of the service
host: app.teem.com
# will be prefixed to all paths
@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 / 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