How to create database & user in PostgreSQL

This is a quick reminder to myself about how to quickly create PostgreSQL database (along with the user & password). Since it’s quite usual for me that db name and user name are the same, I’m putting them the same in a script to make search&replace easier.

sudo -u postgres psql
postgres=# CREATE USER user_db_name WITH ENCRYPTED PASSWORD 'mypass';
postgres=# CREATE DATABASE user_db_name WITH OWNER user_db_name ENCODING='UTF-8' LC_COLLATE='en_US.utf8' LC_CTYPE='en_US.utf8' TEMPLATE template0;

How to add ESLint/Prettier support to create-react-app

This is a short reminder for myself about adding ESLint support to a new create-react-app project with typescript (which is my default frontend template for now).

Instructions include setting up file watchers in VSCode and WebStorm, so all files are automatically formatted on save.

So, here we go.

yarn add @typescript-eslint/parser @typescript-eslint/eslint-plugin prettier eslint-config-prettier eslint-plugin-prettier

Extract the configs from archive into the folder of a project. This will set up watchers and default configs for both ESLint and Prettier.

Don’t forget to restart your IDE to get all the goodies.

Настройка Web-Deploy на IIS7

Эта заметка из разряда «напоминалок чтобы не забыть».

Установить web-deploy проще всего через Web Platform Installer (если уже установлен — запустить из меню Пуск->Web Platform Installer).
В Web Platform Installer поиском по слову «deploy» найти «Web Deploy 3.0» или «Web Deployment Tool 2.1 blablabla».
Установить. Радоваться :)

В настройках one-click publish в VS прописать адрес сервера и имя сайта, в который будет идти деплой.
Обработчик web-deploy на стороне сервера будет работать по адресу http://xxxxxxx/MSDEPLOYAGENTSERVICE, на 80-м порту.

Деплоить на этот адрес смогут администраторы сервера. При получении ошибки 401 Unauthorized добавить ключ в реестр: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System (DWORD: LocalAccountTokenFilterPolicy = 1)
Это решит проблему, если пользователь, от имени которого идет деплой не «админ», но состоит в группе «Администраторы».

Настройка деплоя под неадминистративным пользователем требует доп. настроек прав доступа в IIS->Управление(Management)->Делегирование службы управления(Management Service Delegation). Требуется добавить правило «Развертывания приложений» для нужных пользователей. Детали хорошо описаны по ссылке.

В проблеме 401 Unauthorized может также помочь ссылка.