Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Recovering engineering student

Matt Segal MattSegal

💭
Recovering engineering student
View GitHub Profile
View _dynamic_table_form.html
<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 %}
View dynamic_table_form.py
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.
View nginx.conf
user root;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
##
View website.confg
### Virtual Host Config
## HTTP Redirects
server {
listen 80;
listen [::]:80;
server_name www.mattslinks.xyz;
return 301 http://mattslinks.xyz$request_uri;
}
server {
View example2.js
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(){
View example.js
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(){
View tts.py
"""
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
View schema.yaml
runtime:
type: dict
schema:
cuda:
type: boolean
required: true
nullable: false
logging:
type: dict
View config.yaml
# Training config
runtime:
cuda: true
logging:
# Logging to Weights and Bias dashboard
wandb:
project_name: null
# Saving checkpoint to S3
checkpoint:
save_name: null
View config_validation.py
from cerberus import Validator
ENV_CHOICES = ("aws", "desktop", "laptop")
CONFIG_SCHEMA = {
"runtime": {
"type": "dict",
"schema": {"cuda": {"type": "boolean", "required": True, "nullable": False},},
},
"logging": {
"type": "dict",