Skip to content

Instantly share code, notes, and snippets.

View CharlyWargnier's full-sized avatar
🎈

Charly Wargnier CharlyWargnier

🎈
View GitHub Profile
@tvst
tvst / SessionState.py
Last active September 30, 2024 07:47
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
''
@ines
ines / streamlit_prodigy.py
Created October 3, 2019 20:37
Streamlit + Prodigy
"""
Example of a Streamlit app for an interactive Prodigy dataset viewer that also lets you
run simple training experiments for NER and text classification.
Requires the Prodigy annotation tool to be installed: https://prodi.gy
See here for details on Streamlit: https://streamlit.io.
"""
import streamlit as st
from prodigy.components.db import connect
from prodigy.models.ner import EntityRecognizer, merge_spans, guess_batch_size
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@frankie567
frankie567 / interactive_google_oauth2.py
Last active July 29, 2023 22:07
Interactive Google OAuth2 flow with Streamlit
import asyncio
import streamlit as st
from httpx_oauth.clients.google import GoogleOAuth2
st.title("Google OAuth2 flow")
"## Configuration"
client_id = st.text_input("Client ID")
function ConnectButton(){
console.log("Connect pushed");
document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click()
}
setInterval(ConnectButton,60000);
# Scrape Shopify themes using scrapy.org
#!pip install scrapy
#%%writefile shopify_theme_spider.py
import scrapy
class ShopifyThemeSpider(scrapy.Spider):
name = 'bshopifyspider'
start_urls = ['https://themes.shopify.com/themes?page=1']
@johnmurch
johnmurch / keywordsFromUrl.js
Last active October 22, 2020 01:36
Parse keywords from URL
let url = "https://www.amazon.com/SanDisk-128GB-microSDXC-Memory-Adapter/dp/B073JYC4XM/";
let kwparse = (url.replace('https://','').replace('http://','').replace('www','').replace('com','').split('-').join().split('/').join().split('.')).join(',').replace(/^,/, '')
let kwuniq = [...new Set(kwparse.split(','))].filter(function(e){return e});
console.log(kwuniq)
// ["amazon", "SanDisk", "128GB", "microSDXC", "Memory", "Adapter", "dp", "B073JYC4XM"]
// Hat Tip - Find a cleaner version at https://gist.github.com/dsottimano/52060e6a43d96804f33c59366c472305
from urllib.parse import urlparse
import re
url="https://www.amazon.com/SanDisk-128GB-microSDXC-Memory-Adapter/dp/B073JYC4XM/"
print(set(re.split("[/-]", urlparse(url).path)))
#output
#{'', 'B073JYC4XM', 'dp', '128GB', 'microSDXC', 'Memory', 'SanDisk', 'Adapter'}