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 asyncio | |
from datetime import datetime | |
from functools import partial | |
from concurrent.futures import ProcessPoolExecutor | |
from youtube_dl import YoutubeDL as YDL | |
PPE = ProcessPoolExecutor() | |
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 os | |
import asyncio | |
from zipfile import ZipFile | |
__all__ = ("ZipFile", ) | |
@asyncio.coroutine | |
def async_extract(self, member, path=None, pwd=None, loop=None): | |
loop = loop or asyncio.get_event_loop() |
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 facebook | |
token = "your token" | |
api = facebook.GraphAPI(token) | |
timestamp = " your timestamp " | |
feeds = api.request('/me/posts/', args={'filter':'created_time', 'until':timestamp}) |
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 pathlib import Path | |
from win32com.client import Dispatch | |
xls = Dispatch("Excel.Application") | |
doc = Dispatch("Word.Application") | |
def export_images(fp, prefix="img_", suffix="png"): | |
""" export all of images(inlineShapes) in the word file. |
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 time | |
import asyncio | |
import contextvars | |
from random import random | |
from threading import current_thread | |
from concurrent.futures import ThreadPoolExecutor | |
# declare context var | |
request_id = contextvars.ContextVar('Id of request.') |
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 ast | |
import asyncio | |
import code | |
import concurrent.futures | |
import inspect | |
import sys | |
import threading | |
import types | |
import warnings | |
import contextvars |
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
# extended from http://xlsxwriter.readthedocs.io/example_chart_stock.html | |
from datetime import datetime | |
import xlsxwriter | |
workbook = xlsxwriter.Workbook('chart_ohlc_stock.xlsx') | |
worksheet = workbook.add_worksheet() | |
bold = workbook.add_format({'bold': 1}) | |
date_format = workbook.add_format({'num_format': 'dd/mm/yyyy'}) |
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 A: | |
def calc(self): | |
print('A', __class__, self) | |
class B(A): | |
def calc(self): | |
print('B', __class__, self) | |
super().calc() | |
class C(B): |
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 time | |
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
def main(url, path="chromedriver.exe"): | |
chrome_options = Options() | |
chrome_options.add_argument("--headless") # uncomment for headless | |
driver = webdriver.Chrome(path, chrome_options=chrome_options) | |
driver.get(url) |
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 asyncio | |
from weakref import WeakSet | |
from json import dumps, loads | |
def _validator(dict_data): | |
""" Default validator function for Observer class. """ | |
return dict_data['event'], dict_data['data'] | |
NewerOlder