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:758124
Created December 29, 2010 03:33
How to install phpunit for cake
#!/bin/sh
#put this shellcode on cake vendors directory, then do it.
# origin code from http://cakephp.lighthouseapp.com/projects/42648/phpunit-migration-hints
mkdir -p ~/tmp/cake_phpunit
wget --no-check-certificate https://github.com/sebastianbergmann/phpunit/tarball/3.5.5 -O ~/tmp/cake_phpunit/phpunit.tgz
wget --no-check-certificate https://github.com/sebastianbergmann/phpunit-mock-objects/tarball/1.0.3 -O ~/tmp/cake_phpunit/mock_objects.tgz
wget --no-check-certificate https://github.com/sebastianbergmann/php-code-coverage/tarball/1.0.2 -O ~/tmp/cake_phpunit/code_coverage.tgz
@ichikaway
ichikaway / gist:758214
Created December 29, 2010 05:27
upgrade PCRE for CentOS(32bit) using unicode-properties
# wget ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/SRPMS/pcre-6.6-2.el5_1.7.src.rpm
# rpm -ivh pcre-6.6-2.el5_1.7.src.rpm
# vi /usr/src/redhat/SPECS/pcre.spec
%configure --enable-utf8 --enable-unicode-properties
# rpmbuild -ba /usr/src/redhat/SPECS/pcre.spec
# rpm -Uvh /usr/src/redhat/RPMS/i386/pcre-6.6-2.7.i386.rpm /usr/src/redhat/RPMS/i386/pcre-devel-6.6-2.7.i386.rpm
@ichikaway
ichikaway / KioskSample.php
Created February 10, 2011 08:07
Kioskの超シンプル版 Mongo編
<?php
// https://github.com/basuke/kiosk
//いつものw
function pr($data) {
echo "<pre>";
print_r($data);
echo "</pre>";
@ichikaway
ichikaway / gist:1164596
Created August 23, 2011 07:49
add conditions
$this->logQuery("db.{$Model->useTable}.update( :conditions :fields, :params )",
array('conditions' => $conditions, 'fields' => $fields, 'params' => array("multiple" => true))
@ichikaway
ichikaway / gist:1172839
Created August 26, 2011 06:39
protection of DOS attack
@ichikaway
ichikaway / gist:1252431
Created September 30, 2011 01:29
phpThumbセキュリティ設定
外部画像のサムネイル禁止、画像サイズ上限設定
phpThumb.config.php
<?php
$PHPTHUMB_CONFIG['cache_maxsize'] = 1024 * 1024 * 1024; //キャッシュ画像全体の上限容量 1Gbyte
$PHPTHUMB_CONFIG['output_maxwidth'] = 1000;
$PHPTHUMB_CONFIG['output_maxheight'] = 1000;
$PHPTHUMB_CONFIG['nohotlink_enabled'] = true; //外部画像のサムネイル禁止
@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"
@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: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: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