Rails连接远程mongo数据库报错:"Could not connect to a primary node for replica set #]>"配置文件内容如下:development: sessions: default: database: spider h...
分类:
其他好文 时间:
2015-02-09 09:18:25
阅读次数:
189
页面中本来设计一个按钮,功能是当按下时跳转到index方法,然后实现一段功能.关键是其中需要传递一个参数show_all,其值为true.
index方法中通过判断是否含有该参数来实现不同的逻辑,类似如下:if params[:show_all]
@products = Product.all
else
@products = Product.where("loca...
分类:
其他好文 时间:
2015-02-07 21:43:55
阅读次数:
163
虽然写了很多年的Java代码,但是基本上只把JVM当blackbox处理。介绍JVM的书也看过几本,但效果不佳。看OpenJDK代码?提不起兴趣。最近有几个礼拜的空闲时间,于是我决定用GO语言写了一个JVM,彻底征服JVM这头怪兽!
为什么选择GO
首先不想用动态语言来写。实现JVM的初衷就是想离机器更近一点,所以排除了JavaScript、Python、Ruby等语言。其次也不想用Java来...
分类:
编程语言 时间:
2015-02-07 18:59:53
阅读次数:
1488
rails项目中由于后期需求变化,需要在products数据库中增加一个字段来满足多国家商品的分类:rails g migration add_locale_to_products locale:string...
分类:
数据库 时间:
2015-02-07 18:59:22
阅读次数:
291
键值对
题目:考虑包含键-值元组的列表,如[{erlang, “a functinal language”}, {ruby, “an OO language”}]。写一个函数,接受列表和键为参数,返回该键对应的值。
get_value(Map, Key) ->
element(2, hd(lists:dropwhile(fun({K, _})-> Key /= K end, Map) +...
分类:
编程语言 时间:
2015-02-06 20:31:23
阅读次数:
228
rails server (默认为开发环境)rails server -p503 -e production (指定为生产环境 ,并指定站点端口)rake RAILS_ENV=production assets:precompile --trace (预编译)intel app frame jque...
分类:
其他好文 时间:
2015-02-06 16:30:56
阅读次数:
191
article = nilarticle.nil? # => trueempty? checks if an element - like a string or an array f.e. - is empty:# Array[].empty? #=> true# String"".empt...
分类:
其他好文 时间:
2015-02-06 12:58:01
阅读次数:
82
1. wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O -|sh
2. 在.zshrc下添加这两条:
plugins=(git textmate ruby autojump osx mvn gradle)
[[ -s `brew --prefix`/etc/autojump.sh ...
分类:
系统相关 时间:
2015-02-06 11:22:43
阅读次数:
289
Tram
Time Limit: 1000MS
Memory Limit: 30000K
Total Submissions: 10622
Accepted: 3877
Description
Tram network in Zagreb consists of a number of intersections and rails ...
分类:
其他好文 时间:
2015-02-05 14:59:17
阅读次数:
143
调用bootstrap css框架时,将bootstrap文件夹放入 vendor/assets/下 bootstrap文件结构如下: [shenma@localhost demo]$ ls vendor/assets/bootstrap/ css img js [shenma@localhost ...
分类:
Web程序 时间:
2015-02-05 11:07:09
阅读次数:
240