Skip to content

Instantly share code, notes, and snippets.

View shchegol's full-sized avatar
😄
Try to update my personal page

Alexander shchegol

😄
Try to update my personal page
View GitHub Profile
@DreaMinder
DreaMinder / A Nuxt.js VPS production deployment.md
Last active October 11, 2023 11:33
Deployment manual for a real-world project built with nuxt.js + koa + nginx + pm2

Example of deployment process which I use in my Nuxt.js projects. I usually have 3 components running per project: admin-panel SPA, nuxt.js renderer and JSON API.

This manual is relevant for VPS such as DigitalOcean.com or Vultr.com. It's easier to use things like Now for deployment but for most cases VPS gives more flexebillity needed for projects bigger than a landing page.

UPD: This manual now compatible with nuxt@2.3. For older versions deployment, see revision history.


Let's assume that you have entered fresh installation of Ubuntu instance via SSH. Let's rock:

@zmts
zmts / tokens.md
Last active May 2, 2024 15:03
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

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

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@rumkin
rumkin / middleware.js
Created August 8, 2016 11:56
Koa boilerplate code
import Router from 'koa-router';
export function moduleMiddleware(options = {}) {
const router = new Router();
router.get('/', async (ctx, next) => {
// ... do some job
});
return router;
@everdimension
everdimension / outside_click.js
Last active March 11, 2023 15:20
Listener for clicks outside the element, for example, for closing menus on outside click.
var el = document.getElementById('el');
document.addEventListener('click', outsideEvtListener);
function outsideEvtListener(evt) {
if (evt.target === el || el.contains(evt.target)) {
return;
}
// code handling outside click
@mike-gusiev
mike-gusiev / js-developer.txt
Last active January 25, 2023 15:07
Middle JavaScript Developer - что надо знать
Что надо знать чтобы устроится на Middle JavaScript Developer:
1) JavaScrit (версия ES5) (20%)
2) jQuery (20%)
3) HTML5, CSS3 (10%)
4) Bootsrap, LESS, SASS (10%)
5) JS Build Systems (npm, bower, gulp, grunt) (10%)
6) git, gitHub (10%)
7) Design Patterns (5%)
8) Refactoring (5%)
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@realmyst
realmyst / gist:1262561
Created October 4, 2011 19:34
Склонение числительных в javascript
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
use:
declOfNum(count, ['найдена', 'найдено', 'найдены']);