Skip to content

Instantly share code, notes, and snippets.

View blackary's full-sized avatar

Zachary Blackwood blackary

View GitHub Profile
@blackary
blackary / caching.py
Last active January 9, 2024 06:37
Caching Snowflake queries in Streamlit
def get_pandas_from_sql(sql: str) -> pd.DataFrame:
start = time.start()
with st.expander("Show the SQL query that generated this data"):
st.code(sql, language="sql")
@st.cache_data(ttl=TTL)
def get_df(sql):
dataframe = session.sql(sql).to_pandas()
@blackary
blackary / script.py
Created January 28, 2023 12:32
Getting access to a public Google sheet without any authentication setup
# First pip install 'shillelagh[all]'
from shillelagh.backends.apsw.db import connect
connection = connect(":memory:")
cursor = connection.cursor()
query = """
SELECT country, SUM(cnt)
FROM "https://docs.google.com/spreadsheets/d/1_rN3lm0R_bU3NemO0s9pbFkY5LQPcuy1pscv8ZXPtg8/edit#gid=0"
git clone --bare https://github.com/blackary/dotfiles2 $HOME/.cfg
function config {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
mkdir -p .config-backup
config checkout
if [ $? = 0 ]; then
echo "Checked out config.";
else
echo "Backing up pre-existing dot files.";