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 request = require('superagent') | |
| const fs = require('fs') | |
| const path = require('path') | |
| const lessonsDir = path.resolve(__dirname, 'lessons') | |
| const getLink = (season, episode) => { | |
| episode = String(episode).padStart(2, '0') | |
| return `https://radiodownloaddw-a.akamaihd.net/Events/dwelle/deutschkurse/deutschwarumnicht/serie${season}/eng/DWN_Englisch_Serie${season}_Lektion${episode}_dwdownload.mp3` | |
| } |
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 { Writable } = require('stream') | |
| const fs = require('fs') | |
| const split = require('split') | |
| let counter = 0 | |
| const linecounter = new Writable({ | |
| write(chunk, encoding, callback) { | |
| counter = counter + 1 | |
| callback() |
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 log = require('debug')('app') | |
| const request = require('superagent') | |
| const H = require('highland') | |
| function batchCreate(bodies) { | |
| const calls = H(bodies) | |
| .map(body => { | |
| log(`start ${body.name}`) | |
| return H(request | |
| .post('localhost:3000/people') |
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 debug = require('debug')('app') | |
| const express = require('express') | |
| const app = express() | |
| const port = 3000 | |
| app.use(express.json()) | |
| app.post('/people', (req, res) => { | |
| debug('call') | |
| setTimeout( |
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 assert = require('assert') | |
| var solution = function() { | |
| var result = Array.prototype.reduce.call( | |
| arguments, | |
| function(acc, next) { | |
| var woDuplicates = next.filter(function(x) { | |
| var timestamp = x.lastModified.getTime() | |
| if(x.lastModified.getTime() in acc.dates) { | |
| return false |
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 request = require('superagent') | |
| const express = require('express') | |
| const H = require('highland') | |
| const app = express(); | |
| const delay = (ms) => { | |
| return new Promise((resolve) => { | |
| setTimeout( | |
| resolve, |
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 express = require('express') | |
| const EventEmitter = require('events') | |
| class MyEmitter extends EventEmitter { | |
| timer() { | |
| setTimeout( | |
| () => { | |
| this.emit('tick') | |
| }, | |
| 200 |
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 request = require('superagent') | |
| const address = 'http://localhost:3000' | |
| async function main() { | |
| for (let i=0; i < 1000; i++) { | |
| let resp = await request.get(address + '/') | |
| console.log(resp.text) | |
| } | |
| } |
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
| git checkout -b <branch-name> # task-4 is a bad name, filters is a good name | |
| git fetch origin master | |
| git reset --hard FETCH_HEAD |
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
| async function grab(offset = 0, rows = 1000) { | |
| while(true) { | |
| const items = await getAPI(offset, rows) | |
| if (_.isEmpty(items)) { | |
| break | |
| } | |
| await insertDB(items) | |
| offset = offset + rows | |
| } | |
| } |