Skip to content

Instantly share code, notes, and snippets.

#include <cstdio>
#include <math.h>
class C {
public:
C() {}
C(double) { printf("hello world\n"); }
};
int main(int argc, char** argv)
@kazuho
kazuho / gist:425469503fb6125c3d47
Created July 10, 2014 02:12
C++ template-like dependency injection in Java
package test;
interface Wrap {
static interface Builder {
public <T> Wrap build(T o);
}
public void say();
}
public class Test {
$ perl -I../SQL-Maker/lib -MSQL::Maker -e 'warn $SQL::Maker::VERSION'
1.15 at -e line 1.
$ perl -I../SQL-Maker/lib -Ilib t/002_common/001_insert.t
# Subtest: insert mock_basic data/ insert method
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@ Teng 's Exception @@@@@
Reason : DBD::SQLite::st execute failed: datatype mismatch at lib/Teng.pm line 277.
SQL : INSERT INTO "mock_basic"
("name", "id")
@kazuho
kazuho / gist:0df08d52802376feafe6
Last active August 29, 2015 14:05
s.y becomes corrupt when compiled with -O2 using clang 503-0.40 (Xcode 5.1)
#include <stddef.h>
#include <stdio.h>
typedef struct {
size_t x;
size_t y;
} S;
static S next(S s)
{
num-threads: 4
port: 8080
files:
/: examples/doc_root
request-timeout: 10
mime-types:
txt: text/plain
html: text/html
gif: image/gif
png: image/png
@kazuho
kazuho / gist:98dad12310c629f488d2
Last active August 29, 2015 14:06
trusterd SEGV on /usr/local/http2-14/bin/nghttp http://127.0.0.1:8080/
$ uname -a
Linux ubuntu1404 3.13.0-35-generic #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ ls -l htdocs/
total 4
-rw-rw-r-- 1 kazuho kazuho 6 Sep 19 18:30 index.html
$ git diff conf/
diff --git a/conf/trusterd.conf.rb b/conf/trusterd.conf.rb
index 0f39292..9570e09 100644
--- a/conf/trusterd.conf.rb
+++ b/conf/trusterd.conf.rb
$ uname -a
Linux ubuntu1404 3.13.0-35-generic #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ cat gt.c
#include <stddef.h>
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
int main(int argc, char **argv)
{
$ cat gt.c
#include <pthread.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
static void *doit(void* _unused)
{
diff --git a/examples/simple.c b/examples/simple.c
index ae359b9..3391f34 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -208,14 +208,12 @@ int main(int argc, char **argv)
#endif
/* disabled by default: uncomment the block below to use HTTPS instead of HTTP */
- /*
ssl_ctx = h2o_ssl_new_server_context("server.crt", "server.key", h2o_http2_tls_identifiers);
@kazuho
kazuho / gist:1f64c62e5f059954ead2
Created October 2, 2014 01:06
converting an IPv4 address to string would become x7.6 faster if the format string of sprintf was parsed at compile-time
$ cat ipv4addr.c
#include <stdio.h>
struct ct_printf_t {
char *str;
size_t off;
};
struct ct_printf_t ct_printf_init(char *str)
{