小编vaj*_*oja的帖子

action和action.async之间的区别

我写了两个动作来测试action和action.asyc之间的区别.但是,我发现在Thread.sleep完成后,这两个方法都返回值.action.asyc应该根据描述立即返回值吗?

def intensiveComputation(): Int = {
    Thread.sleep(5000)
    return 1
}

def testPromise() = Action {
   Ok("sync" + intensiveComputation())
}

def testPromise = Action.async {
   val futureint = scala.concurrent.Future { intensiveComputation() }
   futureint.map(i => Ok("async" + i))
}
Run Code Online (Sandbox Code Playgroud)

scala playframework-2.0

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

port select --list gcc返回none(active)

我正在运行Yosemite并在其上安装了xcode 6.1.我还用brew install gcc命令手动安装了gcc.

但是当我运行port select --list gcc命令时,它会返回以下消息

 Available versions for gcc:
       none (active)
Run Code Online (Sandbox Code Playgroud)

gcc版本显示了与LLVM的铿锵声.gcc --version配置: - prefix =/Volumes/DEV/Applications/Xcode.app/Contents/Developer/usr - with-gxx-include-dir =/usr/include/c ++/4.2.1 Apple LLVM版本6.0(clang-600.0.54)(基于LLVM 3.5svn)目标:x86_64-apple-darwin14.0.0线程模型:posix

gcc

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

鱿鱼 sslbump 与私人连接警告一起使用

我使用带有 sslbump 功能的 squid 3.5 进行 https 流量过滤。我用 openssl 生成了我的私钥和证书文件。但是,当我打开 https 网站时,浏览器收到警告消息,该证书是由未知机构颁发的。我使用 comodo 创建了 ssl 证书,但我仍然收到相同的警告消息。

有没有办法消除这个警告?

# Squid normally listens to port 3128
http_port 3128 ssl-bump cert=/var/tmp/example.com.cert key=/var/tmp/example.com.private

# Squid listen Port
cert=/var/tmp/example.com.cert
# SSL Bump Config
always_direct allow all
ssl_bump server-first all

url_rewrite_program /usr/bin/sh /var/tmp/middle_squid_wrapper.sh start -C /var/tmp/middle_squid_config.rb

# required to fix HTTPS sites (if SslBump is enabled)
acl fix_ssl_rewrite method GET
acl fix_ssl_rewrite method POST
url_rewrite_access allow fix_ssl_rewrite
url_rewrite_access deny all
Run Code Online (Sandbox Code Playgroud)

ssl https squid

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

仅创建 zip 包的校验和而不是每个文件就足够了吗?

我想检查下载的zip包的真实性。是否只创建zip包的校验和并在本地检查它是否足够?我是否需要创建包含的每个文件的校验和?

    m = hashlib.md5()  
    file = io.FileIO('test.zip','r')  
    bytes = file.read(1024)  
    while(bytes != b''):  
        m.update(bytes)  
        bytes = file.read(1024)   
    file.close() 
Run Code Online (Sandbox Code Playgroud)

python python-2.7

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

来宾VM无法通过桥接模式获取IP地址

我在MAC OSX主机上的VMWare上运行了一个来宾VM(Windows 7).当我使用"NAT"模式时,来宾VM可以获得IP等连接到互联网.但是,当我更改为使用"bridege"模式时,来宾操作系统无法连接到互联网.如何解决这个问题?

__PRE__

vmware virtual-machine

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

使用tensorflow和python进行值预测

我有一个包含股票价格列表的数据集.我需要使用tensorflow和python来预测收盘价.

Q1:我有以下代码,它将第一个2000条记录作为训练,2001年作为20000条记录作为测试,但我不知道如何更改代码来预测今天和1天后的收盘价??? 请指教!

#!/usr/bin/env python2

import numpy as np
import pandas as pd
import tensorflow as tf
import matplotlib.pyplot as plt

def feature_scaling(input_pd, scaling_meathod):
    if scaling_meathod == 'z-score':
       scaled_pd = (input_pd - input_pd.mean()) / input_pd.std()
    elif scaling_meathod == 'min-max':
       scaled_pd = (input_pd - input_pd.min()) / (input_pd.max() - 
    input_pd.min())
    return scaled_pd

def input_reshape(input_pd, start, end, batch_size, batch_shift, n_features):
    temp_pd = input_pd[start-1: end+batch_size-1]
    output_pd = map(lambda y : temp_pd[y:y+batch_size], xrange(0, end-start+1, batch_shift))
    output_temp = map(lambda x : np.array(output_pd[x]).reshape([-1]), xrange(len(output_pd)))
    output = np.reshape(output_temp, …
Run Code Online (Sandbox Code Playgroud)

machine-learning bigdata tensorflow

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

使用Random.Next()的概率

我想写一个彩票抽奖程序,需要从1-2000000范围内随机选择20000个数字.代码如下:

Random r = New Random(seed); //seed is a 6 digits e.g 123456
int i=0;
while(true){
   r.Next(2000000);
   i++;
   if(i>=20000)
      break;
}
Run Code Online (Sandbox Code Playgroud)

我的问题是:

  1. 它可以确保所有数字从1到2000000的相同可能性吗?
  2. 上限2000000是否包含在r.Next()
  3. 有什么建议吗?

c# random

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