Skip to content

Instantly share code, notes, and snippets.

View olehwebdev's full-sized avatar
🏠
Working from home

Oleh H olehwebdev

🏠
Working from home
View GitHub Profile
@olehwebdev
olehwebdev / tsconfig.json
Created September 22, 2020 21:03 — forked from KRostyslav/tsconfig.json
tsconfig.json с комментариями.
// Файл "tsconfig.json":
// - устанавливает корневой каталог проекта TypeScript;
// - выполняет настройку параметров компиляции;
// - устанавливает файлы проекта.
// Присутствие файла "tsconfig.json" в папке указывает TypeScript, что это корневая папка проекта.
// Внутри "tsconfig.json" указываются настройки компилятора TypeScript и корневые файлы проекта.
// Программа компилятора "tsc" ищет файл "tsconfig.json" сначала в папке, где она расположена, затем поднимается выше и ищет в родительских папках согласно их вложенности друг в друга.
// Команда "tsc --project C:\path\to\my\project\folder" берет файл "tsconfig.json" из папки, расположенной по данному пути.
// Файл "tsconfig.json" может быть полностью пустым, тогда компилятор скомпилирует все файлы с настройками заданными по умолчанию.
// Опции компилятора, перечисленные в командной строке перезаписывают собой опции, заданные в файле "tsconfig.json".
@olehwebdev
olehwebdev / A Nuxt.js VPS production deployment.md
Created August 10, 2018 14:07 — forked from DreaMinder/A Nuxt.js VPS production deployment.md
Deployment manual for a real-world project built with nuxt.js + koa + nginx + pm2

Example of deployment process which I use in my Nuxt.js projects. I usually have 3 components running per project: admin SPA, nuxt.js renderer and JSON API.

This manual is relevant for VPS such as DigitalOcean.com or Vultr.com. It's easier to use things like Now for deployment but for most cases VPS gives more flexebillity needed for projects bigger then a landing page.


Let's assume that you have entered fresh installation of Ubuntu instance via SSH. Let's rock:

1.Initial setup.

git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
axios.get(https://www.googleapis.com/youtube/v3/search?key={API_KEY}&channelId={CHANNEL_ID}&part=snippet,id&order=date&maxResults=2)
.then(result => {
console.log(result)
})
@olehwebdev
olehwebdev / app.js
Created January 3, 2018 22:25 — forked from stongo/app.js
Joi validation in a Mongoose model
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
db.on('error', function() {
return console.error.bind(console, 'connection error: ');
});
@olehwebdev
olehwebdev / pairs.js
Created September 11, 2017 08:20
Converting an array to an object from key-value pairs
const pairs = [['a', 1], ['b', 2], ['c', 3]];
const asObject = pairs.reduce((res, [key, value]) => ({...res, [key]: value }), {})
const asObject2 = { ...(new Map(pairs)) }
console.log(asObject)
@olehwebdev
olehwebdev / Unique.js
Created September 11, 2017 08:17
This code returns a new array|object, only unique numbers.
const array = [1,1,2,3,4,5,5,5,6,7,8];
const array2 = new Set(array);
const uniq = [...new Set(array)];
//Unique Array
console.log('Unique array', uniq);
//Unique Object
console.log('Object', array2);
@olehwebdev
olehwebdev / redirect toUrl to zf2
Created June 3, 2016 14:36
Редирект на ту-же страницу в zf2
///Controller///
protected function serverUrl($fullpath = true)
{
$serverUrl = $this->getServiceLocator()->get('viewhelpermanager')->get('serverurl');
return $serverUrl($fullpath);
}
@olehwebdev
olehwebdev / Прибили footer :)
Created March 26, 2016 13:56
Прибиваем футер к низу страници с помощью FLEX
<?php
$HOME = dirname(__FILE__);
// Если пользуешься OpenServer или хостинг на Windows измени значение $WIN = 1;
$WIN = 0;
// Понеслась
?>
<!DOCTYPE HTML>
<html>