Skip to content

Instantly share code, notes, and snippets.

View vojtech-dobes's full-sized avatar

Vojtěch Dobeš vojtech-dobes

View GitHub Profile
@nikic
nikic / php-5.5-features.md
Last active August 31, 2020 10:39
List of new features in PHP 5.5
@lm
lm / index.php
Last active July 24, 2020 15:30
<?php
class AdminerColors
{
function head()
{
static $colors = array(
'127.0.0.1' => '#ED1C24',
'localhost' => '#009245',
@melanke
melanke / MultiGetSet.js
Created June 19, 2012 20:53
MultiGetSet.JS - Quickly generate getters and setters for multiple attributes
var MultiGetSet = function(opt){
var getType = function(o) {
return ({}).toString.call(o).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
};
if(!opt.public || !opt.private)
return opt.public;
if(opt.handler && opt.handler.init)
@fprochazka
fprochazka / BasePresenter.php
Created October 6, 2012 16:22
Image pipe for #nettefw templates
<?php
/**
* @author Filip Procházka <filip@prochazka.su>
*/
abstract class BasePresenter extends Nette\Application\UI\Presenter
{
/**
* @var \Img\ImagePipe
<?php
use Nette\Latte\Compiler;
use Nette\Latte\MacroNode;
use Nette\Latte\PhpWriter;
class Macros extends \Nette\Latte\Macros\MacroSet {
public static function install(Compiler $compiler) {
@kaja47
kaja47 / csfd-crawler.php
Created March 12, 2014 01:06
Example crawler using Matcher and AsyncCurl
<?php
use Atrox\Matcher;
use Atrox\Curl;
use Atrox\Async;
$userListMatcher = Matcher::multi('//table[@class="ui-table-list"]//tr', (object) [
'url' => Matcher::single('td/a/@href')->map(function ($x) { return "http://www.csfd.cz$x"; }),
'points' => Matcher::single('td[3]')->asInt(),
'ratings' => Matcher::single('td[4]')->asInt(),
@dg
dg / output detector.php
Created June 20, 2013 18:59
How can I find out where my output started?
<?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);
@NoxArt
NoxArt / Keys.php
Created November 9, 2012 13:58
WebDriver key codes
<?php
class Keys {
const KEY_NULL = "\xEE\x80\x80";
const KEY_CANCEL = "\xEE\x80\x81";
const KEY_HELP = "\xEE\x80\x82";
const KEY_BACKSPACE = "\xEE\x80\x83";
const KEY_TAB = "\xEE\x80\x84";
const KEY_CLEAR = "\xEE\x80\x85";
const KEY_RETURN = "\xEE\x80\x86";
const KEY_ENTER = "\xEE\x80\x87";
@juzna
juzna / flow.md
Last active March 14, 2016 17:28
Cooperative Multitasking Components in Nette Framework example

Cooperative Multitasking, Components, Nette & Flow

On GitHub I provide example or Cooperative Multitasking components on a single site served by Nette Framework. These components need to process several network requests to render themselves, which is normally slow.

This example takes advantage of yield operator (available since PHP 5.5) to switch between tasks, Flow as scheduler and Rect as parallel http client.

This post introduces the Flow framework and cooperative multitasking in general.

The Example Application

@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]);
}
}
});