Skip to content

Instantly share code, notes, and snippets.

View kelunik's full-sized avatar

Niklas Keller kelunik

View GitHub Profile
@kelunik
kelunik / github-default-issue-list.userscript.js
Created September 22, 2016 10:36
GitHub Default Issue List
// ==UserScript==
// @name GitHub Default Issue List
// @namespace http://tampermonkey.net/
// @version 0.1
// @description GitHub Default Issue List
// @author Niklas Keller <me@kelunik.com>
// @match https://github.com/*
// @grant none
// ==/UserScript==
@kelunik
kelunik / php-parameter-variance.md
Last active November 14, 2016 15:43
PHP Parameter Variance
@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;
#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",
#!/usr/bin/env bash
function is_browser {
local path=$1
local basename=$(basename $path)
if [[ $basename = "chromium-browser" ]]; then
return 1
fi
@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
<?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";