- Sorting:
- Bubble, or sinking sort
- Seeks for the lowers value, swaps in the inner level
- Means that every iteration would swap values
- Seeks for the lowers value, swaps in the inner level
- Selection:
- Seeks for the lowest value, swaps only when found AT the outter level
- Means that not all iteration would swap values
- Seeks for the lowest value, swaps only when found AT the outter level
- Bubble, or sinking sort
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 Map extends ArrayObject | |
{ | |
public function __construct($input = [], $flags = 0, $iterator_class = "ArrayIterator") | |
{ | |
parent::__construct([], $flags, $iterator_class); | |
foreach ($input as $k=>$v) { | |
$this[$k] = $v; |
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 Dilmas extends \SplFloat | |
{ | |
public function __construct($value) | |
{ | |
$currency = json_decode(file_get_contents('http://api.fixer.io/latest?base=USD&symbols=BRL'), true); | |
$brl =(float) $currency['rates']['BRL']; | |
parent::__construct(((float) round($value / $brl, 2))); |
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
String.prototype.replaceMap = function(parameters) { | |
var string = this.toString(); | |
Object.keys(parameters).forEach(function(key){ | |
string = string.replace(new RegExp(key, 'g'), parameters[key]); | |
}); | |
return string; | |
} |
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() { | |
var m = 'font-family:monospace;color:#'; | |
if(window.console) { | |
console.log('%cyour %cmessage %chere! %chttp://www.site.com', m+'1EFF00',m+'FF0000',m+'668CFF', m+'C6F612'); | |
} | |
}()) |
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 bubble(array $array) | |
{ | |
$n = count($array); | |
for($counter = 1; $counter < $n; $counter++) { | |
for ($current = $n -1; $current >= $counter; $current--) { | |
$next = $current - 1; |
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 Node | |
{ | |
private $left; | |
private $right; | |
public function __construct(Node $left = null, Node $right = null) | |
{ | |
$this->left = $left; |
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 | |
SuaPlatform extends MySQLWHateverPlatform | |
{ | |
/** .. **/ | |
public function getDefaultValueDeclarationSQL($field) | |
{ | |
$default = parent::getDefaultValueDeclarationSQL($field); | |
$this->decorateDatetime($field, $default); |
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 FileObject extends \SplFileObject | |
{ | |
private $size; | |
public function fwrite($content, $len = null) // :int | |
{ | |
$this->size = $len ?: strlen($content); |
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
# ~/.bash_profile | |
# ... | |
# Docker cleanup | |
dcleanup(){ | |
docker rm -v $(docker ps --filter status=exited -q 2>/dev/null) 2>/dev/null | |
docker rmi $(docker images --filter dangling=true -q 2>/dev/null) 2>/dev/null | |
} | |
# Git cleanup | |
gitcleanup() { |