`
holin
  • 浏览: 17683 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论
文章列表
1. type Base struct { Id        int `PK` CreatedAt time.Time UpdatedAt time.Time SyncedAt  time.Time }   2. type Note struct { Base Title string Body  string }   3. var note models.Note note.Title = "First term" note.Body = "body goes here!" note.CreatedAt = t ...
class String def utf8_to_gb2312 encode_convert(self, "gb2312", "UTF-8") end private def encode_convert(s, to, from) require 'iconv' begin converter = Iconv.new(to, from) converter.iconv(s) rescue s end end end ...
装其他gem没问题,装google-appengine就有问题了。 HoLin:webcurl holin$ gem install thin Building native extensions. This could take a while... Successfully installed thin-1.2.7 1 gem installed Installing ri documentation for thin-1.2.7... Installing RDoc documentation for thin-1.2.7... HoLin:webcurl holin ...
  在做二级域名支持的项目的时候,需要配置多个域名都指向127.0.0.1,而且二级域名是动态增加的。   在改/etc/hosts的时候就会有这样的需求:127.0.0.1     *.domain.com   不幸的是/etc/hosts并不支持这样的配置。所以好心人就提供了泛域名解析到127.0.0.1。这样的域名有:   lvh.me   smackaho.st   请看: Holin:~ holin$ ping lvh.me PING lvh.me (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icm ...
Textmate的goto file功能是我最喜欢的功能,打开想要的文件那叫一个快,支持模糊匹配。比如要打开tasks_controller.rb文件,我一般输入taskcon就能找到。但还是有爽的地方,那就是不能指定路径查找,在碰到一大批文件名一样的文件就不是那么好用了。比如Rails项目中的index.html.erb,基本上是一个controller都要有一个,同名文件之多可想而知。直接上图看看就知道了,你也会觉得很头大。   还好我们有:gotofile.tmbundle,这个buddle在已有goto file功能之外,支持/输入,可以按目录过滤想要打开的文件。上图你就知 ...
在一个Rails应用中连接多个数据库,我们常常这么做: class Cookie < ActiveRecord::Base establish_connection :monitor_spider ... end 这样,在使用Cookie.find等操作的时候,就会连接到database.yml中monitor_spider配置的数据库上操作。 以 ...
官网:http://mechanize.rubyforge.org   登录 require 'rubygems' require 'mechanize' require 'logger' # Mechanize.log = Logger.new(STDOUT) agent = Mechanize.new # pp agent.methods.sort.grep(/agent/) agent.user_agent_alias = 'Mac Safari' # pp agent.user_agent page = agent.get('https://passport. ...
在使用Flash Builder 4 Debug的时候,老是停在57%。在网上查了是没有装Flash播放器的debugger版本的原因。 看是否是debugger版本的flash player,可以通过这个网站看到:http://flashplayerversion.com/ 是不是发现了自己的不是Debugger版本??但是,之前已经装过Debugger版本了,我印象很深刻,但为什么现在又显示不是了呢?原因是我的Chrome浏览器自动把FlashPlayer升级成非Debugger版本了。 好吧,Chrome真要这样,咱也就不和它对着来了,我换Safari还不成吗!!我通过 
Paperclip是很方便的处理上传附件的插件,三下两下就为应用增加上传文件功能。 我有个应用场景是在文件上传后,得到文件的行数并保存下来。于是我增加了一个after_filter: after_save :set_item_count attr_accessor :no_after_save_filter def set_item_count return if @no_after_save_filter return if self.asset.path.nil? if File.exist?(self.asset.path) File.open(self.as ...
原来好好的项目,今天启动的时候提示: /usr/local/lib/ruby/gems/1.8/gems/hpricot-0.8.2/lib/hpricot_scan.bundle: dlopen(/usr/local/lib/ruby/gems/1.8/gems/hpricot-0.8.2/lib/hpricot_scan.bundle, 9): no suitable image found. Did find: (LoadError)<br> /usr/local/lib/ruby/gems/1.8/gems/hpricot-0.8.2/lib/hpr ...
Global site tag (gtag.js) - Google Analytics