Skip to content

Instantly share code, notes, and snippets.

View CharlyWargnier's full-sized avatar
🎈

Charly Wargnier CharlyWargnier

🎈
View GitHub Profile
@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
start_date = '2016-10-16' #@param {type:"date"}
end_date = '2016-10-17' #@param {type:"date"}
print('start date for the exported csv is: ' + start_date)
print('end date for the exported csv is: ' + end_date)
print ('')
print ('FYI, the dataset spans the following time intervals:')
print (df['Date'].min(), df['Date'].max())
#Define the function
def reverse_dns(ip_address):
'''
This method returns the true host name for a
given IP address
'''
host_name = socket.gethostbyaddr(ip_address)
reversed_dns = host_name[0]
return reversed_dns