Skip to content

Instantly share code, notes, and snippets.

@terradive
terradive / tokens.md
Created September 8, 2021 07:25 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

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

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@terradive
terradive / json-parse-and-stringify.html
Created March 16, 2018 10:29
JSON parse and stringify
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>do json</title>
<meta name="robots" content="noindex, nofollow" />
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
@terradive
terradive / common-javascript-functions.js
Created May 21, 2017 15:20
Common JavaScript functions
// 1. Получить случайный элемент из списка
const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
// Распространенный вариант
function getRandomItem(list){
return list[Math.floor(Math.random() * (list.length))];
}
getRandomItem(months);
// Underscore и Lodash
_.sample(months);
@terradive
terradive / untar-archive.php
Created May 19, 2017 20:03
Untar tar archive with php.
<?php
//echo __FILE__;
try {
$phar = new PharData('/full/path/a.tar');
$phar->extractTo('/full/path/to/dir'); // extract all files
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}