Skip to content

Instantly share code, notes, and snippets.

@kawa-
kawa- / ooc.c
Last active October 11, 2015 19:18
Object Oriented C lang
# just wrote them.
# ふと思いついたので書いてみた。これでOOPなCじゃんっていう。継承とか出来ないけど。
#include <stdio.h>
struct person {
double height;
double weight;
int age;
char* name;
@kawa-
kawa- / redis_all_key_value.php
Created May 19, 2013 04:46
Get all the key and values of Redis.
<?php
$redis = new Redis();
$redis->connect("localhost", 6379, 2.5); // 2.5 sec timeout.
$redis->flushAll();
$redis->set(uniqid("key_"), uniqid("key_value_1_"));
$redis->set(uniqid("key_"), uniqid("key_value_2_"));
$redis->set(uniqid("key_"), uniqid("key_value_3_"));
@kawa-
kawa- / generate_unique_pairs.php
Created July 24, 2014 10:21
MySQLでselectした結果があるかどうかをメソッド化し、さらに存在しない組み合わせを作成する
<?php
/* usage:
$ php generate_unique_pair.php 3
48881407 24892092
49164657 48309651
43192279 7385075
*/
define('NUM_PAIRS', $argv[1]);
@kawa-
kawa- / my.conf
Last active August 29, 2015 14:04
My my.conf for MySQL (fastest ever in my experience. approx. 100000 qps!)
# Kawa's config for MySQL
#
# Restrictions:
# - Debian
# - DRAM >= 32GB
# - MySQL 5.5
#
# Benchmark (Core i7-3820):
# $ mysqlslap --no-defaults --create-schema=SLAP --auto-generate-sql --auto-generate-sql-guid-primary --engine=InnoDB --number-int-cols=1 --number-char-cols=1 --concurrency=50 --auto-generate-sql-write-number=10000 --auto-generate-sql-execute-number=10000 --auto-generate-sql-load-type=key --iterations=3 --user=root --password=root --host=localhost --port=3306
# Benchmark
@kawa-
kawa- / generate_unique_pair.php
Created July 24, 2014 13:54
MySQLにアクセスして、ユニークなuserid, followerid, timestampを生成する。
<?php
# usage: $ php generate_unique_pair.php 10000 > unique_pairs.txt
define('NUM_PAIRS', $argv[1]);
define('MAX_USERS', 5000 * 10000);
$dbname = 'db01';
$host = 'localhost';
$user = 'root';
@kawa-
kawa- / insert_bench.pl
Created July 24, 2014 13:55
insertのベンチマークを取る。mybenchと組み合わせて使う。このgistの前のgenerate_unique_pair.phpでファイルを生成し、それを読み込んで実行。Redisの立ち上げが必須。
#!/usr/bin/perl -w
# usage : $ ./insert_bench.pl -n 100 -d db01 -t t01 -f ./script/unique_pairs.txt
use strict;
use MyBench;
use Getopt::Std;
use Time::HiRes qw(gettimeofday tv_interval);
use DBI;
use Redis;
@kawa-
kawa- / select_verbose.pl
Created July 24, 2014 14:22
有効なuseridの群のファイルを読み込んで、selectのベンチマークをする。verbose版。
#!/usr/bin/perl -w
# usage : $ ./select_verbose.pl -n 100 -r 1000 -d tw -t t1 -f users.txt
use strict;
use MyBench;
use Getopt::Std;
use Time::HiRes qw(gettimeofday tv_interval);
use DBI;
@kawa-
kawa- / select.pl
Created July 24, 2014 14:24
有効なuseridの群のファイルを読み込んで、selectのベンチマークをする。非verbose版。
#!/usr/bin/perl -w
# usage : $ ./select.pl -n 100 -r 1000 -d db01 -t t01 -f users.txt
use strict;
use MyBench;
use Getopt::Std;
use Time::HiRes qw(gettimeofday tv_interval);
use DBI;
@kawa-
kawa- / select_t11.pl
Created July 24, 2014 14:28
有効なuseridの群のファイルを読み込んで、selectのベンチマークをする。非verbose版。
#!/usr/bin/perl -w
# usage : $ ./select_t11.pl -n 100 -r 1000 -d tw -t t1 -f users.txt
use strict;
use MyBench;
use Getopt::Std;
use Time::HiRes qw(gettimeofday tv_interval);
use DBI;
@kawa-
kawa- / select_t11_verbose.pl
Created July 24, 2014 14:30
有効なuseridの群のファイルを読み込んで、selectのベンチマークをする。verbose版。
#!/usr/bin/perl -w
# usage : $ ./select_t11_verbose.pl -n 100 -r 1000 -d tw -t t1 -f users.txt
use strict;
use MyBench;
use Getopt::Std;
use Time::HiRes qw(gettimeofday tv_interval);
use DBI;