This file contains hidden or 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 concurrent.futures # We'll do computations in separate processes! | |
import mymodule # This is where you'll do the computation | |
# Your st calls must go inside this IF block. | |
if __name__ == '__main__': | |
st.write("Starting a long computation on another process") | |
# Pick max number of concurrent processes. Depends on how heavy your computation is, and how | |
# powerful your machine is. |
This file contains hidden or 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
"""An alternative API for st.session_state using a class decorator. | |
So instead of doing this... | |
if "run_counter" in st.session_state: | |
st.session_state.run_counter = 0 | |
st.session_state.run_counter += 1 | |
st.write("Number of reruns:", st.session_state.run_counter) |
This file contains hidden or 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 FOLDER_ID_TO_MOVE = 'FOLDER ID GOES HERE' | |
const DESTINATION_FOLDER_ID = 'FOLDER ID GOES HERE' | |
function main() { | |
const folderToMove = DriveApp.getFolderById(FOLDER_ID_TO_MOVE) | |
const newParentFolder = DriveApp.getFolderById(DESTINATION_FOLDER_ID) | |
moveFolder(folderToMove, newParentFolder) | |
} | |
function moveFolder(folderToMove, newParentFolder) { |
This file contains hidden or 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 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
NewerOlder