title |
---|
Курс "Magic Python для начинающих" |
Содержание лекций:
Вводная часть:
# Sometimes you just need to "simple" remove docker from your server | |
sudo apt-get purge -y docker-engine docker docker.io docker-ce containerd.io | |
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce containerd.io | |
sudo umount /var/lib/docker/ | |
sudo rm -rf /var/lib/docker /etc/docker | |
sudo rm /etc/apparmor.d/docker | |
sudo groupdel docker | |
sudo rm -rf /var/run/docker.sock | |
sudo rm -rf /usr/bin/docker-compose |
paper = open("turing_paper_1936.txt", "rt") | |
for line in paper: | |
print(line[:-1]) | |
paper.close() |
from ctypes import c_void_p, c_char_p, c_double, c_float, c_int, cdll, util, c_bool | |
import os | |
import time | |
# Load Objective-C runtime: | |
objc = cdll.LoadLibrary(util.find_library('objc')) | |
objc.sel_getName.restype = c_char_p | |
objc.sel_getName.argtypes = [c_void_p] | |
objc.sel_registerName.restype = c_void_p | |
objc.sel_registerName.argtypes = [c_char_p] |
# django shell console logging SQL queries | |
import logging | |
logger = logging.getLogger('django.db.backends') | |
logger.setLevel(logging.DEBUG) | |
logger.addHandler(logging.StreamHandler()) |
codes = { | |
"А": ".-", | |
"Б": "-...", | |
"В": ".--", | |
"Г": "--.", | |
"Д": "-..", | |
"Е": ".", | |
"Ж": "...-", | |
"З": "--..", | |
"И": "..", |
from web3 import Web3, HTTPProvider, IPCProvider | |
web3 = Web3(IPCProvider('/Users/xen/Library/Ethereum/rinkeby/geth.ipc')) | |
# web3 = Web3(IPCProvider('/Users/xen/Library/Ethereum/geth.ipc')) | |
print(web3.eth.blockNumber) | |
print(web3.eth.accounts) |
# implementation of Telegram site authorization checking algorithm | |
# for more information https://core.telegram.org/widgets/login#checking-authorization | |
import collections | |
import hmac | |
import hashlib | |
def check_string(d, token): | |
secret = hashlib.sha256() | |
secret.update(token.encode('utf-8')) |
{ | |
"i18n": { | |
"prefix": "_", | |
"body": [ | |
"{{ _('${TM_SELECTED_TEXT:${1:text}}') }}" | |
], | |
"description": "i18n" | |
}, | |
"gt": { | |
"prefix": "gt", |
import operator | |
def check_erdpou(code): | |
""" Алгоритм проверки кода ЕРДПОУ """ | |
code = int(code) | |
def check(sec, shift=False, step=0): | |
""" Генерация контрольного числа """ | |
nums = list(range(1 + step, 8 + step)) | |
if shift: | |
nums.insert(0, nums.pop(6)) |