Skip to content

Instantly share code, notes, and snippets.

View zmts's full-sized avatar
🇺🇦
russian warship go f*uck yourself

Sasha Zmts zmts

🇺🇦
russian warship go f*uck yourself
View GitHub Profile
@zmts
zmts / tmux.md
Last active June 22, 2023 13:34
tmux

tmux common comands

Configure tmux

> nano ~/.tmux.conf

# default: ctrl-b
# set prefix ctrl-q
set-option -g prefix C-q 
@zmts
zmts / single_quotes.md
Last active January 5, 2024 16:15
Webstorm: auto import with single quotes

Webstorm: auto import with single quotes and spases between braces

Preferences --> Editor --> Code Style --> Typescript/JavaScript --> Punctuation [Tab] --> Use [Single] quotes in [New Code]

Preferences --> Editor --> Code Style --> Typescript/JavaScript --> Spaces [Tab] --> Scroll to section "Within" and check ES6 import/export braces

@zmts
zmts / debian_do.md
Last active December 16, 2023 10:31
Первичная настойка Debian Linux/Разворачиваем серверную инфраструктуру на Digital ocean

Первичная настойка 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 October 25, 2021 17:16
ssh cert to remote server access

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 November 13, 2020 01:33
Raw SQL query vs Query builders (Knex.js/Objection.js)

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)

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
Last active December 2, 2022 12:34
Firebase web push notification
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 January 10, 2021 19:29
Get index in for of

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 January 9, 2020 15:18
Hashicorp Vault

Hashicorp Vault

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

Enable approle auth method

vault auth enable approle

medium-zoom.js next/prev image feature

[...]
mounted () {
    setTimeout(() => {
      const selectors = document.querySelectorAll('[data-zoom-src]')
      const zoom = mediumZoom(selectors)
      nextPrevImageFeature(zoom)
    }, 500)