问题列表 - 第32578页

提取下一个/上一个月的数据

我正在提取查看月份的Fullcalendar数据。当我单击“下一个/上一个月”视图按钮时,它不会熄灭并获取新月份的新数据。

如何获得“下一个/上一个”按钮来再次调用数据库并提取该月的记录?

jquery fullcalendar

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

在表上设置列约束(SQL Server)

我有一个列应该包含2个幂n:2,4,8,16,32等值之一.我想在表模式级别强制执行 - 有没有办法指定这样的列约束?

谢谢!

sql sql-server constraints

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

How do I select the next "n" elements starting from the current element in jQuery?

How do I select the next "n" elements starting from the current element? What I mean is...

 $(this).attr(...);
Run Code Online (Sandbox Code Playgroud)

I want to do this "n" times. For the example of n=4:

$(this).attr(...);
$(this).next().attr(...);
$(this).next().next().attr(...);
$(this).next().next().next().attr(...);
Run Code Online (Sandbox Code Playgroud)

or perhaps do it in a loop:

for (i = 0; i < n; i++) {
    $(this).next().attr(...);
}
Run Code Online (Sandbox Code Playgroud)

How can I do this? Is there a way I can do this by selecting the next "n" elements or in a loop?

jquery jquery-selectors

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

How do I get Bin Path?

I need to the the bin path of the executing assembly. How do you get it? I have a folder Plugins in the Bin/Debug and I need to get the location

.net c#

69
推荐指数
5
解决办法
9万
查看次数

Is there a way to use a custom selected image for UITabBarItem?

I like to have a custom selected image when a user selects an item on the tab bar, by default it selects as blue like but would like to have a green color instead. something like below any thoughts?

alt text http://www.freeimagehosting.net/uploads/11a2137011.png

iphone uitabbaritem uitabbar

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

33
推荐指数
4
解决办法
5万
查看次数

对回文产品问题感到困惑

我一直在学习Ruby,所以我想我会尝试一些项目的Euler难题.令人尴尬的是,我只是解决了问题4 ......

问题4如下:

回文数字两种方式相同.由两个2位数字的乘积制成的最大回文是9009 = 91×99.

找到由两个3位数字的乘积制成的最大回文.

所以我想我会在一个嵌套的for循环中从999循环到100并对回文进行测试,然后当我找到第一个(应该是最大的一个)时突破循环:

final=nil
range = 100...1000
for a in range.to_a.reverse do
  for b in range.to_a.reverse do
    c=a*b
    final=c if c.to_s == c.to_s.reverse
    break if !final.nil?
  end
  break if !final.nil?
end
puts final
Run Code Online (Sandbox Code Playgroud)

这确实输出了回文580085,但显然这不是该范围内两个三位数字的最高乘积.奇怪的是,如果我将范围更改为10 ... 100,则相同的代码成功返回9009,就像在示例中一样.

  • 谁能告诉我哪里出错了?
  • 还有,有一种更好的方法可以打破内部循环吗?

谢谢

ruby puzzle math palindrome

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

"operator char*"问题

下面的代码预计打印"​​kevin"但是,它的打印垃圾值.我已经检查了调试器."operator char*"调用返回的指针无效.任何的想法?

class Wrapper
{
private:
    char* _data;

public:

    Wrapper(const char* input)
    {
        int length = strlen(input) + 1;
        _data = new char[length];
        strcpy_s(_data, length, input);
    }

    ~Wrapper()
    {
        delete[] _data;
    }

    operator char*()
    {
        return _data;
    }
};

int main()
{
    char* username = Wrapper("kevin");
    printf(username);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++

9
推荐指数
2
解决办法
3050
查看次数

多线程Python脚本比非线程脚本花费更长时间

免责声明:我对多线程非常糟糕,所以我完全有可能做错了.

我在Python中编写了一个非常基本的光线跟踪器,我一直在寻找可能加速它的方法.多线程似乎是一种选择,所以我决定尝试一下.但是,虽然原始脚本需要大约85秒来处理我的示例场景,但多线程脚本最终需要大约125秒,这看起来非常不直观.

这是原始的样子(我不会复制绘图逻辑和东西.如果有人认为需要找出问题,我会继续把它放回去):

def getPixelColor(x, y, scene):
    <some raytracing code>

def draw(outputFile, scene):
    <some file handling code>
    for y in range(scene.getHeight()):
        for x in range(scene.getWidth()):
            pixelColor = getPixelColor(x, y, scene)
            <write pixelColor to image file>

if __name__ == "__main__":
    scene = readScene()
    draw(scene)
Run Code Online (Sandbox Code Playgroud)

这是多线程版本:

import threading
import Queue

q = Queue.Queue()
pixelDict = dict()

class DrawThread(threading.Thread):
    def __init__(self, scene):
        self.scene = scene
        threading.Thread.__init__(self)

    def run(self):
        while True:
        try:
            n, x, y = q.get_nowait()
        except Queue.Empty:
            break
        pixelDict[n] = getPixelColor(x, y, …
Run Code Online (Sandbox Code Playgroud)

python multithreading

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

根据宽高比和宽度计算图像/视频的高度

我有宽度:240我有宽高比:2.40我需要根据这两个变量得到高度.公式是什么?

formula aspect-ratio

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