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 FileHandler { | |
/** | |
* allowable default file types | |
*/ | |
public $enabled_mimes = array ( | |
'image/png', | |
'image,jpg', #and what ever you want. | |
); |
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 | |
use Illuminate\Database\Migrations\Migration; | |
class CreatePersRolesTable extends Migration { | |
/** | |
* Run the migrations. | |
* | |
* @return void |
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 | |
# start session | |
session_start(); | |
# if logged in name else make the name FALSE to make an access denied redirect | |
$name = (empty($_SESSION['username'])?false:$_SESSION['username']); | |
# Redirect if not logged in | |
if (!$name) | |
{ |
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
function idIsValid(code) | |
{ | |
var L=code.length; | |
if(L<8 || parseInt(code,10)==0) return false; | |
code=('0000'+code).substr(L+4-10); | |
if(parseInt(code.substr(3,6),10)==0) return false; | |
var c=parseInt(code.substr(9,1),10); | |
var s=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
var s=0; | |
var m=0; | |
var h=0; | |
setInterval(function(){elecTimerHandler()},1000); | |
function elecTimerHandler(){ | |
s++; | |
if (s>59){ | |
s = 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 | |
// I called following loop 5 times | |
for ($i = 1 ; $i <= 200; $i++) | |
{ | |
\Queue::push(function ($job){ | |
if (! \Cache::has('start_time')){ | |
\Cache::put('start_time', time() , 1500); // global start time | |
} | |
sleep(10); //mock network delay for 25 requests | |
$id = 25; // number of async request |
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
[2014-06-26 11:46:45] local.INFO: 2703 ms & 301 files included & 355 classes included & "+"4.75mb. [] [] | |
[2014-06-26 11:46:47] local.INFO: 1035 ms & 301 files included & 355 classes included & "+"4.75mb. [] [] | |
[2014-06-26 11:46:50] local.INFO: 978 ms & 301 files included & 355 classes included & "+"4.75mb. [] [] | |
[2014-06-26 11:46:53] local.INFO: 981 ms & 301 files included & 355 classes included & "+"4.75mb. [] [] | |
[2014-06-26 11:46:53] local.INFO: 25 [] [] | |
[2014-06-26 11:46:53] local.INFO: 50 [] [] | |
[2014-06-26 11:46:53] local.INFO: 75 [] [] | |
[2014-06-26 11:46:53] local.INFO: 100 [] [] | |
[2014-06-26 11:46:53] local.INFO: 125 [] [] | |
[2014-06-26 11:46:53] local.INFO: 150 [] [] |
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 | |
public function __construct (\GuzzleHttp\Client $client) | |
{ | |
$this->client = $client; | |
} | |
public function asyncReqs () | |
{ | |
$requests = []; |
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
Machine: | |
Core i3 CPU 3Ghz | |
RAM 6GB | |
Hard Disk , SataII ~7000 rpm | |
Logic: | |
Laravel has queue:work in daemon and non-daemon mode, the non-daemon mode takes a job from Queue processes it and then the framework is shut down. | |
Test logic relies on multi processing + async request using non-daemon mode, |
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 | |
public function daemon($connectionName, $queue = null, $delay = 0, $memory = 128, $sleep = 3, $maxTries = 0) | |
{ | |
$lastRestart = $this->getTimestampOfLastQueueRestart(); | |
while (true) | |
{ | |
if ($this->daemonShouldRun()) | |
{ | |
$this->runNextJobForDaemon( |
OlderNewer