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 sys | |
from utils import * | |
from pdfminer.high_level import extract_pages | |
from pdfminer.layout import LTTextContainer, LTChar, LTPage, LTTextLine | |
def avg_char_height(container:LTTextContainer): | |
chars = n_sample(container, 2, required_types=[LTTextLine, LTChar], max_samples=[4, 20]) | |
char_size = list(map(lambda c: c.size, chars)) | |
if len(char_size) > 0: return sum(char_size)/len(char_size) |
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 functools import wraps | |
from flask import Flask, request, abort | |
from waitress import serve | |
app = Flask(__name__) | |
APPKEY = 'EXAMPLE_KEY' | |
def require_appkey(view_function): | |
@wraps(view_function) | |
def decorated_function(*args, **kwargs): | |
if request.args.get('key') and request.args.get('key') == APPKEY: |
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
# Inspired by https://github.com/simonwillcock/RipReddit/ | |
import json | |
import requests | |
# The main cmd | |
def get_items(subreddit, sort='hot',count:int=1000): | |
""" Returns a list of items from the given subreddit, sorted by hot, new, controversial, or top. """ | |
url = 'http://www.reddit.com/r/{}/{}.json?limit={}'.format(subreddit, sort,count) | |
header = { 'User-Agent' : 'Amazing script' } | |
try: |