Skip to content

Instantly share code, notes, and snippets.

View tcbegley's full-sized avatar

Tom Begley tcbegley

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tcbegley
tcbegley / app.py
Last active January 18, 2024 22:03
from __future__ import annotations
from uuid import UUID
from litestar import Litestar, get
from litestar.contrib.sqlalchemy.base import UUIDBase
from litestar.contrib.sqlalchemy.dto import SQLAlchemyDTO, SQLAlchemyDTOConfig
from litestar.contrib.sqlalchemy.plugins import (
AsyncSessionConfig,
SQLAlchemyAsyncConfig,
@tcbegley
tcbegley / app.py
Created May 16, 2020 09:46
Dismissable list of cards in dash
import json
import dash
import dash_bootstrap_components as dbc
import dash_html_components as html
from dash.dependencies import ALL, Input, Output, State
from dash.exceptions import PreventUpdate
FONT_AWESOME = "https://use.fontawesome.com/releases/v5.13.0/css/all.css"
app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP, FONT_AWESOME])
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
"""
Fairlearn expects scikit-learn models. This submodule has some shims to work
around that issue.
"""
import numpy as np
import tensorflow as tf
class KerasWrapper:
def __init__(self, model, model_path="/tmp/corrected-model.h5"):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import matplotlib.pyplot as plt
import numpy as np
import requests
# data source
URL = "http://www.stat.columbia.edu/~gelman/book/data/light.asc"
# simulation hyperparams
N_SIM = 200 # number of simulations
# -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
from dash.dependencies import Input, Output
import pandas as pd
import datetime as dt
from io import StringIO
@tcbegley
tcbegley / layout_demo.py
Created June 10, 2020 07:05
Fixed up app from dash-bootstrap-components issue tracker.
# -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
from dash.dependencies import Input, Output
import pandas as pd
import datetime as dt
from io import StringIO
@tcbegley
tcbegley / app.py
Created May 9, 2019 18:12
A demo app using query parameters to set dropdown value on a different page.
import dash
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
def parse_query_params(s):
s = s.lstrip("?")
return dict(pair.split("=") for pair in s.split("&"))