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
cache = {} | |
def fizz_buzz(n: int, factor_1: int = 3, factor_2: int = 5) -> None: | |
""" | |
Given an integer n, for a list of integers 1-n, the task is to print, | |
"FizzBuzz" if i is divisible by `factor_1` and `factor_2`, | |
"Fizz" if i is divisible by `factor_1`, |
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 areArraysEqual(a, b) { | |
if (!Array.isArray(a) || !Array.isArray(b)) { throw new Error("At least one argument is not an Array."); } | |
if (a === b) { return true; } | |
if (a.length !== b.length) { return false; } | |
for (let i = 0; i < a.length; i++) { | |
if (a[i] !== b[i]) { | |
return false; |
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 hours = Math.floor(duration / 3600); | |
const minutes = String(Math.floor(duration % 3600 / 60)).padStart(2, "0"); | |
const seconds = String(duration % 60).padStart(2, "0"); | |
return `${hours}:${minutes}:${seconds}`; |
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 object = getDependentObject({ | |
name: "john", | |
age: 39, | |
yearsTil40() { return 40 - this.age; } | |
}); | |
console.log(object.yearsTil40); // 40 - 39 = 1 | |
object.age = 30 |
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 math | |
from typing import Iterable | |
def slice_generator(iterable: Iterable, *, start_index: int = 0, end_index: int = math.inf): | |
""" | |
Iterate over `iterable` yielding only indices | |
between `start_index` and `end_index` inclusive and exclusive, respectively. | |
:param iterable: Any iterable |
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
class EnvironmentConfig: | |
def __init__(self, environment_variables_specs: Dict[str, EnvironmentVariable]): | |
self._environment_variables_specs = environment_variables_specs | |
self.PORT = None # The naming convention is different because this value is automatically injected by Code Engine | |
self.SDG_DB_USERNAME = None | |
self.SDG_DB_PASSWORD = None | |
self.SDG_DB_HOSTNAME = None | |
self.SDG_DB_SCHEMA_NAME = None | |
self.SDG_DB_TABLE_NAME = None |
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
background-color: white; | |
background-image: url("ruler-vertical.png"); /* Use any image for which being able to see the top and bottom would be easy. */ | |
background-size: contain; | |
background-repeat: no-repeat; | |
background-position-x: center; | |
background-attachment: local; */ Ensures the image will fill the height and scroll with content. */ |
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
<template> | |
<div id="mainLayout"> | |
<div id="header"></div> | |
<div id="leftNav"></div> | |
<div id="mainView"></div> | |
</div> | |
</template> | |
<style> | |
html, body { /* nothing necessary */ } |
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
def sample_list_evenly(list_: List[Any], samples: int) -> List[Any]: | |
""" | |
Return the contents of 'list_' sampled evenly accross its current order. | |
NOTE: Doesn't work perfectly yet... | |
:param list_: A list of anything. | |
:param samples: The number of samples to return. |
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
def find_hex_namespace_boundaries(number_of_bytes:int, number_of_sets:int = 2) -> Tuple[str]: | |
""" | |
Return a list of tuples representing the inclusive lower and upper boundaries | |
of each range of hexadecimal values from a namespace with 'number_of_bytes' bytes | |
divided into 'number_of_sets' "equal" sets. | |
:param number_of_bytes: The length of the hexadecimal namespace in bytes. | |
:param number_of_sets: The number of sets to divide the namespace into. | |
NOTE: The sets will be of as close to equal length as possible |
NewerOlder