Skip to content

Instantly share code, notes, and snippets.

View MattSegal's full-sized avatar
💭
Recovering engineering student

Matt Segal MattSegal

💭
Recovering engineering student
View GitHub Profile
user root;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
##
from django.forms import ModelForm
from django.template.loader import render_to_string
from django.shortcuts import render
from django.http import Http404
from django.contrib import messages
class DynamicTableForm(ModelForm):
"""
Renders a table which can be optionally edited by a user using htmx.
<div id="dynamic-form-{{ form.slug }}">
{% if form.editable %}
<form
class="ui form {% if form.errors %}error{% else %}success{% endif %}"
method="post"
hx-post="./{{ form.slug }}/"
hx-target="#dynamic-form-{{form.slug}}"
hx-swap="outerHTML"
>
{% for field in form %}
@MattSegal
MattSegal / mini-bash-cli.sh
Created October 3, 2022 01:53
a tiny bash function that turns a folder containing bash scripts into a CLI with auto complete
function matt {
if [[ ! -d "./matt "]]; then
echo "No matt folder found."
else
options=$(ls matt | grep ".*\.sh$" | cut -d. -f1)
if [[ -z "$1" ]]; then
echo -e "Options:\n\n$options\n"
else
echo "Running $1"
bash ./matt/$1.sh ${@:2}
function gitlab {
# Find the branch we're on.
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
# Find whether there is an MR open for this branch.
# Requires the Gitlab CLI: https://gitlab.com/gitlab-org/cli
MR_ID=$(glab mr list --author=@me | grep "← ($BRANCH_NAME" | cut -f1)
MR_ID=${MR_ID:1}
# Find the git remote URL.
from typing import List
from datetime import timedelta, datetime
import streamlit as st
import pandas as pd
IGNORE_DESCRIPTIONS = [
"Internal Transfer",
"International Transaction Fee",
]