Skip to content

Instantly share code, notes, and snippets.

View Winand's full-sized avatar
🐍
<-Python

Makarov Andrey Winand

🐍
<-Python
View GitHub Profile
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import http.server, webbrowser, threading
from urllib.parse import urlencode, urlparse, parse_qs
class VK():
import asyncio, itertools
data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
def grouper(iterable, n):
"Collect data into fixed-len chunks: stackoverflow.com/a/31185097/1119602"
it = iter(iterable)
return iter(lambda: list(itertools.islice(it, n)), [])
class WaitForModification():
"wait for /path/ file to be modified before exiting /with/ block"
def __init__(self, path):
self.path = path
self.mtime = not os.path.exists(path) or os.path.getmtime(path)
def __enter__(self):
pass
def __exit__(self, *args):
while True:
try:
@Winand
Winand / span.py
Last active August 1, 2016 10:10
find column respecting row/colspans
# 0-based /row/ to search for /text/
def find_column(table, row, text):
trs = table.find_all('tr')
results = [[c for c in trs[i].findChildren(recursive=False)]
for i in range(0, row+1)]
for r in range(row-1, -1, -1):
i = 0
for c in results[r]:
if r+int(c.get('rowspan', 0)) > row:
results[-1].insert(i, None)
@Winand
Winand / handle_unhandled.py
Created September 14, 2016 06:06
print exception before you die
if QtCore.QT_VERSION >= 0x50501:
def excepthook(type_, value, traceback_):
traceback.print_exception(type_, value, traceback_)
QtCore.qFatal('')
sys.excepthook = excepthook
[ 0.126799] tegra124-pinctrl tegra124-pinctrl: Config param 0003 not supported on group kb_row4_pr4
[ 0.126830] tegra124-pinctrl tegra124-pinctrl: Config param 0003 not supported on group kb_row5_pr5
[ 0.126888] tegra124-pinctrl tegra124-pinctrl: Config param 0003 not supported on group clk3_req_pee1
[ 0.126921] tegra124-pinctrl tegra124-pinctrl: Config param 0003 not supported on group pu2
[ 0.126952] tegra124-pinctrl tegra124-pinctrl: Config param 0003 not supported on group pu3
[ 0.126984] tegra124-pinctrl tegra124-pinctrl: Config param 0003 not supported on group pu4
[ 0.127015] tegra124-pinctrl tegra124-pinctrl: Config param 0003 not supported on group pu5
[ 0.127046] tegra124-pinctrl tegra124-pinctrl: Config param 0003 not supported on group pu6
[ 0.127079] tegra124-pinctrl tegra124-pinctrl: Config param 0003 not supported on group spdif_out_pk5
[ 0.127111] tegra124-pinctrl tegra124-pinctrl: Config param 0003 not supported on group pk2
--------- beginning of main
11-21 21:31:53.497 153 153 W auditd : type=2000 audit(0.0:1): initialized
11-21 21:31:56.294 161 161 I /system/bin/tzdatacheck: tzdata file /data/misc/zoneinfo/current/tzdata does not exist. No action required.
11-21 21:31:56.409 164 164 I sysinit : Running /system/etc/init.d/00banner
--------- beginning of system
tribution
writing manifest file 'pandas.egg-info\SOURCES.txt'
running build_ext
skipping 'pandas\_libs\join.c' Cython extension (up-to-date)
skipping 'pandas\_libs\index.c' Cython extension (up-to-date)
building 'pandas._libs.index' extension
D:\andray\Software\Python\WinPython-32bit-3.4.4.5Qt5\python-3.4.4\Scripts\gcc.ex
e -mdll -O -Wall -Ipandas/_libs/src/klib -Ipandas/_libs/src -ID:\andray\Software
\Python\WinPython-32bit-3.4.4.5Qt5\python-3.4.4\lib\site-packages\numpy\core\inc
lude -ID:\andray\Software\Python\WinPython-32bit-3.4.4.5Qt5\python-3.4.4\include
....
/*
* Wraps `localtime` functionality for multiple platforms. This
* converts a time value to a time structure in the local timezone.
*
* Returns 0 on success, -1 on failure.
*/
static int get_localtime(NPY_TIME_T *ts, struct tm *tms) {
char *func_name = "<unknown>";
#if defined(_WIN32)