小编Aut*_*ico的帖子

是什么导致OpenSSL :: SSL :: SSLErrorWaitReadable"读取会阻塞"?

什么OpenSSL::SSL::SSLErrorWaitReadable "read would block"意思?

我收到错误OpenSSL::SSL::SSLErrorWaitReadable消息read would block.我认为这是因为超时,但我找不到有关该主题的任何文档.

任何人都可以帮我找出造成这种情况的原因吗?我还能做些什么来防止这个问题呢?

偶尔产生此错误的代码:

data = {hello: "world"}
path = "https://example.com/api"
uri = URI.parse(path)
http = Net::HTTP.new(uri.host, uri.port)

http.use_ssl = (uri.scheme == "https")
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
request = Net::HTTP::Post.new(uri.request_uri)
request.body = Oj.dump(data)
request["Content-Type"] = "application/json"
begin
    response = http.request(request) #this line produces the error.
rescue
    return nil
end
Run Code Online (Sandbox Code Playgroud)

我在osx上使用ruby版本2.1.5p273和openssl版本.1.0.1i10.10.3

使用命令找到版本 ruby -v -ropenssl -rfiddle -e 'puts Fiddle::Function.new(Fiddle.dlopen(nil)["SSLeay_version"], [Fiddle::TYPE_INT], Fiddle::TYPE_VOIDP).call(0)' 感谢@bayendor

ruby net-http

10
推荐指数
1
解决办法
2628
查看次数

如何使用Cassandra存储后端删除Titan中的图形?

我使用Titan 0.4.0 All,在Ubuntu 12.04上以共享VM模式运行Rexster.

我怎样才能正确删除使用Cassandra存储后端的Titan中的图形?

我试过了TitanCleanup.clear(graph),但它并没有删除所有内容.指数仍在那里.我真正的问题是我有一个我不想要的索引(它会崩溃每个查询),但是我了解Titan的文档,一旦创建了索引就不可能删除它.

cassandra titan tinkerpop rexster

9
推荐指数
2
解决办法
5054
查看次数

如何获取请求的字节大小?

我正在Node.js Express中创建一个API,它可能会收到大量请求.我真的很想知道请求有多大.

//....
router.post('/apiendpoint', function(req, res, next) {
  console.log("The size of incoming request in bytes is");
  console.log(req.????????????); //How to get this?
});
//....
Run Code Online (Sandbox Code Playgroud)

node.js express

9
推荐指数
2
解决办法
7874
查看次数

仅运行下一个迁移文件

是否可以使用sequelize-cli仅运行下一个迁移文件?

我一直在浏览cli的文档和帮助部分,它似乎不是这样的功能.

例如,运行sequelize db:migrate:status命令时我有以下内容;

Loaded configuration file "config/config.js".
Using environment "development".
up   20170301090141-create-something.js
up   20170301133113-create-else.js
up   20170301133821-Update-some-stuff.js
up   20170301135339-create-some-model.js
up   20170307152706-update-some-stuff-two.js
down 20170316142544-create-an-index.js
down 20170421112638-do-some-refactor.js
Run Code Online (Sandbox Code Playgroud)

我想只运行20170316142544-create-an-index.js.

当然,我可以删除所有相关文件.然后我逐个添加每个迁移,在每个迁移之间运行"所有"迁移.但这似乎是野蛮的.

migrate sequelize-cli

8
推荐指数
3
解决办法
3636
查看次数

冒号的前置和追加之间的区别(:项目与项目:)

在红宝石中附加和预先添加结肠有什么区别?

例:

#In rails you often have things like this:
has_many :models, dependent: :destroy
Run Code Online (Sandbox Code Playgroud)

为什么dependent:有一个附加的结肠,但:models:destroy有预谋的结肠?有什么不同?

ruby ruby-on-rails colon

7
推荐指数
2
解决办法
526
查看次数

install_name_tool无法使用更改"因为更大的更新加载命令不适合"

我需要重新链接一个文件install_name_tool.有问题的文件允许我更改其中一个dylib路径,但是当我更改第二个(7个)时,我收到此错误:

install_name_tool: changing install names or rpaths can't be redone for: some/library (for architecture i386) because larger updated load commands do not fit (the program must be relinked, and you may need to use -headerpad or -headerpad_max_install_names)
Run Code Online (Sandbox Code Playgroud)

在谷歌搜索后,我发现文件中的新路径没有足够的空间,我可能能够使用该ld工具,或者libtool解决这个问题.但是,我无法弄清楚如何.我没有这个库的源代码,所以我无法重新编译它.

没有办法让我更新这个文件的所有dylib路径?任何帮助将非常感谢!


我在osx 10.10我正在使用的命令: install_name_tool -change old/dylib/path.dylib new/dylib/path.dylib file/to/update

dylib ld libtool install-name-tool

7
推荐指数
1
解决办法
1888
查看次数

Stub/mock process.platform sinon

我正在使用process.platform并希望将该字符串值存根以伪造不同的操作系统.

(这个对象是我无法实现的,我需要测试它可以采用的不同值)

是否可以存根/伪造这个值?

我没试过就试过以下内容:

stub = sinon.stub(process, "platform").returns("something")
Run Code Online (Sandbox Code Playgroud)

我收到了错误 TypeError: Attempted to wrap string property platform as function

如果我尝试使用这样的模拟,会发生同样的事情:

mock = sinon.mock(process);
mock.expects("platform").returns("something");
Run Code Online (Sandbox Code Playgroud)

mocking stub node.js sinon

7
推荐指数
1
解决办法
1336
查看次数

c#regex高CPU使用率

我的小程序正在检查脚本网站使用的是什么类型,它使用超过80%的cpu i7处理器.我不知道这是正常的吗?

码:

public static class EnginesMatcher
{

    public static readonly Regex Drupal1 =
        new Regex(
            @"/misc/drupal\.js|Drupal\.settings|href=""http://drupal\.org""|\?q=node/[0-9]+|/\?q=user/register|/\?q=user/password|/user/register\?destination|<li class=""collapsed""><a href=""/node/add"">|/dpl3/files/|/modules/node/",
            RegexOptions.Compiled);

    public static readonly Regex XE1 =
        new Regex(
        @"XpressEngine|content=""zeroboardXE|content=""xe_board""|var zbxe_session_name|/xe\.css\?2|/xeicon/favicon\.ico""|#xe-editor-container-1|xpress_xeditor",
            RegexOptions.Compiled);

    //and 60 more such regex
Run Code Online (Sandbox Code Playgroud)

在另一堂课

  public async Task<Result> Match(string url)
        {

            if (!await Open(url).ConfigureAwait(false)) return ResultKey;


            if (EnginesMatcher.Drupal1.IsMatch(html))
            {
                return new Result()
                {
                    Key = AResultKey.Success,
                    LogFile = "Drupal.txt",
                    Message = "Drupal",
                    Url = url
                };
            }
            if (EnginesMatcher.XE1.IsMatch(html))
            {
                return new Result()
                {
                    Key = AResultKey.Success,
                    LogFile …
Run Code Online (Sandbox Code Playgroud)

c# regex

6
推荐指数
1
解决办法
1426
查看次数

在formtastic中添加自定义输入字段?

我无法弄清楚,或找到一个非常简单的问题的任何解决方案:"如何在formtastic中定义我自己的输入字段?"

这就是我得到的:

<%= semantic_form_for @someFantasticVariable, :url => "/someFantasticUrl.html" do |f|%>  
    <%= f.inputs do %>
        <%= f.input :something_else_id, :required => true , :as => :select, :collection   => SomethingElse.find(:all), :label =>"The something else"%>
        <%= f.input :fantastic_max_cost, :label => "Budget (max cost)"%>  
    <%end%>


    <%= f.buttons do%>
        <%= f.commit_button :button_html => { :class => "primary", :disable_with =>     'Processing...', :id => "commitButton"}%>
    <%end%>
<%end%>
Run Code Online (Sandbox Code Playgroud)

现在..

我想要一个非常简单的事情.我想要一个不属于该模型的字段.我想有一个日期字段,我可以用它来计算控制器中的一些东西.所以我想这样做:

<%= f.inputs do %>
    <%= f.input :something_else_id, :required => true , :as => :select, :collection   => SomethingElse.find(:all), :label =>"The …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails formtastic

5
推荐指数
1
解决办法
5874
查看次数

Ruby Regex,获取所有可能的匹配(不剪切字符串)

我遇到了红宝石正则表达式的问题.我需要找到所有(可能重叠)的匹配.这是问题的简化:

#Simple example
"Hey".scan(/../)
=> ["He"] 
#Actual results

#With overlapping matches the result should be
=> ["He"], ["ey"]
Run Code Online (Sandbox Code Playgroud)

正在尝试执行的正则表达式并获得所有结果,如下所示:

"aaaaaa".scan(/^(..+)\1+$/) #This looks for multiples of (here) "a" bigger than one that "fills" the entire string. "aa"*3 => true, "aaa"*2 => true. "aaaa"*1,5 => false.
 => [["aaa"]] 

#With overlapping results this should be
 => [["aa"],["aaa"]]
Run Code Online (Sandbox Code Playgroud)

是否有图书馆或方法在ruby中进行正则表达式以获得我追求的结果?

我发现了一些线索,这在Perl中是可能的,但经过数小时的研究后,我没有发现任何关于Ruby方法的事情.

然而,我能够找到这个" Javascript正则表达式 - 查找所有可能的匹配,即使已经捕获的匹配 ",但我无法找到任何类似的Ruby,也没有找到类似于Ruby版本中最后一个索引属性的东西.说实话,我不认为它会起作用,因为我打算使用的正则表达式是递归的并且依赖于整个字符串,而那个方法会切断字符串.

ruby regex

5
推荐指数
1
解决办法
2872
查看次数