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
| this.evaluate = function() { | |
| var maxFitness = 0 | |
| for(var i = 0; i < this.populationSize; i++) { | |
| this.sticks[i].calculateFitness() // the distance from the target relative to current pos | |
| if (this.sticks[i].fitness > maxFitness) { | |
| maxFitness = this.sticks[i].fitness | |
| } | |
| } | |
| for(var i = 0; i < this.populationSize; i++) { |
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
| this.selection = function() { | |
| var newSticks = []; | |
| for (var i = 0; i < this.sticks.length; i++) { | |
| var parentA = random(this.pool).dna; | |
| var parentB = random(this.pool).dna; | |
| var child = parentA.crossover(parentB); | |
| //child.mutation(); |
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
| var population | |
| var lifespan = 200 | |
| var visualLifespan | |
| var count = 0 | |
| var target | |
| function setup() { | |
| createCanvas(400, 300) | |
| population = new Population() |
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 Vue from 'vue' | |
| import Router from 'vue-router' | |
| import Homepage from '@/components/Homepage' | |
| Vue.use(Router) | |
| export default new Router({ | |
| routes: [ | |
| { | |
| path: '/', |
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
| // TO INSTALL: npm init bootstrap-vue --save | |
| import Vue from 'vue' | |
| import App from './App' | |
| import router from './router' | |
| import BootstrapVue from 'bootstrap-vue' | |
| import 'bootstrap/dist/css/bootstrap.css' | |
| import 'bootstrap-vue/dist/bootstrap-vue.css' | |
| Vue.use(BootstrapVue) |
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
| <template> | |
| <div> | |
| <div> | |
| <h1 style="margin-top: 5%; margin-bottom: 3%">News.</h1> | |
| <div class="row"> | |
| <div v-for="article in articles" class="col-md-3" style="margin-right: 5%; margin-bottom: 5%"> | |
| <b-card :title="article.title" | |
| :img-src="article.urlToImage" | |
| img-alt="Image" | |
| img-top |
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
| open: function(filePath) { | |
| return new Promise( | |
| function(resolve, reject) { | |
| const zip = new StreamZip({ | |
| file: filePath, | |
| storeEntries: true | |
| }) | |
| zip.on('ready', () => { | |
| var chunks = [] |
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
| extract: function(filePath) { | |
| return new Promise( | |
| function(resolve, reject) { | |
| module.exports.open(filePath).then(function (res, err) { | |
| if (err) { | |
| reject(err) | |
| } | |
| var body = '' | |
| var components = res.toString().split('<w:t') |
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
| var docx = require('./docx') // my custom file containing the other two functions | |
| docx.extract('path\\to\\my\\file.docx').then(function(res, err) { | |
| if (err) { | |
| console.log(err) | |
| } | |
| console.log(res) | |
| }) |
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 puppeteer = require('puppeteer'); | |
| const PDFDocument = require('pdfkit'); | |
| const fs = require('fs'); | |
| (async () => { | |
| const browser = await puppeteer.launch() | |
| const page = await browser.newPage() | |
| await page.goto('http://localhost:8080') | |
| // await page.screenshot({path: 'screenshots/example.png'}) |