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 | |
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
(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
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
<?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
<?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 | |
abstract class Enum extends \ArrayObject | |
{ | |
public final function __construct() | |
{ | |
$constantsToRemove = ['STD_PROP_LIST', 'ARRAY_AS_PROPS']; | |
$constants = (new \ReflectionObject($this))->getConstants(); | |
foreach ($constants as $constant => $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 | |
function readStdin($message = null) | |
{ | |
if ($message) { | |
echo $message.PHP_EOL; | |
} | |
$fr=fopen("php://stdin","r"); | |
$input = fgets($fr,128); | |
$input = rtrim($input); |
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 hex_sha1(e){return binb2hex(core_sha1(str2binb(e),e.length*chrsz))}function b64_sha1(e){return binb2b64(core_sha1(str2binb(e),e.length*chrsz))}function str_sha1(e){return binb2str(core_sha1(str2binb(e),e.length*chrsz))}function hex_hmac_sha1(e,t){return binb2hex(core_hmac_sha1(e,t))}function b64_hmac_sha1(e,t){return binb2b64(core_hmac_sha1(e,t))}function str_hmac_sha1(e,t){return binb2str(core_hmac_sha1(e,t))}function sha1_vm_test(){return"a9993e364706816aba3e25717850c26c9cd0d89d"==hex_sha1("abc")}function core_sha1(e,t){e[t>>5]|=128<<24-t%32,e[(t+64>>9<<4)+15]=t;for(var r=Array(80),n=1732584193,a=-271733879,o=-1732584194,u=271733878,h=-1009589776,c=0;c<e.length;c+=16){for(var s=n,i=a,f=o,l=u,d=h,A=0;80>A;A++){16>A?r[A]=e[c+A]:r[A]=rol(r[A-3]^r[A-8]^r[A-14]^r[A-16],1);var m=safe_add(safe_add(rol(n,5),sha1_ft(A,a,o,u)),safe_add(safe_add(h,r[A]),sha1_kt(A)));h=u,u=o,o=rol(a,30),a=n,n=m}n=safe_add(n,s),a=safe_add(a,i),o=safe_add(o,f),u=safe_add(u,l),h=safe_add(h,d)}return Array(n,a,o,u,h)}function sha1 |
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
'use strict'; | |
import { createClass } from 'react/addons'; | |
let App = createClass({ | |
render: function() { | |
return <div> | |
<Button label="Open!" target="modalTest" classNames=".buttonStyle" /> | |
<Modal name="modalTest"> | |
<div class='modal'> |