Skip to content

Instantly share code, notes, and snippets.

View repeatedly's full-sized avatar

Masahiro Nakagawa repeatedly

View GitHub Profile
require 'benchmark'
hash = { a: 1, b: 2, c: 3 }
keys = %i[a c d]
hash_proc = hash.to_proc
n = 500000
Benchmark.bmbm do |x|
x.report('&hash') { n.times do
@repeatedly
repeatedly / in_fast_regexp_tail.rb
Created November 10, 2015 08:25
Faster in_tail implementation for regexp format
module Fluent
require 'fluent/plugin/in_tail'
require 'fluent/parser'
class FastRegexpTailInput < TailInput
Plugin.register_input('fast_regexp_tail', self)
include TextParser::TypeConverter
def configure_parser(conf)
require 'benchmark'
require 'ostruct'
#
#% ruby bench_filter.rb
#Rehearsal -------------------------------------------------------
#placeholder 0.120000 0.000000 0.120000 ( 0.128608)
#ruby placeholder 0.550000 0.000000 0.550000 ( 0.548257)
#dynamic placeholder 0.190000 0.000000 0.190000 ( 0.196362)
#---------------------------------------------- total: 0.860000sec
@repeatedly
repeatedly / benchmark.d
Last active October 25, 2015 02:48
TinySegmenter written in D
// Written in the D programming language.
import std.datetime;
import std.stdio;
import std.conv;
import std.file;
import tinysegmenter;
void main()
@repeatedly
repeatedly / gist:82b9d1b2130fcaf03433
Last active September 4, 2015 11:27 — forked from yfakariya/gist:fb6d5c66fa4d8a82346b
Spec draft for embedding type information

Purpose 目的

Make .NET to .NET serialization more easily by embedding type information. Interoperability should be considered as possible. 型情報を埋め込むことで、.NET どうしのシリアライズをもっと楽にする。相互運用性は可能な限り考慮されるべき。

Usecase ユースケース

  1. Serialize polimorphic collection (issue #58) ポリモーフィックなコレクションをシリアライズする
  2. Serialize 'rich' domain model which has own data and logic (issue #47)
■最初のtd-agent.conf
<source>
type dstat
tag dstat
option -lcn
delay 5
</source>
<match dstat>
type copy
@repeatedly
repeatedly / pg_gem_install.sh
Created November 28, 2014 08:17
pg gem installation script for td-agent 2
sudo apt-get install -y build-essential
sudo apt-get build-dep -y postgresql
wget http://ftp.postgresql.org/pub/source/v9.2.8/postgresql-9.2.8.tar.gz
tar -zxvf postgresql-9.2.8.tar.gz
cd postgresql-9.2.8
export MAJOR_VER=9.2
./configure \
--prefix=/opt/td-agent/embedded \
--mandir=/opt/td-agent/embedded/share/postgresql/${MAJOR_VER}/man \
--docdir=/opt/td-agent/embedded/share/doc/postgresql-doc-${MAJOR_VER} \
@repeatedly
repeatedly / template_engine_night.md
Created October 17, 2014 12:35
テンプレートエンジンnight

D言語の話

テンプレートエンジン書くのに便利な機能がいくつかある.

CTFE

コンパイル時に関数が実行出来る.標準ライブラリの有名所は大抵コンパイル時にも動く(std.algorithm, std.range, std.string, etc...).

import std.random, std.stdio;
@repeatedly
repeatedly / compare_json_libraries.d
Created October 4, 2014 11:52
yajl-d, std.json, vibe.data.json comparison
import yajl;
import vibe.data.serialization;
import vibe.data.json;
import std.datetime;
import std.stdio;
import std.json;
import std.traits, std.typecons;
static struct Handa
@repeatedly
repeatedly / filter.md
Last active August 29, 2015 14:06
Fluentd v0.12 Filter API