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 TextToSpeech { | |
| constructor({ volume = 1, rate = 1, pitch = 1, lang = "en" } = {}) { | |
| if (typeof window === 'undefined' || !"speechSynthesis" in window) { | |
| throw new Error("Text to speech is not supported in your browser."); | |
| } | |
| this.engine = new SpeechSynthesisUtterance(); | |
| this.setLanguage(lang) | |
| .setPitch(pitch) | |
| .setRate(rate) |
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
| /** Helper for printing validator reason */ | |
| const warn = msg => { | |
| console.warn('Invalid:', msg) | |
| return false | |
| } | |
| /** Validators */ | |
| const longEnough = (password, minLength = 12) => password.length >= minLength || warn(`Password should contain ${minLength} or more characters.`) | |
| const hasUpperCase = password => /[A-Z]+/.test(password) || warn('Password should have at least one uppercase letter.') | |
| const hasLowerCase = password => /[a-z]+/.test(password) || warn('Password should have at least one lowercase letter.') |
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
| // Solution | |
| type Formatter<T> = (a: T) => (b: T) => string | |
| const numberFormatter: Formatter<number> = decimals => euros => euros.toFixed(decimals).replace(/\./, ',') + ' €' | |
| const toCurrencyString = numberFormatter(2) | |
| // Tests | |
| const suites: [number, string][] = [ | |
| [-1, "-1,00 €"], | |
| [0, "0,00 €"], | |
| [1, "1,00 €"], |
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
| { | |
| "Conventional Commit": { | |
| "prefix": "cc", | |
| "body": [ | |
| "${1:type}(${2:scope}): ${3:title}", | |
| "", | |
| "${4:body}", | |
| "", | |
| "${5:footer}" | |
| ], |
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/env bash | |
| set -euo pipefail | |
| post_install() { | |
| # Checks whether user's shell configuration needs adjustment for Spaceship | |
| # This function does not do anything when user has already activated the | |
| # necessary configuration. | |
| echo "Checking shell configuration" |
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
| from __future__ import annotations | |
| from typing import Any, Callable, Union, Tuple | |
| from functools import reduce | |
| class Pipe(list): | |
| """Type declarations""" | |
| Predicate = Callable[[Any], bool] | |
| Mappable = Callable[[Any], Any] |
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
| <?php declare(strict_types = 1); | |
| function pipe(...$args) { | |
| return function ($arg) use ($args) { | |
| $reducer = function ($prev, $fn) { | |
| return $fn($prev); | |
| }; | |
| return array_reduce($args, $reducer, $arg); | |
| }; |
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 leet = char => { | |
| const charMap = { | |
| 'A': 4, | |
| 'E': 3, | |
| 'I': 1, | |
| 'S': 5, | |
| 'T': 7, | |
| } | |
| char = char.toString().toUpperCase() |
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
| def duplicate_count(text: str) -> int: | |
| """Write a function that will return the count of distinct case-insensitive | |
| alphabetic characters and numeric digits that occur more than once in the | |
| input string. | |
| The input string can be assumed to contain only alphabets | |
| (both uppercase and lowercase) and numeric digits. | |
| "abcde" -> 0 # no characters repeat more than once | |
| "aabbcde" -> 2 # 'a' and 'b' |
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
| { | |
| "sidebarBg": "#15232d", | |
| "sidebarText": "#dddddd", | |
| "sidebarUnreadText": "#9effff", | |
| "sidebarTextHoverBg": "#0d3a58", | |
| "sidebarTextActiveBorder": "#15232d", | |
| "sidebarTextActiveColor": "#ffffff", | |
| "sidebarHeaderBg": "#15232d", | |
| "sidebarHeaderTextColor": "#ffc600", | |
| "onlineIndicator": "#60e019", |