Skip to content

Instantly share code, notes, and snippets.

View jakubkulhan's full-sized avatar

Jakub Kulhan jakubkulhan

View GitHub Profile
-init {
$operators = array(
'+' => 10,
'-' => 10,
'*' => 20,
'/' => 20,
'^' => 30
);
$right_associative = array(
-namespace Nette\Templates
-name LatteParser
-init {
$self = (object) array(
"latte_pair" => array(
"if" => TRUE,
"for" => TRUE,
"foreach" => TRUE,
"while" => TRUE,
calc
= expression !.
// left associative
expression
= f:factor ( "+" g:factor { $f = $f + $g; }
/ "-" g:factor { $f = $f - $g; }
)*
-> $f
<?php
$time = microtime(true);
$i = 0;
loop:
if ($i >= 1000) goto endloop;
$ret = dummy($i);
++$i;
goto loop;
endloop:
+------------+ +--------------+ +---------------+
| reads <:<<<<<<:<<<<<<<<<<<<<<:<<< HTTP resposne <<<:< writes |
| | | -:--- HTTP request ----:> |
| | | | | |
| SSH client | | proxy script | | server script |-----+
| | | | | | |
| writes >:>>>>>>:>>>>>>. | | ^ reads | |
+------------+ +------|-------+ +--|------------+ |
| | |
| +--^----+ |
<?php
namespace sh\commands;
function hello(array $argv, array $envp, array $descriptors)
{
// $descriptors[0] is stdin
// $descriptors[1] is stdout
// $descriptors[2] is stderr
fwrite($descriptors[1], "hello, world!\n");
<?php
class foo
{
function stream_open() { return TRUE; }
function stream_eof() { return FALSE; }
function stream_read($count)
{
$backtrace = debug_backtrace();
if (isset($backtrace[1]['function']) && $backtrace[1]['function'] === 'fread') {
<?php
/**
* Wraps callback with some default params
*/
class fn
{
/**
* @var callback Wrapped callback
*/
private $callback;
<?php
class foo
{
function stream_open() { return TRUE; }
function stream_eof() { return FALSE; }
function stream_read($count)
{
var_dump($count);
return "";
Jak nejlépe na tree walker v PHP?