Wednesday, December 30, 2009

install a git server on ubuntu

install software
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.

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:

#!/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

SVN 常用命令收集

svn log -r2508:head -v

svn propedit svn:ignore ./

Saturday, August 1, 2009

a Joomla module to show special category in anywhere

一哥们是designer,在用Joomla时发现无法实现显示指定的一个category的list到frontpage或其它地方。也没找到相应的module,所以我就写了一个。

点此下载(Download)

其实之前也写了些module,但和客户有保密协议,所以不便发布在这儿。

Tuesday, July 21, 2009

Google Reader API总结

刚刚完成了Google Reader上所有feed中图片自动下载脚本。
现在总结几点在网上找到不到tips:

1.to get all new item that in your google reader subscription

http://www.google.com/reader/api/0/stream/contents/user%2F{$user_id}%2Flabel%2FImages?ot={$last_month}&r=n&xt=user%2F{$user_id}%2Fstate%2Fcom.google%2Fread&n=500

ot: expire item timestamp
n: item numbers once request

*result is JSON format.

2.call google reader api to set "read" state which always getting 400 error from google.

to use POST method to fix 400 error.
POST URL: http://www.google.com/reader/api/0/edit-tag
POST FIELDS:a=user/{$user_id}/state/com.google/read&s={$feed}&i={$item_id}&T={$token}

现在我的小脚本正在疯狂下载中,哈哈哈哈哇。

Saturday, July 18, 2009

to Get Google Reader Token codes

想写一个脚本把Google reader上我订阅的所有Feed里的图片抓下来(最近订了几个毛图站,哈哈)。看了Google Reader API,挺简单。但比较讨厌的是如果要设置一个read-listing里的item为已读,则要用到token。在网上找了一圈没有。。妈的,只好自己写。这个token不只是要Google登陆验证,有两个步骤,请看代码:


/* ------- start code ------- */
$authentication_url = 'https://www.google.com/accounts/ClientLogin';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $authentication_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "service=reader&Email=[your google account]&Passwd=[your pw]");
ob_start();
curl_exec($ch);
$sid = ob_get_clean();
curl_close($ch);

$cookie = preg_replace('/[\r\n]/','; ',$sid);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.google.com/reader/api/0/token');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
ob_start();
curl_exec($ch);
$token = ob_get_clean();
curl_close($ch);

echo $token //here you go baby.
/* ------- end code ------- */