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 heapq | |
from collections import namedtuple | |
Task = namedtuple('Task', 'priority, id, content') | |
class TaskFlow: | |
def __init__(self): | |
self._queue = [] | |
self._id = 0 |
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# нажми здесь shift+enter, чтобы увидеть список магий\n", | |
"%lsmagic" |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# 1) pip install selenium | |
# 2) ChromeDriver: http://chromedriver.chromium.org/downloads | |
from selenium import webdriver | |
DRIVER = 'chromedriver' | |
driver = webdriver.Chrome(DRIVER) | |
driver.get('https://erugame.ru/') # какой сайт | |
driver.save_screenshot("screenshot.png") |
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 hashlib | |
import ecdsa | |
import os | |
from binascii import hexlify | |
from base58 import b58encode | |
# Installation: | |
# pip install base58 ecdsa | |
# Use that service to make sure that this generator works well: |
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 socket | |
import select | |
from urllib.parse import urlsplit | |
def brutal_download(url, save_to): | |
url_components = urlsplit(url) | |
host = url_components.netloc | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect((host, 80)) |
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 operator | |
class Item: | |
def __init__(self, name, price, qty): | |
self.name = name | |
self.price = price | |
self.qty = qty | |
def total_cost(self): |
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
# это пример показывает применение __matmul__ и __imatmul__ для пользовательских классов | |
class MyMatrix: | |
def __init__(self, data): | |
self.data = data | |
# для получения элементов матрицы как A[строка, столбец] | |
def __getitem__(self, pos): | |
i, j = pos | |
return self.data[i][j] |
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
# this is Radix sort prove of O(n) time complexity | |
import random | |
import matplotlib.pyplot as plt | |
import time | |
def radix_sort(a_list, radix=10): | |
max_length_achieved = False | |
tmp, placement = -1, 1 |
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 random | |
class ASCIICanvas: | |
def __init__(self, w=50, h=100): | |
assert 0 < w < 1000 and 0 < h < 1000 | |
self.w = w | |
self.h = h | |
self.buffer = [] | |
self.clear() |