This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import time | |
class TimeIt(object): | |
"""Simple timer for profiling Streamlit apps. | |
Usage | |
----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from streamlit.ScriptRequestQueue import RerunData | |
from streamlit.ScriptRunner import RerunException | |
from streamlit.server.Server import Server | |
import streamlit.ReportThread as ReportThread | |
def rerun(): | |
"""Rerun a Streamlit app from the top!""" | |
widget_states = _get_widget_states() | |
raise RerunException(RerunData(widget_states)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MEDIA_TYPE = "video/webm;codecs=vp9,opus" | |
//const MEDIA_TYPE = "video/webm;codecs=h264" | |
const BLOB_TYPE = "video/webm" | |
class ScreenCastRecorder { | |
constructor({ recordAudio }) { | |
this.recordAudio = recordAudio | |
this.inputStream = null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Another prototype of the State implementation. | |
Usage | |
----- | |
How to import this: | |
import streamlit as st | |
import st_state_patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Adds an st.rerun() command to Streamlit. | |
Usage: | |
import streamlit as st | |
import st_rerun_patch | |
# ... | |
st.rerun() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
def is_running_in_streamlit(): | |
thread = threading.current_thread() | |
return type(thread).__module__.startswith('streamlit.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import pandas as pd | |
from vega_datasets import data | |
""" | |
# Using different charting libraries | |
""" | |
@st.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import requests | |
def download_file(url, folder, filename): | |
"""Downloads a file from the internet, but only if it doesn't already exist on disk. | |
Parameters | |
---------- | |
url : str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import streamlit as st | |
import subprocess | |
import os | |
# Hack to make app runnable directly with "python scriptname.py" | |
if not st._is_running_with_streamlit: | |
import sys | |
import streamlit.bootstrap |