Skip to content

Instantly share code, notes, and snippets.

View EminQasimov's full-sized avatar
🎯
Focusing

Emin Gasimov EminQasimov

🎯
Focusing
View GitHub Profile
@EminQasimov
EminQasimov / reduce browser repaints
Last active April 22, 2019 15:41
60fps scrolling using pointer-events: none
/*
.disable-hover,
.disable-hover * {
pointer-events: none !important;
}
if you have many box-shadow elements or any animated elements
that cause of browser repaints
@EminQasimov
EminQasimov / short arithmetic functions names
Last active April 22, 2019 15:35
short access to Math.functions
/* because me lazy */
Object.getOwnPropertyNames(Math).map(function(p) {
window[p] = Math[p];
});
// PI/3,
// cos(a);
// sin(a);
@EminQasimov
EminQasimov / currying
Created April 22, 2019 15:33
Currying
function curry( fn ) {
var arity = fn.length;
return (function resolver() {
var memory = Array.prototype.slice.call( arguments );
return function() {
var local = memory.slice(), next;
Array.prototype.push.apply( local, arguments );
next = local.length >= arity ? fn : resolver;
return next.apply( null, local );
};
@EminQasimov
EminQasimov / country names 2letters code array
Last active April 23, 2019 19:52
country names 2 letters code array
['AF','AX','AL','DZ','AS','AD','AO','AI','AQ','AG','AR','AM','AW','AU','AT','AZ','BS','BH','BD','BB','BY','BE','BZ','BJ','BM','BT','BO','BA','BW','BV','BR','IO','BN','BG','BF','BI','KH','CM','CA','CV','KY','CF','TD','CL','CN','CX','CC','CO','KM','CG','CD','CK','CR','CI','HR','CU','CY','CZ','DK','DJ','DM','DO','EC','EG','SV','GQ','ER','EE','ET','FK','FO','FJ','FI','FR','GF','PF','TF','GA','GM','GE','DE','GH','GI','GR','GL','GD','GP','GU','GT','GG','GN','GW','GY','HT','HM','VA','HN','HK','HU','IS','IN','ID','IR','IQ','IE','IM','IL','IT','JM','JP','JE','JO','KZ','KE','KI','KR','KW','KG','LA','LV','LB','LS','LR','LY','LI','LT','LU','MO','MK','MG','MW','MY','MV','ML','MT','MH','MQ','MR','MU','YT','MX','FM','MD','MC','MN','ME','MS','MA','MZ','MM','NA','NR','NP','NL','AN','NC','NZ','NI','NE','NG','NU','NF','MP','NO','OM','PK','PW','PS','PA','PG','PY','PE','PH','PN','PL','PT','PR','QA','RE','RO','RU','RW','BL','SH','KN','LC','MF','PM','VC','WS','SM','ST','SA','SN','RS','SC','SL','SG','SK','SI','SB','SO','ZA','GS','ES
@EminQasimov
EminQasimov / Spectrum background
Last active April 25, 2019 11:45
Spectrum background
overlay three gradients to make a background with nearly the full spectrum of colors that can be displayed on a monitor.
https://blog.logrocket.com/advanced-effects-with-css-background-blend-modes-4b750198522a
.spectrum-background {
background:
linear-gradient(red, transparent),
linear-gradient(to top left, lime, transparent),
linear-gradient(to top right, blue, transparent);
background-blend-mode: screen;
@EminQasimov
EminQasimov / hide input, video etc..
Last active May 16, 2019 13:29
hide dom elements with css
/*
* Hide only visually, but have it available for screenreaders: h5bp.com/v
no display:none, ---> disable tab focusing. not playing video
*/
.visuallyhidden {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
@EminQasimov
EminQasimov / css blob animation border-radius
Created May 1, 2019 17:06
css blob animation keyframe with border-radius
@keyframes border-transform{
0%,100% { border-radius: 63% 37% 54% 46% / 55% 48% 52% 45%; }
14% { border-radius: 40% 60% 54% 46% / 49% 60% 40% 51%; }
28% { border-radius: 54% 46% 38% 62% / 49% 70% 30% 51%; }
42% { border-radius: 61% 39% 55% 45% / 61% 38% 62% 39%; }
56% { border-radius: 61% 39% 67% 33% / 70% 50% 50% 30%; }
70% { border-radius: 50% 50% 34% 66% / 56% 68% 32% 44%; }
84% { border-radius: 46% 54% 50% 50% / 35% 61% 39% 65%; }
}
@EminQasimov
EminQasimov / concurrency with promises
Created May 3, 2019 13:44
concurrency with promises
const delay = second => () => new Promise((resolve, rejects) => {
setTimeout(() => {
resolve()
}, second * 1000);
})
// some tasks that take long time
let tasks = [
delay(0),
@EminQasimov
EminQasimov / html-escape.md
Created May 3, 2019 16:50 — forked from WebReflection/html-escape.md
How to escape and unescape from a language to another

update

I've created a little repository that simply exposes the final utility as npm module.

It's called html-escaper


there is basically one rule only: do not ever replace one char after another if you are transforming a string into another.

@EminQasimov
EminQasimov / setZeroTimeout
Created May 4, 2019 18:59
setTimeout in most browsers doesn't allow a delay less than about 10 milliseconds
// Only add setZeroTimeout to the window object, and hide everything
// else in a closure.
(function() {
var timeouts = [];
var messageName = "zero-timeout-message";
// Like setTimeout, but only takes a function argument. There's
// no time argument (always zero) and no arguments (you have to
// use a closure).
function setZeroTimeout(fn) {