`
wtb
  • 浏览: 103578 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论
文章列表
运行时提示已active0.4.5.不能active1.0.0,那直接删除0.4.5的gem就行了。
转道友Blog中的一小段code说明ruby中的闭包 procs = [] (1..3).each do |i| procs << lambda { puts i } end procs.each { |p| p.call } # Output: # 1 # 2 # 3 ############################################### procs = [] for j in (1..3) do procs << lambda { puts j } ...

截取中文

  def trc_utf8(text, length = 40, t_string = "...")        l=0        char_array=text.unpack("U*")        char_array.each_with_index do |c,i|          l = l+ (c<127 ? 0.5 : 1)          if l>=length            return char_array[0..i].pack("U*")+(i<char_arra ...
 TCMalloc(Thread-Caching Malloc)是google开发的开源工具──“google-perftools”中的成员。与标准的glibc库的malloc相比,TCMalloc在内存的分配上效率和速度要高得多,可以在很大程度上提高MySQL服务器在高并发情况下的性能,降低系统负载。  TCMalloc的实现原理和测试报告请见一篇文章:《TCMalloc:线程缓存的Malloc》  为MySQL添加TCMalloc库的安装步骤(Linux环境):  1、64位操作系统请先安装libunwind库,32位操作系统不要安装。libunwind库为基于64位CPU和操作系统的程序提 ...
require 'net/http'require 'uri'module Net  class HTTP    def HTTP.get_with_headers(uri,headers=nil)      uri=URI.parse(uri) if uri.respond_to? :to_str      start(uri.host,uri.port) do |http|        return http.get(uri.path,headers)      end    end  endend gzipped = Net::HTTP.get_with_headers('http:// ...
用ruby写个网页抓取的小东东,遇到问题: 环境:ubuntu8.04+netbeans6.1+ruby1.8.6 在ruby中使用Net::HTTP.get_response抓取一个GB2312编码的网页后转换成utf8全是乱码,主要代码部分如下 resp=Net::HTTP.get_response(URL,URI) body=resp.body[0,resp.size-1] r=Iconv.iconv("UTF-8//IGNORE","GB2312//IGNORE",body)  接下来我要使用r中的内容 但是发现里面的内容全是乱码,直接写入数据库 ...
== Installation<tt>./script/plugin install http://code.dunae.ca/acts_as_slugable</tt>== Usage examplesIn your target table, add a column to hold the URL slug.=== With scope  class Page < ActiveRecord::Base    acts_as_slugable :source_column => :title, :target_column => :url_slug, ...
http://www.codyfauser.com/2008/1/17/paypal-express-payments-with-activemerchant
中国省,市,县(区)三级数据信息,已转换成mysql的dump文件
爱国的口号天天喊;商场里面的外国货生意一天比一天好; 说的一套,做的又是一套。 你真的爱国嘛? 爱国不是口号,是要行动。 真爱国的就来 http://www.chinaaction.com.cn/实际行动吧。
ubuntu下安装memcached非常简单 运行也很简单 ./memcached -d -m 2048 -l 10.0.0.40 -p 11211 如果要使用caffeine,请参考 http://blog.methodmissing.com/2007/6/4/get-your-caffeine-on/ 本人是使用的 memcache-client gem install memcache-client 后就可以在项目中使用了   首先在environment.rb中要配置连接哪台memcached 下面的是一个例子: CACHE=MemCache.new :namespace=>'m ...
1、安装 ruby script/plugin install http://svn.viney.net.nz/things/rails/plugins/acts_as_taggable_on_steroids 2、 class Post < ActiveRecord::Base acts_as_taggable end 3、 p = Post.find(:first) p.tag_list = "Funny, Silly" #为Post添加Tag p.tag_list # ["Funny", "S ...
首先,在ubuntu下要安装 atp-get install build-essential  zlib1g-dev ruby需要安装dev包 1、安装ferret sudo gem install ferret 2、安装acts_as_ferret 可用gem sudo gem install acts_as_ferret 或用plugins svn://projects.jkraemer.net/acts_as_ferret/trunk/plugin/acts_as_ferret 个人建议用gem稳点 到此安装结束 在model中添加 acts_as_ferret :fields=>[ ...
def setup @controller=***.new @request=ActionController::TestRequest.new @response=ActionController::TestResponse.new end  assert_template 测试是否装载了正确的view assert_tag 'form',:attributes=>{:action=>'/admin/....'} 测试View中是否有这表单,form也可以是div,td,input等html元素。 assert_response :redirect assert_red ...
http://fleximage.rubyforge.org/examples/   Home: http://fleximage.rubyforge.org/ Repository: svn://rubyforge.org/var/svn/fleximage Effect examples: http://fleximage.rubyforge.org/examples resize: resizes an image, with or without cropping. overlay: adds a semi transparent image on top of ...
Global site tag (gtag.js) - Google Analytics