Skip to content

Instantly share code, notes, and snippets.

View JiLiZART's full-sized avatar
💭
I may be slow to respond.

Nikolay Kost JiLiZART

💭
I may be slow to respond.
View GitHub Profile
@JiLiZART
JiLiZART / page.js
Created July 11, 2016 15:58
bem ym page modal
/**
* @module Page
*/
modules.define(
'page',
['i-bem__dom', 'BEMHTML', 'jquery' 'modal'],
function (provide, BEMDOM, BEMHTML, $, Modal) {
/**
* @exports
/**
* @module input_type_tel
*/
modules.define(
'input',
['i-bem__dom', 'jquery'],
function (provide, BEMDOM, jQuery, Input) {
/* borschik:include:../../libs/intl-tel-input/build/js/intlTelInput.js */
var loading = {},
loaded = {},
head = document.getElementsByTagName('head')[0],
runCallbacks = function(path, type) {
var cbs = loading[path], cb, i = 0;
delete loading[path];
while(cb = cbs[i++]) {
cb[type] && cb[type]();
}
},

@kangax's ES6 quiz, explained

@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).

Here we go with the explanations:

Question 1:
(function(x, f = () => x) {
@JiLiZART
JiLiZART / viewport-meta-in-20-best-responsive-designs.md
Created July 17, 2012 22:22 — forked from andreasbovens/viewport-meta-in-20-best-responsive-designs.md
Viewport meta tags used by the 20 sites that are listed in Social Driver's "20 Best Responsive Web Design Examples of 2012"

Intro

http://socialdriver.com/2012/07/20-best-responsive-websites/ lists 20 sites that are supposedly best-in-class when it comes to responsive design techniques. I had a look at the viewport meta tags used in these sites.

Findings

  • All sites use width=device-width, with in most cases an additional initial-scale=1. This is good practice.

However:

  • 8 sites turn off pinch-zooming by setting maximum-scale to 1, or using user-scalable=no. While there are some corner use cases for this, it does not make sense to do this on text-heavy sites as it impairs accessibility.
  • 3 sites use semi-colons as delimiters between viewport values. While this works in newer mobile browsers, it's not officially supported, and breaks in older mobile browser versions.
  • 1 site has 2 viewport meta tags (with different values) in the source...
var loading = {},
loaded = {},
head = document.getElementsByTagName('head')[0],
runCallbacks = function (path, type) {
var cbs = loading[path], cb, i = 0;
delete loading[path];
while (cb = cbs[i++]) {
cb[type] && cb[type]();
}
},
enum Event {
enum app: String {
case install = "app install"
case launch = "app launch"
}
enum list: String {
case created = "list created"
case deleted = "list deleted"
case refreshed = "list refreshed"
const If = (cond) => (truly) => (falsy) => [truly, falsy][!cond + 0]()
const result = If(false)(() => 'true')(() => 'false')
@JiLiZART
JiLiZART / function_invocation.js
Created June 18, 2017 20:17 — forked from myshov/function_invocation.js
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);
@JiLiZART
JiLiZART / isStringBalanced.js
Created August 7, 2017 21:12
Проверка валидности скобок ( и [
const isB = (str) => {
const strArr = str.split('');
const stack = [];
for (let char of strArr) {
if (char.startsWith('[') || char.startsWith('(')) {
stack.push(char);
} else {
// Первый символ строки не открывающаяся скобка, значит уже не верно