Skip to content

Instantly share code, notes, and snippets.

<?php
declare(strict_types=1);
class Loop
{
private static ?Loop $loop = null;
private array $queue = [];
@m6w6
m6w6 / Fibers.md
Last active October 5, 2022 21:56
Fibers are...

Fibers are...

  +------------------------------------------------------------+
  | Process                                                    |
  |   +--------------------------------------------------------+
  |   | Threads (OS/User)                                      |
  |   |   +----------------------------------------------------+
  |   |   | Coroutines                                         |
  |   |   |   + -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - +
 | | | | ┌ Fiber (with stack, yield anywhere) |
@Shelob9
Shelob9 / encrypted-hi-roy.php
Last active July 8, 2020 15:02
Basic Hi Roy example of PHP encryption/decryption. #ApexSecurity
<?php
$key = random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES);
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
$ciphertext = sodium_crypto_secretbox("Hi Roy", $nonce, $key);
$plaintext = sodium_crypto_secretbox_open($ciphertext, $nonce, $key);
if ($plaintext === false) {
throw new Exception("Bad ciphertext");
@rakeshtembhurne
rakeshtembhurne / render_view_as_variable.php
Created July 19, 2013 10:10
CakePHP: Render view in a variable inside controlller
<?php
$view = new View($this, false);
$view->set(compact('some', 'vars'));
$html = $view->render('view_name');