新家地址:
http://www.jiezhang.me
iOS Developer
Sunday, December 25, 2011
Tuesday, May 3, 2011
Unity3d code clip : auto height lable and mouse touchable scrolling
var wasScrolling : boolean = false;
var scrollPosition : Vector2;
var longString = "This is a long-ish string This is an sized label. This is an sized label. This is an sized label. This is an sized label. This is an sized label. ";
function OnGUI () {
var rectForDescription : Rect = Rect(100,100,100,100);
GUILayout.BeginArea(rectForDescription);
scrollPosition = GUILayout.BeginScrollView (scrollPosition, GUILayout.Width (100), GUILayout.Height (100));
GUILayout.Label (longString);
GUILayout.EndScrollView ();
GUILayout.EndArea();
if( Event.current.type==EventType.MouseDown && rectForDescription.Contains(Event.current.mousePosition) ) {
wasScrolling = true;
print("down");
}
if( Event.current.type==EventType.MouseDrag && wasScrolling==true ) {
print(Event.current.delta.y);
scrollPosition.y+=Event.current.delta.y;
}
if( Event.current.type==EventType.MouseUp && wasScrolling == true) {
print("end scrolling");
wasScrolling = false;
}
}
Wednesday, March 9, 2011
a temporary solution for PEAR Install with PHP5.3
I met a Bug of PHP(still doesn't fixed yet) about halt_compiler function which caused installing PEAR fail.
This command doesn't work in PHP5.3
To fix(for the time being) it, use this command:
php go-pear.phar
This command doesn't work in PHP5.3
To fix(for the time being) it, use this command:
php -ddetect_unicode=0 go-pear.phar
Sunday, October 17, 2010
Project "kana50" has created
I've been learning iPhone developing recently.
Finally I created a iPhone App and submitted it to to App store(still waiting to review).
And I decide make this iPhone App project Opensource:
http://code.google.com/p/kana50/
Finally I created a iPhone App and submitted it to to App store(still waiting to review).
And I decide make this iPhone App project Opensource:
http://code.google.com/p/kana50/
Tags:
iphone,
kana50,
objective-c
How to fix PROCEDURE can't return a result set in the given context
CLIENT_MULTI_RESULTS enables the client program to process multiple results. This option must be enabled if you execute CALL statements for stored procedures that produce result sets. Otherwise, such procedures result in an error Error 1312 (0A000): PROCEDURE proc_name can't return a result set in the given context.
http://dev.mysql.com/doc/refman/5.0/en/c-api-multiple-queries.html
http://dev.mysql.com/doc/refman/5.0/en/c-api-multiple-queries.html
Tags:
mysql
Sunday, July 11, 2010
eMule one-click AddOn, a new project is created
It's a firefox add-on that I made recently, just because I'm tried to copy/paste a ed2k link from a window to another windows if you have used eMule web interface to remotely control your eMule client.
Project home:
http://code.google.com/p/emule-oneclick-add-on/
Mozilla Add-On install:
https://addons.mozilla.org/en-US/firefox/addon/195536/
Project home:
http://code.google.com/p/emule-oneclick-add-on/
Mozilla Add-On install:
https://addons.mozilla.org/en-US/firefox/addon/195536/
Tags:
add-on,
ed2k,
emule,
firefox,
javascript,
mozilla,
web interface
Sunday, May 23, 2010
Reading note of 'Real world flash game development'
Chapter 3:
A Quick Review of the Planning Steps
● One- to two-sentence description
● Game screen wireframe and fl ow
● List of game mechanics
● List of assets (art, animation, sound, video, and copy)
● Technical requirements
● UML class diagrams
Chapter 4:
传入任意数量参数到函数/方法
Getter/Setter
to be Continued.
A Quick Review of the Planning Steps
● One- to two-sentence description
● Game screen wireframe and fl ow
● List of game mechanics
● List of assets (art, animation, sound, video, and copy)
● Technical requirements
● UML class diagrams
Chapter 4:
传入任意数量参数到函数/方法
function myFunction (… params):void {
for (var i:int = 0; I < params.length; i + + ) {
if (!(params[i] is DisplayObject)) {
throw new ArgumentError( “ Only DisplayObjects can be used in myFunction. ” );
}
}
}
Getter/Setter
package {
public class MyClass {
protected var _maxNameLength:int = 8;
protected var _name:String;
protected var _lives:int = 3;
public function get name():String {
return _name;
}
public function set name(value:String):void {
name = value.substr(0,maxNameLength);
}
public function get lives():int {
return _lives;
}
}
}
//OUTSIDE CLASS
var myInstance:MyClass = new MyClass();
myInstance .name = “ CHRISTOPHER ” ;
trace (myInstance.name); //OUTPUTS “ CHRISTOP ” ;
trace (myInstance.lives); //OUTPUTS 3;
myInstance .lives = 10; //THROWS ERROR
to be Continued.
Tuesday, April 6, 2010
Using Beyond compare3 as Git diff tool under Cygwin
在Cygwin下使用Beyond compare3(BC3)作用Git的diff工具
分两步走~
step 1.
create new .sh file as Git's diff warpper.
** please notice here, you need specially make a full path of $2, since BC3 will not find your tmp file under Cygwin path. **
** 注意这里的两个路径,第二个是本地文件,因为是相对路径,BC3可以找到,但第一个是绝对路径指向/tmp/xxx,所以我们要特别指定在windows下的真实路径,而不是cygwin的路径,所以我加上了d:/programs/cygwin。
step 2.
Add this line to .bashrc and run it to configure your Git gloabl variable.
Now you can try git diff whatever your file.
分两步走~
step 1.
create new .sh file as Git's diff warpper.
#!/bin/sh
/cygdrive/c/Program\ Files\ \(x86\)/Beyond\ Compare\ 3/BCompare.exe "d:/programs/cygwin$2" "$5"
** please notice here, you need specially make a full path of $2, since BC3 will not find your tmp file under Cygwin path. **
** 注意这里的两个路径,第二个是本地文件,因为是相对路径,BC3可以找到,但第一个是绝对路径指向/tmp/xxx,所以我们要特别指定在windows下的真实路径,而不是cygwin的路径,所以我加上了d:/programs/cygwin。
step 2.
Add this line to .bashrc and run it to configure your Git gloabl variable.
git config --global diff.external /home/z33/git-diff-wrapper.sh
Now you can try git diff whatever your file.
Thursday, March 11, 2010
Wordpress hack tips - Add tags to static pages
I did a lot of wordpress plugin jobs recently. But sometimes clients are not satisfied with what plugins can do. for example there is a client of mine want add tags to any static pages, just like wordpress posts did.
Actually it's very easy to do this(as well as to create a plugin for this).
just paste following lines to page_attributes_meta_bos function in meta-boxes.php:
Actually it's very easy to do this(as well as to create a plugin for this).
just paste following lines to page_attributes_meta_bos function in meta-boxes.php:
<h5>Tags</h5>
<div>
<input type="text" name="tags_input" class="tags-input" id="tags-input" size="30" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />
</div>
Tuesday, March 2, 2010
The most easy way to install geoip php extension note
在网上找了一堆安装geo ip模块的方法,各种方法都很麻烦。现在本尊(无量牛逼最三三尊)来整理一个最简单的安装方法如下。
1.install GEOIP C Library
http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz
./configure
make
sudo make install
2.Install GEOIP PHP Extension
sudo pecl install geoip
3.Following message from step2, for example:
Build process completed successfully
Installing '/usr/local/lib/php/20060613/geoip.so'
install ok: channel://pecl.php.net/geoip-1.0.7
configuration option "php_ini" is not set to php.ini location
You should add "extension=geoip.so" to php.ini
4.Install GeoIP database
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gzip -d GeoIP.dat.gz
sudo cp GeoIP.dat /usr/local/share/GeoIP/
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
sudo cp GeoLiteCity.dat /usr/local/share/GeoIP/GeoLiteCity.dat
sudo mv /usr/local/share/GeoIP/GeoLiteCity.dat /usr/local/share/GeoIP/GeoIPCity.dat
5.test
<?php print_r(geoip_record_by_name('125.63.166.38'));
1.install GEOIP C Library
http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz
./configure
make
sudo make install
2.Install GEOIP PHP Extension
sudo pecl install geoip
3.Following message from step2, for example:
Build process completed successfully
Installing '/usr/local/lib/php/20060613/geoip.so'
install ok: channel://pecl.php.net/geoip-1.0.7
configuration option "php_ini" is not set to php.ini location
You should add "extension=geoip.so" to php.ini
4.Install GeoIP database
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gzip -d GeoIP.dat.gz
sudo cp GeoIP.dat /usr/local/share/GeoIP/
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
sudo cp GeoLiteCity.dat /usr/local/share/GeoIP/GeoLiteCity.dat
sudo mv /usr/local/share/GeoIP/GeoLiteCity.dat /usr/local/share/GeoIP/GeoIPCity.dat
5.test
<?php print_r(geoip_record_by_name('125.63.166.38'));
Sunday, February 7, 2010
这两天遇到的某些国内discuz论坛输出的RSS问题解决。
主要遇到了两个问题。
1.GBK编码问题
如果RSS输出是gbk编码,Zend_Feed可以处理(不过会有些警告)。而Simplepie则全部处理成乱码了。
解决这个问题只能是把gbk当成gb2312来处理。
2.半个汉字,或非gb2312内的字符在第一或最后一个的时候,CDATA标签无法识别(Zend_Feed和SimplePie都不行)。
解决办法就是在CDATA与字符之间加一个空格。
1.GBK编码问题
如果RSS输出是gbk编码,Zend_Feed可以处理(不过会有些警告)。而Simplepie则全部处理成乱码了。
解决这个问题只能是把gbk当成gb2312来处理。
$content = str_replace('encoding="gbk"', 'encoding="gb2312"', $content);2.半个汉字,或非gb2312内的字符在第一或最后一个的时候,CDATA标签无法识别(Zend_Feed和SimplePie都不行)。
解决办法就是在CDATA与字符之间加一个空格。
$content = preg_replace('/\]\]\>/', ' ]]>', $content);
$content = preg_replace('/\<\!\[CDATA\[/', '<![CDATA[ ', $content);
Saturday, February 6, 2010
Version Control with Git 学习笔记(更新中)
1.当git checkout的时候,如果有一个文件名和一个tag重名,可以用两个中线来指定文件名,比如:
2.指定log编辑器
3.--author when met some wired message :P
4.比较两个版本
git log
git diff 0f793b8262cbd843e8ad7c75430aab7bebc6522d^1..HEAD wp-content/themes/bugbam/header.php
5.diff stat
git diff master~5 master
$git checkout main.c //checkout tag name
$git checkout -- main.c //checkout file name
2.指定log编辑器
setenv GIT_EDITOR vim //tch
export GIT_EDITOR=vim //bash
3.--author when met some wired message :P
4.比较两个版本
git log
git diff 0f793b8262cbd843e8ad7c75430aab7bebc6522d^1..HEAD wp-content/themes/bugbam/header.php
5.diff stat
git diff master~5 master
Tags:
git
Tuesday, February 2, 2010
dante server INSTALL note
1. install dante server
skip the error message from the output of configure dante-server once installed. that's cause dante configuration was not complete.
2. start editing the config file
vi /etc/danted.conf
3. run dante-server
sudo apt-get install dante-server
skip the error message from the output of configure dante-server once installed. that's cause dante configuration was not complete.
2. start editing the config file
vi /etc/danted.conf
--
# log to what file
logoutput: stderr /var/log/danted.log
# listening interface and port
internal: ppp0 port = 80
# outgoing interface
external: ppp0
# method: username requires the client to provide a username and password which match the system password file.
# method: none requires no form of authentication.
method: username
# privileged ports like 80 and 443 must use root permission.
user.privileged: root
# the package seems not complied with libwrap support.
#user.libwrap: nobody
# allowed IPs
client pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
}
# allowed protocols with these source IPs
pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
protocol: tcp udp
}
3. run dante-server
sudo /etc/init.d/danted start
Tags:
danted
Monday, January 25, 2010
Change Joomla default meta info in a Component
In the templates of Component, in view.html.php before display() be called. add following line:
$document =& JFactory::getDocument();
$document->setDescription('you description');
$document->setMetaData('keywords', 'you keywords');
Tags:
Joomla
关于对DOM Level 1和2的理解。
参考:
https://developer.mozilla.org/En/DOM_Levels
根据自己的理解总结一下DOM Levels的实现。
DOM Level 1:
实现了文档结构化,就是《a href="xx" target=""》这样的tag以及attribute的定义。
http://www.w3.org/TR/DOM-Level-1/
DOM Level 2:
1.实现了命名空间。
2.实现动态更新以及访问(动态更新后可以看到更新结果)。addChild, removeChild
3.事件,比如addEventListener,来实现响应各种事件,比如EventTarget, MouseEvent(但不包括键盘事件,奇怪,文档上是这么说的)
4.支持CSS的访问了。 比如div.style.display='none';还有一些CSS相关的方法。
5.实现Traversal,比如NodeIterator(我是没用过)。还有Range,这个在online editor里常见,就是TextRange之类的实现。这块不熟,还是看要w3c的详细文档吧:http://www.w3.org/TR/DOM-Level-2-Traversal-Range/
总之现在主流的浏览器基本实现了Level2 小量实现了Level3。
https://developer.mozilla.org/En/DOM_Levels
根据自己的理解总结一下DOM Levels的实现。
DOM Level 1:
实现了文档结构化,就是《a href="xx" target=""》这样的tag以及attribute的定义。
http://www.w3.org/TR/DOM-Level-1/
DOM Level 2:
1.实现了命名空间。
2.实现动态更新以及访问(动态更新后可以看到更新结果)。addChild, removeChild
3.事件,比如addEventListener,来实现响应各种事件,比如EventTarget, MouseEvent(但不包括键盘事件,奇怪,文档上是这么说的)
4.支持CSS的访问了。 比如div.style.display='none';还有一些CSS相关的方法。
5.实现Traversal,比如NodeIterator(我是没用过)。还有Range,这个在online editor里常见,就是TextRange之类的实现。这块不熟,还是看要w3c的详细文档吧:http://www.w3.org/TR/DOM-Level-2-Traversal-Range/
总之现在主流的浏览器基本实现了Level2 小量实现了Level3。
Tags:
dom,
javascript
Friday, January 22, 2010
A little example to figure out Javascript scope
function f1() { var a=1; f2(); }
function f2() { alert(a); }
f1();
function f1() {
var a=2;
function f2() {
alert(a);
}
f2();
}
f1();
Try it.
Tags:
javascript
Wednesday, December 30, 2009
install a git server on ubuntu
install software
edit config with apache
copy file
restart apache
=========================
create a new project rep
git daemon start command
=====================
checkout code
sudo apt-get install git-core gitweb
edit config with apache
sudo vim /etc/apache2/conf.d/git<
<Directory /var/www/git>
Allow from all
AllowOverride all
Order allow,deny
Options ExecCGI> Files gitweb.cgi <
SetHandler cgi-script> /Files
<> /Directory
DirectoryIndex gitweb.cgi
SetEnv GITWEB_CONFIG /etc/gitweb.conf
copy file
sudo mv /usr/share/gitweb/* /var/www/git
cp /usr/lib/cgi-bin/gitweb.cgi /var/www/git/
restart apache
sudo /etc/init.d/apache2 reload
//Then you can visit you git website.
http://localhost/git
=========================
create a new project rep
cd /var/cache/git/
sudo mkdir project.git
cd project.git
sudo git init
sudo vim .git/description
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git commit -a
git daemon start command
touch .git/git-daemon-export-ok
sudo git daemon --base-path=/var/cache/git --detach --syslog --export-all --verbose --enable=receive-pack
=====================
checkout code
cd ~
git clone git://server/project.git project
Monday, September 28, 2009
notes after .ActionScript.3.0.in.Flash.CS3.Professional.Essential.Training(Lynda.com)
_mc.buttonMode = true; //set move clip to button mode(with pointer when mouse over)
_mc.addEventListener(MouseEvent.CLICK, onClick); //MouseEvent.ROLL_OVER ROLL_OUT
function onClick(event:MouseEvent):void { event.target.rotation += 10; }
//Keyboard
stage.addEventListener(KeyboardEvent.KEY_DOWN, jump); //removeEventListener
function jump(e:KeyboardEvent):void { trace(event.keyCode); }
var link:URLRequest = new URLRequest("http://www.google.com");
navigateToURL(link);
stage.addEventListener(Event.ENTER_FRAME, //timeline, trigger it every key frame entering.
stage.addEventListener(Event.ENTER_FRAME, //in action layler first keyframe
//timer
var t:Timer = new Timer(1000);
t.addEventListener(TimerEvent.TIMER, function (e:TimerEvent):void{ _mc.play(); } );
t.start();
//class
package todd.classes {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class CustomClass extends MovieClip {
public var _var:String;
public function CustomClass() { //no return type in constr
this.addEventListener(MouseEvent.ROLL_OVER, grow);
}
private function grow(event:MouseEvent):void { this.scaleX = 1.5; this.scaleY = 1.5; }
}
} //CustomClass.as
_MovieClip.addChild(_mc_boarder);
//Publish:Settings...
//Document class
Library->Movie Clip->Linkage->Export for Actionscript
Math.random(); Math.round(x); Math.floor(x); Math.ceil(x);
var myText:TextField = new TextField(); //addChild(myText); //myText.text = "xxx"; //.width = 15 //.autoSize = TextFieldAutoSize.LEFT;
var myFormat:TextFormat = new TextFormat();
myFormat.font = "Helvetica";
myFormat.color = 0xFF0000;
myFormat.size = 24;
myText.setTextFormat(myFotmat);
myText.wordWrap = true;
var externalLoad:URLLoader = new URLLoader();
externalLoad.load( new URLRequest('external.txt') );
externalLoad.addEventListener(Event.COMPLETE, textReady);
externalLoad.removeEventListener(Event.COMPLETE, textReady);
function textReady(event:Event):void {
external_txt.text = event.target.data;
}
external_text.scrollV++;
var users:Array = new Array();
users[0] = "Todd"; users[1] = "Jimmy";
trace(users);
var users:Array = ['Todd', 'Jimmy'];
for(var i:Number=0; i < users.length; i++) { }
users.push('xxx');
public function setType(type:*):void {}
if(_firstCard == undefined) { _firstCard = event.currentTarget; } //notice differ from event.target
String(_firstCard._type);
_firstCard.gotoAndPlay("any label you set"); or frame idx
if(this.currentFrame == 1) { this.play(); }
var shape:Shape = new Shape(); //MovieClip also works
shape.graphics.lineStyle(1, 0x00ff00);
shape.graphics.beginFill(0x000000);
shape.graphics.drawCircle(100, 100, 50); //.drawRect(100, 100, 200, 100);
shape.graphics.endFill();
addChild(shape);
var colorT:ColorTransform = new ColorTransform();
colorT.blueOffset = -100;
colorT.redOffset = 100;
_mc.transform.colorTransform = colorT;
_mc.filters = [new DropShadowFilter(), new BlurFilter()];
var bs:DropShadowFilter = new DropShadowFilter();
bs.color = 0x0b77a9;
bs.blurX = 10;
bs.blurY = 10;
bs.angle = 66;
bs.distance = 200;
_mc.filters = [bs];
var il:Loader = new Loader();
il.load(new URLRequest('xxx.swf')); //support gif,jpg,png,swf and so on.
addChild(il);
il.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onComplete(e:Event):void {
//make sure the 'Linkage' before do this:Exoprt for ActionScript (there should have a xxx_mc in swf)
e.target.content.xxx_mc.y -= 100;
}
var snd:Sound = new Sound();
snd.load(new URLRequest('xxx.mp3'));
snd.addEventListener(Event.COMPLETE, onComplete);
function onComplete(e:Event):void {
snd.play(); //e.target.play(); //.play(resumeTimeSec);
}
var sndCtl:SoundChannel = new SoundChannel();
sndCtl = snd.play();
sndCtl.stop();
var resumeTime = sndCtrl.position;
var volCtl:SoundTransform = new SoundTransform();
volCtl.volume += .1; sndCtl.soundTransform = volCtl;
/* only for flash CS3, now it is already out-date.
var n:NetConnection = new NetConnection();
n.connect(null); //or something other
var ns:NetStream = new NetStream(n);
/*
var metaListener:Object = new Object();
metaListener.onMetaData = onMetaData;
ns.client = metaListener;
function onMetaData(data:Object):void {
//do something play/stop button init works.
ns.play("xxx.flv");
ns.stop();
}
*/
var v:Video = new Video();
video.attachNetStream(ns);
addChild(v);
this.startDrag();
this.stopDrag();
event.currentTarget.hitTestObject(event.currentTarget._obj);
this.parent.addChild(this); //this could set mc to top of mainbox.
Tags:
Actionscript,
flash,
note
Saturday, September 5, 2009
share my two scripts which are using upload your file to client's server(via ftp or sftp)
Lately a guy complain that uploading his finished work files to client's server is not easy. sometimes to many files in anywhere dispersedly which is annoying to cover all files to upload completely.
Don't tell me you are still using WinSCP or Filezilla to upload files? if you are a developer then you should feel shame for what you are doing.
Let's see How do I solve this issue.
Firstly I wrote two scripts. as following:
FOR SFTP:
FOR FTP(need ncftp):
HOW TO USE:
Don't tell me you are still using WinSCP or Filezilla to upload files? if you are a developer then you should feel shame for what you are doing.
Let's see How do I solve this issue.
Firstly I wrote two scripts. as following:
FOR SFTP:
#!/bin/bash
curd=`pwd`
for i in $@; do
scp -P3122 -i /path/to/your/key $i jzhang@www.youclientserver.com:$curd/$i
done
FOR FTP(need ncftp):
#!/bin/bash
curd=`pwd`
for i in $@; do
d=`dirname $i`
ncftpput -uusername -ppasswd ftpdomain.com /footprint/${d//./ } $i
done
HOW TO USE:
$ svn status
? templates/ftp.php
M no_ie6_page.php
z33@gogocat /footprint
$ ~/upload_podbean.sh templates/ftp.php no_ie6_page.php
Friday, September 4, 2009
Subscribe to:
Posts (Atom)
