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 { EventEmitter } = require('events'); | |
| const em = new EventEmitter(); | |
| function eventListener(response) { | |
| console.log(`Response Status: ${response.status}`); | |
| } | |
| function middleware(response) { | |
| em.on('finish', eventListener.bind(null, response)); |
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
| function reducer(object, accumulator, current) { | |
| // check if the object contains a property that matches the current filter | |
| const hasOwnProperty = Object.prototype.hasOwnProperty.call(object, current); | |
| // add it to the accumulator if it has, by dynamically selecting the computed property | |
| return { | |
| ...accumulator, | |
| ...(hasOwnProperty && { [current]: object[current] }) | |
| }; | |
| } |
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 { Client } = require("@hapi/catbox"); | |
| const CatboxRedis = require("@hapi/catbox-redis"); | |
| const RMSClient = require("@bbc/rms-client"); | |
| const stats = { | |
| increment: (metric) => { | |
| console.log(`stats.increment("${metric}")`); | |
| }, | |
| timing: (metric, value) => { | |
| console.log(`stats.timing("${metric}", ${value})`); |
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 basicAuth = require('express-basic-auth') | |
| const app = express() | |
| app.use('/secret', basicAuth({ | |
| users: { 'sounds': 'supersecret' }, | |
| unauthorizedResponse: (req) => { | |
| return req.auth ? ('Credentials rejected') : 'No credentials provided' | |
| }, | |
| challenge: true, |
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
| /** | |
| * The scope of the first "one" variable is the region of the function a, included function b. | |
| * Its visibility though doesn't coincide, because the second variable called "one" within the function "b" | |
| * hides it. This doesn't mean that the scope is reduced. | |
| */ | |
| function a() { | |
| const one = 1; | |
| function b() { | |
| const one = -1; |
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 Validator = require('jsonschema').Validator; | |
| const v = new Validator(); | |
| // Address, to be embedded on Person | |
| const addressSchema = { | |
| id: '/SimpleAddress', | |
| type: 'object', | |
| properties: { | |
| lines: { | |
| type: 'array', |
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
| #include <iostream> | |
| #include <vector> | |
| #include <string> | |
| using namespace std; | |
| void vectorTest(); | |
| int main() { | |
| vectorTest(); |
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
| package prova; | |
| import java.io.BufferedReader; | |
| import java.io.FileInputStream; | |
| import java.io.FileNotFoundException; | |
| import java.io.IOException; | |
| import java.io.InputStreamReader; | |
| import java.util.HashMap; | |
| import java.util.HashSet; | |
| import java.util.Map; |
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
| #include <cstdlib> | |
| #include <iostream> | |
| #include <string.h> | |
| using namespace std; | |
| void readGroups(char** g1, char** g2, int& n, int& m) { | |
| cout << "Numero di parole: "; | |
| cin >> n; | |
| cout << "Numero di caratteri: "; | |
| cin >> m; |
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
| #include <iostream> | |
| #include <cstring> | |
| using namespace std; | |
| struct Arco { | |
| string nodo1; | |
| string nodo2; | |
| int peso; | |
| }; |