Skip to content

Instantly share code, notes, and snippets.

View rostyq's full-sized avatar
🇺🇦
remember: russia is a terrorist state

Rostyslav Bohomaz rostyq

🇺🇦
remember: russia is a terrorist state
View GitHub Profile
def get_user_int(msg):
'''
Return integer from user.
:param msg:
:return user_input:
'''
user_input = input(msg)
try:
user_input = int(user_input)
except:
def get_list_ends(input_list):
"""
Return the first and last item of list.
:param input_list:
:return list_ends:
"""
return [input_list[0], input_list[-1]]
a = [5, 10, 15, 20, 25]
def get_user_int(msg):
'''
Return integer from user.
:param msg:
:return user_input:
'''
user_input = input(msg)
try:
user_input = int(user_input)
except:
import numpy
def rnd_list():
size_of_list = numpy.random.randint(10, 20)
return numpy.random.randint(0, 100, size_of_list)
def rm_duplicates_1(lst):
return list(set(lst))
@rostyq
rostyq / password.py
Last active August 22, 2020 18:40
python password generator
import string
import random
def generate(length=35, digits_count=5, upper_count=5, special_count=5):
lower_count = max(0, length - digits_count - upper_count - special_count)
digits = random.sample(string.digits, digits_count)
specials = random.sample(string.punctuation, special_count)
upper = random.sample(string.ascii_uppercase, upper_count)
import requests
from bs4 import BeautifulSoup as bs
url = "https://www.vanityfair.com/style/society/2014/06/monica-lewinsky-humiliation-culture"
# get page and make soup for parsing
soup = bs(requests.get(url).text, "html5lib")
# select all tag p in tag section
article = soup.select('section p')
def print_board(x, y):
for i in range(y):
print('+' + '---+'*x + '\n|' + ' |'*x)
print('+' + '---+'*x)
user = input("Size of board (XxY) -> ")
user = user.split('x')
x = int(user[0])
y = int(user[1])
@rostyq
rostyq / check_tic_tac_toe.py
Created August 2, 2017 09:36
Exercise on http://www.practicepython.org Check Tic Tac Toe Exercise 26
def check_ttt(game_list):
# creating list that contain all possible lines in board
# 8 lines = 3 horizontal + 3 vertical + 2 diagonal
line_list = game_list
line_list += list(zip(*game_list))
line_list += [[game_list[i][j] for i, j in zip(range(3), range(3))],
[game_list[i][-j] for i, j in zip(range(3), range(1, 4))]]
# calculate sum of each line if line have not nulls
@rostyq
rostyq / pupilcenter.py
Last active May 5, 2018 13:02
Pupil Center Labeling Tool
from argparse import ArgumentParser
from pathlib import Path
from cv2 import waitKey
from cv2 import imshow
from cv2 import imread
from cv2 import namedWindow
from cv2 import setMouseCallback
from cv2 import destroyAllWindows
from cv2 import EVENT_LBUTTONUP
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required