Skip to content

Instantly share code, notes, and snippets.

View kuznetsov-m's full-sized avatar

Mikhail Kuznetsov kuznetsov-m

View GitHub Profile
@kuznetsov-m
kuznetsov-m / debug_requests.py
Created February 29, 2020 19:46
Enable debug logging for python requests
# source: https://stackoverflow.com/a/57325050/10504918
import requests
import logging
from http.client import HTTPConnection # py3
log = logging.getLogger('urllib3')
log.setLevel(logging.DEBUG)
# logging from urllib3 to console
@kuznetsov-m
kuznetsov-m / youtube_comment_bot.py
Created May 30, 2020 23:12 — forked from 0xv/youtube_comment_bot.py
Youtube Comment Bot - python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Python bot for comment a list of urls in YouTube
import time
import numpy as np
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
# example bill
fn = '9251440300109733'
fd = '96304'
n = '1'
fp = '3341119416'
t = '02.08.2020+16%3A12'
s = '55.00'
# example
# https://github.com/enrike666/telegram-bot/blob/02c61ccd8622b9b954942b464b74020f6d254029/main_test.go
# file: test_candels.csv
#
# 274.67 274.67 274.67 274.67 123460 2021-01-04
# 274.67 274.67 274.67 274.67 123460 2021-01-05
# file: requirements.txt
#
# backtrader==1.9.76.123
# backtrader-plotting==1.1.0
@kuznetsov-m
kuznetsov-m / backtrader example
Last active April 28, 2021 23:38
backtrader example
# file: requirements.txt
#
# backtrader==1.9.76.123
# backtrader-plotting==1.1.0
# file: dt.csv
#
# date,close,high,low,open
# 2017-01-03T15:00:00,115.450,115.815,115.400,115.600
# 2017-01-03T16:00:00,115.370,115.670,115.135,115.450
import base64
data64 = 'AQAAAAAAAAAA9gS5bBWmAYqIWY0MWjEP4rYzOqSLqRblAr4CV4ylA4RUb5AegR/zDQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJXH2dBhmCO+Qx2UVe6Jt+82VluOtYSKxdN49XuVOGTxQMfjEzKi8XVUfL4wQoTtWZmE7hxytvWvNfNpOPmRXJQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=='
data_bytes = base64.b64decode(data64)
print(data_bytes)
print(len(data_bytes)) # 265
from construct import Int8ub, Int64ub, Struct, Array, Byte, Bytes
from typing import Union
alphabet = b'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def b58encode_int(i: int, default_one: bool = True) -> bytes:
"""
Encode an integer using Base58
"""
if not i and default_one:
return alphabet[0:1]
@kuznetsov-m
kuznetsov-m / i_love_yandex_speechkit.py
Last active June 7, 2021 20:30
Тест yandex_speechkit
import requests
message = 'Я люблю Яндекс Спич кит!'
message = message[:5000]
speed = 1.3
voices = ['alyss', 'jane', 'oksana', 'omazh', 'zahar', 'ermil', 'alena', 'filipp']
voice = voices[6]
emotions = ['good', 'evil', 'neutral']
emotion = emotions[0]
# requirements.txt
# vk-api==11.9.4
# bs4
#
import vk_api
from vk_api.audio import VkAudio
import requests
import shutil
@kuznetsov-m
kuznetsov-m / telegram_forwarder.py
Created August 19, 2021 21:37
Forward messages from channel to channel in Telegram
from telethon.tl.functions.messages import GetDialogsRequest
from telethon.tl.types import InputPeerEmpty
from telethon import TelegramClient
from telethon.tl.functions.messages import AddChatUserRequest
from telethon.tl.functions.messages import ForwardMessagesRequest
from telethon.tl.functions.messages import GetChatsRequest
from telethon.tl.functions.contacts import GetContactsRequest
from telethon.tl.functions.contacts import SearchRequest
from telethon.tl.functions.channels import InviteToChannelRequest
from telethon.tl.functions.channels import GetMessagesRequest