Skip to content

Instantly share code, notes, and snippets.

View CharlyWargnier's full-sized avatar
🎈

Charly Wargnier CharlyWargnier

🎈
View GitHub Profile
@CharlyWargnier
CharlyWargnier / inspirational_quotes_app.py
Last active September 22, 2024 08:53
A Streamlit app for navigating through inspirational quotes with "Next" and "Previous" buttons.
import streamlit as st
if 'count' not in st.session_state:
st.session_state.count = 0
if 'quotes' not in st.session_state:
st.session_state.quotes = [
"Life is what happens when you're busy making other plans. — John Lennon",
"Get busy living or get busy dying. — Stephen King",
"You only live once, but if you do it right, once is enough. — Mae West",
@CharlyWargnier
CharlyWargnier / GTP3_script_for_sheets.txt
Created January 15, 2023 15:00
A script to integrate GTP3 in Google Sheets
const OPENAI_API_KEY = ""; // <- PASTE YOUR SECRET KEY HERE
const OPENAI_API_URL = "https://api.openai.com/v1/completions";
/**
* Submits a prompt to GPT-3 and returns the completion
*
* @param {string} prompt Prompt to submit to GPT-3
* @param {float} temperature Model temperature (0-1)
* @param {string} model Model name (e.g. text-davinci-002)
@CharlyWargnier
CharlyWargnier / download_csv
Created May 30, 2022 18:31
Streamlit - download_csv via markdown
df = pd.read_csv("reuters-allcats.csv")
csv = df.to_csv(index=False)
b64 = base64.b64encode(csv.encode()).decode()
href = f'<a href="data:file/csv;base64,{b64}" download="myfilename.csv">Try a sample first</a>'
st.markdown("👆 Upload a .csv file. " + href, unsafe_allow_html=True)
st.stop()
gd = GridOptionsBuilder.from_dataframe(df)
# Adds pagination
gd.configure_pagination(enabled=True)
# Adds editable cells
gd.configure_default_column(editable=True, groupable=True)
# Enables multi-select in the dataframe
gd.configure_selection(selection_mode="multiple", use_checkbox=True)
gridoptions = gd.build()
grid_table = AgGrid(
df,
# The code below is for the title and logo.
st.set_page_config(
layout=layout, page_title="Dataframe with editable cells", page_icon="💾"
)
def get_search_console_data(webproperty):
if webproperty is not None:
# query = webproperty.query.range(start="today", days=days).dimension("query")
report = (
webproperty.query.search_type(search_type)
.range("today", days=timescale)
.dimension(dimension)
.filter(filter_page_or_query, filter_keyword, filter_type)
.filter(filter_page_or_query2, filter_keyword2, filter_type2)
.get()
import streamlit as st
st.header('test')
faqs = [
{ "question": "Tom", "answer": "10" },
{ "question": "Mark", "answer": "5" },
{ "question": "Pam", "answer": "7" },
{ "question": "Dick", "answer": "12" }
from zipfile import ZipFile
from io import BytesIO
zipObj = ZipFile("sample.zip", "w")
# Add multiple files to the zip
zipObj.write("checkpoint")
zipObj.write("model_hyperparameters.json")
# close the Zip File
zipObj.close()
function getSummary(text){
payload = `text=${text}`;
payload = encodeURI(payload);
console.log(payload);
var url = "https://us-central1-hamlet-title-descr-generator.cloudfunctions.net/t5_post";
function ConnectButton(){
console.log("Connect pushed");
document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click()
}
setInterval(ConnectButton,60000);