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 JpegSectionIterator implements \Iterator | |
{ | |
const | |
UNKNOWN = 'unknown', | |
SOI = 'SOI', // Start Of Image | |
SOF0 = 'SOF0', // Start Of Frame (baseline DCT) | |
SOF1 = 'SOF1', // Start Of Frame (extended DCT) | |
SOF2 = 'SOF2', // Start Of Frame (progressive DCT) |
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 | |
/* | |
* The code mostly peeped in artisan executable file. | |
* Put this file to project root (one level above DocumentRoot) and run | |
* $ php example.php | |
*/ | |
if (php_sapi_name() !== 'cli') { | |
die('This file can be executed from console only'); | |
} |
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
window.moment = require('moment'); | |
require('daterangepicker'); | |
require('bootstrap-select'); |
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
For timezone 'Australia/Melbourne': | |
2018-03-31 10:00:00 | |
+ 24*60*60 == 2018-04-01 09:00:00 | |
strtotime(+1 day) == 2018-04-01 10:00:00 | |
DateTime->add(1d) == 2018-04-01 10:00:00 | |
2018-10-06 10:00:00 | |
+ 24*60*60 == 2018-10-07 11:00:00 | |
strtotime(+1 day) == 2018-10-07 10:00:00 | |
DateTime->add(1d) == 2018-10-07 10:00:00 |
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
C:\>php flatten.php | |
array(4) { | |
[0]=> | |
int(11) | |
[1]=> | |
int(12) | |
[2]=> | |
int(13) | |
[3]=> | |
int(14) |
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
#!/usr/bin/env php | |
<?php | |
/* | |
* Filter to fill the IP gaps in a MaxMind GeoLite tables. | |
* | |
* For every missing range in the file it puts a dummy one. | |
*/ | |
$types = [ | |
'asnum' => [0, 0, 1, "%s,%s,\"-\"\n"], | |
'blocks' => [2, 0, 1, "\"%s\",\"%s\",\"1\"\n"], |
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 | |
function file_get_contents_ex($url, $cookie = null, $proxy = null, $auth = null) | |
{ | |
$opts = array( | |
'http' => array( | |
'method' => 'GET', | |
'user-agent'=> 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36', | |
'header' => "Accept-language: en\r\n" . | |
(!empty($auth) ? "Proxy-Authorization: Basic {$auth}\r\n" : '') . |
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 FileHelper | |
{ | |
public static function openAndLock($filename) | |
{ | |
$fh = fopen($filename, 'r+'); | |
if (!$fh || !flock($fh, LOCK_EX)) { | |
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
<?php | |
/** | |
* Unroll dot-sequenced keys to new dimension | |
* @param array $source | |
* @return array | |
*/ | |
function deep_load($source) | |
{ | |
$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
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_URI} ^/thumb/ | |
RewriteRule ^(.*)$ thumb.php [QSA,L] | |
</IfModule> |
NewerOlder