走过海棠暮

文章 评论 浏览 25

走过海棠暮 2024-08-12 14:07:08

可以在此处找到非常符合 Perl 风格的 RFC822 正则表达式

A very Perl-ish RFC822 compliant regular expression can be found here

再次验证电子邮件地址

走过海棠暮 2024-08-12 11:48:45

您的应用程序是否在带有 IIS 的计算机上运行?如果是这样,您可以通过设置 SMTP 客户端的传送方法来利用内置 SMTP 服务,如下所示:

var client = new SmtpClient 
{ 
    DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis 
};

我在一些应用程序中使用它,它非常可靠。

Is your application running on a machine with an IIS? If so, you could take advantage of the built-in SMTP Service by setting the delivery method of your SMTP client like this:

var client = new SmtpClient 
{ 
    DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis 
};

I am using this in a few applications, and it's very reliable.

.NET System.Net.Mail.SmtpClient 类不会向 SMTP 事务发出 QUIT 命令

走过海棠暮 2024-08-12 10:28:24

所以我走上了部分课程的路线。例如,我添加了以下成员来解决原始示例中的第一个引用成员:

public partial class tb_account
{
    public tb_reference shipping_preference_reference
    {
        get
        {
            return this._tb_reference.Entity;
        }
        set
        {
            this.tb_reference = value;
        }
    }

这远非完美。在大型模型中它需要大量的额外代码,并且依赖于属性的顺序不改变(如果引用表的另一个外键被添加到帐户表中,则该成员实际上可能指向除运输偏好)。
这也有一个好处。由于我已经为其他目的编写了部分类,因此添加这些成员不需要我重新构建应用程序。

So I went down the partial classes route. For instance, I added the following member to address the first reference member in my original example:

public partial class tb_account
{
    public tb_reference shipping_preference_reference
    {
        get
        {
            return this._tb_reference.Entity;
        }
        set
        {
            this.tb_reference = value;
        }
    }

This is far from perfect. It requires a substantial amount of extra code in a large model, and depends on the order of the attributes to not change (if another foreign key to the reference table is added to the account table, this member may actually point to something else than the shipping preference).
There is an upside, too. Since I am already writing partial classes for other purposes, adding these members did not require that I rearchitect the application.

同一个表的多个外键

走过海棠暮 2024-08-12 09:20:45

文档中的这句话对此进行了解释:

The SqlMembershipProvider performs its search using a LIKE clause against the usernameToMatch parameter. Any wildcards that are supported by SQL Server in LIKE clauses can be used in the usernameToMatch parameter value.

SO

“获取成员资格用户的集合,其中用户名包含要匹配的指定用户名。”

是准确的句子,如果您搜索“DAV*”,您应该得到“Dave”、“David”、“Davis”等。

This sentence in the documentation explains it:

The SqlMembershipProvider performs its search using a LIKE clause against the usernameToMatch parameter. Any wildcards that are supported by SQL Server in LIKE clauses can be used in the usernameToMatch parameter value.

SO

"Gets a collection of membership users where the user name contains the specified user name to match."

is the accurate sentence if you do a search for "DAV*" you should get "Dave", "David, "Davis", etc.

FindUsersByName 是否应该包含部分匹配项?

走过海棠暮 2024-08-11 21:51:10

这个术语是可访问性。请访问 W3C 的 WAI 网站。我一直发现 Juicy Studio 是讨论辅助功能的文章的宝贵资源。

The term for this is Accessibility. Take a look at the W3C's WAI Website. I've always found Juicy Studio to be an invaluable resource for articles discussing accessibility.

让视障人士可以访问网站?

走过海棠暮 2024-08-11 21:47:34

我能建议的最好的办法是查询父记录,然后使用 in(父 ID 列表)查询查询子记录。这将为您提供两个数据集。一份给父母,一份给孩子。在客户端,您可以获取父 ID 并获取一组子记录。

The best thing I can suggest is a query for the parent records followed by a query for the children using an in (parent id list) query. This will give you two data sets. One for the parents and one for the children. On the client side you can then take a parent id and get a set of children records.

如何获取列表中的列表(类似于多维数组)?

走过海棠暮 2024-08-11 18:31:04

任何具有本机扩展的 gem 都不能与您的应用程序一起提供,而且很有可能在 DH 上,config.gem 也无法正常工作。您必须安装自己的 ruby​​gems 并让您的应用程序使用它。我建议看看这个:

http://railstips。 org/2008/11/24/rubygems-yours-mine-and-ours

它提供了有关在 DH 上设置环境的详细说明。我上周在服务器升级后才必须这样做,它仍然适用。

Any gem that has native extensions can't be vendored with your app, and there's a good bet that on DH, config.gem won't work right either. You have to install your own rubygems and make your app use it. I recommend taking a look at this:

http://railstips.org/2008/11/24/rubygems-yours-mine-and-ours

It has great instructions for setting up your environment on DH. I just had to do this last week after a server upgrade, and it still applies.

托管帮助 - DreamHost 上的自定义 Gems

走过海棠暮 2024-08-11 17:28:26

修复@willblack 和@Daniel_Kislyuk 答案中的安全漏洞。

如果数据不受信任,您不能只执行

viewset.py

 def get_context_data(self, **kwargs):
    context['my_dictionary'] = json.dumps(self.object.mydict)

template.html

<script>
    my_data = {{ my_dictionary|safe }};
</script>

因为数据可能类似于
{"":""}
默认情况下,正斜杠不会被转义。显然,json.dumps 的转义可能与 Javascript 中的转义不 100% 匹配,这就是问题的根源。

已修复的解决方案

据我所知,以下内容解决了该问题:

<script>
   my_data = JSON.parse("{{ my_dictionary|escapejs }}");
</script>

如果仍然存在问题,请在评论中发表。

Fixing the security hole in the answers by @willblack and @Daniel_Kislyuk.

If the data is untrusted, you cannot just do

viewset.py

 def get_context_data(self, **kwargs):
    context['my_dictionary'] = json.dumps(self.object.mydict)

template.html

<script>
    my_data = {{ my_dictionary|safe }};
</script>

because the data could be something like
{"</script><script>alert(123);</script>":""}
and forward slashes aren't escaped by default. Clearly the escaping by json.dumps may not 100% match the escaping in Javascript, which is where the problems come from.

Fixed solution

As far as I can tell, the following fixes the problem:

<script>
   my_data = JSON.parse("{{ my_dictionary|escapejs }}");
</script>

If there are still issues, please post in the comments.

通过 Django 将 Python 数据传递给 JavaScript

走过海棠暮 2024-08-11 14:53:13

在这种情况下,您最好的选择是 Fiddler (独立程序),篡改数据,或实时标头(都是 Firefox 插件)。

每个都可以让您查看传入的 HTTP 请求。这些可以让您实时查看正在请求的内容,并且可以让您更深入地了解是什么挂起了您的网站。祝你好运!

Your best bet in that case would be something like Fiddler (stand-alone program), Tamper Data, or Live Headers (both Firefox plugins).

Each lets you see the HTTP requests as they come in. These give you real time views of what is being requested and should give you more insight into what is hanging your site up. Good luck!

如何使用 Firebug 判断导致页面加载缓慢的原因?

走过海棠暮 2024-08-11 11:38:00

一种简单的方法是尝试使用 PIL(Python 成像库)加载和验证文件。

from PIL import Image

v_image = Image.open(file)
v_image.verify()

捕获异常...

来自文档

im.verify()

尝试确定文件是否损坏,而不实际解码图像数据。如果此方法发现任何问题,它会引发适当的异常。该方法仅适用于新打开的图像;如果图像已经加载,则结果未定义。另外,如果使用此方法后需要加载图片,则必须重新打开图片文件。

An easy way would be to try loading and verifying the files with PIL (Python Imaging Library).

from PIL import Image

v_image = Image.open(file)
v_image.verify()

Catch the exceptions...

From the documentation:

im.verify()

Attempts to determine if the file is broken, without actually decoding the image data. If this method finds any problems, it raises suitable exceptions. This method only works on a newly opened image; if the image has already been loaded, the result is undefined. Also, if you need to load the image after using this method, you must reopen the image file.

如何以编程方式检查图像(PNG、JPEG 或 GIF)是否已损坏?

走过海棠暮 2024-08-11 11:28:26

虽然 .NET 中没有 LDAP 路径解析器,但有 URI 解析器。对于那些需要简单解析“LDAP://domain/...”路径的人,您可以使用 System.Uri 类,然后您可以获得如下所示的一些详细信息:

var uri = new Uri(SomeDomainURI);
var scheme = uri.Scheme; // == "LDAP" or "LDAPS" usually
var domainHost = uri.Host;
var path = uri.AbsolutePath.TrimStart('/');

如果您使用 此 DN 解析器 您还可以执行以下操作解析路径:

var dn = new DN(uri.AbsolutePath.TrimStart('/'));

虽然我同意 .NET 现在应该已经有了这个(遗憾!),但这至少是满足我需求的一个不错的解决方案,尽管并不完美,而且我怀疑它对每个人来说都足够强大。

While there is no LDAP path parser in .NET, there is a URI parser. For those who need to simply parse "LDAP://domain/..." paths you can use the System.Uri class, then you can get some details like the following:

var uri = new Uri(SomeDomainURI);
var scheme = uri.Scheme; // == "LDAP" or "LDAPS" usually
var domainHost = uri.Host;
var path = uri.AbsolutePath.TrimStart('/');

If you use this DN parser you can also do the following instead to parse the path:

var dn = new DN(uri.AbsolutePath.TrimStart('/'));

While I agree that .NET should have had this by now (shame!), this was at least an ok work around for my needs, though not perfect, and I doubt it will be robust enough for everyone.

.NET LDAP 路径实用程序 (C#)

走过海棠暮 2024-08-11 09:58:06

这是非常不科学的,但我认为看看有多少谷歌结果与这个问题的常见答案和术语“多对多”的组合相关联会很有趣。

基于此,看起来“连接表”是...嗯...多对多关系中连接表最常用的术语。


组合搜索词

“连接表”“多对多”

在 Google 中返回大约 13,700 个结果。

“链接表”“多对多”

返回 4,700 左右。

“联结表”“多对多”

返回 3,500 左右。

“关联表”“多对多”

返回 3,300 左右。

“关系表”“多对多”

返回 3,200 左右。

“交集表”“多对多”

返回 1,500 左右。

“交叉引用表”“多对多”

返回 1,000。

动名词“多对多”

仅返回 450。

This is HIGHLY unscientific, but I thought it would be interesting to see how many Google results were associated with the combination of common answers to this question and the term "many to many".

Based on this, it looks like "join table" is the most commonly used term for the...um...joining table in a many-to-many relationship.


The combined search terms

"join table" "many to many"

return around 13,700 results in Google.

"link table" "many to many"

returns around 4,700.

"junction table" "many to many"

returns around 3,500.

"association table" "many to many"

returns around 3,300.

"relationship table" "many to many"

returns around 3,200.

"intersection table" "many to many"

returns around 1,500.

"cross-reference table" "many to many"

brings back 1,000.

gerund "many to many"

only returns 450.

数据库模式中的多对多关系表是否有正式名称?

走过海棠暮 2024-08-11 02:39:10

好吧,最简单的方法是监听 PropertyChangeEvent.PROPERTY_CHANGE ...如果您声明一个属性可绑定,那么 mxmlc 会生成代码来调度此事件...如果您让编译器保留生成的 ActionScript ,然后你就会看到它......

除此之外,你可能想看看 BindingUtils ...

well, the easiest way is to listen to PropertyChangeEvent.PROPERTY_CHANGE ... if you declare a property bindable, then mxmlc generates the code to dispatch this event ... if you let the compiler keep the generated ActionScript, then you'll see it ...

other than that, you might want to have a look at BindingUtils ...

观察可绑定属性

走过海棠暮 2024-08-11 00:28:36

创建另一个函数(我们将其称为驴),并在每个中使用它:(

抱歉,格式有点混乱)

...
.each(donkey);

function cmdSave_PostCallBack() {
    donkey(1);
}

function donkey(i) {
    var selectionText = $(this.getAttribute("rel")).find(':selected')[0].innerHTML;
    if (selectionText.substr(0, 4) == "All ") {
        this.innerHTML += ": All";
    }
    else {
        this.innerHTML = this.innerHTML + ": " + selectionText;
    }
    });
return false;
}

Create another function (we shall call it donkey), and use that in the each:

(sorry, the formatting is a little messed up)

...
.each(donkey);

function cmdSave_PostCallBack() {
    donkey(1);
}

function donkey(i) {
    var selectionText = $(this.getAttribute("rel")).find(':selected')[0].innerHTML;
    if (selectionText.substr(0, 4) == "All ") {
        this.innerHTML += ": All";
    }
    else {
        this.innerHTML = this.innerHTML + ": " + selectionText;
    }
    });
return false;
}

如何从 JQuery 块外部调用 JQuery

走过海棠暮 2024-08-10 21:03:01

是的,具有单个 inputText 字段的表单在 HTML 4 中的工作方式有所不同。
onSubmit return false 对我不起作用,但下面的修复错误工作正常

<!--Fix  IE6/7/8 and  HTML 4 bug -->
    <input style="display:none;" type="text" name="StackOverflow1370021" value="Fix IE bug" />

Yes, form with a single inputText field working as different in HTML 4.
onSubmit return false not working for me but the below fix bug is working fine

<!--Fix  IE6/7/8 and  HTML 4 bug -->
    <input style="display:none;" type="text" name="StackOverflow1370021" value="Fix IE bug" />

为什么单输入字段的表单在输入中按回车键后会提交

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