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 readline = require('readline'); | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
function generateRandomNumber(min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} |
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
function calculateBMI(weight, height) { | |
// Convert height from centimeters to meters | |
var heightInMeters = height / 100; | |
// Calculate BMI using the formula | |
var bmi = weight / (heightInMeters * heightInMeters); | |
// Round the BMI to two decimal places | |
return bmi.toFixed(2); | |
} |
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 cachedApiCall = (time) => { | |
const cache = {}; | |
return async (url, config = {}) => { | |
const key = `${url}${JSON.stringify(config)}`; | |
const entry = cache[key]; | |
if(!entry || Date.now() > entry.expiry){ | |
try{ |
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
import fetch from 'node-fetch'; | |
async function fetchFileStructure() { | |
return await fetch('https://api.jsonbin.io/v3/b/64cef151b89b1e2299cc09a2'); | |
} | |
async function useAndFetchFileStructure() { | |
try { | |
const response = await fetchFileStructure(); | |
const fileStructure = await response.json(); |
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
@Injectable({ providedIn: 'root' }) | |
export class OfflineService { | |
constructor(private toast: HotToastService) { | |
fromEvent(window, 'offline').pipe( | |
tap(() => | |
this.toast.warning('There is no internet connection', { | |
duration: 10_000, | |
}) | |
) | |
).subscribe() |
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
type SearchScopes = 'All Data' | 'Current Project' | 'My Projects'; | |
type Page = 'PL' | 'Search'; | |
type Search = `${SearchScopes}-${Page}`; | |
var a: Search = 'All Data-PL'; // Possible combinations = 6 |
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
console.log('Add test'); |