This file contains hidden or 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
const object = {a: 1, b: 2}; | |
Object.defineProperty(Object.prototype, Symbol.iterator, { | |
enumirable: false | |
, configurable: true | |
, get: () => function * () { | |
for (const key of Object.keys(this)) | |
yield [key, this[key]]; | |
} | |
}); |
This file contains hidden or 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
let array = [1, 'b', 3, 'f', 'f', 'd', 'a', 9, 'b', 8, 'd', 4, 9, 'a', 5, 10, 3, 'c', 8, 7, 7, 6, 1, 'g', 'a', 'g', 4, 'e', 9, 8, 6, 5, 5, 2, 'c', 'd', 'e', 1, 6, 4, 2, 'b', 3, 10, 'e', 'f', 2, 'c', 10, 'g', 7]; | |
array = array.filter((e, i, l) => i == l.lastIndexOf(e)); | |
console.log(array); // => [ 'a', 9, 8, 5, 'd', 1, 6, 4, 'b', 3, 'e', 'f', 2, 'c', 10, 'g', 7 ] |
This file contains hidden or 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 Watch (obj, scheme, handler, pathOriginal = [], _obj = {}) { | |
scheme.forEach(fieldName => { | |
const path = pathOriginal.map(e => e); | |
if (typeof fieldName === 'string') { | |
path.push(fieldName); | |
if (['string', 'number', 'boolean'].indexOf(typeof obj[fieldName]) !== -1 || obj[fieldName] === null) { | |
_obj[fieldName] = obj[fieldName]; | |
delete obj[fieldName]; | |
Object.defineProperty(obj, fieldName, { | |
enumerable: true |
This file contains hidden or 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 res = ` | |
1111110 | |
1111100 | |
1111111 | |
1111111 | |
1111111 | |
0111111 | |
0111111 |
This file contains hidden or 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 isIntersection (x1, y1, x2, y2, x3, y3, x4, y4) { | |
var angles = [ | |
getAngleOf(x2, y2, x1, y1, x3, y3) + getAngleOf(x2, y2, x1, y1, x4, y4), | |
getAngleOf(x4, y4, x3, y3, x1, y1) + getAngleOf(x4, y4, x3, y3, x2, y2), | |
getAngleOf(x1, y1, x2, y2, x3, y3) + getAngleOf(x1, y1, x2, y2, x4, y4), | |
getAngleOf(x3, y3, x4, y4, x2, y2) + getAngleOf(x3, y3, x4, y4, x1, y1) | |
]; | |
var sum = angles[0] + angles[1] + angles[2] + angles[3]; |
This file contains hidden or 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
// Удаление шапки в которой написн вариант. | |
$('div.header').remove(); | |
// Удаление номеров каждого задания. | |
var elements = $('.nobreak.pbody').find('span'); | |
for (var i = 0; i < elements.length; i++) { | |
var element = $(elements[i]), | |
text = element.text(), | |
index = text.indexOf('.'), | |
text = '№ ' + text.substr(0, index) + ')'; |
This file contains hidden or 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
sudo apt-get install thunderbird apache2 mysql-server php5-mysql php5 libapache2-mod-php5 php5-mcrypt git gitk npm vim htop ssh traceroute vlc |
This file contains hidden or 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 sum (a, b) { | |
var c = [], buff = false; | |
for (var i = a.length - 1; i >= 0; i--) | |
if ((a[i] && b[i]) || (!a[i] && !b[i])) { | |
c.unshift(buff); | |
buff = a[i]; | |
} else c.unshift(!buff); | |
if (buff) c.unshift(true); |
This file contains hidden or 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 insertSort (array) { | |
for (var i = 1; i < array.length; i++) { | |
var key = array[i], j = i - 1; | |
while (j > -1 && array[j] > key) | |
array[j + 1] = array[j--]; | |
array[j + 1] = key; | |
} | |
This file contains hidden or 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 setIntervalControlling (callback, time) { | |
var startMoment = (new Date).getTime(), | |
number = 0, timeOfLoop = 0, difference = 0, | |
realTime = time, minStep = Math.pow(2, -4); | |
var loop; | |
__restart(); | |
return { stop: function () { clearInterval(loop); } }; |