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 | |
| /** | |
| * Code demo for convert base number with custom base character map. | |
| * Not support negative number. | |
| */ | |
| // base from toHex on http://hashids.org/ | |
| function intToChar($input) | |
| { |
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 | |
| use Redis; | |
| use Exception; | |
| /** | |
| * Redis cache - Port from Phalcon Cache | |
| * Cut intergate from backend and front cache | |
| * I don't test or try run it. This pass on php linter. | |
| * When I want to use it, I will check later. |
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
| // Original from http://stackoverflow.com/questions/1638337/the-best-way-to-synchronize-client-side-javascript-clock-with-server-date | |
| // Improved by community and @jskowron | |
| // Synchronize client-side clock with server time using an approximation of NTP | |
| let serverTimeOffset = null; | |
| function getServerTime(callback) { | |
| if (serverTimeOffset === null) { | |
| const scripts = document.getElementsByTagName("script"); | |
| const currentScriptURL = scripts[scripts.length - 1].src; |
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
| var res = {0:0,1:0}; | |
| var r; | |
| for(var i = 0; i < 100; i++) { | |
| r = Math.floor((Math.random() * 2) + 0); | |
| res[r]++; | |
| } | |
| console.log(res); |
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 | |
| if (!function_exists('mb_str_split')) { | |
| /** | |
| * Convert a multibyte string to an array | |
| * | |
| * @param string $string The input string. | |
| * @param integer $split_length Maximum length of the chunk. | |
| * @param string $encoding The encoding parameter is the character encoding. | |
| * @return array |
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 | |
| use Illuminate\Foundation\Testing\DatabaseMigrations; | |
| class ProductControllerTest extends TestCase | |
| { | |
| use DatabaseMigrations; | |
| protected $testSubject = 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
| <?php | |
| /** | |
| * Date function for Thai | |
| * Lazy code version. | |
| * | |
| * Don't remove copyright. | |
| * | |
| * @author Nimit Suwannagate <[email protected]> | |
| */ |
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 | |
| /** | |
| * Array collection helpers | |
| * | |
| * Ported from Laravel4. | |
| * By EThaiZone | |
| */ | |
| if ( ! function_exists('array_add')) | |
| { |
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 | |
| // write by me. | |
| if ( ! function_exists('dq')) | |
| { | |
| function dq($offset = 0, $length = null, $echoOnly = false) | |
| { | |
| s(array_slice(DB::getQueryLog(), $offset, $length)); | |
| if ($echoOnly == false) |
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 | |
| if ( ! function_exists('basePath')) | |
| { | |
| /** | |
| * Get the path to the base of the install. | |
| * | |
| * @param string $path | |
| * @return string | |
| */ |