小编Gra*_*ick的帖子

使用Vue.js过滤列表

我刚刚开始使用Vue.js,这就是我正在做的事情:我正在呈现产品列表,每个产品都有a name,a gender和a size.我希望用户能够按性别过滤产品,方法是使用输入来输入性别.

var vm = new Vue({
      el: '#product_index',
      data: {
        gender: "",
        products: [{name: "jean1", gender: "women", size: "S"}, {name: "jean2", gender: "men", size: "S"}]
      },
      methods:{
        updateGender: function(event){
          this.gender = $(event.target).val()
        }
      }
    }
  )

  <div v-for="product in products" v-if="...">
    <p>{{product.name}}<p>
  </div>
  <input v-on:change="updateGender">
Run Code Online (Sandbox Code Playgroud)

我设法更新了性别,但我有过滤部分的问题.页面加载时,我不希望任何过滤.在文档中,他们建议使用,v-if但它似乎与此配置不兼容.

如果我使用v-if,我可以这样做:

v-if="product.gender == gender" 
Run Code Online (Sandbox Code Playgroud)

但同样,当页面加载时,这不起作用,因为性别是空的.我无法找到解决方法.

我该如何处理这个问题?

javascript vue.js

28
推荐指数
2
解决办法
5万
查看次数

固定高度的Bootstrap轮播:根据图像尺寸水平或垂直居中图像

我有一个固定高度的自举旋转木马.这是CSS:

.carousel-custom .carousel-outer {
  position: relative;
}


@media(min-width: 992px){
    .carousel-custom {
      margin-top: 20px;

    .carousel-inner {
      height: auto;
    .item {
        height:500px;
        line-height:300px;
      }
    }
  }
}

@media(max-width: 991px){
.carousel-custom {
      margin-top: 20px;

    .carousel-inner {
      height: auto;
    .item {
        height:300px;
        line-height:300px;
        text-align:center;

      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

这是我的标记:

    <div id="carousel-custom-1188" class="carousel slide carousel-custom" data-ride="carousel">
      <div class="carousel-outer">
        <!-- Wrapper for slides -->
        <div class="carousel-inner" role="listbox">
            <div class="item active">
              <img class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459261752/w8edcuvz1yl3uc4g4o34.jpg" alt="Jinallzupvfazqqr67nd">
              <div class="carousel-caption"></div>
            </div>
            <div class="item">
              <img class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459175684/w4ueot8o49dh2fyulv0x.jpg" alt="K1yov5hpur8mgsb9r15p">
              <div class="carousel-caption"></div>
            </div> …
Run Code Online (Sandbox Code Playgroud)

html css image twitter-bootstrap

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

Keras:单个图像的model.predict

我想用Keras预测单个图像.我训练了我的模型,所以我只是加载重量.

from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D
from keras.layers import Activation, Dropout, Flatten, Dense
from keras import backend as K
import numpy as np
import cv2

# dimensions of our images.
img_width, img_height = 150, 150



def create_model():
  if K.image_data_format() == 'channels_first':
    input_shape = (3, img_width, img_height)
  else:
    input_shape = (img_width, img_height, 3)

  model = Sequential()
  model.add(Conv2D(32, (3, 3), input_shape=input_shape))
  model.add(Activation('relu'))
  model.add(MaxPooling2D(pool_size=(2, 2)))

  model.add(Conv2D(32, (3, 3)))
  model.add(Activation('relu'))
  model.add(MaxPooling2D(pool_size=(2, 2)))

  model.add(Conv2D(64, (3, 3)))
  model.add(Activation('relu')) …
Run Code Online (Sandbox Code Playgroud)

deep-learning keras

10
推荐指数
3
解决办法
2万
查看次数

hdf5文件到pandas dataframe

我下载了一个存储在.h5文件中的数据集.我只需保留某些列,并能够操纵其中的数据.

为此,我尝试将其加载到pandas数据帧中.我试过用:

pd.read_hdf(path)
Run Code Online (Sandbox Code Playgroud)

但我得到: No dataset in HDF5 file.

我已经在SO上找到了答案(将条件下的HDF5文件读取到pandas DataFrame)但我不需要条件,答案会增加关于文件编写方式的条件,但我不是文件的创建者所以我可以'对此做任何事情.

我也尝试过使用h5py:

df = h5py.File(path)
Run Code Online (Sandbox Code Playgroud)

但这不容易被操纵,我似乎无法从中获取列(仅使用列的名称df.keys())有关如何执行此操作的任何想法?

python hdf5 pandas

8
推荐指数
2
解决办法
1万
查看次数

Travis CI:启动rails服务器

我需要在Travis上启动rails服务器来运行集成测试.我已将此添加到配置文件中:

before_script:
  - psql -c 'create database scalia_test;' -U postgres
  - "bundle exec rails server -p 3000 &"
Run Code Online (Sandbox Code Playgroud)

但是,我仍然收到赛普拉斯的错误:

http://localhost:3000/users/sign_in
We attempted to make an http request to this URL but the request failed without a response.
We received this error at the network level:
  > Error: connect ECONNREFUSED 127.0.0.1:3000
Common situations why this would fail:
  - you don't have internet access
  - you forgot to run / boot your web server
  - your web server isn't accessible
  - you …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails travis-ci cypress

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

在 Jenkins 管道中找不到 docker

我按照基本示例将 jenkins 管道与 docker 映像一起使用。

在构建开始时,我收到一个docker: command not found错误:

[Pipeline] Start of Pipeline
[Pipeline] node
Running on FleetCloud XXX in /tmp/jenkins-XXX/workspace/XXX-pipeline
[Pipeline] {
[Pipeline] sh
+ docker inspect -f . node:7-alpine
/tmp/jenkins-XXX/workspace/XXX-pipeline@tmp/durable-92bb0321/script.sh: line 1: docker: command not found
[Pipeline] sh
+ docker pull node:7-alpine
/tmp/jenkins-XXX/workspace/XXX-pipeline@tmp/durable-8317f88b/script.sh: line 1: docker: command not found
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
sh: line 1: 12623 Terminated              sleep 3
sh: line 1: 12636 Terminated              sleep 3
ERROR: script …
Run Code Online (Sandbox Code Playgroud)

jenkins docker

6
推荐指数
0
解决办法
2867
查看次数

定义方法参数的条件

我有一个方法只采用一个参数:

def my_method(number)

end
Run Code Online (Sandbox Code Playgroud)

如果使用number < 2?调用方法,如何引发错误?通常,我如何定义方法参数的条件?

例如,我想在调用时出错:

my_method(1)
Run Code Online (Sandbox Code Playgroud)

ruby methods

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

使用 Net::HTTP POST 请求到 HTTPS

这个使用 Ajax 的 POST 请求完美地工作:

var token = "my_token";

function sendTextMessage(sender, text) {
  $.post('https://graph.facebook.com/v2.6/me/messages?',
    { recipient: {id: sender}, 
      message: {text:text},
      access_token: token
    },
    function(returnedData){
         console.log(returnedData);
  });
};

sendTextMessage("100688998246663", "Hello");
Run Code Online (Sandbox Code Playgroud)

我需要有相同的请求,但在 Ruby 中。我尝试使用 Net:HTTP,但它不起作用,我没有收到任何错误,所以我无法调试它:

    token = "my_token"
    url = "https://graph.facebook.com/v2.6/me/messages?"
    sender = 100688998246663
    text = "Hello"
    request =  {
                 recipient: {id: sender},
                 message: {text: text},
                 access_token: token
                }.to_json


  uri = URI.parse(url)
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE

  request = Net::HTTP::Post.new(uri.request_uri)

  response = http.request(request)
  response.body
Run Code Online (Sandbox Code Playgroud)

我应该如何继续获取错误或我哪里出错了?

ruby post ruby-on-rails rest-client net-http

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

Elastic Beanstalk:没有模块命名设置

我正在尝试在 Amazon Elastic Beanstalk 上运行 django 应用程序,我正在学习教程。

但是,在部署时,我收到 500 错误,并且在查看日志时:

ImportError: No module named settings
[Tue Sep 06 15:22:32.138981 2016] [:error] [pid 1940] [remote 127.0.0.1:42845] mod_wsgi (pid=1940): Target WSGI script '/opt/python/current/app/fasttext/wsgi.py' cannot be loaded as Python module.
[Tue Sep 06 15:22:32.139006 2016] [:error] [pid 1940] [remote 127.0.0.1:42845] mod_wsgi (pid=1940): Exception occurred processing WSGI script '/opt/python/current/app/fasttext/wsgi.py'.
Run Code Online (Sandbox Code Playgroud)

似乎我的 wsgi.py 文件是问题所在:

"""
WSGI config

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, …
Run Code Online (Sandbox Code Playgroud)

python django amazon-web-services amazon-elastic-beanstalk

5
推荐指数
0
解决办法
991
查看次数

将文件传递给活动作业/后台作业

我通过标准文件输入接收请求参数中的文件

def create
  file = params[:file]
  upload = Upload.create(file: file, filename: "img.png")
end
Run Code Online (Sandbox Code Playgroud)

但是,对于大型上传,我想在后台作业中执行此操作。Sidekiq 或 Resque 等流行的后台作业选项依赖于 Redis 来存储参数,因此我不能只通过 Redis 传递文件对象。

我可以使用Tempfile,但在某些平台(例如 Heroku)上,本地存储并不可靠。

我必须有哪些选项才能使其在“任何”平台上可靠?

ruby-on-rails background-process resque redis sidekiq

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