Archive

Posts Tagged ‘ubuntu’

netbeans 6.7 问题

June 4th, 2009 cashplk No comments

中文显示正常,但是字体明显变瘦,不容易辨识。
原因是因为使用了openjava。

netbeans安装目录下的 etc/netbeans.conf里面设定默认使用了openjava
更改为就正常了。
# Default location of JDK, can be overridden by using –jdkhome :
netbeans_jdkhome=”/usr/lib/jvm/java-6-sun/jre”

接下来解决乱码问题:

把宋体字拷贝到你的用户目录下,然后执行如下操作:
1、 cd /usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/fonts

2、sudo mkdir fallback

3、sudo mv ~/simsun.ttc /usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/fonts/fallback/

ruby操作CouchDB

May 23rd, 2009 cashplk No comments

以下是一个简单的使用Ruby操作CouchDB数据库的代码:

新建fromRuby2CouchDB.rb文件,具体内容如下:

require 'net/http'
 
module Couch
  class Server
    def initialize(host, port, option = nil)
      @host = host;
      @port = port;
      @option = option;
    end
 
    def delete(uri)
      request(Net::HTTP::Delete.new(uri))
    end
 
    def get(uri)
      request(Net::HTTP::Get.new(uri))
    end
 
    # put json to request
    def put(uri, json)
      req = Net::HTTP::Put.new(uri)
      req["content.type"] = "application/json"
      req.body = json
      request(req)
    end
 
    def post(uri, json)
      req = Net::HTTP::Post.new(uri)
      req["content-type"] = "application/json"
      req.body = json
      request(req)
    end
 
    def request(req)
      res = Net::HTTP.start(@host, @port) {
        |http|http.request(req)
      }
      if (not res.kind_of?(Net::HTTPSuccess))
        handle_error(req, res)
      end
      res
    end
 
    private
 
    def handle_error(req, res)
      e = RuntimeError.new("#{res.code}:#{res.message}\nMETHOD:" +
 
          "#{req.method}\nURI:#{req.path}\n#{res.body}")
      raise e
    end
  end
 
end

在文件路径下,以命令行模式运行:irb,启动ruby编译器:
irb(main):001:0> require “fromRuby2CouchDB.rb”
=> true
irb(main):002:0> server = Couch::Server.new(“127.0.0.1″,”5984″)
=> #<Couch::Server:0xb7bdd258 @option=nil, @port=”5984″, @host=”127.0.0.1″>
irb(main):003:0> server.get(“/blog/”)
会插入一个新的数据库,名为blog。如果不对,会打印出相应的错误。成功后,可以在页面查看是否存在该数据库。

Categories: Erlang, Ruby Tags: , , ,

CouchDB初探

May 23rd, 2009 cashplk No comments

看到InfoQ上关于CouchDB的报道,正好最近也在研究Erlang,就看看。

CouchDB是一个文档形数据库。本身的程序已经实现了基本的管理。和数据库的交互采用的是JS,具体传输的数据是JSON格式的。

下面是Eralng的架构图:

erlang-arch

可以看到,中间层完全使用Erlang编写, 底层搜索则是Lucene。

ubuntu下面的安装:

sudo apt-get install couchdb

OK了之后,直接运行: sudo couchdb 即可运行。

/etc/couchdb/couch.ini,可以对运行的程序参数进行配置。

访问:http://127.0.0.101:5984/_utils/browse/index.html 就可以看到数据库的情况了。

此后的所有操作都可以在界面完成。

假如新建了一个blog的数据库,字段为text.

需要查询数据的时候,直接访问:http://127.0.0.1:5984/blog/1 就可以了。

显示的数据和这个类似:

{"_id":"1","_rev":"2166111176","text":"hello,world"}

初步使用了一下,觉得还不错,但是还是有几个疑问:
1,对于大规模的操作,性能如何?
2,直接页面编辑,必须按照JSON格式, 输入字符之类的,要“”补全。不能自动实现此功能,不爽。
3,中文字符似乎处理还不是很好。

Erlang的官方网站:http://couchdb.apache.org/index.html

Categories: DataBase, Erlang Tags: , ,

cashplk的心路历程 is Digg proof thanks to caching by WP Super Cache