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 binaryGap($n) | |
{ | |
$result = []; | |
$tab = explode("1", decbin($n)); | |
if ($tab[count($tab) - 1] != "") { | |
array_pop($tab); | |
} | |
foreach ($tab as $t) { |
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 push($item = null) | |
{ | |
$stack = []; | |
if ($item) { | |
$stack[] = $item; | |
} | |
return $stack; | |
} |
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 stackUnwind($n) | |
{ | |
if ($n > 0) { | |
echo 'Parameter: ' . $n . PHP_EOL; | |
stackUnwind($n - 1); | |
} | |
foreach (debug_backtrace() as $key => $val) { | |
foreach ($val['args'] as $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 | |
class Container | |
{ | |
public $bindings = []; | |
/** | |
* @param $key | |
* @param $value | |
*/ |
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 | |
/* | |
|-------------------------------------------------------------------------- | |
| PHP IoC/DI container | |
|-------------------------------------------------------------------------- | |
| | |
| Most simple IoC/DI container implemented in PHP. | |
| Also includes interface implementation (duck typing is not allowed when binding | |
| concrete class to container) | |
*/ |
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 Student | |
{ | |
protected static $instance; | |
public function __construct($name = null) | |
{ | |
$this->name = $name; | |
} | |
public static function instance() |
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 Order | |
{ | |
protected $basket = []; | |
protected $maxSize; | |
protected $confirmed = false; | |
private function __construct($product) | |
{ |
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 arr = []; | |
var links = document.getElementsByTagName("a"); | |
for(var i=0; i<links.length; i++) { | |
arr.push(links[i].href); | |
} | |
for(i = 0; i < arr.length;i++){ | |
console.log(arr[i]); | |
}; |
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 | |
require "../vendor/autoload.php"; | |
use Symfony\Component\HttpFoundation\Request; | |
function curlProxy($params = null) | |
{ | |
$request = Request::createFromGlobals(); | |
$data = json_decode($request->getContent()); | |
$curl = curl_init(); |
NewerOlder