Skip to content

Instantly share code, notes, and snippets.

View andfanilo's full-sized avatar
🎈
Streamlitin'

Fanilo Andrianasolo andfanilo

🎈
Streamlitin'
View GitHub Profile
@andfanilo
andfanilo / st_counter_timer_fragments.py
Created April 8, 2024 07:56
Playing with Streamlit Fragments (v1.33) - Timer + Counter
import streamlit as st
##### Initialize Session State
if "counter" not in st.session_state:
st.session_state.counter = 0
if "timer" not in st.session_state:
st.session_state.timer = 0
##### Build Logic into Fragments
@andfanilo
andfanilo / streamlit_app_vega_datasets.py
Last active June 30, 2023 08:08
Vega Datasets Streamlit Explorer
import streamlit as st
from vega_datasets import data
st.title("Vega Datasets Explorer")
all_datasets = data.list_datasets()
selected_dataset = st.selectbox("Select data:", all_datasets)
df = getattr(data, selected_dataset.replace("-", "_"))()
st.dataframe(df, use_container_width=True)
@andfanilo
andfanilo / search_asr_models.py
Created February 18, 2023 07:45
Streamlit + HfAPI to test ASR models
import streamlit as st
from transformers import pipeline
from huggingface_hub import HfApi
from huggingface_hub import ModelFilter
st.set_page_config(page_title="Huggingface Course", page_icon="🤗")
@st.cache_resource
def load_hf_model(model: str):
import streamlit as st
from streamlit.delta_generator import DeltaGenerator
from streamlit.proto.Markdown_pb2 import Markdown as MarkdownProto
from streamlit.string_util import clean_text
def markdown_but_yelling(body, unsafe_allow_html=False):
body = f"# {body.upper()}!!!!"
markdown_proto = MarkdownProto()
markdown_proto.body = clean_text(body)
{
"editor.fontSize": 16, // 16 on demo, 14 otherwise
"editor.lineHeight": 22, // 22 on demo, 18 otherwise
"window.zoomLevel": 1.5, // 1.5 on demo, 1.2 otherwise
"editor.formatOnSave": false,
"editor.formatOnPaste": false,
"editor.lineNumbers": "off",
"editor.quickSuggestionsDelay": 3000,
"editor.quickSuggestions": {
"other": false,
@andfanilo
andfanilo / streamlit_app_stars_per_component.py
Created November 30, 2022 14:36
Scrape Components Tracker wiki
"""
pip install beautifulsoup4 ghapi requests streamlit
Add [github] > key value of your Github API Token in .streamlit/secrets.toml
streamlit run streamlit_app.py
"""
from typing import Tuple
import pandas as pd
import requests
import streamlit as st
@andfanilo
andfanilo / st_intersect_animation.py
Created July 23, 2022 15:32
Intersection Observer API + CSS Transition
import base64
import streamlit as st
import streamlit.components.v1 as components
import plotly.express as px
df = px.data.iris()
@st.experimental_memo
def get_img_as_base64(file):
@andfanilo
andfanilo / st_jspdf.py
Last active September 1, 2022 05:04
Frontend no bundler JSPDF Streamlit app
"""https://www.freakyjolly.com/multipage-canvas-pdf-using-jspdf/"""
import requests
import plotly.express as px
import streamlit as st
import streamlit.components.v1 as components
@st.experimental_memo
def load_unpkg(src: str) -> str:
return requests.get(src).text
@andfanilo
andfanilo / st_ghapi_starhistory.py
Created March 21, 2022 18:11
Star History but in Python with Streamlit + ghapi + Plotly Express
import pandas as pd
import plotly.express as px
import streamlit as st
from ghapi.all import GhApi
from ghapi.all import pages
@st.experimental_singleton
def load_ghapi() -> GhApi:
@andfanilo
andfanilo / st_ghapi_reacted_issues.py
Last active March 21, 2022 18:10
Query to sort issues in Github project per number of +1 reactions
import streamlit as st
from ghapi.all import GhApi
@st.experimental_singleton
def load_ghapi():
return GhApi()