Skip to content

Instantly share code, notes, and snippets.

View webshru's full-sized avatar

Dmitry Shamrilo webshru

  • 05:14 (UTC +03:00)
View GitHub Profile
@webshru
webshru / imageBrightness.js
Created August 3, 2020 20:15 — forked from vincentorback/imageBrightness.js
Get Image Brightness
function getImageBrightness(imageSrc, callback) {
var img = document.createElement('img'),
colorSum = 0,
i = 0,
len,
canvas,
ctx,
imageData,
data,
brightness,
Generate new SSH keys
ssh-keygen -t rsa -b 4096 -C "personal@mail.com" -f ~/.ssh/id_rsa_gitlab
ssh-keygen -t rsa -b 4096 -C "personal@mail.com" -f ~/.ssh/id_rsa_github
add config ~/.ssh/config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_github
# Personal gitlab account
@webshru
webshru / open-window-share.js
Last active March 31, 2020 09:29
Настройка окна для шаринга
const openWindowShare = (name, evt) => {
const href = evt.currentTarget.href
const PARAMS = {
vk: {
width: 650,
height: 570
},
fb: {
width: 600,
height: 745
@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)
}
find . -name "node_modules" -exec rm -rf '{}' +
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;
},
const getRandomNumber = (min, max) => {
return Math.round(min - 0.5 + Math.random() * (max - min + 1));
};
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)
@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()