This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
import {Priv as Bempriv, Html as Bemhtml, XJT as xjt} from 'bem-server' | |
// menu.priv.js - es6priv | |
Bempriv.decl('menu', class menu extends Bempriv { | |
constructor() { | |
this.prop('items', this.getItems()); | |
} | |
getItems() { | |
// Выдуманная, но близкая к реальности логика маппинга данных |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TOC | |
// Intro | |
// # New BEM based blocks concept — BEMS | |
// # New 3-step templating concept | |
// Example | |
/** | |
# New BEM based blocks concept — BEMS | |
## Нейминг: Не мода, а поле |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
block('viewer-controls')( | |
def()(function() { | |
return applyNext({ | |
params: this.ctx.params | |
}); | |
}), | |
content()(function() { | |
return [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fuzzysearch (sub, str) { | |
var l1 = sub.length, l2 = str.length; | |
var i = 0, j = 0; | |
if (l1 > l2) return false; | |
for (; i < l1; ++i, ++j) { | |
if (sub[i] == str[j]) continue; | |
do { | |
++j; | |
if (j >= l2) return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => {'use strict'; | |
let table, tr, td, div, _el, cl; | |
document.body.innerHTML = 'loading...'; | |
$.get('http://yitv.herokuapp.com') | |
.then((data) => { | |
let rows = data.body.reduce((prev, item)=>{ | |
let title = div(item.title, 'title'); | |
let vals = div(item.add_values.join(', ')); | |
let row = td(item.value, 'value') + td(title + vals, null, { title: item.detail }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sumTree (tree) { | |
var sum = tree.value; | |
var root = tree; | |
var stack = [root.next]; | |
while(stack.length) { | |
sum = stack.pop().reduce((sum, root) => { | |
stack.push(root.next); | |
return sum + root.value; | |
}, sum); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var summary = hubs => _(hubs) | |
.groupBy('browserName') | |
.mapValues((data, bro) => | |
_(data).mapTuple(['active', 'total']).sumTuple().value() | |
) | |
.value(); | |
var hubs = [{ | |
host: 'hub01', | |
browserName: 'firefox', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cloneObj = obj => { | |
var newObj = {}; | |
Object.keys(obj).forEach((key) => { | |
newObj[key] = obj[key]; | |
}); | |
return newObj; | |
}; | |
var appendTrace = (trace, key, val) => { | |
var newTrace = cloneObj(trace); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// on input[type="file"]#change | |
var file = fileInput.files[0]; | |
(function(){ | |
var reader = new FileReader(); | |
reader.onload = function(e) { | |
var view = new DataView(e.target.result), | |
// 0xFFD8 — jpeg file signature (filesignatures.net/?search=jpg&mode=EXT) | |
isPngSignature = view.getUint32(0, false) === 0x89504E47 && view.getUint32(4, false) === 0x0D0A1A0A, | |
// 0x 89 50 4E 47 0D 0A 1A 0A — png signature (filesignatures.net/?search=png&mode=EXT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var workerFunction = function() { | |
self.onmessage = function(e) { | |
self.postMessage('msg from worker' + e.data); | |
self.close(); | |
}; | |
}; | |
var createWorker = fn => { | |
var workerFunctionBlob = new Blob(['('+fn.toString()+')()'], { type: "text/javascript" }); | |
var worker = new Worker(URL.createObjectURL(workerFunctionBlob)); |