Skip to content

Instantly share code, notes, and snippets.

@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 / 01-choose.png
Created January 23, 2012 20:30
GitHub Play
01-choose.png
@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 / 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 / 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 / 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 / output.txt
Created February 5, 2012 18:58
PHP native object support
object(Pepa)#2 (1) {
["myObj"]=>
object(stdClass)#1 (2) {
["ahoj"]=>
int(1)
["novak"]=>
string(4) "pepa"
}
}
@juzna
juzna / Object.php
Created March 14, 2012 22:05
PhpStorm inconsistent use proof
<?php
namespace MyApp;
/**
*/
class Object {
function isThisAnObject() {
}
}
@juzna
juzna / MyPresenter.php
Created March 17, 2012 16:40
{if authorized} macro for nette
/**
* Handle action, only valid for a logged-in user
* @User
*/
public function handleLike($itemId) { ... }
@juzna
juzna / arraysTest.php
Created March 26, 2012 08:38
Multidimensional arrays in PHP
<?php
class Tool {
/**
* @return Tool[][]
*/
function getItems() {
return call_user_func('x'); // dummy
}
}