Skip to content

Instantly share code, notes, and snippets.

View Majkl578's full-sized avatar
💥
breaking builds

Michael Moravec Majkl578

💥
breaking builds
View GitHub Profile
@Majkl578
Majkl578 / intro.md
Created August 21, 2012 08:50 — forked from juzna/intro.md
Nette\Object performance tests

Nette\Object performance tests

I guess you already saw a short note Latency Numbers Every Programmer Should Know. I wanted to check how well Nette performs with its magic properties on Nette\Object.

You can see the testing code below together with raw output on my machine.

It show how much time in seconds it took to execute one million iterations of a particular action, thus it is also time in microseconds of one such call. You should compare it to null test, which execute empty iterations.

Results

@Majkl578
Majkl578 / gist:3584811
Created September 1, 2012 19:38
Nella ConnectionPanel registration (in DI extension)
// connection/query panel
$builder->addDefinition($this->prefix('panel'))
->setClass('Nella\NetteAddons\Doctrine\Diagnostics\ConnectionPanel')
->addSetup('setConnection')
->addSetup('Nette\Diagnostics\Debugger::$bar->addPanel(?)', array('@self'))
->addSetup('Nette\Diagnostics\Debugger::$blueScreen->addPanel(?)', array(array('@self', 'renderException')))
->addSetup(array('@Doctrine\ORM\Configuration', 'setSQLLogger'))
->addTag('run');
@Majkl578
Majkl578 / gist:3822948
Created October 2, 2012 20:02
form's button that triggered submit (jQuery)
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
</head>
<body>
<form id="x">
<input type=submit name="a">
<input type=submit name="b">
</form>
<script>
@Majkl578
Majkl578 / BufferedTextResponse.php
Created October 22, 2012 20:09
BufferedTextResponse
<?php
namespace App\Application\Responses;
use Nette;
class BufferedTextResponse extends Nette\Application\Responses\TextResponse
{
public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
{
@Majkl578
Majkl578 / debianize.sh
Last active December 11, 2015 04:19
Steam .deb package repacker to achieve compatibility on Debian.
#!/bin/bash
if [[ ! $# -eq 1 ]] ; then
echo "Usage: ./debianize.sh steam_version.deb"
exit
fi
VERSION_APPEND="+repack.1"
TMP=/tmp/steam-repack
NAME=$1
@Majkl578
Majkl578 / gist:4948914
Created February 13, 2013 22:22
Nette Framework tests failing with Zend Optimizer +
Nette Tester (v0.9)
-------------------
PHP 5.4.12RC1 | 'php-cgi' -c '/www/nette/tests/php.ini-unix'
ss.............................................................F..........FF...................F.....................F.............F.F...............F....FF.FF...FF....F..F....F.....F......F..........F.................FF.......F.....F................F........F..............................................................................Fs.ss.sssssssssssssssssssssssssss..............................................................................................F....................................................................F.
-- FAILED: Nette\Forms image button. | Nette/Forms/Forms.image.phpt
Failed asserting that TRUE is identical to expected array(2)
in Nette/Forms/Forms.image.phpt(32)
<?php
/**
* @param string
* @return bool
*/
public function isModuleCurrent($module)
{
$module = trim((string) $module);
@Majkl578
Majkl578 / gist:5102017
Created March 6, 2013 18:59
nette.ajax.js + Google Analytics
// push new URL into GA pageview tracker
$.nette.ext('ga', {
success: function (payload) {
if (payload.url) {
_gaq.push(['_trackPageview', payload.url]);
}
}
});
@Majkl578
Majkl578 / test.php
Last active December 14, 2015 20:39
PHP overlazyfying is evil Ilustrating cost of 1000 object instantiations on a large object (presenter) without constructor
<?php
require '/www/nette/Nette/loader.php';
class FooPresenter extends Nette\Application\UI\Presenter {}
$max = 1e3; // 1000
$foo = array_fill(1, $max, NULL);
@Majkl578
Majkl578 / gist:5367340
Created April 11, 2013 21:29
Variant of Presenter::restoreRequest() which ignores signals.
<?php
use Nette\Application\IResponse;
use Nette\Application\Responses\ForwardResponse;
use Nette\Application\UI\Presenter;
trait RestoreRequestWithoutSignalTrait
{
/**
* Restores current request to session. Ignores signals.