Skip to content

Instantly share code, notes, and snippets.

View Beraliv's full-sized avatar
📺
Contributing to OSS 7-9am, 7-9pm UK time (respond within a week)

Alexey Berezin Beraliv

📺
Contributing to OSS 7-9am, 7-9pm UK time (respond within a week)
View GitHub Profile
@Beraliv
Beraliv / gist:63547289544bfec59d8ce7eeba189fb7
Created January 11, 2023 12:01 — forked from six8/gist:1732686
Javascript dependency graph resolution
// Dependency resolution, adapted from https://gist.github.com/1232505/f16308bc14966c8d003c2686b1c258ec41303c1f
function resolve(graph) {
var sorted = [], // sorted list of IDs ( returned value )
visited = {}; // hash: id of already visited node => true
// 2. topological sort
Object.keys(graph).forEach(function visit(name, ancestors) {
if (!Array.isArray(ancestors)) ancestors = [];
ancestors.push(name);
visited[name] = true;
@Beraliv
Beraliv / bbcuser.js
Last active July 21, 2020 17:14
BBC User API in html on bbc.co.uk
var USERINFO_URL = "";
var USERINFO_PREFIX = "www." || "www.";
function initUserCache(orbitUser) {
var availableAttr = [
'X-Country',
'X-Ip_is_advertise_combined',
'X-Ip_is_uk_combined'
];
var userCache = availableAttr.reduce(function(user, curr, i) {
@Beraliv
Beraliv / simplified-playback-source-fetcher.min.js
Last active May 4, 2020 17:19
Simplified minified and deobfuscated Joyn playback source fetcher
/*! @vod/playback-source-fetcher 0.0.72 17-04-2020 13:44:58 */
(function (modules) {
var installedModules = {};
function __webpack_require__(moduleId) {
if (installedModules[moduleId]) {
return installedModules[moduleId]["exports"];
}
var module = (installedModules[moduleId] = {
i: moduleId,
@Beraliv
Beraliv / recursive_to_iterative.ts
Last active January 29, 2020 15:23
Recursive to iterative algorithm change
export const decompose = (n: number) => {
const decomposeWithIndex = (rest: number, index: number, currentResult = []) => {
var repeat = true;
var saved = [];
while (repeat) {
repeat = false;
if (index < 0) {
@Beraliv
Beraliv / recursive_squares.ts
Created January 29, 2020 08:10
Recursive solution to a task
export class G964 {
public static decompose = (n: number) => {
const decomposeWithIndex = (rest: number, index: number, currentResult = []) => {
if (index < 0) {
return null;
}
if (index * index > rest) {
return decomposeWithIndex(rest, index - 1, currentResult);
}
@Beraliv
Beraliv / iterative_squares.ts
Created January 29, 2020 08:07
Iterative solution to a task
export class G964 {
public static decompose = (n: number) => {
const decomposeWithIndex = (rest: number, index: number, currentResult = []) => {
var repeat = true;
var saved = [];
while (repeat) {
repeat = false;
@Beraliv
Beraliv / async_event_example.json
Created January 7, 2020 19:28
Async example of events for Udemy
[
{
"mapve": "2.0",
"memve": "2.7.0",
"ualnm": "Chrome",
"ualve": "79.0.3945.88",
"ualeg": "Blink",
"udvnm": null,
"udvcg": "",
"udvmn": null,
@Beraliv
Beraliv / sync_event_example.json
Last active January 7, 2020 18:57
Sync example of events for Udemy
[
{
"mapve": "2.0",
"bdm": "litix.io",
"psqno": 26,
"xsqno": 26,
"pispa": false,
"pphti": 1339532,
"uti": 1578401570429,
"ake": "vfq2nsli1v76fglgdl9puq0cd",
@Beraliv
Beraliv / vendor-videojs.js
Created January 7, 2020 08:24
Udemy player bundle
(window.webpackJsonp = window.webpackJsonp || []).push([["vendor-videojs"], {
"./node_modules/video.js/dist/video.cjs.js": function(e, t, r) {
function n(e) {
return e && "object" == typeof e && "default"in e ? e.default : e
}
var i, o, a, s, p = n(r("./node_modules/global/window.js")), f = n(r("./node_modules/global/document.js")), d = n(r("./node_modules/tsml/tsml.js")), v = n(r("./node_modules/safe-json-parse/tuple.js")), y = n(r("./node_modules/xhr/index.js")), l = n(r("./node_modules/videojs-vtt.js/lib/browser-index.js")), m = "6.12.1", u = p.navigator && p.navigator.userAgent || "", c = /AppleWebKit\/([\d.]+)/i.exec(u), h = c ? parseFloat(c.pop()) : null, _ = /iPad/i.test(u), g = /iPhone/i.test(u) && !_, b = /iPod/i.test(u), T = g || _ || b, w = (i = u.match(/OS (\d+)_/i)) && i[1] ? i[1] : null, k = /Android/i.test(u), S = function() {
var e = u.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);
if (!e)
return null;
@Beraliv
Beraliv / tvip-script-app-store.js
Created December 21, 2019 23:59
BBC iPlayer initial redux state
window.__IPLAYER_REDUX_STATE__ = {
"translations": {
"page_title_version_ad": "Audio Described",
"page_title_version_sign": "Signed",
"related_episodes_this_episode_label": "This episode",
"related_episodes_title": "More episodes",
"related_episodes_view_all": "View all",
"msi_modal_title": "You need to sign in. It's quick & easy.",
"msi_modal_text": "And we'll keep you signed in.",
"msi_modal_why_sign_in": "Why sign in to the BBC?",