Skip to content

Instantly share code, notes, and snippets.

@francisco-perez-sorrosal
francisco-perez-sorrosal / object_builder.py
Last active April 24, 2019 18:41
Object Builder for Class Hierarchies
class BaseClass(object): pass
class Hello(BaseClass):
"""Example naive class"""
def __init__(self, arg1):
self.arg1 = arg1
def __repr__(self):
return "arg1 {}".format(self.arg1)
@francisco-perez-sorrosal
francisco-perez-sorrosal / nc_webserver.sh
Last active March 2, 2020 21:54
Netcat Webserver with config Serving Delay
#!/bin/bash
PORT=${1:-8000}
SERVING_DELAY_SECS=${2:-10}
command -v pv >/dev/null 2>&1 || { echo >&2 "pv requied but not installed. Exiting..."; exit 1; }
cat <<EOF > /tmp/index.html
<!doctype html>
<html>
@francisco-perez-sorrosal
francisco-perez-sorrosal / streamlit_paged_df.py
Last active August 10, 2022 19:20
Paged Dataframe in Streamlit
import streamlit as st
class PagedDataframe:
def __init__(self, key, df, page_entries=10):
self.key = f"{key}_page"
self.df = df
self.page_entries = page_entries
self.last_page = len(df) // page_entries
if self.key not in st.session_state: