Skip to content

Instantly share code, notes, and snippets.

<?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;
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))
<?php
$now = time();
$locales = `locale -a`;
$locales = preg_split('/\s/is', $locales);
//var_dump($locales); exit;
echo "<ul>";
@meglio
meglio / cors.nginxconf
Last active March 18, 2016 05:46 — forked from pauloricardomg/cors.nginxconf
Nginx configuration for CORS-enabled HTTPS proxy with origin white-list defined by a simple regex
#
# 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;
@meglio
meglio / inline-watch.js
Last active December 14, 2015 16:29
Replaces jQuery element or its content temporarily with watch symbol of iconic font (icon-refresh). To be used with http://fortawesome.github.com
/**
* 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) {
@meglio
meglio / Router.php
Created February 17, 2013 03:00
Simple HTTP routing utility
<?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
{
@meglio
meglio / Lazy.php
Last active November 24, 2015 02:02
<?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:
@meglio
meglio / Router.php
Created February 3, 2014 19:35
A simple web-router
<?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']
*/
@meglio
meglio / Router.php
Created August 28, 2014 13:52
Simple router class for small and medium projects
<?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;
@meglio
meglio / example-nginx-website
Created February 18, 2015 12:24
Nginx website virtual host example
# 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;
}