问题列表 - 第24648页

在Scala 2.8集合中,为什么Traversable类型添加到Iterable之上?

我知道Traversable,你需要一个foreach方法.Iterable需要一种iterator方法.

Scala 2.8集合SID和"与类型战斗的Bitrot"论文基本上都没有提到为什么Traversable被添加.SID只说"David McIver ......将Traversable提议为Iterable的概括".

我从IRC的讨论中模糊地收集到,当收集的遍历终止时,它与回收资源有关吗?

以下内容可能与我的问题有关.有一些奇怪的函数定义TraversableLike.scala,例如:

def isEmpty: Boolean = {
  var result = true
  breakable {
    for (x <- this) {
      result = false
      break
    }
  }
  result
}
Run Code Online (Sandbox Code Playgroud)

我认为有一个很好的理由不仅仅是作为:

def isEmpty: Boolean = {
  for (x <- this)
    return false
  true
}
Run Code Online (Sandbox Code Playgroud)

scala scala-2.8 scala-collections

20
推荐指数
2
解决办法
2177
查看次数

BeautifulSoup可以以不区分大小写的方式工作吗?

我正在尝试为获取的网页提取元描述.但在这里,我面临的是BeautifulSoup区分大小写的问题.

有些页面有<meta name="Description,有些有<meta name="description.

我的问题非常类似于Stackoverflow上的问题

唯一的区别是我不能使用lxml ..我必须坚持使用Beautifulsoup.

python beautifulsoup

21
推荐指数
4
解决办法
4829
查看次数

为什么javascript IF只能运行一次?

我有javascript代码,它复制输入文件的值,并在文本框中实时传递.

<script>
function copyit(){

var thephoto=document.getElementById('thephoto').value;
var fileonchange=document.getElementById('fileonchange').value;

if(!thephoto==fileonchange){
document.getElementById('fileonchange').value=thephoto;
}

}

window.setInterval("copyit()", 500);  
</script>

Choose File : <input type="file" id="thephoto"><br>
Here Is the file name : <input type="text" id="fileonchange">
Run Code Online (Sandbox Code Playgroud)

遗憾的是,这只能工作一次,然后在再次更改文件时停止粘贴值.(我的意思是你应该重新加载页面再次工作)

IF有缓存的东西?你可以自己试试看代码.

谢谢你们

javascript javascript-events

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

如何在VB.NET中将数组设置为值列表?

我无法弄清楚如何将数组设置为两组数字之一(稍后会有更多),我尝试的每种方式都会引发某种错误.我试图在case语句中调暗数组,但后来我不能在For Each中使用数组,这使得它毫无价值......任何想法都会受到赞赏.

码:

Dim HourArray() As Integer

Select Case CurrentShapeRow(ROW_PERIOD)
    Case "ON", "2X16"
        HourArray = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}
    Case "2X8", "5X8"
        HourArray = {0, 1, 2, 3, 4, 5, 22, 23}
    Case Else
        Throw New Exception(String.Format("Unhandled Period: {0}", CurrentShapeRow(ROW_PERIOD)))
End Select


For Each HourCount As Integer In HourArray()
     'DO SOME STUFF HERE
Next
Run Code Online (Sandbox Code Playgroud)

vb.net arrays

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

使用 Excel Interop VB.Net 在 Excel 中设置边距

任何人都有使用 excel interop 和 vb.net 设置边距(上、左、右、下)的代码。我认为它必须是工作表对象的一部分,但可能是工作簿对象。很难找到一个例子。提前致谢。

c# vb.net excel

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

确定IP地址是否是蜂窝IP地址

在.NET Compact Framework中,设备可以有多个IP地址,我想找到一个不是来自Cellular连接的IP地址.目标是WiFi或以太网连接.

有没有办法做到这一点?

看起来像状态和通知经纪人会有办法做到这一点,但没有找到方法.

mobile compact-framework geolocation windows-mobile

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

滚动日志记录文件大小和时间

我一直在尝试设置一个简单的logback项目来按日期和文件大小滚动我的日志文件,到目前为止,我一直无法让我的appender转到另一个文件.而是写入<file />标记指定的日志.

这是我的logback.xml配置文件:

<?xml version="1.0"?>
<configuration scan="true" scanPeriod="10 seconds">
    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
        </layout>
    </appender>

    <appender name="milliroller" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>log/output.log</file>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
        </layout>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>log/mylog-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>1KB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
    </appender>

    <root level="DEBUG">
        <appender-ref ref="stdout"/>
        <appender-ref ref="milliroller"/>
    </root>

    <logger name="com.tkassembled.logback" level="DEBUG"/>
</configuration>
Run Code Online (Sandbox Code Playgroud)

乍一看,它看起来应该有效,对吗?有什么我做错了吗?我的整个可构建项目都可以在这里找到:http://www.mediafire.com/file/2bxokkdyz2i/logback.zip

java logging logback

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

在Fedora上安装MySQL gem的问题

当我尝试rake db:migrate时,我收到以下错误:

The bundled mysql.rb driver has been removed from Rails 2.2.
Please install the mysql gem and try again: gem install mysql.
rake aborted! no such file to load -- mysql
Run Code Online (Sandbox Code Playgroud)

当我尝试时 gem install mysql

Building native extensions. This could take a while... ERROR: Error installing
mysql: ERROR: Failed to build gem native extension. /usr/bin/ruby extconf.rb
Can't find header files for ruby. Gem files will remain installed in
/usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
Run Code Online (Sandbox Code Playgroud)

$ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

也尝试了但同样的错误.我在Fedora …

ruby mysql gem

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

使用证书进行SSL身份验证:证书是否应具有主机名?

问题的快速版本

Gmail,TD(加拿大银行),皇家银行(加拿大银行)都使用ssl.当你检查他们的证书时,他们都有

Common Name (CN)   mail.google.com
Run Code Online (Sandbox Code Playgroud)

或者更一般地说:

Common Name (CN)   <url>
Run Code Online (Sandbox Code Playgroud)

这是否需要防止中间人攻击?

摘要

JBoss允许客户端和服务器使用证书和ssl进行身份验证.有一件事似乎很奇怪,你不需要在证书上提供你的主机名.

我认为这意味着如果服务器B在您的信任库中,则服务器B可以伪装成他们想要的任何服务器.

(同样地:如果客户B在您的信托商店......)

我在这里错过了什么吗?

验证步骤

(Wikipeida页面摘要)

Client                                                  Server
=================================================================================================
1) Client sends Client Hello
        ENCRIPTION: None
        - highest TLS protocol supported
        - random number
        - list of cipher suites
        - compression methods

                                                        2) Sever Hello
                                                                ENCRIPTION: None
                                                                - highest TLS protocol supported
                                                                - random number
                                                                - choosen cipher suite
                                                                - choosen compression method

                                                        3) Certificate Message
                                                                ENCRIPTION: None
                                                                -

                                                        4) ServerHelloDone
                                                                ENCRIPTION: None

5) Certificate …
Run Code Online (Sandbox Code Playgroud)

security authentication ssl certificate ssl-certificate

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

如何找出命名空间如何被污染?

考虑以下一小段代码:

// all of these include other headers, lots of code:
#include "myheader1.h"
#include "myheader2.h"
#include <string>

void foo() {
  string s("hello world"); // oh no, why does this compile??
}
Run Code Online (Sandbox Code Playgroud)

这个编译,显然一些递归包含的头文件有一个

using namespace std;
Run Code Online (Sandbox Code Playgroud)

某处.您将如何找到违规代码行的位置?

只是grep在所有头文件上使用都不会真正起作用,因为该语句通常函数内部使用,它是安全的并且不会污染其余的代码.

c++ unix namespaces header-files

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