Skip to content

Instantly share code, notes, and snippets.

View CharlyWargnier's full-sized avatar
🎈

Charly Wargnier CharlyWargnier

🎈
View GitHub Profile
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);
@CharlyWargnier
CharlyWargnier / interactive_google_oauth2.py
Last active May 3, 2020 16:27 — forked from frankie567/interactive_google_oauth2.py
[Google Console Connect] - 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")
import streamlit as st
import pandas as pd
import pandas as pd
import requests
import base64
import os
st.markdown('## **Bulk HTTP Status Code Checker**')
st.markdown('*Made with* :heart: *with [Streamlit](https://www.streamlit.io/)*')
'''
If you have a lengthy training job running on Colab, why bother monitoring it when you can simply send yourself an email when it's finished? This code, credit again to Rohit Midha, can be placed after your training loop, and can send you a message once training has completed. You can likely envision some more creative ways to configure what types of emails are sent for failed tasks, completed tasks, etc, or checkpoint emails for different points along your machine learning pipeline, perhaps.
The code snippet uses the smtplib library which is included by default in your Colab environment. Just fill in the email addresses and passwords (use the same for both in order to send a message to yourself, for example) as well as the message and away you go.
'''
import smtplib
dfLasMonth['FruitClass'] = pd.np.where(dfLasMonth.Title.str.contains("Pear"), "Pear",
pd.np.where(dfLasMonth.Title.str.contains("Apple"), "Apple",
pd.np.where(dfLasMonth.Title.str.contains("Banana"), "Banana",
pd.np.where(dfLasMonth.Title.str.contains("Oranges"), "Oranges", "Else"))))
dfLasMonth
dfFiltered = df[(df['Date'] > start_date) & (df['Date'] <= end_date) & (df['httpCodeClass'].isin(myNewList))]
csvName = "csvExport2" #@param {type:"string"}
csvName = csvName + '.csv'
dfFiltered.to_csv(csvName)
myNewList = []
Code_2XX = False # @param {type:"boolean"}
Code_3XX = True # @param {type:"boolean"}
Code_4XX = True # @param {type:"boolean"}
Code_5XX = True # @param {type:"boolean"}
if Code_2XX == True:
myNewList.append('Success (2XX)')
if Code_3XX == True:
DfPivotCodes = df.groupby(['httpCode']).agg({'httpCode': ['count']})
DfPivotCodes.columns = ['_'.join(multi_index) for multi_index in DfPivotCodes.columns.ravel()]
DfPivotCodes = DfPivotCodes.reset_index()
DfPivotCodes