Skip to content

Instantly share code, notes, and snippets.

@juzna
juzna / index.html
Created August 3, 2012 15:34
Bookmarklets
<h1>Bookmarklets</h1>
<p>Usefull bookmarklets. Drag & drop them to your bookmark bar and then use whenever needed</p>
<ul>
<li><a href="javascript:var s = document.createElement('script'); s.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'; document.body.appendChild(s)">Add jQuery</a> - adds jQuery to current page
<li><a href="javascript:$.post("http://ladenka.juzna.cz/record/add?message="+$("#netteBluescreenError p")[0].firstChild.nodeValue.trim(),{content:document.getElementById("netteBluescreen").innerHTML},function(a){if(a&&a.link){window.open(a.link)}else{alert("Uploaded failed")}})">Share BlueScreen</a> - share Nette BlueScreen to the cloud (https://github.com/nette/nette/pull/717)
@juzna
juzna / constructor-experiment.php
Created May 7, 2012 19:45
PHP experiment: object construction
<?php
/**
* Experiment: constructor to have already partially initialized object, before it gets called.
*/
class Foobar {
private $a;
private $b;
private $c;
@juzna
juzna / MyTest.php
Created April 19, 2012 19:48
Nette DI container and @Inject annotation
<?php
/**
* Example of what a decent Dependency Injection Container should inject to make our life happier
*/
class MyTest {
public function __construct(\Nette\Security\User $user) { // Constructor injection
}
@juzna
juzna / RepositoryClassListener.php
Created April 16, 2012 08:49
Doctrine listener: Updates custom repository class definition if explicitly defined in parent class
<?php
use \Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Nette,
Doctrine,
Doctrine\ORM\Events;
/**
* Updates custom repository class definition if explicitly defined in parent class
@juzna
juzna / autoload.php
Created March 30, 2012 10:28
Nette skeleton autoload
<?php
/**
* Class loader for the whole application
*
* Makes sure all the classes are available when they're needed. No less, no more.
* Usually the first file to load in your app
*
* @author Jan Dolecek <[email protected]>
* @author Filip Procházka ([email protected])
*/
@juzna
juzna / compare.php
Created March 26, 2012 18:57
PHP compare bug
<?php
$a = new ArrayObject(array(
'single' => "ahoj",
'double' => "lamo",
));
$b = new ArrayObject(array(
'single' => "zdar",
'double' => "vole",
@juzna
juzna / config.php
Created March 26, 2012 10:52
UIR-ADR update
<?
$dbHost = 'localhost';
$dbUser = '...';
$dbPass = '...';
$dbDatabase = '...';
@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
}
}
@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 / Object.php
Created March 14, 2012 22:05
PhpStorm inconsistent use proof
<?php
namespace MyApp;
/**
*/
class Object {
function isThisAnObject() {
}
}