- Сортировка пузырьком
- Сортировка выбором
- Сортировка вставками
- Развернуть односвязный список
- Обход дерева в глубину
- Обход дерева в ширину
- Найти все простые числа от 1 до N
- Бинарный поиск в отсортированном массиве
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
const path = require('path'); | |
const BabiliPlugin = require('babili-webpack-plugin'); | |
module.exports { | |
entry: { | |
'bundle.min': './src/index.js', | |
'sw': './src/sw.js' | |
}, | |
output: { | |
path: path.resolve(__dirname, 'dist'), |
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
const hasOwnProperty = Object.prototype.hasOwnProperty; | |
const toString = Object.prototype.toString; | |
/** | |
* Проверяет, что переданный объект является "плоским" (т.е. созданным с помощью "{}" | |
* или "new Object"). | |
* | |
* @param {Object} obj | |
* @returns {Boolean} | |
*/ |
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
const streets = [ | |
'Абельмановская улица', | |
'площадь Абельмановская Застава', | |
'Абрамцевская просека', | |
'Абрамцевская улица', | |
'Абрикосовский переулок', | |
'Авангардная улица', | |
'улица Авиаконструктора Микояна', | |
'улица Авиаконструктора Миля', | |
'улица Авиаконструктора Сухого', |
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'; | |
class Request { | |
constructor() { | |
this._history = []; | |
this._promiseChain = Promise.resolve(); | |
} | |
get(url, resolve, reject) { | |
this._promiseChain = this._promiseChain | |
.then(() => __fetch(url)) |
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
<!-- Tweak for Google Analytics to catch SPA navigation --> | |
<script> | |
var currentPage = window.location.href; | |
window.onload = function() { | |
setInterval(function() { | |
if (currentPage !== window.location.href) { | |
currentPage = window.location.href; | |
var newPage = window.location.pathname + window.location.hash | |
ga('set', 'page', newPage); | |
ga('send', 'pageview'); |
A simple asynchronous data store.
STATUS: This is a thought experiment, not a serious proposal. Would basic async storage like this be useful? With this plus some locking primitive, could you build Indexed DB?
Like Indexed DB:
- rich value types - store anything you can structured clone
- rich key types - Number, String, Date, Array (of other key types)
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
const files = [fetch('file1'), fetch('file2'), fetch('file3')]; | |
let chain = Promise.resolve(); | |
for (const file of files) { | |
chain = chain | |
.then(() => { | |
return file; | |
}) | |
.then(file => console.log(file)); |
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
const parseArgs = require('minimist'); | |
const io = require('socket.io')(); | |
const tf = require('@tensorflow/tfjs-node'); | |
const { model: modelDir = 'model', speed: maxSpeed = 30 } = parseArgs( | |
process.argv.slice(2) | |
); | |
tf.loadLayersModel(`file://${modelDir}/model.json`).then((model) => { | |
io.on('connection', async (socket) => { |
OlderNewer