Skip to content

Instantly share code, notes, and snippets.

View hansthen's full-sized avatar

Hans Then hansthen

View GitHub Profile
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):
@hansthen
hansthen / argparse_with_map
Created April 3, 2025 17:31
argparse form v2
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
@hansthen
hansthen / cast streamlit argparse
Created April 2, 2025 22:09
casting in streamlit argparse
# get the supplied values and cast them
# to the correct type
value = getattr(result, action.dest)
match value:
case None:
pass
case [*_]:
value = [str(v) for v in value]
value = parser._get_values(
action, value
@hansthen
hansthen / streamlit-argparse.py
Last active March 9, 2025 15:04
streamlit-argparse
import argparse
import streamlit as st
import shlex
from copy import deepcopy
from streamlit_tags import st_tags
class Form():
def __init__(
self,
parser,