Skip to content

Instantly share code, notes, and snippets.

View hansthen's full-sized avatar

Hans Then hansthen

View GitHub Profile
@hansthen
hansthen / nginx.conf
Created June 26, 2026 06:11
nginx config for streamlit
location /streamlit/ {
set $backend "streamlit:8501";
proxy_pass http://$backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 86400;
@hansthen
hansthen / topbar.py
Last active June 14, 2026 15:01
styled navigation
import streamlit as st
from streamlit_redirect import redirect
st.session_state.setdefault("blur", False)
st.session_state.setdefault("page", None)
def toggle_blur():
pg = st.session_state.page
st.session_state.blur = not st.session_state.blur
st.switch_page(pg)
import streamlit as st
button = st.html("<span id='button' draggable='true' style='border: 1px solid red;'>hello world</span>")
with st.container(key="board") as cont:
left, right = st.columns(2)
with left:
st.markdown('<div data-column="left" class="column-marker"/>', unsafe_allow_html=True)
st.write("left")
import folium
import streamlit as st
from folium.plugins import GeoMan, MousePosition
from folium import JsCode
from streamlit_folium import st_folium
from scenario import parser
from streamlit_argparse import Form
import requests
@hansthen
hansthen / geoman.py
Created June 18, 2025 21:12
geoman multiple shapes
import folium
import streamlit as st
from folium.plugins import GeoMan, MousePosition
from folium import JsCode
from streamlit_folium import st_folium
st.set_page_config(
page_title="geoman",
layout="wide"
@hansthen
hansthen / multiple shapes
Created June 18, 2025 21:09
example streamlit-argparse
mport argparse
from streamlit_argparse import Form
from streamlit_folium import st_folium
import folium
from folium.plugins import Draw
import streamlit as st
import shlex
import jq
import json
import streamlit as st
from streamlit_template import Template
st.set_page_config(
layout="wide"
)
style = """
.card {
/* Add shadows to create the "card" effect */
@hansthen
hansthen / shortcuts.py
Created June 15, 2025 21:10
Keyboard shortcuts in streamlit
def shortcuts(**buttons):
key = str(uuid.uuid4())
styl = f"""
<style>
.st-key-{key} {{
display: none;
}}
</style>
"""
st.markdown(styl, unsafe_allow_html=True)
@hansthen
hansthen / timeout.py
Last active May 25, 2025 19:14
fetchlib with timeouts
mport aiohttp
import asyncio
from datetime import datetime
from aiostream import stream as aiozip
from pipe import Pipe
import json
import jq
import aiohttp
import asyncio
from pipe import Pipe
import json
import jq
api_key="<your key>"
async def schedule(interval):