- 博客(15)
- 收藏
- 关注
整个项目的mongoid表重建索引
Object.constants.map(&:constantize).select {|c| c.included_modules.include?(Mongoid::Document) rescue nil }.compact.map(&:create_indexes)
2011-12-31 17:56:10
289
redis和memcached初始化内存比较
$ redis-stat ------- data ------ --------------------- load -------------------- - child -keys mem clients blocked requests connections 3 1.30M 1 ...
2011-12-19 17:18:25
126
解决yum错误Error: requested datatype primary not available
服务器信息:[mvj3@sdk2 ~]$ cat /proc/version Linux version 2.6.18-194.el5 (mockbuild@ca-build10.us.oracle.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Mon Mar 29 22:10:29 EDT 2010出错信息...
2011-11-15 15:19:10
1157
Rails覆写默认default_scope
Rails里多项目公用models时定义了default_scope,在别的项目里,虽然可以用unscoped,或with_exclusive_scope来取消或覆写,但是RailsAdmin的框架机制不方便直接改写。因为scope的机制是更新或添加条件,但是不能删除条件,所以在添加default_scope的时候判断一下即可:[code="ruby"]default_scope ...
2011-11-15 14:15:47
239
exception_notification_rails3没有发邮件
Rails项目里同事发现配置的 exception_notification_rails3 没有正常的发出异常错误邮件对比了下我这边正常的配置,把config.middleware.use ExceptionNotifier 放到config/application.rb里最后就可以了,虽然没有从源码里看出问题来 = =...
2011-11-03 13:45:02
117
Mongodb删除重复数据
统计分析需要跑各个时间粒度的任务,如果异常中断后重新选择某个时间删除后再跑的时候,有时候还是会有重复的统计数据。在mongodb中建立唯一索引时加上dropDups选项可以解决此问题:A unique index cannot be created on a key that has pre-existing duplicate values. If you would like ...
2011-11-03 10:40:27
328
CentOS本地安装nokogiri
帮同事在一台centos上安装nokogiri,记载如下:系统信息:[root@localhost ~]# uname -aLinux localhost.localdomain 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:14 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux[root@localhost ~]# ...
2011-10-20 10:50:01
295
CentOS上sqlite3版本兼容问题
sqlite3-ruby的1.3版本在CentOS不兼容,访问数据库时报如下错误:/usr/local/ruby/ruby-enterprise-1.8.7-2011.03/bin/ruby: symbol lookup error: /usr/local/ruby/ruby-enterprise-1.8.7-2011.03/lib/ruby/gems/1.8/gems/sqlite3-1.3...
2011-10-09 16:12:04
576
bundle install --local 利用本地缓存来加速Gem安装
如果Gemfile所列出来的gem全在Gemfile.lock里,加上--local选项可以直接绕过 请求rubygems.org的gem列表,从而达到加速本地生成Gemfile.lock。
2011-10-09 16:04:16
988
Rails 3.1找不到静态资源
发现一个诡异的现象,Rails在production模式下启动后找不到资源,报如下错误:Started GET "/images/people.jpg" for 127.0.0.1 at Mon Jul 25 14:21:35 +0800 2011ActionController::RoutingError (No route matches [GET] "/images/people...
2011-07-25 14:41:34
182
Gemfile里引用没有gemspec的gem
在Gemfile里引用一个没有gemspec的gem时,运行bundle install的时候会提示Could not find gem 'mechanize (>= 0)' in git://github.com/mvj3/mechanize.git (at master).Source does not contain any versions of 'mechanize (>...
2011-06-17 11:10:11
340
二分查找和插入
[code="ruby"]# 二分查找(又称折半查找)是在一个有序表里查找元素的复杂度为O(log(n))的算法。先从中# 二分查找(又称折半查找)是在一个有序表里查找元素的复杂度为O(log(n))的算法。先从中间位置开始比较,相等则返回,如小于中间值,则将接下来的查找范围设定为前一子表,大于则为后一子表,以下如此类推。# 维基百科参考:http://en.wikipedia.org/w...
2011-02-24 21:22:34
215
sphinx覆盖旧索引
换用sphinx后,产品同事发现旧的数据也能搜索出新数据来,查了下官方文档 http://sphinxsearch.com/docs/manual-0.9.9.html#index-merging, 发现更新索引时thinking-sphinx没有把它自定义的sphinx_deleted属性同时更新上去,导致在执行增量索引时用的--merge-dst-range选项无效。现解决方案如下:1...
2011-02-01 19:56:44
198
一个简单的姓名拼音匹配
[code="ruby"]# 一个简单的姓名拼音匹配## 姓名一般是由两三个汉字组成,选其顺序且连续的拼音缩略的组合就算匹配成功。#require 'chinese_pinyin'@name = "成吉思汗"pinyins = Pinyin.t(@name).split# 把姓名生成对应的拼音数组array = []pinyins.each_with_i...
2011-01-19 22:32:15
573
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人