Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

David Grudl dg

🏠
Working from home
Block or report user

Report or block dg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dg
dg / ObjectTrait.php
Created Jul 2, 2011
Nette\ObjectTrait
View ObjectTrait.php
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004, 2011 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
View MultiplierControl.php
<?php
class MultiplierControl extends Nette\Application\UI\Control
{
private $factory;
public function __construct($factory)
{
View gist:2338940
body {
color: blue;
}
@dg
dg / fibonacci.js
Last active Oct 2, 2015
Fibonacci number benchmark
View fibonacci.js
// fibonacci(40) takes 2 seconds in Node.js 0.6.14
// http://en.wikipedia.org/wiki/Fibonacci_number
function fibonacci(n) {
return n < 2 ? n : fibonacci(n-2) + fibonacci(n-1);
}
@dg
dg / gist:2891542
Created Jun 7, 2012
Nette Framework Forms, year 2006
View gist:2891542
<?php
// history of Nette Framework Forms, year 2006
class NHtml
{
static protected $empty = array('img'=>1,'hr'=>1,'br'=>1,'input'=>1,'meta'=>1,'area'=>1,'base'=>1,'col'=>1,'link'=>1,'param'=>1);
static public function tag($tag, $attrs=NULL, $content=NULL)
@dg
dg / gist:3644321
Created Sep 5, 2012
Texy on nette.org
View gist:3644321
<?php
/**
* Texy parser for wiki page.
*/
class Parser extends Nette\Object
{
/**
* @return void
@dg
dg / gist:5090424
Last active Dec 14, 2015
Pár tipů, co by bylo fajn zlepšit na novém Zdroják.cz
View gist:5090424

Homepage

  • chybí odkaz na zprávičky
  • odkaz "Další články" dole nevede na další články, ale na první články
  • tři hlavní články se opticky slévají
  • není úplně zřejmá souvislost tří horních článků a pravého sloupce (a zpráviček)
  • pouze na homepage je levý sloupec ten vedlejší
  • v levém sloupci je proklikávací pouze nadpis Root.cz
  • odkaz na poštovní obálku vede na jakýsi obrázek
@dg
dg / gist:5616877
Created May 21, 2013
Workaround for missing ::class in PHP < 5.5
View gist:5616877
<?php
use Nette\Http;
echo Http\Request::class; // prints 'Nette\Http\Request' since PHP 5.5
echo Http\Request\type::of; // prints 'Nette\Http\Request' alwyas ;)
@dg
dg / ssl.conf
Created Dec 14, 2015
Redirect to HTTPS for all except Windows XP
View ssl.conf
server {
...
listen 443 ssl;
listen 80;
if ($server_port = 80) {
set $xp A;
}
@dg
dg / output detector.php
Created Jun 20, 2013
How can I find out where my output started?
View output detector.php
<?php
ob_start(function($s, $flag) {
if ($flag & PHP_OUTPUT_HANDLER_START) {
$e = new \Exception;
$s = nl2br("Output started here:\n{$e->getTraceAsString()}\n\n") . $s;
}
return $s;
}, 2);
You can’t perform that action at this time.