问题列表 - 第31391页

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

Safari的Reader代码在哪里?

Safari 5获得了一项新功能:阅读器.它显示了文章页面的简化版本,只包含文章本身(而不是所有杂乱的文章).它还将多个页面(如果文章分为多个页面)合并为一个页面.

这是一个非常有用的功能,我想将其移植到Chrome.

我在WebKit主干中搜索Readers代码(例如http://svn.webkit.org/repository/webkit/trunk/),但我找不到它.

有什么提示我可以找到它吗?

safari code-analysis webkit google-chrome

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

Python:类似于`map`的东西,适用于线程

我确信在标准库中有这样的东西,但似乎我错了.

我有一堆我想urlopen并行的网址.我想要内置map函数,除了工作由一堆线程并行完成.

是否有一个很好的模块可以做到这一点?

python parallel-processing multithreading map-function

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

我如何使用PHP 5.3 Closures,比如我们在Ruby中使用Blocks

我如何使用PHP 5.3 Closures,比如我们在Ruby中使用Blocks.我从来没有在Ruby中使用'for'循环,因为使用带有'each''read_all''inject'方法的块.

我如何使用像Ruby块这样的PHP 5.3闭包,并说再见'for'Loops :)

就像在{和}之间是一个闭包(或块或匿名函数)

fruit = %w[apple banana orange]
fruit.each { |f| print "#{f}, " }
Run Code Online (Sandbox Code Playgroud)

我用PHP这样做,

$fruit = array('apple', 'banana', 'orange');
foreach ($fruit as $f) 
{
 print "$f, "; 
}
Run Code Online (Sandbox Code Playgroud)

有没有办法使用PHP闭包的Ruby方式,因为PHP 5.3支持它.

php ruby lambda closures

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

OSX上的总线错误 - pthreads

我试图了解以下内容:

有一个小程序我试图移植到OSX(intel)通过pthread_create调用函数doWork(),在函数中,我首先创建一个像这样的长数组:

long myarray[DIMENSION]

在OSX上,对于以下DIMENSION值,我得到以下内容:

0->65434 = fine
65435->67037 = SIGBUS
67037+ = SIGSEGV

我在这里完全感到困惑,我知道SIGBUS通常是由于内存对齐问题,我检查了sizeof(long),在这个平台上看起来似乎是8.有人能指出我应该在这里阅读的文档的正确方向吗?

这是来源:


#include pthread.h
#include stdio.h
#define NUM_THREADS     5
#define DIMENSION       12345

void *doStuff(void *threadid)
{
   long array[DIMENSION];
   pthread_exit(NULL);
}

int main (int argc, char *argv[])
{
   pthread_t threads[NUM_THREADS];
   int rc;
   long t;
   for(t=0; t lt NUM_THREADS; t++){
      printf("In main: creating thread %ld\n", t);
      rc = pthread_create(&threads[t], NULL, doStuff, (void *)t);
      if (rc){
         printf("ERROR; return code from pthread_create() is %d\n", rc);
         exit(-1);
      }
   } …
Run Code Online (Sandbox Code Playgroud)

c macos pthreads

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

如何将jQuery Datepicker连接到Ruby on Rails表单?

我正在尝试使用jQuery Datepicker在我的Ruby on Rails表单中设置日期字段,但我无法弄清楚如何做到这一点.有人能指出我正确的方向吗?

jquery jquery-ui ruby-on-rails jquery-ui-datepicker

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

Calculating the Moment Of Inertia for a concave 2D polygon relative to its orgin

I want to compute the moment of inertia of a (2D) concave polygon. I found this on the internet. But I'm not very sure how to interpret the formula...

Formula http://img101.imageshack.us/img101/8141/92175941c14cadeeb956d8f.gif

1) Is this formula correct?
2) If so, is my convertion to C++ correct?

float sum (0);
for (int i = 0; i < N; i++) // N = number of vertices
{
    int j = (i + 1) % N;
    sum += (p[j].y - p[i].y) * (p[j].x + …
Run Code Online (Sandbox Code Playgroud)

c++ java math 2d vector

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

压缩Log4j文件

是否可以压缩日志文件(我通过RollingFileAppender进行压缩)?

java log4j properties

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

限制字符串中的句子数量

初学者的Python问题:

我有一个包含x个句子的字符串.如何提取前2个句子(可能以.或?或!结尾)

python

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

GOTO和THROW之间的区别?

最近有很多人指责我只提一个字 - "goto".
这让我很奇怪,为什么它被认为是一个令人讨厌的词.
我知道之前有几个关于这个主题的讨论,但它并没有让我信服 - 答案只是说"它很糟糕"甚至没有尝试解释,有些带来理由,与PHP,IMO等脚本语言无关.

无论如何,我将问一个非常特别的问题:
让我们进行比较gotothrow陈述.
在我看来,两者都做同样的事情:避免基于某些条件执行某些代码.
如果是这样 - throw与goto有同样的缺点吗?(如果有的话)?
如果不是 - 那就是惠特.

任何经验丰富的人,谁能说出以下两个代码片段的代码结构之间的基本概念差异?
关于这些非常的代码片段,不是"在理论上"或"一般"或"这里是一个不错的XKCD漫画!".
为什么第一个被认为是辉煌的而后一个被认为是最致命的罪?

#$a=1;
#$b=2;

/* SNIPPET #1 */

try {
    if (!isset($a)) {
      throw new Exception('$a is not set');
    }
    if (!isset($b)) {
      throw new Exception('$b is not set');
    }
    echo '$a + $b = '.($a + $b)."<br>\n";
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "<br>\n";
}

/* SNIPPET #2 …
Run Code Online (Sandbox Code Playgroud)

php exception-handling goto try-catch

7
推荐指数
5
解决办法
1732
查看次数