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 | |
LOG_FILE= | |
function log() { | |
local LOG_TEXT="${1}" | |
local LOG_DATE= | |
LOG_DATE="$(date -u +'%Y-%m-%dT%H:%M:%S.%3NZ')" | |
if [ ! -z "${LOG_FILE}" ]; then |
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); | |
ini_set('memory_limit', '1G'); | |
ini_set('max_execution_time', '0'); | |
/** | |
* Maps the given number to array of its digits. | |
* | |
* @param int $number |
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); | |
/** | |
* @param mixed $var | |
* @return bool | |
*/ | |
function is_int_safe($var): bool | |
{ | |
return is_numeric($var) && preg_match('/^-?\d*$/', (string)(float)$var); |
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
'use strict'; | |
/** | |
* @param {Array} arr | |
* @param {Function} cb | |
* @returns {Array} | |
*/ | |
function map(a, b) { | |
const result = []; |
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
'use strict'; | |
function debounce(func, wait) { | |
let timeout | |
return function (...args) { | |
const _this = this | |
clearTimeout(timeout) | |
timeout = setTimeout(() => func.apply(_this, args), wait) | |
} | |
} |
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
'use strict'; | |
/** | |
* | |
* @param {string} string1 | |
* @param {string} string2 | |
* @returns {boolean} | |
*/ | |
function isAnagram(string1, string2) { | |
var string1 = string1.split('').sort().join('').trim().toLowerCase(); |
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 divide(x, y) { | |
if (y === 0) { | |
throw new Error('Division by zero'); | |
} | |
var xabs = x < 0 ? -x : x; | |
var yabs = y < 0 ? -y : y; | |
var result = 0; | |
while (xabs >= yabs) { | |
result++; | |
xabs -= yabs; |
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
'use strict'; | |
function toromans(number) { | |
const decimals = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]; | |
const romans = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]; | |
let result = ''; | |
for (var i = 0; i <= decimals.length; i++) { | |
const decimal = decimals[i]; | |
const roman = romans[i]; | |
const remain = number % decimal; |
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); | |
ini_set('html_errors', 'false'); | |
error_reporting(E_ALL | E_STRICT); | |
set_exception_handler('error'); | |
define('DB_HOST', '127.0.0.1'); | |
define('DB_USER', 'root'); | |
define('DB_PASS', null); |
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
/** | |
* FizzBuzz | |
* | |
* A program that prints the numbers from 1 to 100. | |
* Multiples of three print “Fizz” instead of the number, and multiples of five print “Buzz”. | |
* For numbers which are multiples of both three and five print “FizzBuzz”. | |
*/ | |
#include <stdio.h> |
NewerOlder