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
| def file(name, flag = False): | |
| f = open(name) | |
| if flag == 'w': | |
| return f | |
| return f.readlines() | |
| def readfile(filename): | |
| lines = [line for line in file(filename)] | |
| print(len(lines)) | |
| # First line is the column titles |
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
| export const cancelablePromise = (promise) => { | |
| let state = false | |
| const prom = (...param) => | |
| new Promise((resolve, reject) => { | |
| promise(...param) | |
| .then((res) => { | |
| if (!state) resolve(res) | |
| }) | |
| .catch((err) => { | |
| if (!state) reject(err) |
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
| class Perceptron { | |
| constructor(bias=1,learningRate=0.1,weights=[]) { | |
| this.bias = bias; | |
| this.learningRate = learningRate; | |
| this.weights = weights; | |
| this.trainingSet = []; | |
| } | |
| init(inputs,bias=this.bias) { | |
| // Initialize weights to 0 and adding bias weight |
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 path = require('path') | |
| const webpack = require('webpack') | |
| const merge = require('webpack-merge') | |
| const WebpackBabelExternalsPlugin = require('webpack-babel-external-helpers-2') | |
| const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin | |
| const UglifyJSPlugin = require('uglifyjs-webpack-plugin') | |
| const ExtractTextPlugin = require('extract-text-webpack-plugin') | |
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
| import React from 'react' | |
| import { render } from 'react-dom' | |
| import { routes } from './scheme-route' | |
| import { StaticRouter } from 'react-router-dom' | |
| render(( | |
| <StaticRouter> | |
| {routes} | |
| </StaticRouter> | |
| ), 0) |
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 eventEmitter() { | |
| const state = {} | |
| return { | |
| subscribe: (channel, fn) => { | |
| state[channel] = fn | |
| }, | |
| emit: (channel, ...param) => { | |
| if (state[channel]) { | |
| state[channel](...param) | |
| } |
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
| compose = (...fns) => | |
| fns.reduceRight((prevFn, nextFn) => | |
| (...args) => nextFn(prevFn(...args)), | |
| value => value | |
| ) | |
| composeWithState = (...fns) => (res) => fns.reduceRight((value, fn) => fn(value, res), res) | |
| const closest = (arr, g) => | |
| arr.reduce((prev, cur) => |
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
| /** | |
| * @param {object[]} data [{ name:'group', [elementName]:[] }, ...] | |
| * @param {number} columns 3 | |
| * @param {number} groupHeight высота между групапами, 1 эквивалентно высоте одного элемента группы | |
| * @param {string} elementName имя свойства элементов в группе | |
| * @returns {object[]} [{ column:1, data: [group, ...] }, ...] | |
| */ | |
| function sortGroupColumn(data, columns, groupHeight, elementName) { | |
| // в каком столбце какие данные (data); len - общее кол-во значений в группах | |
| const column = {} |
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 equalInterface(sample, eq) { | |
| const type = t => Object.prototype.toString.call(t).slice(8,-1).toLocaleLowerCase() | |
| debugger | |
| let isEqual = true | |
| if (type(sample) === 'object') { | |
| Object.keys(sample).forEach(key => { | |
| if (type(sample[key]) === 'object') { | |
| const intoIsEqual = equalInterface(sample[key], eq[key]) | |
| console.log(sample[key], eq[key], intoIsEqual) |
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
| /* eslint-disable func-names, no-underscore-dangle */ | |
| import EventBus from 'vertx3-eventbus-client' | |
| const delayObserver = (timeCount) => { | |
| const state = [] | |
| let stop = false | |
| return ({ | |
| emmit: () => { | |
| if (stop) return false |