Skip to content

Instantly share code, notes, and snippets.

View sliim35's full-sized avatar
💭
👻

Maksim Dvoinishnikov sliim35

💭
👻
  • 05:53 (UTC +04:00)
View GitHub Profile
@sliim35
sliim35 / node_nginx_ssl.md
Created September 30, 2019 11:39 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@sliim35
sliim35 / service-worker.md
Last active August 26, 2019 07:34
Service Worker Cheatsheet

Readme

What is a service worker / Source

A service worker is a script that your browser runs in the background, separate from a web page, opening the door to features that don't need a web page or user interaction. Today, they already include features like push notifications and background sync. In the future, service workers might support other things like periodic sync or geofencing. The core feature discussed in this tutorial is the ability to intercept and handle network requests, including programmatically managing a cache of responses.

Lifecycle

lifecycle

@sliim35
sliim35 / myscript.sh
Created August 20, 2019 09:50 — forked from bradtraversy/myscript.sh
Basic Shell Scripting
#! /bin/bash
# ECHO COMMAND
# echo Hello World!
# VARIABLES
# Uppercase by convention
# Letters, numbers, underscores
NAME="Bob"
# echo "My name is $NAME"
// docs: https://nodejs.org/dist/latest-v10.x/docs/api/https.html#https_https_request_url_options_callback
// all methods working, but post only with x-form-urlencoded. return promise with resolved object on line 64.
// extra options parameters: json=[bool], params=[object]
const querystring = require('querystring')
const https = require('https')
const http = require('http')
const cleanObject = (object, filterKeys) => Object
.keys(object)
.reduce((acc, key) => {
@sliim35
sliim35 / mongo.js
Created July 23, 2019 14:44
Lectrum
print("=== BEGIN ===");
use mdvoy
db.dropDatabase()
use mdvoy
const bulkWriteArray = [];
const writeCustomer = () => {
@sliim35
sliim35 / redux-saga.js
Created July 23, 2019 07:12
Redux Saga
// https://github.com/redux-saga/redux-saga
// const generator = function* () {} ✅
// const generator = ()* => {} ❌
/**
* Effects - https://redux-saga.js.org/docs/api/
* - Thread managment: - Action creation - Data seeding - Flow control
* call put select take
* fork takeEvery
* spawn takeLatest
@sliim35
sliim35 / mock-axios.js
Created July 19, 2019 09:11 — forked from cowboy/mock-axios.js
axios mocking via interceptors
import axios from 'axios'
let mockingEnabled = false
const mocks = {}
export function addMock(url, data) {
mocks[url] = data
}
function createQuery(connection) {
return function query(sql) {
return connection.query(sql)
}
}
function createOrder(query) {
return function order() {
query('blalblbalbbla')
}

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@sliim35
sliim35 / tokens.md
Created July 9, 2019 07:42 — 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 система авторизации проверит имеет ли право юзер обращатся к этому ресурсу (проще говоря переходить по неким разрешенным ссылкам)