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
function loop() { | |
const now = Date.now() | |
dt = (now - before) / 1000 | |
// update(dt) | |
render() | |
before = now | |
window.requestAnimationFrame(loop) |
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 canvas = document.getElementById('canvas'); | |
const context = canvas.getContext('2d'); | |
const totalFigures = 50 | |
const figures = [] | |
function drawSquare(x, y, size, angleOfRotation) { | |
// Store the painting state in a stack | |
context.save() |
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 canvas = document.getElementById('canvas'); | |
const context = canvas.getContext('2d'); | |
function drawSquare(x, y, size, angleOfRotation) { | |
// Translate in the context the origin of coordinates | |
context.translate(x, y); | |
// Rotate the context | |
const radians = Utils.degreeToRadian(angleOfRotation) | |
context.rotate(radians); |
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
import Network from '../network' | |
// Training data for a xor gate | |
const trainingData = [{ | |
input : [0,0], | |
output: [0] | |
}, { | |
input : [0,1], | |
output: [1] | |
}, { |
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
import sigmoid from './sigmoid' | |
import Connection from './connection' | |
import Layer from './layer' | |
class Network { | |
constructor(numberOfLayers) { | |
// Create a network with a number of layers. For layers different than the input layer we add a random Bias to each neuron | |
this.layers = numberOfLayers.map((length, index) => { | |
const layer = new Layer(length) | |
if (index !== 0 ) { |
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 fs = require('fs') | |
const ffmpeg = require('fluent-ffmpeg') | |
const path = require('path') | |
const FRAMES_PER_SECOND = 30 | |
const framesFolder = path.resolve('myfolder', 'videos', 'frames') | |
function getAllFilesFromFolder(folderPath, extension) { | |
return new Promise((resolve, reject) => { |
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
class Calculator { | |
add = (a, b) => { | |
return a + b | |
} | |
} |
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
describe('add method', () => { | |
it('should return a SUM when receiving two different numbers', () => { | |
for (var i = 0; i < 100; i++) { | |
const valueA = Math.round(Math.random() * 100) | |
const valueB = Math.round(Math.random() * 100) | |
const sum = valueA + valueB | |
expect(calculator.add(valueA, valueB)).toEqual(sum) | |
} | |
}) | |
}) |
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
class Calculator { | |
add = () => { | |
return 4 | |
} | |
} |
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
describe('add method', () => { | |
it('should return 4 when receiving 2 and 2', () => { | |
expect(calculator.add(2, 2)).toEqual(4) | |
}) | |
}) |