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 / 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)
@zmts
zmts / docker.md
Last active May 19, 2024 14:47
Docker, TypeScript, Node.js

Docker, TypeScript, Node.js

Preconditions:

  • TS application listening port: 7777
|-- dist
|-- src
|-- .dockerignore
|-- Dockerfile
@zmts
zmts / fingerprint.md
Last active February 1, 2025 11:44
Get browser fingerprint example (fingerprintjs2)

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 = {
@zmts
zmts / js_type.md
Last active November 23, 2020 22:25
Object type vs Array type. Handle JavaScript types

Object type vs Array type. Handle JavaScript types

Object.prototype.toString.call(true) // [object Boolean]
Object.prototype.toString.call('hello') // [object String]
Object.prototype.toString.call(10) // [object Number]
Object.prototype.toString.call({}) // [object Object]
Object.prototype.toString.call([]) // [object Array]
Object.prototype.toString.call(null) // [object Null]
Object.prototype.toString.call(undefined) // [object Undefined]
@zmts
zmts / s3_aws-sdk_digitalocean.md
Last active August 27, 2020 08:55
Configure AWS SDK with Digital Ocean endpoint; S3

Configure AWS SDK with Digital Ocean endpoint

const AWS = require('aws-sdk')
const spacesEndpoint = new AWS.Endpoint('nyc3.digitaloceanspaces.com');

const s3 = new AWS.S3({
    endpoint: spacesEndpoint,
    accessKeyId: 'ACCESS_KEY',
 secretAccessKey: 'SECRET_KEY'
@zmts
zmts / postgresql-set-id-seq.sql
Created April 25, 2019 15:17 — forked from henriquemenezes/postgresql-set-id-seq.sql
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));
@zmts
zmts / countries.sql
Last active May 1, 2019 15:26 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@zmts
zmts / makeArray.md
Created April 2, 2019 10:02
Create array with specific size Javascript

Create array with specific size Javascript

[  ...Array(10).keys() ] // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]