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 | |
from concurrent import futures | |
def primes(num): | |
rv = [] | |
p = [0] * num | |
k, n = 0, 2 | |
print("start time:", time.time()) |
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 asyncio | |
def q(val, fut): | |
print(val) | |
fut.set_result(val) | |
def cb(fut): | |
r = fut.result() |
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 | |
loop = asyncio.get_event_loop() | |
def p(val, stop=False): | |
print(val) | |
if stop: | |
loop = asyncio.get_event_loop() | |
loop.stop() |
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 | |
def q2(val): | |
print("delay 1 second") | |
time.sleep(1) | |
print(val) | |
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 types import MethodType | |
from weakref import WeakValueDictionary | |
from flask import Flask, views | |
_cached = WeakValueDictionary() | |
def _route(self, rule, **options): | |
def wrapper(cls): |
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
#!/usr/bin/env python | |
# coding:UTF-8 | |
import re | |
import os | |
import json | |
from datetime import datetime | |
import requests |
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
import os | |
from array import array | |
from random import sample | |
from collections import deque | |
from os.path import exists | |
class Shuffler: | |
def __init__(self, stop, buff=100000, cache=10000): |
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
# scope is thread class. | |
def run(self): | |
if self.step.isOpen(): | |
with open('gcode/cathy.gcode', 'r') as f: | |
gcode = (line for line in f.readlines()) # generator. | |
while 1: | |
if self.is_pause: | |
time.sleep(0.5) | |
continue | |
try: |