Skip to content

Instantly share code, notes, and snippets.

View TutorialDoctor's full-sized avatar

RaphaelSmith TutorialDoctor

View GitHub Profile
TutorialDoctor /
Last active January 9, 2022 18:56
Demonstration of SqlAlchemy relationship types
from sqlalchemy import create_engine,ForeignKey,Column,Date,Integer,String,Boolean
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship,backref,sessionmaker
# Course has many sections
# Section belongs to many courses
# Section has a label
# Label belongs to many sections
# Label belogns to many courses
# Section has a label
TutorialDoctor / gif_to_pngs
Last active January 8, 2022 10:43
Convert gif to png images
from PIL import Image
from PIL import GifImagePlugin
import os,time,zipfile
imageObject ="./source.gif")
# info =
for frame in range(0,imageObject.n_frames):['transparency'] = 255
TutorialDoctor /
Created November 27, 2020 14:30
Convert MP4 video to a PNG sequence
# This code is not mine:
# pip3 install opencv-python
# Importing all necessary libraries
import cv2
import os
# Read the video from specified path
TutorialDoctor / vue_vuex.html
Last active January 18, 2020 20:00
Vue Vuex Tailwind and Axios in a single HTML file
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
TutorialDoctor /
Created January 1, 2020 19:04
Summarize web pages given a URL
import bs4 as bs
import urllib.request
import re
import nltk
#Install beautifulsoup
#Article this is from:
#NLTK help:
TutorialDoctor /
Last active January 7, 2019 10:29
Tutorial Code for Python Decorators
# A decorator is a function that takes a function as an argument and adds a bow tie on top of it.
def decorator(func):
return func
#This "decorator" doesn't really decorate the input function. It just returns the input function.
def aFunc():
TutorialDoctor /
Created December 12, 2018 14:48
Similarity of two strings using Levenstein distance. Edited slightly from code found online.
Problem Statement
Given two strings str1 and str2, find the minimum number of edits (edit one character to another, delete char from str1
or delete char from str2) to change str1 to str2.
TutorialDoctor /
Created December 11, 2018 21:13
Testing pymongo for python with a mongo database
from pymongo import MongoClient
#pip3 install pymongo
if __name__ == "__main__":
client = MongoClient()
db = client.test_database
people = db.people
TutorialDoctor /
Last active May 5, 2020 10:36
This program can read "A is B" statements and parse them into KEY-VALUE pairs. Trying to teach the computer how to learn.
import urllib,pprint
from bs4 import BeautifulSoup
def train(url):
soup = BeautifulSoup(html)
# kill all script and style elements
for script in soup(["script", "style"]):
script.extract() # rip it out
text = soup.get_text()
TutorialDoctor / JavascriptSyntax.js
Last active January 28, 2018 01:44
Javascript Syntax
var intro = "Remove multiline comments to run the code therein"
var __version__ = "0.1"
document.write("Version:" +__version__)
function capitalize(s)
return s[0].toUpperCase() + s.slice(1);
function title1(name=""){