Skip to content

Instantly share code, notes, and snippets.

View flavius's full-sized avatar

Flavius Aspra flavius

View GitHub Profile
@flavius
flavius / problemă.php
Created February 3, 2011 17:14
problemă :-)
(#1): Bobu', Cristi, Florea, Mărin şi Sorin locuiesc la etaje diferite într-un bloc cu 4 etaje (4+1=5 nivele)
(#2): Bobu' nu locuieşte la ultimul etaj.
(#3): Cristi nu locuieşte la parter.
(#4): Florea nu locuieşte nici la parter, nici la ultimul etaj.
(#5): Mărin locuieşte la un etaj superior lui Cristi.
(#6): Sorin nu locuieşte pe un etaj adiacent cu Florea.
(#7): Florea nu locuieşte pe un etaj adiacent cu Cristi.
Unde locuieşte fiecare?
Implementaţia o adăugăm în fişierul \texttt{functions.php}
\begin{lstlisting}[numbers=none,title=functions.php]
function build_menu_from_pages($pages) {
$r = '<ul>';
foreach($pages as $pagename => $metadata) {
$r .= '<li><a href="?show='.$pagename.'">'.$metadata['title'].'</a></li>';
}
return $r.'</ul>';
}
\end{lstlisting}
@flavius
flavius / README
Created April 12, 2011 08:26
pastium.org importer and exporter tool
With this tool you can paste entire projects to pastium.org and even import entire directory structures from pastes created with it.
LICENSE
You must spend me a free drink of my choice when you meet me. Otherwise you are free to use it anyway you like.
%left INCLUDE INCLUDE_ONCE EVAL REQUIRE REQUIRE_ONCE.
%left COMMA.
%left LOGICAL_OR.
%left LOGICAL_XOR.
%left LOGICAL_AND.
%right PRINT.
%left EQUAL PLUS_EQUAL MINUS_EQUAL MUL_EQUAL DIV_EQUAL CONCAT_EQUAL MOD_EQUAL AND_EQUAL OR_EQUAL XOR_EQUAL SL_EQUAL SR_EQUAL.
%left QUESTION_MARK COLON.
%left BOOLEAN_OR.
%left BOOLEAN_AND.
articles
========
id title category
1 hello php IT
2 hello linux IT
categories
==========
id
IT
<?php
function push_stack($stack, $idx, $val) {
$val = array($idx => $val);//val is a zval*, the data its points to is already allocated on the heap, no duplication is needed
$stack[] = $val;
return $stack;
}
$stack = array();
$val = array('foo');
RE2C_FLAGS=-g --no-generation-date --case-inverted -cbdF
$(srcdir)/php_scanner.c: $(srcdir)/php_scanner.re $(srcdir)/php_parser.h
$(RE2C) $(RE2C_FLAGS) -t php_scanner_defs.h -o php_scanner.c php_scanner.re
$(srcdir)/php_parser.c $(srcdir)/php_parser.h: $(srcdir)/lemon $(srcdir)/php_parser.y
@(cd $(srcdir); ./lemon php_parser.y)
$(srcdir)/lemon:
$(CC) lemon.c -o lemon
POST /test HTTP/1.0
Host: www.iana.org
HTTP/1.1 404 NOT FOUND
Date: Sun, 08 May 2011 17:01:30 GMT
Server: Apache/2.2.3 (CentOS)
Connection: close
Content-Type: text/html; charset=utf-8
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
header('Content-Type: text/plain');
?>
<html>
<body>
<h1>hello</h1>
</body>
</html>