Skip to content

Instantly share code, notes, and snippets.

View tagomoris's full-sized avatar

Satoshi Tagomori tagomoris

View GitHub Profile
@tagomoris
tagomoris / apachelog_tsv_bench.pl
Created February 8, 2011 07:49
dankogaiスクリプト tsv の処理対象を $tsv に変えただけ
#!/usr/local/bin/perl
# original: http://blog.livedoor.jp/dankogai/archives/50924886.html
use strict;
use warnings;
use Benchmark qw/timethese cmpthese/;
my $logline =
q{localhost.local - - [04/Oct/2007:12:34:56 +0900] "GET /apache_pb.gif HTTP/1.1" 200 2326 "http://www.dan.co.jp/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7"};
#!/usr/bin/env perl
use local::lib "./extlib/";
use Thrift;
use Thrift::Socket;
use Thrift::BufferedTransport;
use Thrift::BinaryProtocol;
use ThriftHive;
my $socket = Thrift::Socket->new("localhost", 10000);
@tagomoris
tagomoris / ldap_idle_test.rb
Created March 29, 2011 03:09
ldap接続を15分前後アイドルにして、その次のクエリが失敗するかどうかのテスト
#!/usr/bin/env ruby
require 'ldap'
SERVER_NAME = '192.168.0.128'
SERVER_PORT = 389
AUTH_DN = 'cn=binduser,cn=Users,dc=ad,dc=livedoor,dc=intranet'
AUTH_PASS = 'yourpassword'
def connection
@tagomoris
tagomoris / kc_test.js
Created April 6, 2011 10:11
set/append/get performance test script of kyoto-client
// test for kyoto-client.js
var crypto = require('crypto');
var randomSelect = function(array){
return Math.floor(Math.random() * array.length);
};
var makedata = function(times){
var seed = 'abcdefghijklmnopqrstuvwxyz012345'; //32bytes
var thrift = require('thrift'),
ttransport = require('thrift/transport'),
ThriftHive = require('gen-nodejs/ThriftHive');
var connection1 = thrift.createConnection("localhost", 10000, {transport: ttransport.TBufferedTransport, timeout: 1*1000}),
client1 = thrift.createClient(ThriftHive, connection1);
var connection2 = thrift.createConnection("localhost", 10000, {transport: ttransport.TBufferedTransport, timeout: 1*1000}),
client2 = thrift.createClient(ThriftHive, connection2);
connection1.on('error', function(err){ console.error(err); });
var thrift = require('thrift'),
ttransport = require('thrift/transport'),
ThriftHive = require('gen-nodejs/ThriftHive');
var connection1 = thrift.createConnection("localhost", 10000, {transport: ttransport.TBufferedTransport, timeout: 1*1000}),
client1 = thrift.createClient(ThriftHive, connection1);
var connection2 = thrift.createConnection("localhost", 10000, {transport: ttransport.TBufferedTransport, timeout: 1*1000}),
client2 = thrift.createClient(ThriftHive, connection2);
connection1.on('error', function(err){ console.error(err); });
var thrift = require('thrift'),
ttransport = require('thrift/transport'),
ThriftHive = require('gen-nodejs/ThriftHive');
var connection1 = thrift.createConnection("localhost", 10000, {transport: ttransport.TBufferedTransport, timeout: 1*1000}),
client1 = thrift.createClient(ThriftHive, connection1);
var connection2 = thrift.createConnection("localhost", 10000, {transport: ttransport.TBufferedTransport, timeout: 1*1000}),
client2 = thrift.createClient(ThriftHive, connection2);
connection1.on('error', function(err){ console.error(err); });
@tagomoris
tagomoris / md_sync_call.sh
Created April 20, 2011 06:33
Run "check" about specified md device if it's status is "idle"
#!/bin/sh
TARGET_MD=$1
### call md verifying when idle.
######
# HOW TO USE
### md_sync_call.sh md0
error_exit() {
@tagomoris
tagomoris / gist:1252572
Created September 30, 2011 03:32
strace of fluentd (with in_scribe) dropped into busy loop...
epoll_wait(57, {}, 64, 0) = 0
clock_gettime(CLOCK_MONOTONIC, {8098696, 447030916}) = 0
futex(0x1178c68, FUTEX_WAIT_PRIVATE, 2, NULL) = 0
futex(0x1178c68, FUTEX_WAIT_PRIVATE, 2, NULL) = 0
futex(0x1178c68, FUTEX_WAIT_PRIVATE, 2, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x1178c68, FUTEX_WAKE_PRIVATE, 1) = 1
clock_gettime(CLOCK_MONOTONIC, {8098696, 448022916}) = 0
epoll_wait(57, {}, 64, 0) = 0
clock_gettime(CLOCK_MONOTONIC, {8098696, 448186916}) = 0
futex(0x1178c68, FUTEX_WAIT_PRIVATE, 2, NULL) = 0
@tagomoris
tagomoris / gist:1300534
Created October 20, 2011 06:07
Encode::decode_utf($str, 1) bug?
use Data::Dumper;
my $x = {1 => "ichi", 2 => "ni"};
warn Dumper $x;
{
use Encode;
my $decoded = Encode::decode_utf8($x->{1}, 1);
local $x->{1} = $decoded;
warn Dumper $x;
}
warn Dumper $x;