Skip to content

Instantly share code, notes, and snippets.

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

Slava Fomin II slavafomin

✌️
Let's make this World a better place!
View GitHub Profile
@slavafomin
slavafomin / install-telegram.sh
Last active June 2, 2017 15:40
Install Telegram on Ubuntu using shell automatically
#/usr/bin/env bash
set -o errexit
set -o pipefail
shopt -s nullglob
INSTALL_PATH="$HOME/Telegram"
TEMP_PATH="$HOME/.tmp"
sudo apt-get install xz-utils
@slavafomin
slavafomin / install-phpstorm.sh
Last active September 29, 2017 12:04
Bash shell script to install PhpStorm automatically
#!/usr/bin/env bash
# @todo: load URL from here: https://data.services.jetbrains.com/products/releases?code=PS&latest=true&type=release
set -o errexit
set -o pipefail
shopt -s nullglob
DROPBOX_PATH="$HOME/Dropbox"
INSTALL_PATH="$HOME/PhpStorm"
@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
@slavafomin
slavafomin / nodejs-custom-es6-errors.md
Last active March 9, 2024 12:03
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 / 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.

const gulpPostcss = require('gulp-postcss');
const postcssPartialImport = require('postcss-partial-import');
const postcssCssnext = require('postcss-cssnext');
const gulpRename = require('gulp-rename');
const gulpLivereload = require('gulp-livereload');
const gulpCssnano = require('gulp-cssnano');
const gulpif = require('gulp-if');
const sourcemaps = require('gulp-sourcemaps'); // <========================================
@slavafomin
slavafomin / confirm-one-click-action.twig
Created October 2, 2016 04:31
This partial in Twig defines "Confirm" one-click action for E-Mail messages.
{#
Defined "Confirm" one-click action.
@param {string} title
@param {string} url
@param {string} [description]
#}
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="potentialAction" itemscope itemtype="http://schema.org/ConfirmAction">
<meta itemprop="name" content="{{ title }}"/>
@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 &amp;&amp; windowWidth &lt; minWidthForVideo) {
@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 / add-user.sh
Last active February 18, 2021 14:59
Generate .htpasswd file for nginx basic authentication
#!/usr/bin/env bash
read -p "Username: " USERNAME
read -s -p "Password: " PASSWORD; echo
printf "${USERNAME}:$(openssl passwd -crypt ${PASSWORD})\n" >> ./.htpasswd