Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kelunik's full-sized avatar

Niklas Keller kelunik

View GitHub Profile
@kelunik
kelunik / Driver.php
Created December 22, 2016 10:53
Strict types sadness demo.
<?php
interface Driver {
public function set(callable $callback);
public function invoke($foo);
}
<?php
class DriverA implements Driver {
private $callback;
@kelunik
kelunik / remove-w3schools-from-google-search.user.js
Created December 9, 2014 13:52
Remove w3schools.com from Google Search results
// ==UserScript==
// @name Remove w3schools.com from Google
// @namespace https://www.kelunik.com
// @include https://www.google.com/*
// @include https://www.google.de/*
// @version 1
// @grant none
// ==/UserScript==
function forEach(list, callback) {
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/input.h>
#include <string.h>
#include <stdio.h>
static const char *evval[3] = {
"RELEASED",
@kelunik
kelunik / RespParser.php
Created June 6, 2017 11:19
A simple RESP parser based on Amp\Parser.
<?php
use Amp\Parser\Parser;
class RespParser extends Parser {
private $onResponse;
public function __construct(callable $onResponse) {
$this->onResponse = $onResponse;
parent::__construct($this->parse());
Kelunik\StreamingResp\IterativeRespParser: 0.526520 @ simpleString
Kelunik\StreamingResp\IterativeRespParser: 0.788227 @ bulkString
Kelunik\StreamingResp\IterativeRespParser: 1.780007 @ simpleArray
Kelunik\StreamingResp\IterativeRespParser: 3.999639 @ incompleteArray
Kelunik\StreamingResp\IterativeRespParser: 0.163905 @ clueDos
Kelunik\StreamingResp\RecursiveRespParser: 0.779131 @ simpleString
Kelunik\StreamingResp\RecursiveRespParser: 1.274417 @ bulkString
Kelunik\StreamingResp\RecursiveRespParser: 3.103048 @ simpleArray
Kelunik\StreamingResp\RecursiveRespParser: 7.358338 @ incompleteArray
Kelunik\StreamingResp\RecursiveRespParser: 0.329863 @ clueDos
#!/usr/bin/env bash
function is_browser {
local path=$1
local basename=$(basename $path)
if [[ $basename = "chromium-browser" ]]; then
return 1
fi
<?php
namespace Amp\Socket;
final class TlsContext {
const TLSv1_0 = \STREAM_CRYPTO_METHOD_TLSv1_0_SERVER;
const TLSv1_1 = \STREAM_CRYPTO_METHOD_TLSv1_1_SERVER;
const TLSv1_2 = \STREAM_CRYPTO_METHOD_TLSv1_2_SERVER;
private $minVersion = \STREAM_CRYPTO_METHOD_TLSv1_0_SERVER;
<?php
$opts = [
"http" => [
"header" => "User-Agent: kelunik"
]
];
$context = stream_context_create($opts);
<?php
# Benchmark for the cost of returning a new promise from then() for coroutines.
#
# - composer install
# - php bench.php
# - vi vendor/amphp/amp/lib/functions.php # remove 'done' branch --> https://git.io/v7NWW
# - php bench.php
require __DIR__ . "/vendor/autoload.php";

test tab not enter

*test *tab* not enter*