Skip to content

Instantly share code, notes, and snippets.

View xelinel32's full-sized avatar
🌱
Believe you can, and you’re halfway there

Artem Sedliar xelinel32

🌱
Believe you can, and you’re halfway there
View GitHub Profile
@Sengulair
Sengulair / .eslintrc.cjs
Created February 2, 2024 00:38
Vue 3.4+ lint+prettier+ts+vite starter
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
sourceType: 'module',
@JamieMason
JamieMason / group-objects-by-property.md
Created September 14, 2018 07:38
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
@rproenca
rproenca / Clipboard.js
Last active January 21, 2025 03:16
Copy text to clipboard using Javascript. It works on Safari (iOS) and other browsers.
window.Clipboard = (function(window, document, navigator) {
var textArea,
copy;
function isOS() {
return navigator.userAgent.match(/ipad|iphone/i);
}
function createTextArea(text) {
textArea = document.createElement('textArea');
@DawidMyslak
DawidMyslak / vue.md
Last active April 22, 2024 12:49
Vue.js and Vuex - best practices for managing your state

Vue.js and Vuex - best practices for managing your state

Modifying state object

Example

If you have to extend an existing object with additional property, always prefer Vue.set() over Object.assign() (or spread operator).

Example below explains implications for different implementations.

@zmts
zmts / tokens.md
Last active April 21, 2025 07:44
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@paulirish
paulirish / what-forces-layout.md
Last active April 19, 2025 04:59
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@jessetan
jessetan / secondsToSMPTE.js
Last active April 6, 2023 21:11
Convert seconds to SMPTE timecode JSON object and string
/** Convert seconds to SMPTE timecode JSON object, example input is html video.currentTime */
function secondsToSMPTE(seconds, framerate) {
var f = Math.floor((seconds % 1) * framerate);
var s = Math.floor(seconds);
var m = Math.floor(s / 60);
var h = Math.floor(m / 60);
m = m % 60;
s = s % 60;
return {h: h, m: m, s: s, f: f};