Skip to content

Instantly share code, notes, and snippets.

View jakubkulhan's full-sized avatar

Jakub Kulhan jakubkulhan

View GitHub Profile
@jakubkulhan
jakubkulhan / main.js
Created January 6, 2016 22:54
js event-stream head-of-line blocking
var EventStream = require('event-stream'),
i = 0;
process.stdin
.pipe(EventStream.map(function (req, cb) {
if (i++ % 2 === 0) {
setTimeout(function () {
cb(null, "" + req);
}, 5000);
@jakubkulhan
jakubkulhan / ClassDeclarationSniff.php
Last active October 10, 2018 06:43
Skrz Coding Standard
<?php
class Skrz_Sniffs_Classes_ClassDeclarationSniff implements PHP_CodeSniffer_Sniff
{
public function register()
{
return [T_CLASS, T_INTERFACE, T_TRAIT];
}
@jakubkulhan
jakubkulhan / rpc_client.php
Created June 2, 2015 21:00
BunnyPHP RPC example
<?php
namespace Example;
use Bunny\Channel;
use Bunny\Client;
use Bunny\Message;
use React\Promise\Deferred;
use React\Promise\PromiseInterface;
require_once __DIR__ . "/vendor/autoload.php";
@jakubkulhan
jakubkulhan / async_example.php
Created April 23, 2015 18:38
BunnyPHP Async Example
<?php
namespace Bunny\Example;
use Bunny\Async\Client;
use Bunny\Channel;
use React\EventLoop\Factory;
$loop = Factory::create();
$c = new Client($loop, [
<?php
$q = [
"query" => ["filtered" => [
"filter" => ["range" => [
"created" => ["gte" => "-31 days"],
]],
]],
"aggs" => [
"by_date" => ["date_histogram" => [
@jakubkulhan
jakubkulhan / gist:ac02cf43568d3156871f
Last active January 23, 2017 13:41
Redirect utm_* from QS to hash in Nginx
server {
# ...
location / {
set $utm_hash "";
if ($args ~* "^(.*&?)utm_source=([a-zA-Z0-9._-]*)(&(.*))?") {
set $args $1$4;
set $utm_hash "$utm_hash&utm_source=$2";
}
@jakubkulhan
jakubkulhan / db-benchmark.txt
Created April 26, 2014 13:25
Výsledky db-benchmark pro SkrzORM
SkrzORM | Time: 0.305 s | Memory: 10.7 MB | PHP: 5.5.10
NDB 2.0 | Time: 3.072 s | Memory: 14.0 MB | PHP: 5.5.10 | Nette: 2.0.14
NDB 2.1 | Time: 0.442 s | Memory: 13.7 MB | PHP: 5.5.10 | Nette: 2.1.2
NDB 2.2 | Time: 0.447 s | Memory: 13.7 MB | PHP: 5.5.10 | Nette: 2.2.x
Nextras\Orm | Time: 0.507 s | Memory: 19.5 MB | PHP: 5.5.10
NotOrm | Time: 0.900 s | Memory: 7.2 MB | PHP: 5.5.10
LeanMapper | Time: 0.393 s | Memory: 15.7 MB | PHP: 5.5.10
Doctrine2 | Time: 15.213 s | Memory: 32.4 MB | PHP: 5.5.10 | Doctrine: 2.4.1
@jakubkulhan
jakubkulhan / PlannerOptimalityTest.java
Last active August 29, 2015 13:57
planner optimality test (against reference results)
package cz.cvut.atg.zui.astar;
import eu.superhub.wp5.graphcommon.graph.Graph;
import eu.superhub.wp5.planner.planningstructure.GraphEdge;
import eu.superhub.wp5.planner.planningstructure.GraphNode;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
#lang scheme
(require rackunit)
(require rackunit/text-ui)
(define minimal-maze
'(
(w w w)
(w 0 w)
(w w w)
@jakubkulhan
jakubkulhan / some.file.js
Created March 5, 2014 01:24
js2php's usage example
console.log("hello, world!");