Skip to content

Instantly share code, notes, and snippets.

@monchier
monchier / dashboard.py
Created October 25, 2019 04:45
dashboard.py
"""Simple sliding window dashboard-style
plot that updates periodically pulling from
a random generator
"""
import streamlit as st
import time
import random
# session_state from https://gist.github.com/tvst/036da038ab3e999a64497f42de966a92
from session_state import get
# st_rerun from https://gist.github.com/tvst/ef477845ac86962fa4c92ec6a72bb5bd
@monchier
monchier / Server.py.patch
Created November 13, 2019 21:00
Patch to Streamlit Server.py to allow for an extra endpoint to download a static file
diff --git a/lib/streamlit/server/Server.py b/lib/streamlit/server/Server.py
index c292a48e..199128a9 100644
--- a/lib/streamlit/server/Server.py
+++ b/lib/streamlit/server/Server.py
@@ -153,6 +153,16 @@ def start_listening(app):
)
+class MyFileHandler(tornado.web.StaticFileHandler):
+ def initialize(self, path):
worker_processes 1;
events {
worker_connections 1024;
}
http {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
@monchier
monchier / gist:0eaa243d667a4578cc4d3c5f7c0daf8a
Last active December 18, 2019 15:28
Notes on a Streamlit dev env on Ubuntu 16.04
# Install python3
# https://docs.python-guide.org/starting/install3/linux/
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6
# Refer to this: https://github.com/streamlit/streamlit/issues/665
# change python3-distutils to libpython3.7-stdlib
@monchier
monchier / mutable.py
Created February 28, 2020 18:44
st.cache for mutable state
import streamlit as st
@st.cache(allow_output_mutation=True)
def get_mutable():
return []
x = st.sidebar.slider("Choose x value: ", 0, 10)
mutable_object = get_mutable()
mutable_object.append(x)
st.write(f"Choice history is {mutable_object}")
import (
"github.com/stretchr/testify/assert"
apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/metrics/pkg/apis/metrics/v1beta1"
mfake "k8s.io/metrics/pkg/client/clientset/versioned/fake"
"testing"
"time"