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
@rostyq
rostyq / firebase_sdkconfig_to_env.py
Created December 27, 2022 11:25
Convert Firebase SDK Config to environment file.
from pathlib import Path
from typing import TypedDict, Literal, NotRequired, TYPE_CHECKING, Optional
from argparse import Namespace
if TYPE_CHECKING:
from _typeshed import SupportsWrite
class Config(TypedDict):
(function() {
function popItem(key) {
const value = this.getItem(key);
this.removeItem(key);
return value;
}
window.localStorage.__proto__.popItem = popItem.bind(window.localStorage);
window.sessionStorage.__proto__.popItem = popItem.bind(window.sessionStorage);
})();
@rostyq
rostyq / windowmoveevent.js
Last active December 3, 2021 12:39
Browser `windowmove` event
(function() {
let screenX = window.screenX;
let screenY = window.screenY;
function update() {
const movementX = window.screenX - screenX;
const movementY = window.screenY - screenY;
if (movementX != 0 || movementY != 0) {
screenX = window.screenX;
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
@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
@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
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])
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')
@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 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))