Skip to content

Instantly share code, notes, and snippets.

@mohnatus
mohnatus / promise.js
Created February 11, 2019 10:07
general promise constructor
let promise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('new value');
}, 1000)
});
promise
.then(
data => console.log(data),
error => console.log(error)
@mohnatus
mohnatus / equals.js
Last active February 11, 2019 12:38
deep comparison
const equals = (a, b) => {
if (a === b) return true;
if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime();
if (!a || !b || (typeof a != 'object' && typeof b !== 'object')) return a === b;
if (a === null || a === undefined || b === null || b === undefined) return false;
if (a.prototype !== b.prototype) return false;
let keys = Object.keys(a);
if (keys.length !== Object.keys(b).length) return false;
return keys.every(k => equals(a[k], b[k]));
};
@mohnatus
mohnatus / placeholder.css
Created February 11, 2019 12:45
crossbrowser placeholder style
::-webkit-input-placeholder { /* Chrome/Opera/Safari */
color: pink;
}
::-moz-placeholder { /* Firefox 19+ */
color: pink;
}
:-ms-input-placeholder { /* IE 10+ */
color: pink;
}
:-moz-placeholder { /* Firefox 18- */
@mohnatus
mohnatus / scrollbar.css
Created February 11, 2019 12:46
webkit scrollbar style
*::-webkit-scrollbar-button {
background-image:url('');
background-repeat:no-repeat;
width:5px;
height:0px
}
*::-webkit-scrollbar-track {
background-color:#ecedee
}
@mohnatus
mohnatus / userselect.html
Created February 11, 2019 12:48
user select off
<!--IE-->
<div unselectable="on" onselectstart="return false;">текст</div>
<style>
.content {
-webkit-user-select: none; /* для Chrome и Safari */
-moz-user-select: none; /* для Firefox */
-ms-user-select: none; /* для IE 10+ */
-o-user-select:none;
-khtml-user-select: none;
@mohnatus
mohnatus / favicon.html
Created February 11, 2019 12:48
add favicon
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
@mohnatus
mohnatus / mail.html
Created February 11, 2019 12:50
email template
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body style="
margin: 0; padding: 0; width: 100% !important; min-width: 100%;
@mohnatus
mohnatus / mail-elements.html
Created February 11, 2019 12:51
email template elements
<!--Главный контейнер ряда:-->
<tr style=" margin: 0; padding: 0;">
<td style="
width: 100%;
margin: 0; padding: 0;
border-spacing: 0; border-collapse: collapse;"
bgcolor="#ffffff" width="600px">
<table style="
width: 100%; margin: 0; padding: 0;
border-spacing: 0; border-collapse: collapse;
@mohnatus
mohnatus / social.html
Created February 11, 2019 12:55
social svg icons
<!-- vk -->
<svg width="60" height="60" viewBox="0 0 60 60" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>vk_icon</title>
<g id="Canvas" transform="translate(-12567 -6309)">
<g id="vk_40x40">
<g id="Vector">
<use xlink:href="#vk_path" transform="translate(12581.8 6330)" fill="#FFFFFF"/>
</g>
</g>
@mohnatus
mohnatus / requestAnimationFrame.js
Created February 12, 2019 09:22
requestAnimationFrame definition
let requestAnimationFrame = window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame;
window.requestAnimationFrame = requestAnimationFrame;