问题列表 - 第35048页

为什么IE使用jQuery帖子发出随机XHR 408/12152响应?

我刚刚遇到一个与IE有关的问题,似乎几乎没有关于'网络的文件 - 只有少数人提出类似的问题.

当我使用jQuery(1.4.2)向我的服务器发送POST请求(服务器通过发送JSON数据来响应)时,我偶尔会收到XHR 408错误(意味着服务器在等待客户端完成其时会超时)请求)和(不太常见),XHR 12152错误(我不知道这些意味着什么).似乎没有这种模式.

这只发生在IE(版本8 - 我没有尝试过其他版本,但我可以确认问题发生在两个不同的安装).Safari和Opera似乎很好.

对于GET请求,这似乎不是问题.

如果有人对此事有任何想法,我将非常感激.

ajax post internet-explorer

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

如何通过Python中另一个列表的相应成员划分列表成员?

假设我有两个数据集.我有一周一周的用户尝试我的服务.

trials = [2,2,2,8,8,4]
Run Code Online (Sandbox Code Playgroud)

我有一周一周的注册试用用户.

conversions = [1,0,2,4,8,3]
Run Code Online (Sandbox Code Playgroud)

我可以通过这种方式快速完成:

conversion_rate = []
for n in range(len(trials)):
   conversion_rate.append(conversions[n]/trials[n])
Run Code Online (Sandbox Code Playgroud)

你能想到更优雅的方式吗?

奖励:结果是一个整数列表[0, 0, 1, 0, 1, 0] ,而不是一个浮点列表.获取浮动列表的最简单方法是什么?

python

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

如何检查有符号整数是否为正?

使用按位运算符,我想加法和减法,我如何检查有符号整数是否为正(特别是,不是负数而不是零)?我相信这个问题的答案非常简单,但它并没有找到我.

c bit-manipulation bitwise-operators

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

如何强制Apple的OpenCL编译器重新编译缓存的内核?

我想在我的OpenCL内核中使用#include语句,但看起来Apple的OpenCL编译器会缓存内核,因此如果您更改包含文件的内容而不是执行包含的文件的内容,则程序在运行之间不会更改.

我编写了一个例子来说明这一点:http: //github.com/enjalot/adventures_in_opencl/tree/master/experiments/inc/

如果你编译并运行,它应该工作正常.然后,如果你在inc.cl中注释出结构定义,它仍然可以正常运行(或者更改lvl2.cl中的任何内容)

在Ubuntu上使用NVIDIA编译器可以获得预期的行为.

那么有什么办法迫使clBuildProgram重新编译内核?

opencl

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

PHP GD调色板颜色

PHP GD中,如何将真彩色图像转换为调色板而不会丢失任何颜色.随着imagetruecolortopallete不起作用.我有一个贯穿所有颜色并过滤它们的功能(例如灰度).并且它不保留所有颜色,例如兰博基尼的这张照片 -

图片

替代文字

这是我的代码

$im = imagecreatefrompng("lamborghini.png");
$degrees = 0;

$img = imagecreatetruecolor(imagesx($im), imagesy($im));
imagecopy($img, $im, 0, 0, 0, 0, imagesx($im), imagesy($im));
imagetruecolortopalette($img, true, 256);
$t = imagecolorstotal($img);
for ($i = 0; $i < $t; $i++) {
  $rgb = imagecolorsforindex($img, $i);
  $hsv =rgbtohsv($rgb['red'], $rgb['green'], $rgb['blue']);
  $h = $degrees;
  $s = $hsv['s'];
  $v = $hsv['v'];
  while ($h > 360) {$h -= 360;};
        $nrgb = hsvtorgb($h, …
Run Code Online (Sandbox Code Playgroud)

php gd image colors palette

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

如何确定"最低"编码可能?

脚本

您在数据库或服务器上存储了许多以UTF-16格式存储的XML文件,而空间不是问题.您需要将大部分这些文件作为XML文件传递到其他系统,因此尽可能少地使用空间至关重要.

问题

实际上,只有大约10%的以UTF-16存储的文件需要存储为UTF-16,其余的可以安全地存储为UTF-8并且没问题.如果我们可以使那些需要UTF-16的那些,并且其余的是UTF-8,我们可以在文件系统上使用大约40%的空间.

我们试图对数据进行很好的压缩,这很有用,但我们发现我们得到的UTF-8压缩比与UTF-16相同,UTF-8压缩也更快.因此,最终如果尽可能多的数据存储为UTF-8,我们不仅可以在存储解压缩时节省空间,即使压缩也可以节省更多空间,我们甚至可以节省压缩本身的时间.

目标

要弄清楚XML文件中何时需要UTF-16的Unicode字符,所以我们只能在必要时使用UTF-16.

关于XML文件和数据的一些细节

虽然我们控制XML本身的模式,但是我们不能控制从Unicode角度看哪些类型的"字符串",因为源可以自由地提供要使用的Unicode数据.然而,这种情况很少见,所以我们不希望每次只使用UTF-16来支持只需要10%时间的东西.

发展环境

我们在.Net Framework 4.0中使用C#.

编辑:解决方案

解决方案就是使用UTF-8.

这个问题是基于我对UTF的误解,我感谢所有帮助我的人.谢谢!

c# unicode utf-8 utf-16 character-encoding

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

Ruby,从Date.day_fraction_to_time获取小时,秒和时间

我在这里找到了这个方法.

  start = DateTime.now
  sleep 15
  stop = DateTime.now
  #minutes
  puts ((stop-start) * 24 * 60).to_i

  hours,minutes,seconds,frac = Date.day_fraction_to_time(stop-start)
Run Code Online (Sandbox Code Playgroud)

我有以下错误:

`<main>': private method `day_fraction_to_time' called for Date:Class (NoMethodError)
Run Code Online (Sandbox Code Playgroud)

我检查了/usr/lib/ruby/1.9.1/date.rb,我发现了它:

def day_fraction_to_time(fr) # :nodoc:
  ss,  fr = fr.divmod(SECONDS_IN_DAY) # 4p
  h,   ss = ss.divmod(3600)
  min, s  = ss.divmod(60)
  return h, min, s, fr * 86400
end
Run Code Online (Sandbox Code Playgroud)

但如果我用ruby1.8运行它,我没有问题./usr/lib/ruby/1.8/date.rb给了我:

  def self.day_fraction_to_time(fr)
    ss,  fr = fr.divmod(SECONDS_IN_DAY) # 4p
    h,   ss = ss.divmod(3600)
    min, s  = ss.divmod(60)
    return h, …
Run Code Online (Sandbox Code Playgroud)

ruby comparison datetime method-missing

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

iOS4.1 SDK中单个库中的重复符号

我正在开发一个iPhone应用程序.我对Xcode不熟悉,所以请耐心等待.我有iOS 4.1 Device SDK.当我在"Active ..."下拉框中选择"Simulator"时,我的应用程序编译没有错误并在iPhone模拟器中运行.

但是,当我在下拉框中选择"设备"时,我收到有关重复符号的以下链接器错误:

Ld build/PineCone.build/Debug-iphoneos/PineCone.build/Objects-normal/armv6/PineCone normal armv6
cd /Users/isaacsutherland/fydp/PineCone/PineCone
setenv IPHONEOS_DEPLOYMENT_TARGET 4.1
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk -L/Users/isaacsutherland/fydp/PineCone/PineCone/build/Debug-iphoneos -L/Users/isaacsutherland/fydp/PineCone/PineCone/../3rd/libGHUnitIPhone -F/Users/isaacsutherland/fydp/PineCone/PineCone/build/Debug-iphoneos -filelist /Users/isaacsutherland/fydp/PineCone/PineCone/build/PineCone.build/Debug-iphoneos/PineCone.build/Objects-normal/armv6/PineCone.LinkFileList -dead_strip -all_load -ObjC -miphoneos-version-min=4.1 -framework Foundation -framework UIKit -framework CoreGraphics /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20Core.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20Network.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20Style.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20UI.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20UICommon.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20UINavigator.a -framework QuartzCore -framework CFNetwork -framework MobileCoreServices -framework SystemConfiguration -lz.1.2.3 /Users/isaacsutherland/fydp/PineCone/ClientDal/build/Debug-iphoneos/libClientDal.a -lGHUnitIPhone4_0 -o /Users/isaacsutherland/fydp/PineCone/PineCone/build/PineCone.build/Debug-iphoneos/PineCone.build/Objects-normal/armv6/PineCone

ld: duplicate symbol _RedirectionLimit in /Users/isaacsutherland/fydp/PineCone/ClientDal/build/Debug-iphoneos/libClientDal.a(libASIHTTPRequest.a-armv6-master.o) and /Users/isaacsutherland/fydp/PineCone/ClientDal/build/Debug-iphoneos/libClientDal.a(libASIHTTPRequest.a-armv6-master.o)
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
Run Code Online (Sandbox Code Playgroud)

错误是奇怪的,因为它抱怨_RedirectionLimit被发现两次 …

xcode xcodebuild ios4 ios

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

否定布尔评估的真实性导致5倍减速?

我正在尝试实现一个八叉树,为此,我需要一个快速的AABB射线交叉算法.经过一番搜索,我偶然发现了这篇文章.从这里提供的源代码中,我将pluecker_cls_cff函数转换为C#,如下所示:

public bool Intersect_2(ref RayPluecker r)
{
  switch (r.Classification)
  {

    // 7 same-ish cases snipped

    case Classification.PPP:

      return !((r.Position.X > this.Max.X) || (r.Position.Y > this.Max.Y) || (r.Position.Z > this.Max.Z) ||
        (r.PlueckerCoefficient.X + r.Direction.X * this.Max.Y - r.Direction.Y * this.Min.X < 0) ||
        (r.PlueckerCoefficient.X + r.Direction.X * this.Min.Y - r.Direction.Y * this.Max.X > 0) ||
        (r.PlueckerCoefficient.Y + r.Direction.X * this.Min.Z - r.Direction.Z * this.Max.X > 0) ||
        (r.PlueckerCoefficient.Y + r.Direction.X * this.Max.Z - r.Direction.Z * …
Run Code Online (Sandbox Code Playgroud)

c# performance intersection aabb

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

好主意还是坏主意?使用静态类变量存储全局

我有一个我在我的代码中使用的课程.它包含设置和其他核心功能.这就是我现在正在使用的课程.

$settings = new Settings();
$settings->loadSettings();
Run Code Online (Sandbox Code Playgroud)

然后,当我需要在另一个类中的一些随机函数中的代码时,我做这样的事情:

function abc() {
    global $settings;
    $variable = $settings->a;
}
Run Code Online (Sandbox Code Playgroud)

我厌倦了随机调用全局$设置来拉入该设置对象.我不想使用$ _GLOBALS数组(我不知道为什么,我只是不想).

我想我想切换到设置中有一个名为$ settings的静态类变量.代码如下所示:

Settings::$settings = new Settings();
Settings::$settings->loadSettings();
Run Code Online (Sandbox Code Playgroud)

然后,每当我想使用它时,我都不必担心通过全局运算符将其吸入:

function abc() {
    $variable = Settings::$settings->a;
}
Run Code Online (Sandbox Code Playgroud)

好主意还是坏主意?

php design-patterns global-variables

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