最新博文
http://railscasts.com/episodes/127-rake-in-background
deliver mail in background
system("rake balhblahblah &") #直接系统调用后台运行
http://railscasts.com/episodes/128-starling-and-workling
Starling
starling -d -P tmp/pids/starling.pid -q log/
starling as a messagequeue # server / client memcache as the server
例子很cool starling 比较酷
http://rubyforge.org/projects/starling #听说是推特的一个项目
http://railscasts.com/episodes/129-custom-daemon
BackgroundJob
BackgrounDRb
Background Fu
http://www.ibm.com/developerworks/cn/web/1003_yekai_railsarch/
# 介绍了一个实例
http://vanadiumlin.iteye.com/blog/1456947 # message queue的列表
https://github.com/robey/kestrel # starling的后续发展
https://github.com/jmettraux/rufus-scheduler # 定时功能,自我标榜没有替代产品,不过确实不错
https://developers.google.com/protocol-buffers/docs/techniques?hl=zh-CN#union
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
public class Test {
public static void main(String args[]) throws IOException{
//Union.OneMessage.Type.FOO;
//Union.OneMessage
Union.OneMessage.Builder b = Union.OneMessage.newBuilder();
b.setType(Union.OneMessage.Type.FOO);
Union.Foo.Builder fb = Union.Foo.newBuilder();
fb.setName("i try");
b.setFoo(fb.build());
Union.OneMessage msg = b.build();
FileOutputStream fout = new FileOutputStream("c:/proto.txt");
msg.writeTo(fout);
fout.close();
System.out.println("done");
FileInputStream str = new FileInputStream("c:/proto.txt");
Union.OneMessage msg2 = Union.OneMessage.parseFrom(str);
//Union.OneMessage msg2 = Union.OneMessage.parseFrom(strContent.toString());
System.out.println(msg2.getFoo().getName());
}
}
// parse 的过程
public Builder clear() {
super.clear();
type_ = Union.OneMessage.Type.FOO;
bitField0_ = (bitField0_ & ~0x00000001);
if (fooBuilder_ == null) {
foo_ = Union.Foo.getDefaultInstance();
} else {
fooBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000002);
if (barBuilder_ == null) {
bar_ = Union.Bar.getDefaultInstance();
} else {
barBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000004);
if (bazBuilder_ == null) {
baz_ = Union.Baz.getDefaultInstance();
} else {
bazBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000008);
return this;
}
可见使用union即便在开始的parse,效率也是个问题
至少要遍历所有的属性
http://lists.jboss.org/pipermail/netty-users/2010-January/001876.html # 有java代码
http://stackoverflow.com/questions/9121612/protocol-buffers-detect-type-from-raw-message # 推荐了三种实现
http://www.mail-archive.com/protobuf@googlegroups.com/msg03627.html # 还是推荐了union对于有限个类型
http://code.google.com/p/protobuf
https://developers.google.com/protocol-buffers/docs/techniques?hl=zh-CN#union
https://developers.google.com/protocol-buffers/docs/techniques?hl=zh-CN#self-description
http://code.google.com/p/protoc-gen-as3/wiki/FAQ
http://code.google.com/p/protoc-gen-as3/wiki/AdvancedUsage#AMF_Wrapper
//message.proto
import "options.proto";
message Person {
option (as3_amf_alias) = "JK";
required string name = 1;
required int32 id = 2;
}
//Test.java
public class Test{
public static void main(String args[]){
Message.Person.Builder b = Message.Person.newBuilder();
b.setName("hello world");
b.setId(123);
Message.Person p = b.build();
byte [] bs = p.toByteArray();
System.out.println(bs.length);
for(int i = 0; i < bs.length; i++){
System.out.print(Integer.toHexString(bs[i]));
System.out.print(" , ");
}
System.out.println("");
System.out.println(String.valueOf(bs));
System.out.println("hello world");
}
}
生成protobuf的类
protoc --java_out=. message.proto
/usr/local/protobuf/bin/protoc --plugin=/home/kk.shen/mybin/protoc-gen-as3/protoc-gen-as3 --as3_out=. message.proto
# 需要options.proto protoc-gen-as3 项目中有 和google的proto 官方项目自带
javac -sourcepath . -classpath protobuf-java-2.4.1.jar -classpath protoc-gen-as3.jar Test.java
java -cp .:protobuf-java-2.4.1.jar Test
sudo emerge -av postgresql-server
http://www.postgresql.org/docs/9.1/interactive/index.html
sudo -u postgres initdb /var/lib/postgresql/9.1/data
sudo -u postgres postgres -D /var/lib/postgresql/9.1/data/
sudo -u postgres psql
psql -U postgres -h 127.0.0.1 mydb # psql会用当前用户作为用户名 psql --help
\? , \h , \h select , \q , \d TABLENAME , \d+ TABLENAME
\db # list tablespaces
http://www.postgresql.org/docs/9.1/interactive/tutorial-accessdb.html
create table , drop table
http://www.postgresql.org/docs/9.1/interactive/tutorial-table.html
insert data
http://www.postgresql.org/docs/9.1/interactive/tutorial-populate.html
select data
http://www.postgresql.org/docs/9.1/interactive/tutorial-select.html
join table select
http://www.postgresql.org/docs/9.1/interactive/tutorial-join.html
postgresql 全文搜索
http://www.postgresql.org/docs/9.1/interactive/textsearch.html
碰到了很多问题,应该拿本书看看,学习学习
- <a href=&quo
2012-5-18 9:18:47 - extension eg
me
2012-5-10 17:42:57 - http://coding.s
2012-2-16 17:06:12 - patch -R 回滚 pat
2012-2-2 10:26:43 - http://translat
2012-1-21 13:19:39 - int normal(){
2011-11-10 17:52:04 - 1, 挂靠加金
2,自由职业者
2011-10-9 16:18:48 - 刚留言没看到,再发一次。希望能
2011-8-26 10:41:46 - tag id
http://
2011-7-19 18:05:08 - 字节序
http://baik
2011-7-19 15:58:29