Skip to content

Instantly share code, notes, and snippets.

@tatsuhiro-t
tatsuhiro-t / mergesort.cc
Created November 7, 2017 15:17
Compile-time merge sort
#include <cstdint>
#include <type_traits>
#include <array>
#include <iostream>
#include <iterator>
template <int64_t... Args> struct Array {
const std::array<int64_t, sizeof...(Args)> data;
constexpr Array() : data{{Args...}} {}
};
@tatsuhiro-t
tatsuhiro-t / author.py
Created March 21, 2016 03:31
List up commit log author from git-log
#!/usr/bin/env python
# script to extract commit author's name from standard input. The
# input should be <AUTHOR>:<EMAIL>, one per line.
# This script expects the input is created by git-log command:
#
# git log --format=%aN:%aE
#
# This script removes duplicates based on email address, breaking a
# tie with longer author name. Among the all author names extract the
@tatsuhiro-t
tatsuhiro-t / tcp-client.c
Created January 30, 2016 16:06
TCP HTTP/2 client
/*
* nghttp2 - HTTP/2 C Library
*
* Copyright (c) 2016 Tatsuhiro Tsujikawa
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
@tatsuhiro-t
tatsuhiro-t / td.cc
Last active October 31, 2015 01:42
Describe data type in English
#include <iostream>
#include <cxxabi.h>
template <typename T> struct TypeDescriptor {};
// function
template <typename Ret, typename... Args>
std::ostream &operator<<(std::ostream &os,
const TypeDescriptor<Ret(Args...)> &td) {
return os << "function returning " << TypeDescriptor<Ret>();
#include <iostream>
#include <string>
#include <mutex>
#include <thread>
#include <future>
#include <deque>
#include <nghttp2/asio_http2_server.h>
using namespace nghttp2::asio_http2;
#include <iostream>
#include <string>
#include <mutex>
#include <thread>
#include <future>
#include <deque>
#include <nghttp2/asio_http2_server.h>
using namespace nghttp2::asio_http2;
#include <string>
#include <array>
#include <iostream>
// compile-time string from
// http://blog.biicode.com/template-metaprogramming-cpp-ii/
template <char... C> struct String {
static constexpr std::array<char, sizeof...(C)+1> data = {{C..., '\0'}};
constexpr operator const char *() const { return data.data(); }
};
@tatsuhiro-t
tatsuhiro-t / hexdump.c
Last active August 29, 2015 14:21
hexdump -C compatible output; useful for debugging
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#define HEXDUMP_MIN(X, Y) ((X) < (Y) ? (X) : (Y))
static void hexdump8(FILE *out, const uint8_t *first, const uint8_t *last) {
const uint8_t *stop = HEXDUMP_MIN(first + 8, last);
const uint8_t *k;
for(k = first; k != stop; ++k) {
@tatsuhiro-t
tatsuhiro-t / sample.rst
Created March 26, 2015 11:06
h2load against gRPC greeter_server

command-line:

$ h2load http://localhost:50051/helloworld.Greeter/SayHello \
      -d grpc-upload \
      -H 'te: trailers'
      -H 'content-type: application/grpc'
      -n1000000 -c100 -m100

Create grpc-upload file using following python script:

@tatsuhiro-t
tatsuhiro-t / bench-backend.conf
Last active August 4, 2017 17:24
HTTP/2 server benchmark Jan 2015
listen: 3001
http2-max-concurrent-requests-per-connection: 1024
max-connections: 15000
num-threads: 1
hosts:
localhost:
paths:
/:
file.dir: /path/to/htdocs