Author Archive

Auto reload .vimrc 自动加载 .vimrc

Tuesday, June 15th, 2010
 :source ~/.vimrc 

数据库读写分离(Master/Slave)

Wednesday, April 7th, 2010

研究中

Google: new approach to china

Wednesday, March 24th, 2010

啥都不说,看图说话

转战mac平台

Monday, March 22nd, 2010

通过了mac port 搭建了自己满意的lamp开发平台,一切尽在掌握中~

世子赋

Saturday, March 20th, 2010
风流少年时 笑看浮生变 神仙府里赛神仙 谈笑江湖间
醉卧美人膝 醒掌天下权 乱世风云出我辈 金戈峥嵘归
玉盏琉璃杯 绫罗飞天绘 酒不醉人人自醉 暖帐芙蓉被
拨花弄柳月 行走无常间 左拥右抱岂是罪 惹尽芳心也累累累
琴瑟回 轻鸿飞 秋水星眸 幽幽舞 衣掩 娇媚
桃花魅 清风醉 古壁凝尘 芳菲绵绵相思泪
暗流风乍起 修罗意阑珊 红袖别苑藏玄机 誓忠轩辕王
犹冀凌云志 冥冥眷红尘 庙堂之高伤神事 云龙御平尘
别离伤幽肠 长乐少年狂 傲雪霜冷尤清艳 焚梅念故人
风流徒枉然 世事话无常 痴心未曾两相忆 潇洒为红颜狂狂狂
风憔悴 心难慰 十载春秋 唯守庵 外度 春晖
无尘泪 雨愁倍 万丈红尘 如殇笑眼看定王

学吉他的终极目标

Friday, December 18th, 2009

久石让的吉他独奏 天空之城

PHP编辑器VIM

Tuesday, December 15th, 2009

我的php编辑器:vim(windows or linux), macvim(mac osx )

kohana中使用PHPRPC

Friday, November 13th, 2009

kohana版本: 2.34
PHPRPC介绍: PHPRPC

以下是实现kohana 使用 PHPRPC的具体实例,已经应用在一具体的项目中。功能不算强大,算是抛砖引玉吧。

Library 中 Rpc.php

<?php defined('SYSPATH') OR die('No direct access allowed.');

class RPC_Core {

private static $instance;

private static $data;

private static $server;

private $phprpc;

public static function instance()
{
if (!isset(self::$instance))
{
$class = __CLASS__;
self::$instance = new $class;
}
return self::$instance;
}

public function __construct()
{
//self::$server = "http://172.16.7.5";
$this->phprpc = TRUE;
$this->phprpc = FALSE;
self::$server = "http://site.fj";
}

public function __call($name, $args){

$class = $name;

$method = $args[0];

$args = array_slice($args,1);

if($this->phprpc)
{
require_once(MODPATH.'phprpc/phprpc_client.php');
$client = new PHPRPC_Client(self::$server.'/server/data/'.$class.'/'.$method);
return $client->{$method}($args);
}else{
$class = 'As_'.$class;
$class = new $class;
return $class->{$method}($args);
}
}
}

服务器上Controllers中的 server.php

<?php defined('SYSPATH') OR die('No direct access allowed.');

class Server_Controller extends Controller {

public function data($class)
{
$method = $this->uri->segment(4);
require_once(MODPATH.'phprpc/phprpc_server.php');

$server = new PHPRPC_Server();
$class = 'As_'.$class;
$server->add($method , new $class);
$server->start();
}
}

服务器端事物处理文件 Library 中 As_user.php

<?php defined('SYSPATH') OR die('No direct access allowed.');
class As_user_Core {
public function hello($name)
{
return 'hello world '.kohana::debug($name);
}

public function test()
{
return '-m-';
}
}

客户端测试Controllers 代码

public function test()
{
echo 'rpc test ...................................<br/>';
$rpc = Rpc::instance();
echo $rpc->user('hello',$class='class',$name='1');
}

mac屏幕截图

Sunday, November 1st, 2009

Command-Shift-3 整个屏幕
Command-Shift-4 鼠标选择
Command-Shift-4 空格 当前应用程序借口

kohana3 tips: get orm validate errors

Monday, October 26th, 2009
echo kohana::debug($orm_object->validate()->errors());