Skip to content

Instantly share code, notes, and snippets.

@sandys
sandys / Fastapi-sqlalchemy-pydantic-dataclasses-reloadable-logging.md
Last active June 30, 2024 09:23
fastapi with python 3.10 dataclasses - used to create both sqlalchemy and pydantic models simultaneously. And setting up sqlalchemy the right way (without deadlocks or other problems). Additionally, this also takes care of unified logging when running under gunicorn..as well as being able to run in restartable mode.
import os
import pickle
import warnings
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from tensorflow.keras.callbacks import EarlyStopping
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import Dropout
@JavascriptMick
JavascriptMick / Header.vue
Created May 12, 2023 13:39
Vue 3 Toast notifications using Pinia and DaisyUI
<script setup lang="ts">
import { storeToRefs } from 'pinia';
const notifyStore = useNotifyStore();
const { notifications } = storeToRefs(notifyStore);
</script>
<template>
....
<div class="toast toast-end toast-top">
<div v-for="notification in notifications" :class="notification.type">
@craigsc
craigsc / geotiff.client.ts
Created July 9, 2023 22:11
MapLibre GeoTiff source support
import { encode } from "fast-png";
import type { GeoTIFFImage, ReadRasterResult } from "geotiff";
import { fromUrl, Pool } from "geotiff";
import type { RasterSourceSpecification } from "maplibre-gl";
import maplibregl from "maplibre-gl";
const tileSize = 256;
const decoderPool = new Pool();
/**