Skip to content

Instantly share code, notes, and snippets.

View webshru's full-sized avatar

Dmitry Shamrilo webshru

  • 11:54 (UTC +03:00)
View GitHub Profile
@webshru
webshru / git editor vs-code
Last active April 6, 2020 15:50
Редактор по умолчания для гита (vs code)
git config --global core.editor "code --wait"
@webshru
webshru / fonts.css
Last active January 23, 2019 07:30
Подключение шрифтов на сайт
@font-face {
font-family: "Name";
font-style: normal;
src: url("../fonts/name-Medium.woff2") format("woff2"),
url("../fonts/name-Medium.woff") format("woff");
font-weight: 500;
}
@font-face {
font-family: "Name";
@webshru
webshru / NodeList.forEach.js
Last active August 3, 2022 14:45
Polyfill. Добавление forEach к NodeList (для IE 11)
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = function (callback, thisArg) {
thisArg = thisArg || window
for (var i = 0; i < this.length; i++) {
callback.call(thisArg, this[i], i, this)
}
}
}
// Или
@webshru
webshru / request-fullscreen.js
Last active November 16, 2018 07:38
Отображение элемента в полноэкранном режиме (с префиксами событий для браузеров)
// Открытие элемента в полноэкранный режим
const launchFullScreen = (el) => {
if (el.requestFullscreen) {
el.requestFullscreen()
} else if (el.webkitRequestFullScreen) {
el.webkitRequestFullScreen()
} else if (el.mozRequestFullScreen) {
el.mozRequestFullScreen()
} else if (el.msRequestFullscreen) {
el.msRequestFullscreen()
function debounce (func, wait, immediate) {
let timeout
return function () {
const context = this
const args = arguments
const later = function () {
timeout = null
if (!immediate) {
func.apply(context, args)
const getRandomNumber = (min, max) => {
return Math.round(min - 0.5 + Math.random() * (max - min + 1));
};
const easings = {
linear (t, b, c, d) {
return c * t / d + b;
},
easeInQuad (t, b, c, d) {
return c * (t /= d) * t + b;
},
easeOutQuad (t, b, c, d) {
return -c * (t /= d) * (t - 2) + b;
},
find . -name "node_modules" -exec rm -rf '{}' +
@webshru
webshru / valid-email.js
Created October 23, 2019 20:34
Проверка валидного email
const validateEmail = (email) => {
const re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
return re.test(email)
}