Install openvpn server on ubuntu

wget https://git.io/vpn -O openvpn-install.sh
sudo bash openvpn-install.sh
19 апреля 2022, 09:59

Gitlab invalid: EXPKEYSIG

curl -L https://packages.gitlab.com/gitlab/gitlab-ee/gpgkey | sudo apt-key add -
26 марта 2022, 02:55

Enable file public url access on AMAZON S3

s3
Write in bucket policy
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AddPerm",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::my_bucket_name/*"
            ]
        }
    ]
}
22 марта 2022, 16:01

Install vue app with npx

npx @vue/cli create --default my-vue-app
15 марта 2022, 16:28

Docker removes volumes

docker-compose down -v
26 января 2022, 22:22

Copy schema table in postgres

CREATE TABLE new_table_name (LIKE old_table_name INCLUDING ALL);
2 ноября 2021, 11:33

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