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
<?php | |
/** | |
* Message Form | |
* | |
* @author Steven Pray <steven@stevenpray.com> | |
* @copyright Copyright (c) 2014 Steven Pray | |
* @license http://www.opensource.org/licenses/mit-license.php MIT | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
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
<?php | |
/** | |
* 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”. | |
*/ |
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
/** | |
* 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> |
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
<?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 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 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 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 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 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 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); |
OlderNewer