This file contains 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
{ | |
"default": "Hello There!", | |
"GCM": "{\"notification\":{\"body\":\"Hello There!\",\"title\":\"Hello\"}}" | |
} |
This file contains 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 sum = (n, m) => n + m; | |
module.exports = { sum }; |
This file contains 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 call(value) { | |
const label = `Promise ${value}`; | |
console.time(label); | |
return new Promise((resolve) => { | |
setTimeout(() => { | |
console.timeEnd(label); | |
resolve(); | |
}, Math.floor(9 * Math.random() + 1) * 1000); | |
}); |
This file contains 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
// Usage: node converter.js <file path> | |
const { | |
promises: { readFile, writeFile }, | |
} = require("fs"); | |
const [, , filePath] = process.argv; | |
async function converter(path) { | |
return readFile(path) |
This file contains 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
require("reflect-metadata"); | |
const { | |
EntitySchema, | |
createConnection, | |
Table, | |
getConnection, | |
} = require("typeorm"); | |
const { randomUUID } = require("crypto"); | |
const Tag = new EntitySchema({ |
This file contains 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 fs = require("fs"); | |
const path = require("path"); | |
const axios = require("axios"); | |
const { pipeline } = require("stream/promises"); | |
const api = axios.create({ | |
baseURL: "https://pokeapi.co/api/v2/pokemon", | |
}); | |
const requestsInParallel = 3; | |
const limit = 10; |
This file contains 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
// node . [total-words] (e.g. node . 1000) | |
const firstAlphabetLetter = "a".charCodeAt(); | |
const alphabetRange = "z".charCodeAt() - firstAlphabetLetter; | |
const [,,totalWordsArg = 10000] = process.argv; | |
const generateRandomWord = (min, max) => { | |
const randomMaxChars = Math.floor(Math.random() * max); | |
let word = ""; | |
for (let i = 0; i <= min || i <= randomMaxChars; i++) { |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Radial Image Transparency</title> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<body> |
This file contains 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
// https://nodejs.org/api/process.html | |
process.on("uncaughtException", (err) => { | |
console.log("Of course we can!"); | |
console.log(`We catch a ${err.name}`); | |
}); | |
class CallError extends Error { | |
constructor(message) { | |
super(message); | |
console.log(message); |
This file contains 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
// https://nodejs.org/api/events.html | |
const EventEmmiter = require("events"); | |
const eventEmmiter = new EventEmmiter(); | |
const cooking = async ({ name }) => ({ name }); | |
const driveTo = async () => true; | |
const leave = async () => ({ delivered: true }); | |
async function cook({ pizzaOrder, user }) { | |
console.log(`Cooking a ${pizzaOrder.name}`); |