Skip to content

Instantly share code, notes, and snippets.

View staslysak's full-sized avatar
🚀
Working from home

Stas Lysak staslysak

🚀
Working from home
View GitHub Profile
const qsort = (arr) => {
if (arr.length < 2) {
return arr;
} else {
// Опорная точка для деления массива, выбирается случайно
const pivotPosition = Math.floor(Math.random() * arr.length);
const pivot = arr[pivotPosition];
// Значения меньшие, либо равные опорному
// попадают в новый массив less
const less = arr.filter((value, index) => {
@staslysak
staslysak / taskt-example.md
Created October 5, 2019 14:50 — forked from romabelka/taskt-example.md
Kickstart testing example

You have a long piece of text, and you want to send it to your friend as a series of SMS messages. Your text consists of English letters (uppercase and lowercase) and spaces. The text doesn't contain any leading spaces at the beginning or trailing spaces at the end. There are no two consecutive spaces in the text.

One proper SMS can contain at most K characters. If the text is longer, it needs to be split into parts. Each part should be sent in a separate message that fulfills the maximum length requirement. Text may not be split within words. The order of the words and the messages can't change, so that we can later concatenate the resulting messages to retrieve the original text. Spaces at the start and end of all messages are removed, and thus are not accounted for in the overall message length.

The goal is to count the number of SMS messages needed to accommodate the whole text, keeping the length of each message less than or equal to K. The total number of SMS messages must be kept to a minimum, ho

@staslysak
staslysak / tokens.md
Created September 17, 2019 21:31 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Основы:

Аутентификация(authentication, от греч. αὐθεντικός [authentikos] – реальный, подлинный; от αὐθέντης [authentes] – автор) - это процесс проверки учётных данных пользователя (логин/пароль). Проверка подлинности пользователя путём сравнения введённого им логина/пароля с данными сохранёнными в базе данных.

Авторизация(authorization — разрешение, уполномочивание) - это проверка прав пользователя на доступ к определенным ресурсам.

Например после аутентификации юзер sasha получает право обращатся и получать от ресурса "super.com/vip" некие данные. Во время обращения юзера sasha к ресурсу vip система авторизации проверит имеет ли право юзер обращатся к этому ресурсу (проще говоря переходить по неким разрешенным ссылкам)