(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| const express = require('express') | |
| const textBodyParser = require('body-parser').text() | |
| const isPrime = require('./is-prime') | |
| const app = express() | |
| app.post('/', textBodyParser, (req, res) => { | |
| res.send(req.body.split('\n').map((line) => line.split('').reverse().join('')).join('\n')) | |
| }) | |
| app.get('/', (req, res) => { |
| const express = require('express') | |
| const app = express() | |
| const storage = [] | |
| app.get('/factorial', (req, res) => { | |
| const rootUrl = (url) => req.protocol + '://' + req.get('host') + url; | |
| const id = storage.length + 1; | |
| setTimeout(() => { | |
| let sum = 1; |
| const express = require('express') | |
| const os = require('os') | |
| const app = express() | |
| const workerFarm = require('worker-farm') | |
| const worker = workerFarm(require.resolve('./worker.js')) | |
| app.get('/', (req, res) => { | |
| const max = Number(req.query.max) || 1000 | |
| worker(max, (err, primes) => { | |
| if (err) res.status(500).send(err) |
| (() => { | |
| const { spawn } = require('child_process'); | |
| const ls = spawn('ls', ['-lh', '/usr']); | |
| ls.stdout.on('data', (data) => { | |
| console.log(`stdout: ${data}`); | |
| }); | |
| ls.stderr.on('data', (data) => { | |
| console.log(`stderr: ${data}`); |
| const cluster = require('cluster') | |
| const os = require('os') | |
| const express = require('express') | |
| const isPrime = require('./is-prime') | |
| if (cluster.isMaster) { | |
| const cpuCount = os.cpus().length | |
| for (let i = 0; i < cpuCount; i++) { | |
| cluster.fork() | |
| } |
| const express = require('express') | |
| const isPrime = require('./is-prime') | |
| const app = express() | |
| app.get('/', (req, res) => { | |
| const primes = [] | |
| const max = Number(req.query.max) || 1000 | |
| for (let i = 1; i <= max; i++) { | |
| if (isPrime(i)) primes.push(i) | |
| } |
| # to be placed in ./bootsrc/sources of https://github.com/simple-lang/simple | |
| program_NAME := simple | |
| program_C_SRCS := $(wildcard *.c) | |
| program_CXX_SRCS := $(wildcard *.cpp) | |
| program_C_OBJS := ${program_C_SRCS:.c=.o} | |
| program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o} | |
| program_OBJS := $(program_C_OBJS) $(program_CXX_OBJS) | |
| program_INCLUDE_DIRS := | |
| program_LIBRARY_DIRS := |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| using System; | |
| using System.Collections.Generic; | |
| using System.Threading.Tasks; | |
| using System.Net; | |
| using System.Net.Http; | |
| using System.Net.Http.Headers; | |
| using System.Diagnostics; | |
| using Newtonsoft.Json; | |
| using System.Text; |