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 | |
/** | |
* Create blank array by number | |
* | |
* @param int Number of members in each dimension | |
* @return array | |
*/ | |
function createBlankArray() | |
{ | |
$dimensions = func_get_args(); |
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 sortByArray($array, $sortOrder, $options = SORT_REGULAR, $descending = false) | |
{ | |
// Before first! LOL | |
// I just extend sortBy in Laravel collection to can use with normal array | |
// and it will sort data from another array. | |
// Perfect!! | |
// Before first. We will add diff array index to last item of sortOrder |
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 App\Models\Traits; | |
use Exception; | |
/** | |
* This is trait for use with eloquent model only. | |
* Develop by Nimit Suwannagate <ethaizone@hotmail.com> | |
* I don't allow to modify anythings in this code. |
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 | |
// Composer install this package. | |
// https://github.com/reactphp/socket | |
// Command support: broadcast, who | |
require 'vendor/autoload.php'; | |
$loop = React\EventLoop\Factory::create(); |
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
var net = require('net'); | |
// Config | |
var config = { | |
server: { | |
port: 7890 | |
} | |
}; | |
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
// create array for hold all dogs data | |
// just loop by get data from getNames() | |
// getNames() is generator so it's simple loop | |
// and we just need 5 dogs only | |
// each dog will name as value | |
// echo all dogs as json |
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
// This is function for function | |
// Usage like http://php.net/manual/en/function.get-called-class.php | |
function get_called_func() | |
{ | |
$trace = array_slice(debug_backtrace(), -2, 1); | |
return $trace['function']; | |
} |
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
var data = []; | |
data.push(['S', 'M', 'L']); | |
data.push(['RED', 'YELLOW']); | |
data.push(['IRON', 'COTTON']); | |
data.push(['ccc', 'ddd']); | |
// For clone array | |
Array.prototype.clone = function() { | |
return this.slice(0); | |
}; |
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 App\Traits; | |
use Illuminate\Database\Eloquent\Relations\Relation; | |
use Illuminate\Database\Eloquent\Relations\HasOneOrMany; | |
use Illuminate\Database\Eloquent\Relations\BelongsTo; | |
use Illuminate\Database\Eloquent\Relations\HasManyThrough; | |
use Closure; | |
use Exception; |
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 | |
/** | |
* Copyright @ 2016 by Nimit Suwannagate <ethaizone@hotmail.com>. All rights reserved. | |
*/ | |
// Run this file in cli mode for best view. | |
// Try to edit this one. | |
$maxNumber = 500000000000; |