Skip to content

Instantly share code, notes, and snippets.

View cubicdaiya's full-sized avatar

Tatsuhiko Kubo cubicdaiya

View GitHub Profile
@cubicdaiya
cubicdaiya / colorized-unidiff.patch
Created October 22, 2015 23:54
colorized unidiff
--- unidiff.cpp 2015-10-23 08:47:36.000000000 +0900
+++ unidiffcolor.cpp 2015-10-23 08:51:06.000000000 +0900
@@ -14,6 +14,61 @@
using dtl::Diff;
using dtl::elemInfo;
using dtl::uniHunk;
+using dtl::SES_ADD;
+using dtl::SES_DELETE;
+using dtl::SES_COMMON;
+using dtl::Printer;
diff --git a/lib/common/time.c b/lib/common/time.c
index 5308848..dab3c24 100644
--- a/lib/common/time.c
+++ b/lib/common/time.c
@@ -139,7 +139,11 @@ void h2o_time2str_log(char *buf, time_t time)
{
struct tm localt;
localtime_r(&time, &localt);
+#if HAVE_TM_GMTOFF
int gmt_off = (int)(localt.tm_gmtoff / 60);
@cubicdaiya
cubicdaiya / bench_memo.md
Last active August 29, 2015 14:18
nginx benchmark

環境

  • nginx-1.7.11
  • c4.8xlarge

ベンチマークコマンド

./wrk -c 100 -t 10 -d 10 http://127.0.0.1/
@cubicdaiya
cubicdaiya / benchmark
Last active August 29, 2015 14:15
JSON encode/decode benchmark with encoding/json and ugorji/go/codec
$ go test -bench . -benchtime 1s
PASS
BenchmarkMarshal 500000 2989 ns/op
BenchmarkCodecJsonBufEncode 1000000 2245 ns/op
BenchmarkCodecJsonIOEncode 1000000 2376 ns/op
$
@cubicdaiya
cubicdaiya / tmp_nginx.conf
Created January 7, 2015 13:28
/tmp for nginx.conf
server {
listen 80;
root /tmp;
}
@cubicdaiya
cubicdaiya / epoch2datetime.py
Created August 14, 2014 14:07
epoch2datetime
ts_epoch = time.time()
ts = datetime.datetime.fromtimestamp(ts_epoch).strftime('%Y-%m-%d %H:%M:%S')
print ts
@cubicdaiya
cubicdaiya / count_cpunum.sh
Created June 24, 2014 02:23
Counting CPU numbers
#!/bin/sh
cat /proc/cpuinfo | egrep "^processor" | wc -l
@cubicdaiya
cubicdaiya / post-commit
Created June 4, 2014 01:02
checking go fmt by git-hook
#!/bin/bash
echo "go fmt ./..." $'\n'
result=`go fmt ./...`
if [ "$result" != "" ];
then
msg="You forgot to execute 'go fmt' to the following files"
if [ `uname` = "Darwin" ]; then
echo $'\e[31m'$msg$'\e[m' $'\n'
@cubicdaiya
cubicdaiya / nginxV.py
Last active August 29, 2015 14:00
formater for `nginx -V`
# -*- coding: utf-8 -*-
import commands
def nginxV_except_configure_args():
return commands.getoutput('nginx -V 2>&1 | grep -v "configure arguments:" ')
def nginxV_only_configure_args():
return commands.getoutput('nginx -V 2>&1 | grep "configure arguments:" ')
@cubicdaiya
cubicdaiya / hoge.c
Last active August 15, 2021 14:04
mruby example
#include <stdio.h>
#include <mruby.h>
#include <mruby/proc.h>
#include <mruby/data.h>
#include <mruby/compile.h>
#include <mruby/string.h>
#include <mruby/hash.h>
#include <mruby/variable.h>
static struct RProc *compile(mrb_state *mrb, const char *path)