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 | |
namespace Toptal\SpeedCoding\Controller\Api; | |
use Exception; | |
use Respect\Validation\Validator as v; | |
use Toptal\SpeedCoding\Api\ApiResult; | |
use Toptal\SpeedCoding\Auth; | |
use Toptal\SpeedCoding\Challenge\EmailProcessor; | |
use Toptal\SpeedCoding\Challenge\TaskResultComparator; |
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
static function detect($path1, $path2, $colorPrecision = null, $gaussianBlur = false) | |
{ | |
$img1 = imagecreatefrompng($path1); | |
$img2 = imagecreatefrompng($path2); | |
$w1 = imagesx($img1); $h1 = imagesy($img1); | |
$w2 = imagesx($img2); $h2 = imagesy($img2); | |
# Stop early if the size of images such that images can not be part of each other | |
if (($w1 > $w2 && $h2 > $h1)) |
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 | |
$now = time(); | |
$locales = `locale -a`; | |
$locales = preg_split('/\s/is', $locales); | |
//var_dump($locales); exit; | |
echo "<ul>"; |
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
# | |
# Acts as a nginx HTTP proxy server | |
# enabling CORS only to domains matched by regex | |
# | |
server { | |
listen 80; | |
server_name corsproxy.mydomain.com; | |
location / { | |
proxy_redirect off; |
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
/** | |
* Replaces jQuery element or its content temporarily with watch symbol of iconic font (icon-refresh) | |
* | |
* To be used with http://fortawesome.github.com | |
*/ | |
function replaceByWatch(el, replaceInnerContent) { | |
var watch = $icon('icon-refresh icon-spin') | |
if (replaceInnerContent) { |
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 | |
/** | |
* Class Router is static class which serves for routing purposes and can be used in 2 modes: full-map and on-the-go modes. | |
* | |
* Reads request uri path from $_GET['_REQUEST_URI'] | |
*/ | |
class Router | |
{ |
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 | |
/** | |
* Trait Lazy | |
* | |
* Allows for static and dynamic lazy initialization. | |
* NB. Include "use Lazy;" in every class you want this functionality, otherwise collision may happen if any of parents use Lazy. | |
* | |
* Example: |
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 | |
/** | |
* Serves for routing purposes and can be used in 2 modes: | |
* 1. Build the full map and then process | |
* 2. Process on the go until a matched mapping is found | |
* | |
* Reads request uri path from $_GET['_REQUEST_URI'] | |
*/ |
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 | |
/** | |
* Class Router is static class which serves for routing purposes and can be used in 2 modes: full-map and on-the-go. | |
* | |
* Reads request uri path from $_GET['_REQUEST_URI'] | |
*/ | |
namespace _\web; |
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
# WWW HTTP(S) -> non-WWW | |
server { | |
listen 80; | |
#listen 443 ssl; | |
server_name www.EXAMPLE.COM; | |
return 301 $scheme://EXAMPLE.COM$request_uri; | |
#ssl_certificate /home/USER/.ssl/ssl-unified.crt; | |
#ssl_certificate_key /home/USER/.ssl/ssl.key; | |
} |