This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertToPeriodicValue(value, periodLength) { | |
let modValue = value % periodLength; | |
if (modValue < 4) { | |
return 0; | |
} else if (modValue >= 4 && modValue < 7) { | |
return 1; | |
} else if (modValue >= 7 && modValue < 9) { | |
return 4; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
NewerOlder