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
from typing import List
from datetime import timedelta, datetime
import streamlit as st
import pandas as pd
IGNORE_DESCRIPTIONS = [
"Internal Transfer",
"International Transaction Fee",
]
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.
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.
@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}
<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 %}
### Virtual Host Config
## HTTP Redirects
server {
listen 80;
listen [::]:80;
server_name www.mattslinks.xyz;
return 301 http://mattslinks.xyz$request_uri;
}
server {
user root;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
##
import React, { useState } from 'react'
import Header from './components/Header.js'
import Game from './components/Game.js'
import LeaderBoard from './components/LeaderBoard.js'
import Spinner from './components/Spinner.js'
// Don't hardcode strings, use constants
const DEFAULT_NAME = 'jeff'
export default function App(){
@MattSegal
MattSegal / example.js
Last active September 15, 2020 23:20
import React, { useState } from 'react'
import Header from './components/Header.js'
import Game from './components/Game.js'
import LeaderBoard from './components/LeaderBoard.js'
import Spinner from './components/Spinner.js'
// Don't hardcode strings, use constants
const DEFAULT_NAME = 'jeff'
export default function App(){
"""
Synthesizes speech from the input string of text.
from reader.services.translate.polly import text_to_speech_mp3
reading = Reading.objects.last()
with open('./test.mp3', 'wb') as f:
text_to_speech_mp3(reading, f)
"""
from io import BytesIO
import boto3