Skip to content

Instantly share code, notes, and snippets.

@Mefistophell
Mefistophell / README.MD
Last active January 30, 2020 15:01
Read a large file without blocking the event loop

To test:

Set the path to a large file in worker.js

Run: node index.js

Then you can run this bash: while true; do date && curl -m 5 http://localhost:3000/ && echo; sleep 1; done

and open a browser http://127.0.0.1:3000/read

@Mefistophell
Mefistophell / RUST.MD
Last active July 1, 2024 14:01
How to Compile a Rust Program on Mac for Windows

Question: I want to compile my Rust source code for the Windows platform but I use macOS.

Solution:

  1. Install target mingw-w64: brew install mingw-w64
  2. Add target to rustup: rustup target add x86_64-pc-windows-gnu
  3. Create .cargo/config
  4. Add the instructions below to .cargo/config
[target.x86_64-pc-windows-gnu]
@Mefistophell
Mefistophell / tokens.md
Created October 8, 2018 13:13 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

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

Preconditions:

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

Основы:

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

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