View synaptic-shape-training.js
const Layer = require('synaptic').Layer;
const Network = require('synaptic').Network;
const Trainer = require('synaptic').Trainer;
const inputLayer = new Layer(15);
const hiddenLayer = new Layer(40);
const outputLayer = new Layer(4);
inputLayer.project(hiddenLayer);
hiddenLayer.project(outputLayer);
View pre-commit
#!/bin/bash
# Check for .only() in this path
FOLDER="./webapp/src/js"
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
View node-multiple-calls-render.js
const express = require('express')
const app = express()
const path = require('path')
const fetch = require('node-fetch')
const PORT = process.env.PORT || 3000
app.get('/api/user', (req, res) => {
res.json({ name: 'Richard' });
});
View Enhance.js
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
View advent-day1.js
const fs = require('fs');
const file = fs.readFileSync('./1.txt').toString('utf8');
let level = 0;
let findWay = (char) => {
if (char === '(') return 1;
else if (char === ')') return -1;
}
View TemplateStore.js
// Mock our global environment using JSDOM
require('../dom-mock')('<html><body></body></html>');
let jsdom = require('mocha-jsdom');
import {
React,
sinon,
assert,
expect,
View webpack.js
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var folders = {
APP: path.resolve(__dirname, '../app'),
BUILD: path.resolve(__dirname, '../build'),
BOWER: path.resolve(__dirname, '../bower_components'),
NPM: path.resolve(__dirname, '../node_modules')
};
View sequentialPromise.js
// Kinda pseudo code
// This script will download and resize each image to half
// Because the images can be RRREAAALLY big
// the download and resize is done sequentially (in my case, inside a child_process)
// to ensure that memory is released after each image.
// We dont know how many images there are
let images = [
'https://flickr.com/photo/1',
'https://flickr.com/photo/2'
View external-requests-time.js
/**
* From Google Developers; Collect all third party requests using the Performance API.
* Source: https://developers.google.com/web/updates/2015/07/measuring-performance-in-a-service-worker
*
*/
var getThirdPartyRequests = function() {
var thirdPartyRequests = [];
var requests = window.performance.getEntriesByType("resource");
var currentHost = window.location.host