Skip to content

Instantly share code, notes, and snippets.

View akleandrov's full-sized avatar

Alexey Kleandrov akleandrov

  • Russia,Saint-Petersburg
View GitHub Profile
akleandrov / nginx.conf
Created June 5, 2018 11:46 — forked from thoop/nginx.conf
Official nginx.conf for nginx
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change (server_name) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
root /path/to/your/root;
index index.html;
akleandrov /
Created May 7, 2018 19:50 — forked from zmts/
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию

Token-Based Authentication(JWT)


В данной заметке рассматривается работа JWT с симметичным алгоритмом шифрования (HS256/HS384/HS512)


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

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

Тестовое задание:
Coding task:
Please write a function wrapper slow_guard(timeout, fn) that logs a warning if
the function takes too long to complete. Here is a typical example of how your wrapper can be used:
Array.prototype.sort = slow_guard(1000, Array.prototype.sort);
After this, if sorting an array ever takes longer than one second, a warning
should appear on the developer console.
We expect a short solution about 5-10 lines of code.
Ответ: Если опустить тот факт что так делать ни в коем случае не надо,
<script src=""></script>
<svg width="600" height="400"></svg>
<script id="jsbin-javascript">
// Стандартный кусок кода для описания ширины и отступов графика
var svg ="svg"),
margin = { top: 20, right: 20, bottom: 30, left: 50 },
width = +svg.attr("width") - margin.left - margin.right,
height = +svg.attr("height") - - margin.bottom,
g = svg.append("g").attr("transform", "translate(" + margin.left + "," + + ")")
// Restify Server CheatSheet.
// More about the API:
// Install restify with npm install restify
// 1.1. Creating a Server.
var restify = require('restify');
* Created by kleandrovaa on 12.01.2017.
* Created by kleandrovaa on 28.12.2016.
'use strict';
snfApp.factory('settingsService', function($http){
let promise;
return {
akleandrov / test
Created March 22, 2017 13:10
"show_definitions": false,
"auto_complete": false,
"bold_folder_labels": true,
"color_scheme": "Packages/One Dark Material - Theme/schemes/OneDark.tmTheme",
"fold_buttons": false,
"font_size": 13,
"highlight_line": true,
akleandrov / gist:e34ca7e9bdbb096863721794e89cc65b
Created December 27, 2016 06:05
GSON builder with date format
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
public Date deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context)
throws JsonParseException {
try {
return df.parse(json.getAsString());
} catch (ParseException e) {
return null;
akleandrov / sql
Created December 14, 2016 10:08
Postgres util-requests
Drop all connections
SELECT pg_terminate_backend(
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'TARGET_DB'
AND pid <> pg_backend_pid();
Show all connections
select *
from pg_stat_activity
where datname = 'mydatabasename'
akleandrov / revit-addin-locations.txt
Created September 26, 2016 11:20 — forked from teocomi/revit-addin-locations.txt
Revit Addin folder location
Autodesk Revit addins are generally loaded from the following locations.
User Addins:
Machine Addins (for all users of the machine):
Addins packaged for the Autodesk Exchange store: