Skip to content

Instantly share code, notes, and snippets.

View arturparkhisenko's full-sized avatar
:octocat:
www. www always changes

Artur Parkhisenko arturparkhisenko

:octocat:
www. www always changes
View GitHub Profile
@arturparkhisenko
arturparkhisenko / css-cascade.md
Last active January 12, 2024 14:26
css cascade

css3-cascade spec url, reset from inh: all:initial

Here is how the sources of CSS property values are distributed by priority today (the higher the priority):

  1. Styles set by transitions (CSS Transitions)
  2. Browser styles with !important
  3. Custom styles with !important
  4. Styles with !important from the style attribute
  5. Regular styles with !important
  6. Styles set by animations (CSS Keyframe Animations)
  7. Styles without !important from the style attribute
@arturparkhisenko
arturparkhisenko / supportsNativeHls.js
Created March 29, 2023 15:02
Whether the browser has built-in HLS support.
// From https://github.com/videojs/http-streaming/blob/d258fae646a3a4a6dc2ba26c729710dd8f39876a/src/videojs-http-streaming.js#L430-L464
/**
* Whether the browser has built-in HLS support.
*/
window._supportsNativeHls = (function() {
if (!document || !document.createElement) {
return false;
}
const video = document.createElement('video');
@arturparkhisenko
arturparkhisenko / detect-chromecast.js
Created February 28, 2022 14:51 — forked from lfalke/detect-chromecast.js
Detect Chromecast Model / Generation in Javascript
/**
* We use this workaround to detect the Chromecast device generation.
* Unfortunately the Cast Application Framework (CAF) does not have an API for that.
*
* cc-1: Chromecast 1st Gen.
* cc-2: Chromecast 2nd Gen.
* cc-3: Chromecast 3rd Gen.
* cc-ultra: Chromecast Ultra
* cc-builtin: Android TV with Chromecast built-in
*/
@arturparkhisenko
arturparkhisenko / esm-package.md
Created October 26, 2021 11:06 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@arturparkhisenko
arturparkhisenko / mediaevents-listener.js
Last active February 24, 2021 16:58
mediaevents listener
// https://html.spec.whatwg.org/multipage/media.html#mediaevents
const events = [
'loadstart',
'progress',
'suspend',
'abort',
'error',
'emptied',
'stalled',
'loadedmetadata',

Code patterns:

  • Middleware
  • Routers
  • Single entry point...

OOP patterns:

  • Facade, Singletone
  • Mixin, Closure
  • Factory, Decorator
  • Class, Object
<input readonly onfocus="this.removeAttribute('readonly')">
@arturparkhisenko
arturparkhisenko / js-fun.js
Last active January 11, 2021 16:47
js fun
// https://twitter.com/MylesBorins/status/929414418680643585?s=09
const context = new window.AudioContext();
for (let i = 0; i < 10; i++) {
let osc = context.createOscillator();
osc.type = 'square';
osc.frequency.value = 40 + i * 0.1111;
osc.connect(context.destination);
osc.start();
}
// second part
@arturparkhisenko
arturparkhisenko / fe-vs-be.md
Created October 28, 2020 16:17 — forked from WebReflection/fe-vs-be.md
Front End vs Back End in a nutshell.

FE vs BE

TL;DR enough of this kind of nonsense


I've been in the field for ~20 years and started as BE developer, and this is a reference for people thinking that because they are on the BE side, they're somehow entitled to:

  • earn more money
  • feel superior about FE developers
  • joke about JavaScript or minimize the FE effort in any way
@arturparkhisenko
arturparkhisenko / ds.csv
Created May 26, 2020 23:14 — forked from masrab/ds.csv
Visual data structure selector
Name Indexing (Average) Search (Average) Insertion (Average) Deletion (Worst) Indexing (Worst) Search (Worst) Insertion (Worst) Deletion (Worst) Space
Basic Array O(1) O(n) Undefined Undefined O(1) O(n) Undefined Undefined O(n)
Dynamic Array O(1) O(n) O(n) O(n) O(1) O(n) O(n) O(n) O(n)
Singly-Linked List O(n) O(n) O(1) O(1) O(n) O(n) O(1) O(1) O(n)
Doubly-Linked List O(n) O(n) O(1) O(1) O(n) O(n) O(1) O(1) O(n)
Skip List O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(n) O(n) O(n) O(n) O(n log(n))
Hash Table Undefined O(1) O(1) O(1) Undefined O(n) O(n) O(n) O(n)
Binary Search Tree O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(n) O(n) O(n) O(n) O(n)
Cartresian Tree Undefined O(log(n)) O(log(n)) O(log(n)) Undefined O(n) O(n) O(n) O(n)
B-Tree O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(n)