Skip to content

Instantly share code, notes, and snippets.

View cubicdaiya's full-sized avatar

Tatsuhiko Kubo cubicdaiya

View GitHub Profile
@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 / 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 / count_cpunum.sh
Created June 24, 2014 02:23
Counting CPU numbers
#!/bin/sh
cat /proc/cpuinfo | egrep "^processor" | wc -l
@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 / tmp_nginx.conf
Created January 7, 2015 13:28
/tmp for nginx.conf
server {
listen 80;
root /tmp;
}
@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 / 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/
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);
#define PREFIX_FREE(p) \
do { \
free(p); \
(p) = NULL; \
} while(false)
function round(num)
return math.floor(num+.5)
end