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 | |
/** | |
* This file contains constants and shortcut functions that are commonly used. | |
* Please only include functions are most widely used because this file | |
* is included for every request. Functions are less often used are better | |
* encapsulated as static methods in helper classes that are loaded on demand. | |
*/ | |
/** | |
* This is the shortcut to DIRECTORY_SEPARATOR | |
*/ |
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 | |
/** | |
* Email: <[email protected]> | |
* Date: 19.01.15 | |
* Time: 12:10 | |
* | |
* use \behaviors\Url | |
* ... | |
* | |
* public function behaviors() |
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
/** | |
* Created by Alexander Litvinov | |
* Email: [email protected] | |
* May be freely distributed under the MIT license | |
*/ | |
'use strict'; | |
import _ from 'lodash' |
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
Promise.all( | |
['module1', 'module2', 'module3'] | |
.map(x => System.import(x))) | |
.then(([module1, module2, module3]) => { | |
// Use module1, module2, module3 | |
}); |
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
'use strict'; | |
/** | |
* Created by Alexander Litvinov | |
* Email: [email protected] | |
* May be freely distributed under the MIT license | |
*/ | |
let singleton = Symbol(); | |
let singletonEnforcer = Symbol(); |
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 | |
/** | |
* Created by Alexander Litvinov | |
* Email: [email protected] | |
* May be freely distributed under the MIT license | |
*/ | |
namespace common\behaviors; | |
use Yii; |
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
function BarcodeScannerDetector(options) { | |
this.options = options || {}; // Default | |
this.options.keypressDelay = this.options.keypressDelay || 100; // Delay between press | |
this.chars = []; // Our barcode | |
this.events(); | |
} | |
BarcodeScannerDetector.prototype.delay = function(callback, ms) { | |
clearTimeout(this.timer); | |
this.timer = setTimeout(callback, ms); |
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 | |
/** | |
* Created by Alexander Litvinov | |
* Email: [email protected] | |
* May be freely distributed under the MIT license | |
*/ | |
function typehint($level, $message) { | |
if($level == E_RECOVERABLE_ERROR && preg_match('/^Argument (\d)+ passed to (?:(\w+)::)?(\w+)\(\) must be an instance of (\w+), (\w+) given/', $message, $match)) { | |
if($match[4] == $match[5]) { |
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 | |
function stupid_sort($array) | |
{ | |
$i = 0; | |
$n = count($array); | |
while ($i < $n - 1) { | |
if ($array[$i + 1] < $array[$i]) { | |
list($array[$i], $array[$i + 1]) = array($array[$i + 1], $array[$i]); | |
$i = 0; |
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 | |
function bubble_sort($array) | |
{ | |
$n = count($array); | |
for ($i = 0; $i < $n - 1; $i++) { | |
for ($j = 0; $j < $n - 1 - $i; $j++) { | |
if ($array[$j] > $array[$j + 1]) { | |
list($array[$j], $array[$j + 1]) = [$array[$j + 1], $array[$j]]; |