Skip to content

Instantly share code, notes, and snippets.

View PashaWNN's full-sized avatar

Pavel Shishmarev PashaWNN

View GitHub Profile
@PashaWNN
PashaWNN / palindrome.cpp
Last active March 4, 2020 07:15
8 семестр, оси, к/р №1
#include <windows.h>
#include <windowsx.h>
#include <cstdio>
#include <ctype.h>
#include <clocale>
#define ID_BUTTON 101
HWND hEdit1;
@PashaWNN
PashaWNN / .zshrc
Created July 11, 2019 01:29
My aliases and some settings of ZSH
export ZSH="/home/pashawnn/.oh-my-zsh"
DEFAULT_USER=$USER
ZSH_THEME="agnoster"
COMPLETION_WAITING_DOTS="true"
plugins=(
git
pip
python
sudo
)
@PashaWNN
PashaWNN / selenium_screenshot.py
Last active August 11, 2024 13:34
Take a full screenshot of page in Selenium webdriver
import os
import time
from PIL import Image
def fullpage_screenshot(driver, file):
"""
Saves full page screenshot from selenium webdriver
Originally copied from https://stackoverflow.com/questions/41721734/take-screenshot-of-full-page-with-selenium-python-with-chromedriver
(c) ihightower
@PashaWNN
PashaWNN / loading.py
Created August 18, 2018 07:53
Example of fancy CLI loading indicator in Python
from sys import stdout
from time import sleep
def pr(s):
stdout.write(s)
stdout.flush()
def animate(v):
@PashaWNN
PashaWNN / .bashrc
Created June 23, 2018 14:06
Show branch in terminal
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="[\u@\h \W]\[\033[00;32m\]\$(git_branch)\[\033[00m\]\$ "
@PashaWNN
PashaWNN / gimme_all_chats.py
Last active July 1, 2018 11:28
Бывает, что нужно найти удалённую беседу, чтобы вернуться в неё, но перебирать все беседы по ID вручную — слишком долго. Скрипт после авторизации выдаёт список всех когда-либо существовавших у вас в диалогах бесед вместе со ссылками на них.
import vk_api # Нужно установить эту библиотеку: pip install vk_api
from getpass import getpass as gp
def getChat(vk, id):
try:
r = vk.method('messages.getChat', {'chat_id': str(id)})
except vk_api.exceptions.ApiError:
r = None
return r
@PashaWNN
PashaWNN / automata.py
Created May 8, 2018 16:30
Cell automata
from bitmap import Bitmap
from random import choice, seed
BLACK = (0,0,0)
WHITE = (255,255,255)
class Automata():
def __init__(s, rule, width=512):
s.cells = [False]*width
@PashaWNN
PashaWNN / gen_bitmap.py
Created May 8, 2018 15:17
Simple bitmap file creation
from struct import pack
class Bitmap():
def __init__(s, width, height):
s._bfType = 19778 # Bitmap signature
s._bfReserved1 = 0
s._bfReserved2 = 0
s._bcPlanes = 1
s._bcSize = 12
s._bcBitCount = 24