Install CertBot on ubuntu 20

sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo certbot --nginx
2 ноября 2021, 01:24

List of docker container volumes

docker inspect -f '{{ .Mounts }}' containerid
1 ноября 2021, 16:52

Install certificates on Ubuntu

sudo apt install ca-certificates
7 октября 2021, 10:17

Promise resolve example

(async () => {
  const promises = [];
  promises.push(new Promise((resolve) => {
    resolve(1);
  }));
  promises.push(new Promise((resolve) => {
    resolve(2);
  }));
  const results = await Promise.all(promises);
  console.log(results);
})();
23 сентября 2021, 13:44

Add swap on Ubuntu

sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
10 августа 2021, 12:05

Send HEAD request in nodejs

const http = require('http');
http.request(url, { method: 'HEAD' }, (res) => {
  console.log(res.statusCode);
})
  .on('error', (err) => {
    console.error(err);
  })
  .end();
28 июля 2021, 18:53

Select estimated rows count from timescaledb

SELECT h.schema_name,
    h.table_name,
    h.id AS table_id,
    h.associated_table_prefix,
    row_estimate.row_estimate
   FROM _timescaledb_catalog.hypertable h
     CROSS JOIN LATERAL ( SELECT sum(cl.reltuples) AS row_estimate
           FROM _timescaledb_catalog.chunk c
             JOIN pg_class cl ON cl.relname = c.table_name
          WHERE c.hypertable_id = h.id
          GROUP BY h.schema_name, h.table_name) row_estimate
ORDER BY schema_name, table_name;
6 мая 2021, 13:31

Get estimated count rows

explain (format json) select * from tbl
28 апреля 2021, 17:38

Get weekday name with intl

new Intl.DateTimeFormat('ru-RU', { weekday: 'short' }).format(new Date()) //пн
19 апреля 2021, 23:32

Get start and end of current hour in javascript

const date = new Date();
const d1 = new Date(
  date.getFullYear(),
  date.getMonth(),
  date.getDay(),
  date.getHours(),
  0,
  0,
  0,
);
const d2 = new Date(
  date.getFullYear(),
  date.getMonth(),
  date.getDay(),
  date.getHours(),
  59,
  59,
  999,
);

console.log(d1); // 2021-03-05T09:00:00.000Z
console.log(d2); // 2021-03-05T09:59:59.999Z
19 марта 2021, 12:22

Install nodejs 14 on ubuntu 20

curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
20 февраля 2021, 13:43

HomeBrew fatal error: 'pcre2.h' file not found

ln -s /opt/homebrew/Cellar/pcre2/10.36/include/pcre2.h /opt/homebrew/Cellar/php/8.0.2/include/php/ext/pcre
17 февраля 2021, 00:04

Create user without password

sudo adduser \
   --system \
   --shell /bin/bash \
   --gecos 'description' \
   --group \
   --disabled-password \
   --home /home/us \
   us
16 февраля 2021, 17:43

Error: Node Sass does not yet support your current environment: OS X Unsupported architecture (arm64)

npm rebuild node-sass
16 февраля 2021, 17:00

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';  
15 февраля 2021, 15:19

Install docker on Ubuntu

sudo apt-get remove -y docker docker-engine docker.io containerd runc

sudo apt-get update

sudo apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

sudo apt-get update

sudo apt-get install -y docker-ce docker-ce-cli containerd.io

14 февраля 2021, 12:59

Install ffmpeg with aac on homebrew

brew tap homebrew-ffmpeg/ffmpeg
brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-fdk-aac
13 февраля 2021, 12:48

Open file in new tab instead window in Sublime Text 3

Go to options
"open_files_in_new_window": false
10 февраля 2021, 16:50

Show hidden files on Mac Finder

Type in terminal
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
9 февраля 2021, 19:02

Increate memory limit for process

export NODE_OPTIONS=--max_old_space_size=4096
2 февраля 2021, 20:44