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 fill = function* (start = 0, end = 100, filter = (_) => true, mapper = (x) => x) { | |
| while (start < end) { | |
| if (filter(start)) | |
| yield start; | |
| mapper(start++); | |
| } | |
| }; | |
| const isEven = (num) => num % 2 === 0; | |
| const isOdd = (num) => num % 2 !== 0; | |
| const evens = [...fill(0, 100, isEven)]; |
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
| import React, { useEffect, useState } from "react"; | |
| import { Document, Page } from "react-pdf/dist/esm/entry.webpack"; | |
| import "./App.css"; | |
| let fnGetFileNameFromContentDispostionHeader = function (header: string = "") { | |
| let contentDispostion = header.split(";"); | |
| const fileNameToken = `filename*=UTF-8''`; | |
| let fileName = "downloaded.pdf"; | |
| for (let thisValue of contentDispostion) { | |
| if (thisValue.trim().indexOf(fileNameToken) === 0) { | |
| fileName = decodeURIComponent( |
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
| [ | |
| { | |
| "id": "0", | |
| "level": "2", | |
| "summary": "I dare you to Stand up for 2 turns", | |
| "time": "", | |
| "turns": "2", | |
| "type": "Dare" | |
| }, | |
| { |
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
| #!/usr/bin/python3 | |
| import json | |
| from urllib.request import urlopen | |
| import random | |
| def print_logo(): printline(""" | |
| _________ __ __________ __ | |
| /_ __/ _ \/ / / /_ __/ // / |
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
| /** | |
| * today: Get the current date | |
| */ | |
| exports.today = () => new Date(); | |
| // main.js | |
| const { today } = require("./date"); | |
| console.log(today()); // 2021-08-22T15:59:47.482Z |
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
| // Draft Service class | |
| const services = { | |
| fetchTodos: () => | |
| fetch("https://jsonplaceholder.typicode.com/todos/") | |
| .then((d) => d.json()) | |
| .then((list) => list.slice(0, 5)), // Show last 5 | |
| createTodo: (todo) => | |
| fetch("https://jsonplaceholder.typicode.com/todos/", { | |
| method: "POST", | |
| headers: { |
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 calculateInterest(p: number, t: number, r: number) { | |
| return (p * t * r) / 100; | |
| } | |
| console.log(calculateInterest(1000, 5, 5)); | |
| //250 |
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
| console.log("Welcome to How To Write Services Using JavaScript") | |
| const http = { | |
| cb: [], | |
| intercept(cb) { | |
| this.cb.push(cb); | |
| }, | |
| async get(url, options = {}) { | |
| return this.request(url, null, options) | |
| }, |
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
| class Car { | |
| String type; | |
| String model; | |
| String color; | |
| int speed; | |
| Car(String type, String model, String color) { | |
| this.type = type; | |
| this.model = model; |