Skip to content

Instantly share code, notes, and snippets.

View Defite's full-sized avatar
🚙

Nikita Makhov Defite

🚙
View GitHub Profile
@Defite
Defite / config.development.json
Created July 22, 2021 15:41
Ghost.js, prepend image urls with Cloudinary links. Works for Ghost 4.9.4
{
...
"imageOptimization": {
"cloudinary": {
"baseUrl": "https://res.cloudinary.com/summertimesadness/image/fetch/f_auto,q_auto"
}
}
}
@Defite
Defite / git-commit-template.md
Created October 29, 2020 16:43 — forked from lisawolderiksen/git-commit-template.md
Use a Git commit message template to write better commit messages

Using Git Commit Message Templates to Write Better Commit Messages

One of my colleagues shared an article on writing (good) Git commit messages today: How to Write a Git Commit Message. This excellent article explains why good Git commit messages are important, and explains what constitutes a good commit message. I wholeheartedly agree with what @cbeams writes in his article. (Have you read it yet? If not, go read it now. I'll wait.) It's sensible stuff. So I decided to start following the

@Defite
Defite / git-commit-template.md
Created October 29, 2020 16:43 — forked from lisawolderiksen/git-commit-template.md
Use a Git commit message template to write better commit messages

Using Git Commit Message Templates to Write Better Commit Messages

One of my colleagues shared an article on writing (good) Git commit messages today: How to Write a Git Commit Message. This excellent article explains why good Git commit messages are important, and explains what constitutes a good commit message. I wholeheartedly agree with what @cbeams writes in his article. (Have you read it yet? If not, go read it now. I'll wait.) It's sensible stuff. So I decided to start following the

@Defite
Defite / plural.js
Created April 28, 2020 13:51
Plural.js
/**
* Get plural by number
* @param {Number} value - number
* @param {Array} cases - array of cases
* @returns {String} case
*/
const plural = (value, cases) => {
let n = Math.abs(value);
n %= 100;
@Defite
Defite / formatDateString.js
Created April 27, 2020 18:13
formatDateString.js
/**
*
* @param {Number} date - число в ms
* @param {String} separator - разделитель для даты, например 01.01.1970
* @param {String} format - формат вывода даты, например, 1970.02.25
*/
function formatDateString(date, separator, format) {
if (!date) {
return;
}
@Defite
Defite / counter.js
Created January 24, 2020 16:43
Place counter under some weird business logic
const steps = [31, 29, 31, 30, 31, 30];
const year = [];
let modifiedYear = []
// First date
const counterDate = 14;
// step is equal to month length
steps.forEach(count => {
year.push(Array(count).fill(0))
@Defite
Defite / gzip.md
Created November 22, 2018 11:53 — forked from Busyrev/gzip.md
О сжатии на протокольном уровне (http)

О сжатии на протокольном уровне (http)

Актулизировано на момент 22.11.2018

Обозреваемые форматы сжатия:

  • gzip 1 - минимальный уровень сжатия gzip, результат .gz
  • gzip 9 - максимальный уровень сжатия gzip, результат .gz
  • zopfli - отдельный алгоритм совместимый с распаковщиком gzip, результат .gz
  • brotli 11 - полностью новый формат, 11 это максимальный уровень сжатия, результат .br

Не рассматривается - sdch(нет поддержки в современных браузерах), попытки запустить gzip > 1, zopfli, brotli на лету без пребилда сжатых файлов (для нас не актуально, очень много данных)

@Defite
Defite / mysql-docker.sh
Created November 7, 2018 21:05 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@Defite
Defite / promise_once.js
Created January 12, 2018 09:38
Resolve promise when async action has finished
var bar = function (data) {
return setTimeout(function() {
return 'async data';
}, 1000);
}
var foo = function () {
this._promise new Promise(function(resolve, reject) {
this.once('bar', resolve)
})
@Defite
Defite / global-gitignore.md
Created January 10, 2018 09:04 — forked from subfuzion/global-gitignore.md
Global gitignore

There are certain files created by particular editors, IDEs, operating systems, etc., that do not belong in a repository. But adding system-specific files to the repo's .gitignore is considered a poor practice. This file should only exclude files and directories that are a part of the package that should not be versioned (such as the node_modules directory) as well as files that are generated (and regenerated) as artifacts of a build process.

All other files should be in your own global gitignore file. Create a file called .gitignore in your home directory and add anything you want to ignore. You then need to tell git where your global gitignore file is.

Mac

git config --global core.excludesfile ~/.gitignore

Windows

git config --global core.excludesfile %USERPROFILE%\.gitignore