小编Pau*_*lgo的帖子

Netty:ClientBootstrap 连接重试

我需要连接到服务器,我知道该服务器将在端口上侦听。尽管可能需要一些时间才能投入运营。是否可以让 ClientBootstrap 尝试连接给定的尝试次数或直到达到超时?

目前,如果连接被拒绝,我会收到异常,但它应该尝试在后台连接,例如通过尊重“connectTimeoutMillis”引导选项。

java netty

3
推荐指数
1
解决办法
6262
查看次数

使用Javascript(Croppie)裁剪图像

我正在尝试使用Croppie Library将图像裁剪为cicle

我试图使用他们的函数返回base64编码的图像.它返回一个base64代码,但没有图像:这是我的代码:

<div id="vanilla-demo"></div>
 </div>
<img id="myImage" src="">

<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script src="croppie.js"></script>

<script type="text/javascript">


        var vanilla = new Croppie(document.getElementById('vanilla-demo'), {
            viewport: { width: 200, height: 200 , type:'circle'},
            boundary: { width: 400, height: 400 },
            showZoom: false
        });
        vanilla.bind('dac.jpg');
            vanilla.result('canvas','original').then(function (src) {
                    console.log(src);
                    $('#myImage').attr('src', src);
            });

</script>
Run Code Online (Sandbox Code Playgroud)

javascript canvas image crop croppie

3
推荐指数
1
解决办法
8149
查看次数

测试失败Michael Hartl Ruby on Rails Turorial Chapter 10.28

我和Michael Hartl的教程一起工作.目前我在第10章.在第10.28部分,当我尝试运行测试时:

bundle exec rspec spec/requests/authentication_pages_spec.rb
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

Failures:

  2) Authentication authorization for non-signed-in users in the Microposts
     controller submitting to the destroy action Failure/Error: before { delete   
     microposts_path (FactoryGirl.create(:micropost)) } ActionController::RoutingError:
     No route matches [DELETE] "/microposts.1" 
     # ./spec/requests/authentication_pages_spec.rb:115:in`block(6 levels) in
     <top required)>'
Run Code Online (Sandbox Code Playgroud)

这是我的authentication_pages_spec.rb:

require 'spec_helper'

describe "Authentication" do
  let(:user) { FactoryGirl.create(:user) } 
    subject { page }

  describe "signin page" do
    before { visit signin_path }

    it { should have_selector('h1', text: 'Sign in') }
    it { should have_selector('title', text: …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails railstutorial.org

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

Ruby on Rails教程第11章:Rspec测试在关注者/后续部分失败

我正在研究Hartl教程的第11章,试图non-logged-in users in the Users controller visiting the followers and following page通过.我遇到了一个错误,Rails会抱怨一个未定义的admin?方法,尽管它仅用于User部分方法.

Rails本地服务器

Rendered users/_user.html.erb (9.4ms)
Rendered users/show_follow.html.erb within layouts/application (33.0ms)
Completed 500 Internal Server Error in 43ms

ActionView::Template::Error (undefined method `admin?' for nil:NilClass):
    1: <li>
    2:   <%= gravatar_for user, size: 52 %>
    3:   <%= link_to user.name, user %>
    4:   <% if current_user.admin? && !current_user?(user) %>
    5:     | <%= link_to 'delete', user, method: :delete,
    6:                                   data: { confirm: 'Are you sure?' } …
Run Code Online (Sandbox Code Playgroud)

ruby rspec ruby-on-rails ruby-on-rails-3 railstutorial.org

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

如何获取没有扩展名的文件名?

让我说我有这个string ="C:/EFI/Ulta/Filename.rb",我试图只从它分裂"文件名".

我尝试了string.split.last并返回"Filename.rb",我尝试删除".rb",但drop方法对我不起作用.我还可以使用其他方法吗?

ruby string split

0
推荐指数
1
解决办法
1200
查看次数

dry-struct如何有条件地验证一个属性?

我正在使用dry-type和dry-struct,我想进行条件验证。

上课:

class Tax < Dry::Struct
  attribute :tax_type, Types::String.constrained(min_size: 2, max_size: 3, included_in: %w[IVA IS NS])
  attribute :tax_country_region, Types::String.constrained(max_size: 5)
  attribute :tax_code, Types::String.constrained(max_size: 10)
  attribute :description, Types::String.constrained(max_size: 255)
  attribute :tax_percentage, Types::Integer
  attribute :tax_ammount, Types::Integer.optional
end
Run Code Online (Sandbox Code Playgroud)

如果 `tax_type =='IS',我想验证tax_ammount为整数和强制性。

ruby dry-rb dry-types dry-struct

0
推荐指数
1
解决办法
317
查看次数