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
| <canvas id="c" width="1024" height="1024"> | |
| <script> | |
| // Creds: https://twitter.com/aemkei/status/1378106731386040322 | |
| // let cx = c.getContext('2d'), x, y | |
| // for (x = 0; x < 256; x++) { | |
| // for (y = 0; y < 256; y++) { | |
| // if ((x ^ y) % 2) { | |
| // cx.fillRect(x * x, y * y, x, y); | |
| // } | |
| // } |
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
| // Rewrite | |
| - if ($shippingInfo && $shippingInfo['cost'] && $this->formatPrice($shippingInfo['cost'] != 0)) { | |
| + if (isset($shippingInfo['cost']) && $this->formatPrice($shippingInfo['cost']) > 0) | |
| - $order_id = $this->request->get['order_id']; | |
| + $order_id = (int) $this->request->get['order_id']; | |
| // Refactor | |
| private function formatPrice($number) | |
| { |
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 is_prime(int|float $n): bool { | |
| if ($n == 2) | |
| return true; | |
| if ($n < 2 or $n % 2 == 0) | |
| return false; | |
| for ($i = 3; $i <= sqrt($n); $i++) { |
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 super(...$args) { | |
| $object = debug_backtrace(1, 2)[1]['object']; | |
| $parent = get_parent_class($object); // Let it errorize. | |
| if ($parent && method_exists($parent, '__construct')) { | |
| $ref = new ReflectionMethod($parent, '__construct'); | |
| $ref->invoke($object, ...$args); | |
| } | |
| } |
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
| set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext = null) { | |
| prs("here! $errstr"); | |
| }); | |
| class ErrorHelper { | |
| var $lastError; | |
| function setErrorHandler() { | |
| $this->lastError = null; | |
| set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext = null) { |
OlderNewer