Skip to content

Instantly share code, notes, and snippets.

function SMA(list, interval) {
const result = [];
for (let i = 0; i <= list.length - interval; i++) {
let sum = 0;
for (let j = i; j < i + interval; j++) {
sum += list[j];
}
@tenorok
tenorok / yandex-video-tv.md
Last active April 15, 2018 16:04
Yandex.Video for TV

I started this project alone and later one of my colleague joined me. Together we created frontend of application for Samsung TV store and version for a TV browser.

Application installed from store represents from themselves a thin client with iframe to Yandex.Video. In the browser version user can pick one of two modes: regular (pressing an arrow keys leads to moving a mouse cursor) and application (arrow keys works as in the application) – it was a big challenge.

TVs hardware is actually very weak therefore it was so important point to make a rapid and responsive interface. I had a new ambitious goal: create fast interface which should be controled by arrow buttons. I've never do such task before. It was interesting to invent focus controller which works self-based on marked tags. There are two entities types: elements and areas. Areas serves for join elements to the group. The controller finds nearest element which included in a

@tenorok
tenorok / yandex-suggest.md
Last active February 17, 2018 22:32
Yandex.Search: Suggest

Yandex.Search: Suggest

You can open Yandex.Search and set focus to the search field for seeing suggests.

I was first and single developer and my goal was had to do independent frontend library which will be using in the different services of Yandex. I used traditional technology stack for Yandex at that time: i-bem with jQuery, BEMHTML and pure CSS.

With manager we invented and tried many different experements with interface and format of data. Of course, all actions with suggest elements are saving and sending for analytics. We made versions for three platforms.

// @readme https://github.com/tenorok/bemer#%D0%9C%D0%B5%D1%82%D0%BE%D0%B4-modules
// # Module Selector
// @jsdoc http://tenorok.github.io/bemer/jsdoc/module-Selector-Selector.html
var Selector = bemer.modules('Selector');
new Selector('button')
.mod('bold', true)
.toString(); // → "button_bold"
@tenorok
tenorok / extends.js
Created November 16, 2013 14:02
JavaScript: Extends
/* Base class */
function Shape() {
this.area = function() { throw 'Abstract method'; };
}
/* Extends Shape */
function Rectangle(width, height) {
var parent = new Shape();
@tenorok
tenorok / privileged.js
Created November 15, 2013 13:51
JavaScript: Private properties
/* Constructor */
function Klass(text, separator) {
this.text = text;
this.separator = separator;
/* Private properties */
var _privateField = 'World';
var _privateMethod = function() {
return this.separator + _privateField + Klass.staticMethod() + _privateStaticMethod();
@tenorok
tenorok / private.js
Last active December 28, 2015 09:39
JavaScript: Private properties
/* Constructor */
function Klass(text, separator) {
this.text = text;
this.separator = separator;
this.__bind(); // Set context to private methods
}
Klass.prototype = (function() {
@tenorok
tenorok / gist:6048749
Last active December 20, 2015 01:19
Commands to install php extensions needed to work tenframe.

Blitz

curl -O http://alexeyrybak.com/blitz/blitz-0.8.6.tar.gz
tar zxf blitz-0.8.6.tar.gz
cd blitz-0.8.6 && phpize && ./configure && sudo make install

Runkit

git clone https://github.com/zenovich/runkit.git