Skip to content

Instantly share code, notes, and snippets.

🐝

Sasha Zmts zmts

🐝
Block or report user

Report or block zmts

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@zmts
zmts / debian_do.md
Last active Apr 4, 2020
Первичная настойка Debian Linux/Разворачиваем серверную инфраструктуру на Digital ocean
View debian_do.md

Первичная настойка Debian Linux/Разворачиваем серверную инфраструктуру на Digital ocean

Для проектов среднего и небольшого размера не всегда оправданно использовать AWS/Kubernetes подобную технологию. Для проектов нуждающихся в нескольких серверах отлично подходит Digital ocean. Который к тому же предоставляет средства вертикального скейлинга(увеличение производительной мощности уже существующих серверов).

SSH cертификат

Создаем сертификат под которым будем логинится на сервера нашего проекта (на локальной машине)

ssh-keygen -t rsa -b 4096 -f /Users/alex/.ssh/myproject_test -C "myproject comment"

Не забываем сделать его бекап

@zmts
zmts / ssh_cert.md
Last active Apr 4, 2020
ssh cert to remote server access
View ssh_cert.md

SSH cert to remote server access

Generate ssh certificate with unique filename. Stroring keys in separate files will help make backup without not related keys.

➜ cd /Users/alex/.ssh
➜ ssh-keygen -t rsa -b 4096 -f myproject_test -C "myproject comment"
Generating public/private rsa key pair.
@zmts
zmts / raw_sql_vs_query_builders.md
Last active Mar 22, 2020
Raw SQL query vs Query builders (Knex.js/Objection.js)
View raw_sql_vs_query_builders.md

Raw SQL query vs Query builders (Knex.js/Objection.js)

Raw SQL

static async listPostsPublicRaw ({ offset, limit, filter = {} } = {}) {
    assert.integer(limit, { required: true, min: 10 })
    assert.integer(offset, { required: true, min: 0 })
    assert.validate(filter.blogId, BlogModel.schema.id, { required: true })
    assert.validate(filter.stackId, StackModel.schema.id)
View debounce-function-implemented-with-promises.md

Debounce with promises

// https://stackoverflow.com/questions/35228052/debounce-function-implemented-with-promises

function debounce (inner, ms = 0) {
  let timer = null
  let resolves = []

  return function (...args) {
@zmts
zmts / firebase-messaging-sw.js
Created Mar 11, 2020
Firebase web push notification
View firebase-messaging-sw.js
importScripts('https://www.gstatic.com/firebasejs/7.8.2/firebase-app.js')
importScripts('https://www.gstatic.com/firebasejs/7.8.2/firebase-messaging.js')
firebase.initializeApp({
apiKey: "---",
authDomain: "test.firebaseapp.com",
databaseURL: "https://test.firebaseio.com",
projectId: "test",
storageBucket: "test.appspot.com",
messagingSenderId: "11111111111",
@zmts
zmts / indexInForOf.md
Last active Feb 13, 2020
Get index in for of
View indexInForOf.md

Get index in for of

for (const [index, value] of ['a', 'b', 'c'].entries()) {
  console.log(index, value)
}

/*
0 "a"
1 "b"
@zmts
zmts / vault.md
Last active Jan 9, 2020
Hashicorp Vault
View vault.md

Hashicorp Vault

export VAULT_ADDR='http://127.0.0.1:8200'

Enable approle auth method

vault auth enable approle
View medium-zoom.md

medium-zoom.js next/prev image feature

[...]
mounted () {
    setTimeout(() => {
      const selectors = document.querySelectorAll('[data-zoom-src]')
      const zoom = mediumZoom(selectors)
      nextPrevImageFeature(zoom)
    }, 500)
@zmts
zmts / docker.md
Last active Jan 4, 2020
Docker, TypeScript, Node.js
View docker.md

Docker, TypeScript, Node.js

Preconditions:

  • TS application listening port: 7777
|-- dist
|-- src
|-- .dockerignore
|-- Dockerfile
@zmts
zmts / fingerprint.md
Last active Mar 29, 2020
Get browser fingerprint example (fingerprintjs2)
View fingerprint.md

Get browser fingerprint example (fingerprintjs2)

import * as Fingerprint2 from 'fingerprintjs2'
import * as UAParser from 'ua-parser-js'

function _getFingerprint () {
  return new Promise((resolve, reject) => {
    async function getHash () {
      const options = {
You can’t perform that action at this time.