Skip to content

Instantly share code, notes, and snippets.

View mattn's full-sized avatar
🍛
I love curry 🍛

mattn mattn

🍛
I love curry 🍛
View GitHub Profile
@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)
{
anonymous
anonymous / gist:19bbb1eadf4f1c6bd761
Created June 26, 2014 07:52
pecoで履歴からマッチするキーワードをその場に補完
function in_place_history_keyword_completion() {
pos=CURSOR # 現在のカーソル位置を取得
selected=$(history -10000 | cut -d' ' -f3- | tr '|' ' ' | tr ' ' '\n' | sort -u | peco) # 選択した結果
BUFFER="${BUFFER[1,$pos]}${selected}${BUFFER[$pos,-1]}"
CURSOR=$#BUFFER # move cursor
zle -R -c # refresh
}
zle -N in_place_history_keyword_completion
bindkey '^R' in_place_history_keyword_completion
@hail2u
hail2u / escape-url.patch
Created June 19, 2014 01:37
Escape `$url` before processing `head.flavour`
diff --git blosxom.cgi blosxom.cgi
index 8ffe7ae..0fb7041 100755
--- blosxom.cgi
+++ blosxom.cgi
@@ -764,6 +764,30 @@ sub generate {
}
}
+ # Save unescaped versions and allow them to be used in flavour
+ # templates.
#!/bin/sh
PATH=$HOME/homebrew/bin:$PATH
if [ -n "$TMUX" ]; then
echo "already in tmux session!!"
exit
fi
HELPER_RUNNING=$(ps aux | grep "[u]im-tmux-helper" 2>/dev/null)
#!/usr/bin/env perl
# crontab -l | ./cron2cal > ~/tmp/cron.csv
use utf8;
use strict;
use warnings;
use Encode;
use DateTime;
"loadavg5",
"memory.total",
"memory.free",
"memory.buffers",
"memory.cached",
"memory.swap_cached",
"memory.active",
"memory.inactive",
"memory.swap_total",
"memory.swap_free",
// Package lex implements the lexical scanner for Suneido
package lex
import (
"bytes"
"strings"
"unicode"
"unicode/utf8"
)
@gnue
gnue / Dockerfile
Last active August 29, 2015 13:56
goreman を使って docker で複数プロセスを起動する
# sshd+nginx
#
# VERSION 0.0.1
FROM ubuntu
RUN apt-get update
# sshd
RUN apt-get install -y openssh-server
@miura1729
miura1729 / gist:8333119
Created January 9, 2014 12:07
fib 39のプロファイル mrbjit_exec_send_mrubyはcallinfo構築、 mrbjit_exec_return_fastはcallinfoから復帰のためのCの関数で生成された機械語コードからCのABIを合わせて呼び出される
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ns/call ns/call name
43.44 4.98 4.98 mrbjit_exec_send_mruby
29.57 8.37 3.39 mrbjit_exec_return_fast
13.26 9.89 1.52 _mcount_private
13.00 11.38 1.49 204668284 7.28 7.28 mrbjit_cipush
0.74 11.46 0.09 _fentry__
@lestrrat
lestrrat / perl-go-stf-benchmark.md
Created December 10, 2013 04:55
Simple benchmark against STF Distribute Object Storage written in Perl and in Go

STF Distribute Object Storage (perl vs go)

This is a VERY limited benchmark. Take with a grain of salt. (go-stf-server)[https://github.com/stf-storage/go-stf-server] is still in half baked state, but can connect to the same database as the more mature (perl version)[https://github.com/stf-storage/stf], and handle GET requests.

And since the go version is still half-baked, this benchmark is for GET only.

Basic benchmark strategy

The original STF dispatcher PSGI application is running behind nginx reverse proxy on the same host, which handles the reproxying via X-Reproxy-URL. In this benchmark, I'm just sending GET requests directly to port 5000 (PSGI), and port 8080 (go) on the localhost via ab: