This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smtplib | |
# initialize connection to our email server, we will use Outlook here | |
smtp = smtplib.SMTP('smtp-mail.outlook.com', port='587') | |
smtp.ehlo() # send the extended hello to our server | |
smtp.starttls() # tell server we want to communicate with TLS encryption | |
smtp.login('joe.bloggs@outlook.com', 'Password123') # login to our email server |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from transformers import AutoTokenizer, AutoModelWithLMHead | |
# initialize out T5 tokenizer and model | |
tokenizer = AutoTokenizer.from_pretrained('t5-base') | |
model = AutoModelWithLMHead.from_pretrained('t5-base', return_dict=True) | |
text = "Large chunk of text to produce summary from..." # text to summarize | |
# tokenize the text into input IDs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask_restful import Resource, Api, reqparse | |
import pandas as pd | |
import ast | |
app = Flask(__name__) | |
api = Api(app) | |
class Users(Resource): | |
def get(self): |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tree(dict): | |
def __missing__(self, key): | |
value = self[key] = type(self)() | |
return value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyodbc | |
from datetime import datetime | |
class Sql: | |
"""Class used for establishing a Python to Microsoft SQL Server connection | |
and import/export/manipulation of data files inside the server. | |
""" | |
def __init__(self, database, server="XXVIR00012,55000"): | |
"""Here we are initialising our database and server parameters and | |
our connection to SQL server. |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Users(Resource): | |
# methods go here | |
pass | |
class Locations(Resource): | |
# methods go here | |
pass | |
api.add_resource(Users, '/users') # '/users' is our entry point for Users | |
api.add_resource(Locations, '/locations') # and '/locations' is our entry point for Locations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make a request for the trending posts in /r/Python | |
res = requests.get("https://oauth.reddit.com/r/python/hot", | |
headers=headers) | |
df = pd.DataFrame() # initialize dataframe | |
# loop through each post retrieved from GET request | |
for post in res.json()['data']['children']: | |
# append relevant data to dataframe | |
df = df.append({ |
NewerOlder