Skip to content

Instantly share code, notes, and snippets.

View rafinskipg's full-sized avatar
🏠
Working from home

Venture rafinskipg

🏠
Working from home
  • web3
  • Worldwide
View GitHub Profile
function loop() {
const now = Date.now()
dt = (now - before) / 1000
// update(dt)
render()
before = now
window.requestAnimationFrame(loop)
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()
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);
import Network from '../network'
// Training data for a xor gate
const trainingData = [{
input : [0,0],
output: [0]
}, {
input : [0,1],
output: [1]
}, {
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 ) {
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) => {
class Calculator {
add = (a, b) => {
return a + b
}
}
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)
}
})
})
class Calculator {
add = () => {
return 4
}
}
describe('add method', () => {
it('should return 4 when receiving 2 and 2', () => {
expect(calculator.add(2, 2)).toEqual(4)
})
})