Skip to content

Instantly share code, notes, and snippets.

View nuncjo's full-sized avatar
🎯
Focusing

nuncjo

🎯
Focusing
View GitHub Profile
# -*-coding:utf-8-*-
from importlib.abc import SourceLoader, MetaPathFinder
from importlib.machinery import ModuleSpec
import sqlite3
import os
import sys
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
CODE_DB = os.path.join(BASE_DIR, 'source.db')
import contextlib
import os
import random
import signal
import time
from concurrent.futures import ProcessPoolExecutor, as_completed, process
from multiprocessing import Pool, Process, Queue
from multiprocessing.context import TimeoutError
PIPES_DATA = {
import time
import contextlib
from selenium import webdriver
with contextlib.closing(webdriver.PhantomJS()) as d:
d.implicitly_wait(10)
d.get("http://www.finanse.mf.gov.pl/web/wp/pp/sprawdzanie-statusu-podmiotu-w-vat")
input = d.find_element_by_id('b-7')
input.send_keys('6652451039')
d.find_element_by_id('b-8').click()
time.sleep(4)
@nuncjo
nuncjo / dropdowns.html
Last active November 13, 2016 19:51
dropdowns
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The HTML5 Herald</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
@nuncjo
nuncjo / string-to-asterix.py
Last active November 11, 2016 20:26
Convert some chars in string to asterix
# -*- coding: utf-8 -*-
def stars(text, _map):
asterix_list = []
for character, asterix in zip(text, _map):
if asterix:
asterix_list.append('*')
else:
asterix_list.append(character)
class ListItem:
def __init__(self, tag=None, htmlclass=None): #Uwaga, funkcja nie jest przekazywana do konstruktora !
self.tag = tag or 'li'
self.htmlclass = htmlclass or 'menuitem'
def __call__(self, func): #Uwaga, funkcja jest teraz przekazywana w metodzie __call__ !
@wraps(func)
def wrapper(text_line):
result = "<{0} class='{1}'>{2}</{0}>".format(self.tag, self.htmlclass, func(text_line))
from functools import wraps
class PrinterWrapped2:
def __init__(self, func):
wraps(func)(self)
def __call__(self, *args, **kwargs):
print("Printing..")
f = self.__wrapped__(*args, **kwargs)
print("Document printed..")
import functools
class PrinterWrapped:
def __init__(self, func):
self.func = func
functools.update_wrapper(self, func)
def __call__(self, *args, **kwargs):
print("Printing..")
class Printer:
def __init__(self, func):
self.func = func
def __call__(self, *args, **kwargs):
print("Printing..")
f = self.func(*args, **kwargs)
print("Document printed..")
return f
from functools import wraps, partial
#Dekorator służący do dodawania funkcji jako atrybut obiektu
def attach_wrapper(obj, func=None):
if func is None:
return partial(attach_wrapper, obj)
setattr(obj, func.__name__, func)
return func
def list_item(tag=None, htmlclass=None):