Skip to content

Instantly share code, notes, and snippets.

View andfanilo's full-sized avatar
🎈
Streamlitin'

Fanilo Andrianasolo andfanilo

🎈
Streamlitin'
View GitHub Profile
@brunomsantiago
brunomsantiago / app.py
Last active December 1, 2023 11:29
Streamlit keyboard shortcuts to buttons (tested on streamlit 1.4.0)
import streamlit as st
import streamlit.components.v1 as components
def left_callback():
st.write('Left button was clicked')
def right_callback():
st.write('Right button was clicked')
This file has been truncated, but you can view the full file.
[[{"id":1,"start":2.46,"end":21.12,"text":"Hello, everybody, and welcome to syntax. This is a new podcast that Scott and I are launching. And we already have three episodes recorded. And we'll be launching them shortly. For now we just wanted to let you know that we're going to be launching this podcast. And to sort of get you subscribe to the feed so that when they're ready to drop, you're ready to get them.","speaker":"Wes Bos","initials":"WB","timestamp":{"hh":"00","mm":"00","ss":"02"}},{"id":2,"start":21.3,"end":27.66,"text":" And this is a web development podcast filled with tasty tips and treats for web developers. ","speaker":"Scott Tolinski","initials":"ST","timestamp":{"hh":"00","mm":"00","ss":"21"}},{"id":3,"start":27.96,"end":39.42,"text":"Oh, oh, yeah. So a little bit about ourselves. My name is Wes Bos. I am a full stack developer from Canada. And I essentially create training courses that help web developers get better at their job. ","speaker":"Wes Bos","initials":"WB","timestamp":{"hh":"00","
@ash2shukla
ash2shukla / state.py
Last active February 27, 2024 06:00
state decorator
from streamlit.report_thread import get_report_ctx
from streamlit.hashing import _CodeHasher
from streamlit.server.server import Server
from prometheus_client.registry import REGISTRY
from prometheus_client import Counter
class _SessionState:
def __init__(self, session, hash_funcs):
"""Initialize SessionState instance."""
@FranzDiebold
FranzDiebold / SessionState.py
Last active August 25, 2023 14:38 — forked from tvst/SessionState.py
A possible design for doing per-session persistent state in Streamlit
# https://gist.github.com/FranzDiebold/898396a6be785d9b5ca6f3706ef9b0bc
"""Hack to add per-session state to Streamlit.
Works for Streamlit >= v0.65
Usage
-----
>>> import SessionState
>>>
@andfanilo
andfanilo / deploy_streamlit_cc.md
Last active May 19, 2022 04:35
Steps to release Streamlit Custom Component package
  1. Pass flag _release to True
  2. Rebuild frontend:
cd package/frontend
rm -rf build/
npm run build
cd ../../
  1. Rebuild Python:
@swyxio
swyxio / Tailwindcssunreset.scss
Last active February 14, 2024 01:19
Tailwind CSS Un-Reset - un-reset Tailwind's Preflight CSS Reset so that autogenerated HTML looks consistent with the rest of your Tailwind site. - https://www.swyx.io/writing/tailwind-unreset
.unreset {
a {
@apply text-blue-700 underline;
}
p {
@apply my-4;
}
blockquote,
figure {
from tkinter import *
from PIL import ImageTk,Image
import time
import os
targetImageWidth = 850
targetImageHeight = 400
inputImageWidth = 0
inputImageHeight = 0
worker_processes 1;
events {
worker_connections 1024;
}
http {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
@tvst
tvst / SessionState.py
Last active April 14, 2024 20:24
DO NOT USE!!! Try st.session_state instead.
"""Hack to add per-session state to Streamlit.
Usage
-----
>>> import SessionState
>>>
>>> session_state = SessionState.get(user_name='', favorite_color='black')
>>> session_state.user_name
''
@jeff3dx
jeff3dx / d3-in-react.js
Last active October 27, 2022 09:24
D3 in React with Hooks
import React, { useRef, useEffect } from 'react';
import * as d3 from 'd3';
interface IProps {
data?: number[];
}
/* Component */
export const MyD3Component = (props: IProps) => {
/* The useRef Hook creates a variable that "holds on" to a value across rendering