Skip to content

Instantly share code, notes, and snippets.

@okld
okld / multipage_settings_app.py
Last active July 11, 2024 23:55
Streamlit - Settings page with session state
import streamlit as st
from persist import persist, load_widget_state
def main():
if "page" not in st.session_state:
# Initialize session state.
st.session_state.update({
# Default page.
"page": "home",
@nielsuit227
nielsuit227 / SelectBrushPlot
Last active December 3, 2021 17:33
Time Series Plot (leeoniya/uPlot) with brush and selection option
import React, {useEffect, useRef, useState} from 'react';
import { Switch, Flex, Text } from '@chakra-ui/react';
import UplotReact from 'uplot-react';
import { toast } from 'react-toastify';
import 'uplot/dist/uPlot.min.css';
const colors = [
'#007BFF',
'#FFA62B',
@ktmud
ktmud / __init__.py
Last active December 21, 2024 23:17
An extreme simple Python http server with auto reload and file-system based router
import os
from .app import start_cli_service
env = (os.environ.get("env") or "prod").lower()
is_dev = env == "dev" or env == "local"
port, autoreload_observer = start_cli_service(autoreload=is_dev)
if autoreload_observer:
# move autoreload observer to the foreground so process won't exit
@ymoslem
ymoslem / ChatGPT-translation.py
Last active May 4, 2024 16:50
Minimal working code for translation with GPT-4, "gpt-3.5-turbo" (a.k.a. ChatGPT) and "text-davinci-003"
# pip3 install openai
import openai
import time
OPENAI_API_KEY = "your_api_key_here"
openai.api_key = OPENAI_API_KEY
prompt = """French: La semaine dernière, quelqu’un m’a fait part de sa gratitude envers notre travail.