Skip to content

Instantly share code, notes, and snippets.

<snippet>
<content><![CDATA[
<!-- begin $1 -->
<div class="$1">
$2
</div>
<!-- end $1 -->
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>di</tabTrigger>
# code to take a PDF and scrape address information. Note that this particular script will
# only work using the specific PDF formatting my PDF had so you can use as a guide but
# it will definitely not work on your PDF!
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import HTMLConverter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
*.pyc
*.jpe
*.png
@skyuplam
skyuplam / gist:ffb1b5f12d7ad787f6e4
Created October 13, 2014 07:50
Flask-Security and Flask-Admin example by Steve Saporata
# Example of combining Flask-Security and Flask-Admin.
# by Steve Saporta
# April 15, 2014
#
# Uses Flask-Security to control access to the application, with "admin" and "end-user" roles.
# Uses Flask-Admin to provide an admin UI for the lists of users and roles.
# SQLAlchemy ORM, Flask-Mail and WTForms are used in supporting roles, as well.
from flask import Flask, render_template
from flask.ext.sqlalchemy import SQLAlchemy
@pawl
pawl / gist:f6c0270d83241c31237a
Last active March 19, 2019 04:24
Example of an user selected page_size in flask-admin
from flask import Flask, session, request
from flask_sqlalchemy import SQLAlchemy
import flask_admin as admin
from flask_admin.contrib import sqla
from flask_admin import expose
# Create application
app = Flask(__name__)
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
@emmanuellyautomated
emmanuellyautomated / coroutines.py
Created November 21, 2017 17:14
An example of using Python coroutines to create processing pipelines.
import json
import os
import requests
from copy import copy
# To run try this out, run --> `python coroutines.py`
@dvmn-tasks
dvmn-tasks / exception-bubbling.md
Last active November 2, 2023 16:20
Где перехватывать исключения

Исключения умеют всплывать

Исключения в Python — это особый объект, который умеет путешествовать между функциями и менять их поведение. Своим появлением исключение прерывает обычное исполнение программы — сверху вниз и вглубь — и переводит его в особый обратный режим — наверх до подходящего try except finally.

Для примера рассмотрим программу — информер с прогнозом погоды. Функция request_weather делает запрос к API сайта weather.com и возвращает прогноз погоды:

def request_weather():
    response = requests.get('https://weather.com/api/weather/moscow/')
    return response.json()