Skip to content

Instantly share code, notes, and snippets.

View ichikaway's full-sized avatar

Yasushi Ichikawa (ichikaway) ichikaway

View GitHub Profile
@ichikaway
ichikaway / gist:3291004
Created August 8, 2012 00:48
put current branch name on input cursor(need bash version 4)
bind -x '"\C-o": READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}
`git symbolic-ref HEAD | cut -d/ -f 3` ${READLINE_LINE:${READLINE_POINT}}"'
@ichikaway
ichikaway / gist:3129900
Created July 17, 2012 14:59
check copy on write of PHP
<?php
$GLOBALS['memstart'] = memory_get_usage();
function mem() {
$m2 = memory_get_usage();
echo $m2 - $GLOBALS['memstart'] ."\n";
}
class Foo {
public function bar($x = null){
@ichikaway
ichikaway / gist:2768801
Created May 22, 2012 12:37
RecursiveIteratorIterator example
<?php
Class TableRII extends RecursiveIteratorIterator {
private $parentKey = null;
public function beginIteration() {
echo '<table border=1><tr><th>key</th><th>value</th></tr>';
}
public function endIteration() {
echo '</table>';
@ichikaway
ichikaway / gist:1832549
Created February 15, 2012 02:11
stream wrapper for variable input
<?php
/**
* stream wrapper for variable input
* usage:
* $val = 'Hello <?php echo "World"; ?> hehe.';
* stream_wrapper_register("var", "VariableStream");
* include("var://".urlencode($val));
**/
class VariableStream {
public $position;
@ichikaway
ichikaway / gist:1633368
Created January 18, 2012 14:58
/etc/rc.d/init.d/onMemoryMySQL
#!/bin/bash
#
# Startup script for onMemoryMySQL
# chkconfig: 345 85 15
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/usr/bin:/bin
test -f /root/onMemoryDeploy.sh || exit 0
@ichikaway
ichikaway / gist:1633366
Created January 18, 2012 14:57
/root/onMemoryDeploy.sh
#!/bin/sh
MYSQL=/etc/rc.d/init.d/mysql
MEMDIR=/dev/shm
MEM_MYSQL=$MEMDIR/mysql
LIBDIR=/var/lib
ORIGDIR=$LIBDIR/mysql
@ichikaway
ichikaway / gist:1470366
Created December 13, 2011 03:19
CakePHP2 performance test
normal view.ctp
102 req/sec 2,191calls 15,892 microsecs
-------------------------------
normal index.ctp&default.ctp
40 req/sec
turn off Html->link() on default layout
40 req/sec
@ichikaway
ichikaway / gist:1366429
Created November 15, 2011 08:01
Network transfer measurement
Receiver
nc -l 12345 > hoge
Sender
dd if=/dev/zero of=tempfile bs=1M count=100
time `cat tempfile | nc ReceiverServer 12345`
@ichikaway
ichikaway / gist:1366383
Created November 15, 2011 07:20
result of bonnie++ on SakuraCloud(2G mem plan)
Version 1.96 ------Sequential Output------ --Sequential Input- --Random-
Concurrency 1 -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
test01 4G 998 99 141803 11 115324 17 5078 100 818801 54 3965 119
Latency 10256us 256ms 405ms 2910us 1170us 14621us
Version 1.96 ------Sequential Create------ --------Random Create--------
test01 -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP
16 321 1 +++++ +++ 447 1 333 1 +++++ +++ 449 3
Latency 268ms 380us 91615us 189ms 463us 83468us
@ichikaway
ichikaway / gist:1256946
Created October 2, 2011 02:11
git pull manager
#!/bin/sh
CMDPATH=/usr/local/git/bin/
CMD=git
test -f $CMDPATH$CMD || exit 0
REPO_hoge_app="/usr/local/deploy/git/hoge"
REPO_hoge_app2="/usr/local/deploy/git/hoge2"