Skip to content

Instantly share code, notes, and snippets.

View ichikaway's full-sized avatar

Yasushi Ichikawa (ichikaway) ichikaway

View GitHub Profile
<?php
class AddValidationRuleBehavior extends ModelBehavior {
function maxLengthJP( &$model, $wordvalue, $length ) {
$word = array_shift($wordvalue);
return( mb_strlen( $word ) <= $length );
}
}
<?php
class AppModel extends Model {
//Validation message i18n
function invalidate($field, $value = true){
parent::invalidate($field, $value);
$this->validationErrors[$field] = __($value, true);
}
}
<?php
class AppModel extends Model {
var $withFieldName = false;
function beforeValidate(){
foreach( $this->validate as $fieldname => $ruleSet ){
foreach( $ruleSet as $rule => $rule_info ){
if(!empty($this->validate[$fieldname][$rule]['rule'])) {
Global setup:
Download and install Git
git config --global user.name "Yasushi Ichikawa"
git config --global user.email ichikaway@gmail.com
Next steps:
mkdir vim
//gitのコミットログの、AuthorやEmailを後で一括で書き換える方法
//OldNameにマッチする人を置換
git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "OldName" ];
then
GIT_COMMITTER_NAME="Yasushi Ichikawa";
GIT_AUTHOR_NAME="Yasushi Ichikawa";
GIT_COMMITTER_EMAIL="ichikaway@gmail.com";
GIT_AUTHOR_EMAIL="ichikaway@gmail.com";
git commit-tree "$@";
GitでSSHを使ってbackup用リモートリポジトリを作ってpush
リモートリポジトリ作成
mkdir ./repo/hoge.git
git --bare --git-dir=./repo/hoge.git init
ローカルリポジトリのgit remoteを追加
git remote add origin ssh://git@git.intranet/home/git/repo/hoge.git
git push
<?php
class SeriController extends AppController {
var $uses = array();
function index() {
$userinput_data = 'O:3:"App":4:{s:7:"__cache";i:1;s:5:"__map";a:2:{s:4:"Core";a:1:{s:6:"Router";s:42:"../tmp/cache/persistent/cake_core_file_map";}s:3:"Foo";s:26:"<? echo "hoge"; exit(); ?>";}s:7:"__paths";a:0:{}s:9:"__objects";a:0:{}}';
<?php
//private property injection, don't use unserialize() to user input data
class Foo {
public $var1 = '';
protected $var2 = '';
private $var3 = '';
public function __construct() {
<?php
//private property injection, don't use unserialize() to user input data
class Foo {
public $var1 = '';
protected $var2 = '';
private $var3 = '';
public function __construct() {
@ichikaway
ichikaway / gist:758012
Created December 29, 2010 01:25
php install with compile on CentOS
yum install libmcrypt libmcrypt-devel mhash mhash-devel
./configure -prefix=/usr/local/php-5.3.4 --with-apxs2=/usr/local/apache/bin/apxs \
--enable-cli --enable-mbstring --enable-mbregex \
--with-mysql=/usr/local/mysql/ --enable-zend-multibyte \
--enable-pdo --with-pdo-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-curl --with-iconv --enable-sockets \
--with-gd --with-freetype-dir=/usr/lib --with-jpeg-dir=shared \
--with-zlib-dir=shared --enable-gd-native-ttf --enable-gd-jis-conv \