Skip to content

Instantly share code, notes, and snippets.

@cevek
cevek / code.js
Last active September 2, 2022 11:31
youtube storyboards
(function showStoryboard() {
var template = ytplayer.config.args.raw_player_response.storyboards.playerStoryboardSpecRenderer.spec;
function getStoryboardImages(template) {
var [url, _, _, layer] = template.split('|');
var [w, h, count, cols, rows, _, _, sig] = layer.split('#');
var countPerImage = cols * rows;
var imgCount = Math.ceil(count / countPerImage);
return Array(imgCount)
.fill(0)
search
abort
blur
change
click
close
contextmenu
dblclick
drag
dragend
@cevek
cevek / fast-switch.js
Created October 1, 2020 17:18
Fast binary switch
function id8(p) {
if (p > 3) {
if (p > 5) {
if (p === 6) {
return 6;
} else {
return 7;
}
} else {
const offset = new Date().getTimezoneOffset();
function getDigit(s, p) {
return s.charCodeAt(p) - 48;
}
function parseISOString(d) {
return new Date(
getDigit(d, 0) * 1000 + getDigit(d, 1) * 100 + getDigit(d, 2) * 10 + getDigit(d, 3),
getDigit(d, 5) * 10 + getDigit(d, 6) - 1,
getDigit(d, 8) * 10 + getDigit(d, 9),
getDigit(d, 11) * 10 + getDigit(d, 12),
function prepare(n) {
const arr = [];
for (let i = 0; i < n; i++) {
arr[i] = {a: i % 2 === 0 ? -i : i, b: {h: {x: i}, c: {i: i, d: {e: {e: {u: {x: i}}}}}}};
}
shuffleArray(arr);
return arr;
}
function shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {
import * as React from 'react';
import * as ReactDom from 'react-dom';
type ZoneContext = {name: string; params?: {}; parent: ZoneContext | null; children: ZoneContext[]};
const Context = React.createContext<ZoneContext | null>(null);
function useMetrika(someData?: {}) {
const context = React.useContext(Context);
const parents: ZoneContext[] = [];
if (context !== null) {
let ctx = context;
@cevek
cevek / nouns
Created August 22, 2019 18:34
programing words
specification
interpretation
initialization
implementation
persistence
orientation
inheritance
environment
compilation
registration
import * as ts from 'typescript';
const watchCompilerHost = ts.createWatchCompilerHost(
['index.ts'],
{strict: true, target: ts.ScriptTarget.ESNext},
ts.sys,
);
const originalCreateProgram = watchCompilerHost.createProgram;
watchCompilerHost.watchFile = (path, callback) => {
// console.log('watchFile', path);
return {
@cevek
cevek / index.html
Last active October 25, 2018 17:29
set vs array performance
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
https://cs.chromium.org/chromium/src/v8/src/runtime/runtime.h?l=20&rcl=05720af2b09a18be5c41bbf224a58f3f0618f6be