我发现我可以使用以下任何命令成功安装ruby:
$ rvm reinstall 1.9.3-p327
$ rvm reinstall 1.9.3-p327 --with-openssl-dir=/usr/local
$ rvm reinstall 1.9.3-p327 --with-openssl-dir=/afdlkjasd_not_a_dir
$ rvm reinstall 1.9.3-p327 --with-openssl-dirffadsf=/afdlkjasd_not_a_dir
Run Code Online (Sandbox Code Playgroud)
无论我使用哪种上述命令,我都可以输入:
$ rvm use 1.9.3-p327
Using /home/clay/rvm/gems/ruby-1.9.3-p327
$ which ruby
/home/clay/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
$ ruby -e "puts require('openssl')"
true
Run Code Online (Sandbox Code Playgroud)
无论我做什么,我似乎都有ssl支持.我猜rvm或者ruby构建过程并不介意无效的选项或值.--with-openssl-dir即使我正确地输入(明显地)它,我也不知道该选项是否得到尊重.
rvm是否将我的ruby与我想要的openssl lib(/ usr/local中的那个)链接起来?如何判断哪个openssl lib编译/链接了ruby?
我正在使用Linux Mint 13.
我一直在分支机构工作new_feature:
A -- B -- C -- D master
\ \
\ 1 -- 2 -- 3 new_feature
\
E -- F -- G port
Run Code Online (Sandbox Code Playgroud)
我们的代码库还有一个较旧的分支port,其他开发人员将我们的产品移植到另一个RDBMS.port还没有准备好合并回来master.
最近有必要new_feature开展工作port.所以我将这两个合并到一个新的分支中port/new_feature,并在那里做了一些提交(I,J)以使其工作:
A -- B -- C -- D master
\ \
\ 1 -- 2 -- 3 -- I* -- J* -- K new_feature
\ \
E -- F -- G -- H -- I -- J -- K* port/new_feature …Run Code Online (Sandbox Code Playgroud) #include <stdio.h>
#include <unistd.h>
int main()
{
while(1)
{
fprintf(stdout,"hello-out");
fprintf(stderr,"hello-err");
sleep(1);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我机器上面的输出是
hello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-err
Run Code Online (Sandbox Code Playgroud)
我不得不杀死程序来阻止它.这是正确和预期的行为.或者这是错误的.这是一个面试问题,因此我在这里发帖.
我看到打字100.days给了我[编辑:似乎给了我]一个Fixnum 8640000:
> 100.days.equal?(8640000)
=> true
Run Code Online (Sandbox Code Playgroud)
我原以为这两个值是可以互换的,直到我试过这个:
x = Time.now.to_date
=> Wed, 31 Oct 2012
> [x + 100.days, x + 8640000]
=> [Fri, 08 Feb 2013, Mon, 07 May 25668]
Run Code Online (Sandbox Code Playgroud)
为什么以及如何在相等日期添加明显相等的值会产生不同的结果?
上面的结果来自Rails控制台,使用Rails 3.1.3版和Ruby版1.9.2p320.(我知道,我应该升级到最新版本......)
有时当我在rails控制台中工作时,我发现我想在调试器中逐步执行特定方法(来自我的rails应用程序).在过去,我通过在方法的源代码中临时添加调试器语句,然后从控制台调用该方法来完成此操作.
有没有一种方法可以从控制台"进入"一个方法,而无需编辑其源代码?
这在共享开发服务器上会特别好用,因此我不需要使用vi引入随机调试器语句,并记得稍后删除它们.
我尝试了以下但不出意外它不起作用:
$ rails c --debugger
=> Debugger enabled
Loading development environment (Rails 3.2.13)
irb(main):001:0> def startdebug
irb(main):002:1> debugger
irb(main):003:1> MyModel.last.my_method
irb(main):004:1> end
=> nil
irb(main):005:0> startdebug
Run Code Online (Sandbox Code Playgroud)
它说
*** No sourcefile available for (irb)
Run Code Online (Sandbox Code Playgroud)
很快我终于通过irb代码而不是代码my_method.