Skip to content

Instantly share code, notes, and snippets.

View yannick's full-sized avatar
🏗️

Yannick Koechlin yannick

🏗️
View GitHub Profile
import std.stdio;
import mruby;
import mruby.compile;
import mruby.value;
import mruby.data;
import mruby.mrb_class;
import mruby.value;
import std.string;
import std.conv;
#mruby ghetto PORT from https://ruby-doc.org/stdlib-1.9.3/libdoc/cgi/rdoc/CGI.html#method-c-parse
module CGI
def self.parse(query)
params = {}
query.split(/[&;]/).each do |pairs|
key, value = pairs.split('=',2).collect{|v| CGI::unescape(v) }
if key && value
params.has_key?(key) ? params[key].push(value) : params[key] = [value]
elsif key
params[key]=[]

dynamic configuration.

as discussed in slack i've written down my thoughts on a more dynamic config and what it could be good for to open the discussion. depending on the inputs i'd be happy to research more.

rationale

as more and more setups use cluster orchestration frameworks (such as e.g. kubernetes), h2o makes an excellent candidate for a loadbalancer / ingress controler. however in this type of setup, whenever a new new service is deployed the loadbalancer needs to be quickly updated

# Maintainer: Yannick Koechlin <yannick.koechlin@tamedia.ch>
pkgname=h2o-future
pkgver=r3959.4bc17f98
pkgrel=1
pkgdesc="Optimized HTTP server with support for HTTP/1.x and HTTP/2. git version with extra gems"
arch=('i686' 'x86_64')
depends=('libuv' 'libyaml' 'wslay' 'zlib' 'sqlite3' 'leveldb' 'hiredis' 'librdkafka-git' 'nghttp2' 'curl' 'mbedtls')
makedepends=('cmake' 'libtool' 'make' 'pkg-config' 'ruby')
url="https://github.com/h2o/h2o"
{"protocol":"HTTP/2","duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.117438}
{"protocol":"HTTP/2","duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.185187}
{"protocol":"HTTP/2","duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.09811}
{"protocol":"HTTP/2","duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.070657}
{"protocol":"HTTP/2","duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.091246}
{"protocol":"HTTP/2","duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.071971}
{"protocol":"HTTP/2","duration":0.000253,"processTime":0.000253,"requestTotalTime":0,"connectTime":0.092566}
{"protocol":"HTTP/2","duration":0.000123,"processTime":0.000123,"requestTotalTime":0,"connectTime":0.150442}
{"protocol":"HTTP/2","duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.249123}
{"protocol":"HTTP/2","duration":9.8e-05,"processTime":9.8e-05,"requestTotalTime":0,"connectTime":0.020246}
{"duration":0.000193,"processTime":0.000193,"requestTotalTime":0,"connectTime":0.060501}
{"duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.208037}
{"duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.173926}
{"duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.180362}
{"duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.102043}
{"duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.022843}
{"duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.148757}
{"duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.112583}
{"duration":0.000152,"processTime":0.000152,"requestTotalTime":0,"connectTime":0.118244}
{"duration":0,"processTime":0,"requestTotalTime":0,"connectTime":0.025949}
diff --git a/lib/core/logconf.c b/lib/core/logconf.c
index 1f8b30d8..b1b85e4f 100644
--- a/lib/core/logconf.c
+++ b/lib/core/logconf.c
@@ -34,6 +34,7 @@ enum {
ELEMENT_TYPE_METHOD, /* %m */
ELEMENT_TYPE_LOCAL_PORT, /* %p, %{local}p */
ELEMENT_TYPE_REMOTE_PORT, /* %{remote}p */
+ ELEMENT_TYPE_ENV_VAR, /* %{..}e */
ELEMENT_TYPE_QUERY, /* %q */
class Gist
def initialize
@redis = H2O::Redis.new(:host => 'localhost', :port => 6379)
end
#ghetto parser
def query_params(q)
return Hash[q.split("&").map{|combo| combo.split("=") }]
@yannick
yannick / gist:b0be23f5de1048565fc2bb86ab308cea
Created January 16, 2017 14:44 — forked from ericbmerritt/gist:4013729
A script to generate a valid semver version in any git repo
#!/bin/bash
#
# If run inside a git repository will return a valid semver based on
# the semver formatted tags. For example if the current HEAD is tagged
# at 0.0.1, then the version echoed will simply be 0.0.1. However, if
# the tag is say, 3 patches behind, the tag will be in the form
# `0.0.1+build.3.0ace960`. This is basically, the current tag a
# monotonically increasing commit (the number of commits since the
# tag, and then a git short ref to identify the commit.
#
@yannick
yannick / analyze-json.py
Created January 10, 2017 07:41
sketch of a json analyzer
#!/usr/bin/env python3
import ujson as j
from collections import defaultdict as ddict
class NodeCounter(object):
def __init__(self, name):
self.name = name
self.counter = 0