灯角

文章 评论 浏览 24

灯角 2024-10-02 10:48:38

您可以使用 ContentInterator 来帮助访问大型列表中的 5,000 多个项目,而不会达到列表限制并收到 SPQueryThrottleException。

ContentIterator 实现了一种回调模式,用于对查询进行分段,以便一次处理单个项目。如果您需要处理大量可能超出限制的项目,请考虑使用此功能

You can use ContentInterator which help with accessing more than 5,000 items in a large list without hitting a list throttling limit and receiving an SPQueryThrottleException.

ContentIterator implements a callback pattern for segmenting the query for processing a single item at a time. Consider using this capability if you need to process a large number of items that may exceed a throttling limit

如何在启用限制的情况下从大列表中获取数据?

灯角 2024-10-02 08:46:57

根据 @Konrad 的建议,另一种选择是使用静态方法来构造对象,例如:

class Derived {
public:
    Derived(int p1, int p2, int p3) : Base(p1, p2) { }

    static Derived* CreateDerived(int p3) { return new Derived(42, 314, p3); }
};

我发现这在从库扩展类并具有多个要覆盖的参数时很有用。
您甚至可以将构造函数设置为私有

Another option, based on the suggestion from @Konrad is to have a static method to construct the object, e.g.:

class Derived {
public:
    Derived(int p1, int p2, int p3) : Base(p1, p2) { }

    static Derived* CreateDerived(int p3) { return new Derived(42, 314, p3); }
};

Ive found this useful when extending a class from a library and having multiple parameters to override.
You can even make the constructor private

稍后在 C++ 中调用基类构造函数(不在初始值设定项列表中)

灯角 2024-10-02 08:12:10

这意味着您尝试访问仅包含一项(索引 0)的数组中的第二项(索引 1)。

It means you attempted to access the second item (at index 1) in an array containing only one item (index 0).

*** 由于未捕获的异常“NSRangeException”而终止应用程序,原因:“*** -[NSMutableArray objectAtIndex:]:索引 1 超出范围 [0 .. 0]”

灯角 2024-10-02 06:34:06

我的代码做了一些更复杂的事情,但非常相似。我所做的是在对话框关闭时创建并写入带有空白 ContactID 的电子邮件条目。然后,当我提交联系表单时,我会看到一个包含电子邮件 ID 的字段。在“联系人保存”操作中,我检查电子邮件记录,如果 contactID 字段为空,则插入 ContactID 并保存电子邮件记录。我使用相同的部分视图来创建和编辑,因此如果是编辑现有电子邮件,或向现有联系人添加新电子邮件,则 ContactID 字段已填充。

在这个简单的情况下,当用户关闭对话框以将信息保存到父表单上的隐藏字段时可能更有意义(如果您不希望它们显示,如果您确实希望它们显示,那么 Ryan 的建议是最好的)并且然后在联系人提交中创建并保存这两条记录。

如果这是“创建”,那么我真的不明白为什么你需要 AJAX 请求来获取值......

My code does something a bit more complicated, but very similar. What I do is create and write the email entry with a blank ContactID when the dialog is closed. Then when I submit my Contact form, I have a field with the EmailID. In my Contact Save action, I check the Email record and if the contactID field is empty, I insert the ContactID and save the Email record. I use the same partial view for Creating and Editing, so if it's Editing an existing email, or adding a new email to an existing contact, the ContactID field is already filled.

In this simple case, it may make more sense when the users closes the dialog to save the info to hidden fields on your parent form (if you don't want them displayed, if you do want them displayed then Ryan's suggestion is best) and then create and save both records on the Contact submit.

If this is a "Create" then I don't really understand why you need an AJAX request to get values...

在 asp.net mvc 2 .在创建视图中添加新的关系记录

灯角 2024-10-02 03:57:07

马丁·卡尔曼的想法似乎是最好的方法,因为你没有自然地形来定义一些边界。在您的边界内生成随机点,然后将它们纳入国家边界。我可能会更进一步,比所需的国家/地区提出更多的点,然后合并几个相邻的单元格以使一些结果区域凹入。您可以使用类似于随机 Kruskal 的算法来执行合并(获取所有国家/地区,合并两个相邻国家/地区,重复直到获得所需的总数)。我无法访问 Kylotan 的链接,但它可能描述了一种更好的方法来合并由 Voronoi 生成的单元格。

Martin Källman's idea seems the best way to do it since you don't have natural terrain to define some of the borders. Generate random points within your borders and then Voronoi them into country borders. I would probably take it one step further and make more points than desired countries, and then merge several adjacent cells to make some of the resulting areas concave. You could use an algorithm similar to a randomized Kruskal to perform the merging (take all the countries, merge two adjacent countries, repeat until you have the desired total). I can't get to Kylotan's link, but it may describe a better way to merge the cells generated by the Voronoi.

在 2D 地图上生成区域

灯角 2024-10-02 02:21:59

如果您使用 AJAX 执行此操作,则可能需要处理 XSS 问题。也许您需要为您的应用程序编写一个可以从其他应用程序使用的简单 API。这对 Rails 来说并不困难,您可以从一些好的控制器抽象中获得帮助,例如 inherited_resources

在某些时候,外部应用程序将使用 AJAX 向自身发送表单,并处理它并使用 JSON 或 XML...或任何您想要的格式将其发送到您的 Rails 应用程序。

If you do it with AJAX you may have to handle XSS issues. Maybe you need to write an easy API for your application that could be consumed from that other application. That's not difficult from Rails and you can get help from some good controller abstractions like inherited_resources.

At some point that external application will send a form to itself using AJAX and will handle it and send it to your rails application using JSON or XML... or whatever format you want.

使用 ajax 在外部站点中形成 Rails

灯角 2024-10-01 23:58:12

我认为您应该预处理数据并创建一个结构,列出网格中矩形区域的可能多边形。这样,您可以减少必须检查点的多边形,并且附加结构将适合内存,因为它只有指向多边形的指针。

这是一张图片来说明:

http://img191.imageshack.us/img191/5189/stackoverflowpolygonmes.png

你想要检查黄点位于哪个多边形。您通常会检查所有多边形,但通过网格优化(橙色线,没有绘制整个网格,仅绘制其字段之一),您只需检查填充的多边形因为它们都在或部分在网格区域内。

类似的方法是不将所有多边形数据存储在内存中,而只存储多边形边界框,每个多边形只需要 2 个而不是 3 个 X/Y 对(以及指向实际多边形数据的附加指针),但这没有第一个建议节省那么多空间。

I think you should preprocess the data and create a structure that lists possible polygons for rectangular areas in a grid. This way, you can reduce the polygons you'll have to check against the points and the additional structure will fit into memory as it just has pointers to the polygons.

Here's an image to illustrate:

http://img191.imageshack.us/img191/5189/stackoverflowpolygonmes.png

You want to check which polygon the yellow point is in. You would usually check against all the polygons, but with the grid optimization (the orange lines, didn't draw the whole grid, just one of its fields) you only have to checked the filled polygons as they all are inside or partially inside the grid field.

A similar way would be not to store all the polygon data in memory, but just the polygons bounding boxes which would only require 2 instead of 3 X/Y pairs for each polygon (and an additional pointer to the actual polygon data), but this doesn't save as much space as the first suggestion.

多边形中的 r 点

灯角 2024-10-01 23:46:53

如果在视觉模式下拉动,您还可以使用 '>`> 转到刚刚拉动的视觉选择的最后一行/字符。在这种情况下,这本质上与 ']`] 相同,这显然在 VsVim 等中不受支持。

If yanking in visual mode, you could also use '> or `> to go to the last line/character of the just yanked visual selection. In this context this is essentially the same as '] and `] which is apparently not supported e.g. in VsVim.

在 VIM 中猛拉某个区域而不将光标移动到块的顶部?

灯角 2024-10-01 22:08:39

我可以想到 3 个可能的问题:

  • 当通过较低的 php 系统调用读取/写入文件时,文件被锁定,而您却不知道。这应该会阻止文件最多 1/3 秒。你的经期会比那个更长。
  • fs 缓存启动 fsync(),整个系统会阻止对磁盘的读/写,直到完成为止。作为修复,您可以尝试安装更多 RAM 或升级内核或使用更快的硬盘,
  • 您的“缓存”解决方案未分发,并且它每秒多次撞击整个系统中表现最差的硬件......这意味着您不能通过简单地添加更多机器来进一步扩展它,只能通过提高硬盘速度。您应该看看 memcache 或 APC,甚至可能是共享内存 http://www.php.net/manual/en/function.shm-put-var.php

我能想到的解决方案:

  • 将该文件放入 ramdisk http://www.cyberciti.biz/faq/howto-create-linux-ram-disk-filesystem / 。这应该是避免频繁访问磁盘的最简单方法,无需其他重大更改。
  • 使用内存缓存。在本地使用时速度非常快,扩展性良好,被“大”玩家使用。 http://www.php.net/manual/en/book.memcache。 php
  • 使用共享内存。它是为您在这里尝试做的事情而设计的...具有“共享内存区域”...
  • 更改 cron 调度程序以减少更新,也许实现某种事件系统,因此它只会在必要时更新缓存,并且不按时间
  • 使“写入”脚本写入3个不同的文件,并让“读者”随机地从其中一个文件读取。这可能允许在更多文件中“分布”查找,并且可能会减少某个文件在写入时被锁定的机会......但我怀疑它会带来任何明显的好处。

I can think of 3 possible problems:

  • the file get locked when read/writing to it by lower php system calls without you knowing it. This should block the file for 1/3s max. You get periods longer that that.
  • the fs cache starts a fsync() and the whole system blocks read/writes to the disk until that is done. As a fix you may try installing more RAM or upgrading the kernel or using a faster hard disk
  • your "caching" solution is not distributed, and it hits the worst acting piece of hardware in the whole system many times a second... meaning that you cannot scale it further by simply adding more machines, only by increasing the hdd speed. You should take a look at memcache or APC, or maybe even shared memory http://www.php.net/manual/en/function.shm-put-var.php

Solutions i can think of:

  • put that file in a ramdisk http://www.cyberciti.biz/faq/howto-create-linux-ram-disk-filesystem/ . This should be the simplest way to avoid hitting the disk so often, without other major changes.
  • use memcache. Its very fast when used locally, it scales well, used by "big" players. http://www.php.net/manual/en/book.memcache.php
  • use shared memory. It was designed for what you are trying to do here... having a "shared memory zone"...
  • change the cron scheduler to update less, maybe implement some kind of event system, so it would only update the cache when necessary, and not on a time basis
  • make the "writing" script write to 3 files different, and make the "readers" read from one of the files, randomly. This may allow a "distribution" of the loking across more files and it may reduce the chances that a certain file is locked when writing to it... but i doubt it would bring any noticeable benefits.

PHP 中的 fopen 文件锁定(读取器/写入器类型的情况)

灯角 2024-10-01 22:02:30

那么,最好的方法是在创建主记录时创建关联记录:

class User < ActiveRecord::Base
   has_one       :preference_set, :autosave => true
   before_create :build_preference_set
end

这将对其进行设置,以便每当创建 User 时,PreferenceSet 也会创建。如果您需要使用参数初始化关联记录,请在 before_create 中调用不同的方法,该方法调用 build_preference_set(:my_options => "here") 然后返回 <代码> true。

然后,您可以通过迭代任何没有 PreferenceSet 的记录并通过调用 #create_preference_set 构建一个来标准化所有现有记录。

如果您只想在绝对需要时创建 PreferenceSet,那么您可以执行以下操作:

class User < ActiveRecord::Base
   has_one :preference_set

   def preference_set_with_initialize
     preference_set_without_initialize || build_preference_set
   end

   alias_method_chain :preference_set, :initialize
end

Well the best way to do this is to create the associated record when you create the primary one:

class User < ActiveRecord::Base
   has_one       :preference_set, :autosave => true
   before_create :build_preference_set
end

That will set it up so whenever a User is created, so is a PreferenceSet. If you need to initialise the the associated record with arguments, then call a different method in before_create which calls build_preference_set(:my_options => "here") and then returns true.

You can then just normalise all existing records by iterating over any that don't have a PreferenceSet and building one by calling #create_preference_set.

If you want to only create the PreferenceSet when it is absolutely needed, then you can do something like:

class User < ActiveRecord::Base
   has_one :preference_set

   def preference_set_with_initialize
     preference_set_without_initialize || build_preference_set
   end

   alias_method_chain :preference_set, :initialize
end

Rails:如果没有找到关联,则创建关联以避免零错误

灯角 2024-10-01 13:30:51

我想你想在这里做的是这样的:

var now = DateTime.Now;
if (now.Hour >= 8 && now.Hour < 17)

I think what you want to do here is something like this:

var now = DateTime.Now;
if (now.Hour >= 8 && now.Hour < 17)

日期时间转换/魔法

灯角 2024-10-01 11:48:05

发现这个 http://www.prettyklicks.com/blog/making-a-facebook-feed-using-the-graph-api-json-and-jquery/291/ 教程真正解决了问题。

只是把它放在这里以防其他人需要它。

found this http://www.prettyklicks.com/blog/making-a-facebook-feed-using-the-graph-api-json-and-jquery/291/ tutorial which REALLY cleared things up.

just putting it here in case someone else needs it.

在图库中显示 Facebook 相册第二部分

灯角 2024-10-01 10:51:15

如果是单行,请尝试以下操作:

android:ellipsize="end"
android:maxLines="1"
android:scrollHorizontally="true"
android:singleLine="true"

它对我有用。

If it's for a single line try this:

android:ellipsize="end"
android:maxLines="1"
android:scrollHorizontally="true"
android:singleLine="true"

It worked for me.

Android:比 android:ellipsize="end" 更好的东西添加“...”截断长字符串?

灯角 2024-10-01 09:01:12

这使用了递归:

 def is_sorted(lst):
    if len(lst) == 1:
       return True
    return lst[0] <= lst[1] and is_sorted(lst[1:])

 some_list = [1,2,3,4]
 print(is_sorted(some_list))

请注意,对于长序列,这将引发RuntimeError:超出最大递归深度

This uses recursion:

 def is_sorted(lst):
    if len(lst) == 1:
       return True
    return lst[0] <= lst[1] and is_sorted(lst[1:])

 some_list = [1,2,3,4]
 print(is_sorted(some_list))

Note that this will raise RuntimeError: maximum recursion depth exceeded for long sequences.

检查列表是否已排序的 Pythonic 方法

灯角 2024-10-01 03:09:20

我找到了...

myDataView.RowFilter = "Convert(Time, System.String) <> ''";

I found it...

myDataView.RowFilter = "Convert(Time, System.String) <> ''";

如何根据 TimeSpan 值过滤 DataColumn?

更多

推荐作者

jsonder

文章 0 评论 0

給妳壹絲溫柔

文章 0 评论 0

北笙凉宸

文章 0 评论 0

国产ˉ祖宗

文章 0 评论 0

月下客

文章 0 评论 0

梦行七里

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文