Skip to content

Instantly share code, notes, and snippets.

View slavafomin's full-sized avatar
✌️
Let's make this World a better place!

Slava slavafomin

✌️
Let's make this World a better place!
View GitHub Profile
@kellyrmilligan
kellyrmilligan / s3Sync.sh
Created June 8, 2017 13:38
Sync files to s3 and set cache control headers
#!/bin/bash
if [[ "$1" != "" ]]; then
S3BUCKETNAME="$1"
else
echo ERROR: Failed to supply S3 bucket name
exit 1
fi
aws s3 sync build s3://$S3BUCKETNAME --delete --cache-control max-age=31536000,public
@slavafomin
slavafomin / npm5-vs-yarn.md
Last active May 17, 2018 08:50
npm 5 vs yarn

npm 5 vs yarn

Looks like npm decided to stand up to yarn by releasing npm version 5, which is announced to be 5 times faster than previous version of npm.

I've decided to test it in one of my projects, the results are below:

Performance Benchmark

@slavafomin
slavafomin / 0-README.md
Last active March 15, 2023 13:35
Angular 2 match other field validator / Password match validator

Angular 2 match other field validator

This custom validator for Angular 4 allows you to have fields that must be equal to some other fields. Such validator is very useful for password confirmation validation, for example.

Besides checking if two values are matching, it also subscribes to changes from other control and re-validates when either of two controls is updated.

Usage

@slavafomin
slavafomin / git-submodules.md
Last active February 19, 2025 03:15
Git submodules best practices

Git submodules best practices

Useful commands

— Clone repository with submodules automatically:

git clone --recursive [email protected]:name/repo.git

— Initialize submodules after regular cloning:

@slavafomin
slavafomin / docker-cheat-sheet.md
Created April 17, 2017 21:19
Docker Cheat Sheet

Docker Cheat Sheet

Open shell inside of the running container

docker exec -t -i container-name /bin/bash

Use /bin/sh if your Docker image doesn't has bash (e.g. Alpine).

@slavafomin
slavafomin / tilda-scripts-patch.md
Last active December 7, 2016 21:02
Tilda Cover's Min Width For Video Patch

tilda-scripts-2.6.js

1). Add the following snippet to the cover_init function (before $isMobile is first used):

var minWidthForVideo = parseInt(el.attr('data-min-width-for-video')) || null;
var imageMode = $isMobile;
var windowWidth = $(window).width();
if (minWidthForVideo && windowWidth < minWidthForVideo) {
{% if share_url is not defined %}
{% set share_url = project.url %}
{% endif %}
{% set share_url = share_url|url_encode %}
{% if share_title is not defined %}
{% set share_title = project.readable_name %}
{% endif %}
{% set share_title = share_title|url_encode %}
@slavafomin
slavafomin / javascript-pluralization.md
Last active February 12, 2023 19:22
How to pluralize words in JavaScript in different languages?

How to pluralize any word in different languages using JavaScript?

Hello!

Today, I'm going to show you how to pluralize any word in JavaScript (Node.js or Browser) in almost any language!

I've developed a very simple, but powerful package in JavaScript that will help you to achieve this goal. It's called Numerous.

@slavafomin
slavafomin / nodejs-custom-es6-errors.md
Last active November 14, 2024 11:23
Custom ES6 errors in Node.js

Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.

I've tried to make it as lean and unobtrusive as possible.

Defining our own base class for errors

errors/AppError.js

@slavafomin
slavafomin / 0-install-nodejs-v9.sh
Last active June 19, 2018 08:20
Install latest version of Node.js in Ubuntu using bash shell script
#/usr/bin/env bash
set -o errexit
set -o pipefail
NODE_VERSION="v9"
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
. $HOME/.nvm/nvm.sh