走过海棠暮

文章 0 评论 0 浏览 24

走过海棠暮 2024-12-16 13:41:17

我希望该方法看起来像这样,看起来更安全:

public void DoSomething(IEnumerable<IFoo> things)
{
   foreach(var o in things)
   {
           o.Bar();
   }
}

要阅读有关违反里氏原则的信息:什么是里氏替换原理?

I would expect the method to look like this, it seems much safer:

public void DoSomething(IEnumerable<IFoo> things)
{
   foreach(var o in things)
   {
           o.Bar();
   }
}

To read about the referred violation of the Liskov Principle: What is the Liskov Substitution Principle?

测试一个对象来查看它是否实现了一个接口有什么问题吗?

走过海棠暮 2024-12-16 08:20:49

可能与状态栏有关。根据您配置笔尖的方式,视图顶部最终可能会滑到状态栏下方,从而在底部留下空白区域。检查您是否已指定视图的笔尖中有一个状态栏(在视图检查器的第一个选项卡中)。

Its possibly related to the status bar. Depending on how you have configured your nib the top of your view can end up sliding under the status bar leaving white space at the bottom. Check that you've specified that it has a status bar in the nib for the view (in the first tab of the inspector for the view).

UIWebView 从底部白色边框开始

走过海棠暮 2024-12-16 07:12:17

无法路由地址是这里的关键。

您的 sendmail 似乎不知道如何路由该地址。您需要在这里进行一些邮件调试。第一步可能是检查 DNS 中该域的 MX 记录 - dig example.com MX

如果没有 MX 记录,那就是问题所在。如果存在 MX 记录,您可以尝试 ping 该主机。

failed to route the address is the key here.

Seems that your sendmail doesn't know how to route that address. You need some mail-debugging here. First step could be to check the DNS for MX-records for this domain - dig example.com MX.

If there is no MX record, that is the problem. If there are MX record(s), you might try to ping that hosts.

Diagnostic-Code: SMTP; 是什么意思?第573章 是什么意思?

走过海棠暮 2024-12-16 02:57:09

我想象您对类 Item 的定义至少如下所示:

class Item
{
Item(char* item, int itemType);
private:
    char *_item;
};

您的构造函数必须为 _item 分配内存,以便复制通过构造函数传入的内容。如果不这样做将不可避免地导致内存问题和异常。或者,您可以使用诸如 char 向量之类的东西。

I'm imagining your definition of class Item minimally looks like this:

class Item
{
Item(char* item, int itemType);
private:
    char *_item;
};

Your constructor must allocate memory for _item in order to make a copy of what gets passed in via the constructor. Failure to do that will inevitable result in memory problems and exceptions. Alternatively, you can use something like a vector of char.

C++ 中的 char 数组损坏

走过海棠暮 2024-12-16 02:00:13

这对我来说很有效:

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/wait.h>

void test(/*vector<string> inp,int i*/){
    int fds[2]; // file descriptors
    long count;  // used for reading from stdout
    int fd;     // single file descriptor
    char c;     // used for writing and reading a character at a time
    pid_t pid;  // will hold process ID; used with fork()

    pipe(fds);

    // child process #1.
    fd = open(/*(inp[i+1]).c_str()*/"/tmp/output", O_RDWR | O_CREAT, 0666);
    if (fork() == 0) {
        if (fd < 0) {
            return;
        }

        dup2(fds[0], 0);

        // Don't need stdout end of pipe.
        close(fds[1]);

        // Read from stdout...
        while ((count = read(0, &c, 1)) > 0)
            write(fd, &c, 1); // Write to file.

        _exit(0);
        // child process #2
    } else if ((pid = fork()) == 0) {
        dup2(fds[1], 1);

        // Don't need stdin end of pipe.
        close(fds[0]);

        // Output contents of the given file to stdout.
        char **arguments = new char*[2];/*getArguments(inp[i]);*/
        arguments[0]=(char*)"/bin/bash";
        arguments[1]=0;
        execvp(arguments[0], arguments);
        perror("execvp failed");
        _exit(0);
        // parent process
    } else {
        waitpid(pid, NULL, 0);
        close(fds[0]);
        close(fds[1]);
    }
}

int main(int argc, char* argv[]){
    test();
}

尝试告诉你的错误到底出现在哪里,或者显示你的程序的更多内容,这样我就可以尝试复制你的条件。

This works well for me:

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/wait.h>

void test(/*vector<string> inp,int i*/){
    int fds[2]; // file descriptors
    long count;  // used for reading from stdout
    int fd;     // single file descriptor
    char c;     // used for writing and reading a character at a time
    pid_t pid;  // will hold process ID; used with fork()

    pipe(fds);

    // child process #1.
    fd = open(/*(inp[i+1]).c_str()*/"/tmp/output", O_RDWR | O_CREAT, 0666);
    if (fork() == 0) {
        if (fd < 0) {
            return;
        }

        dup2(fds[0], 0);

        // Don't need stdout end of pipe.
        close(fds[1]);

        // Read from stdout...
        while ((count = read(0, &c, 1)) > 0)
            write(fd, &c, 1); // Write to file.

        _exit(0);
        // child process #2
    } else if ((pid = fork()) == 0) {
        dup2(fds[1], 1);

        // Don't need stdin end of pipe.
        close(fds[0]);

        // Output contents of the given file to stdout.
        char **arguments = new char*[2];/*getArguments(inp[i]);*/
        arguments[0]=(char*)"/bin/bash";
        arguments[1]=0;
        execvp(arguments[0], arguments);
        perror("execvp failed");
        _exit(0);
        // parent process
    } else {
        waitpid(pid, NULL, 0);
        close(fds[0]);
        close(fds[1]);
    }
}

int main(int argc, char* argv[]){
    test();
}

Try to tell where exactly your error appears or show more of your program, so i can try to replicate your conditions.

fork时产生的错误

走过海棠暮 2024-12-15 20:40:17
$query = mysql_query("INSERT INTO `Developers` (`Name`,`Email`,`Username`,`Password`,`Location`,`Platform`,`Developer_or_Designer`,`Tags`, `Paypal_Email`) VALUES ('" . $ud['name'] . "', '" . $ud['email'] . "', '" . $ud['username'] . "', '" .$ud['password'] . "', '" . $ud['location'] . "', '" . $ud['platform'] . "', '" . $ud['developer_or_designer'] . "', '" . $ud['tags'] . "', '" . $ud['paypal_email'] . "')") or die(mysql_error());

尝试一下:)

$query = mysql_query("INSERT INTO `Developers` (`Name`,`Email`,`Username`,`Password`,`Location`,`Platform`,`Developer_or_Designer`,`Tags`, `Paypal_Email`) VALUES ('" . $ud['name'] . "', '" . $ud['email'] . "', '" . $ud['username'] . "', '" .$ud['password'] . "', '" . $ud['location'] . "', '" . $ud['platform'] . "', '" . $ud['developer_or_designer'] . "', '" . $ud['tags'] . "', '" . $ud['paypal_email'] . "')") or die(mysql_error());

try it:)

MySQL 语法错误 - 查询数组

走过海棠暮 2024-12-15 18:16:40
if($('#item1').length) $('#home').hide();

还有其他方法,但这是最简单的。

if($('#item1').length) $('#home').hide();

There are other ways, but that's the simplest.

Jquery查找页面是否包含特定的id?

走过海棠暮 2024-12-15 18:04:35

Yes - no need to hit the db every time... unless the forms are data driven and the mysql query uses input from the users. I would build the whole form into the JavaScript beforehand.

走过海棠暮 2024-12-15 16:49:05

好吧,我想出了如何通过我现有的函数之一删除这些单词:

public static string RemoveHTML(string text)
{
    text = text.Replace(" ", " ").Replace("<br>", "\n").Replace("description", "").Replace("INFRA:CORE:", "")
        .Replace("RESERVED", "")
        .Replace(":", "")
        .Replace(";", "")
        .Replace("-0/3/0", "");
        var oRegEx = new System.Text.RegularExpressions.Regex("<[^>]+>");
        return oRegEx.Replace(text, string.Empty);
}

Ok so I figured out how to remove the words through one of my existing functions:

public static string RemoveHTML(string text)
{
    text = text.Replace(" ", " ").Replace("<br>", "\n").Replace("description", "").Replace("INFRA:CORE:", "")
        .Replace("RESERVED", "")
        .Replace(":", "")
        .Replace(";", "")
        .Replace("-0/3/0", "");
        var oRegEx = new System.Text.RegularExpressions.Regex("<[^>]+>");
        return oRegEx.Replace(text, string.Empty);
}

从字符串中删除单词c#

走过海棠暮 2024-12-15 15:03:10

这是“每组最大的 n”查询。根据此处,以下内容应该在 DB2 中工作

WITH T AS
(
SELECT *,
       ROW_NUMBER() OVER (PARTITION BY personId ORDER BY doneOn DESC) RN
FROM WorkLog
)
SELECT personId , actionType , doneOn 
FROM T
WHERE RN=1

This is a "greatest n per group" query. According to here the below should work in DB2

WITH T AS
(
SELECT *,
       ROW_NUMBER() OVER (PARTITION BY personId ORDER BY doneOn DESC) RN
FROM WorkLog
)
SELECT personId , actionType , doneOn 
FROM T
WHERE RN=1

Sql 获取每种类型的顶行

走过海棠暮 2024-12-15 11:32:48

我不确定你所说的更好是什么意思。如果您正在寻找具有更精美 UI 的东西,您可以随时尝试以下操作: http://android-devblog.blogspot.com/2010/05/wheel-ui-contol.html

I'm not sure what you mean by better. If you are looking for something with a more polished UI you can always try this: http://android-devblog.blogspot.com/2010/05/wheel-ui-contol.html

我在哪里可以找到一个好的时间选择器 android ui 组件

走过海棠暮 2024-12-15 06:27:10

我在调试和发布库之间遇到了同样的问题。
错误出现在解决方案属性/配置属性/配置中。

项目配置与主要配置/平台不匹配。

I had the same issue between debug and release libraries.
The mistake was in the solution properties / Configurations properties / Configurations.

The projects configurations did not match the main configuration / platform.

错误 LNK2038:检测到“_ITERATOR_DEBUG_LEVEL”不匹配:值“0”与值“2”不匹配在 main.obj 中

走过海棠暮 2024-12-15 05:33:24

上面的答案可能并不是最好的解决方案。阅读上面链接的“初始化方法:__cinit__() 和 __init__()”部分提供了以下信息:

如果您的扩展类型有基类型,则在调用您的 __cinit__() 方法之前,会自动调用基类型的 __cinit__() 方法;您无法显式调用继承的 __cinit__() 方法。

如果您预计在 Python 中对扩展类型进行子类化,您可能会发现为 __cinit__() 方法提供 * 和 ** 参数很有用,以便它可以接受和忽略额外的参数。

因此,我的解决方案是仅替换 BaseClass 中的 __cinit()__ 参数,以便可以将可变数量的参数传递给任何派生类:

cdef class BaseClass:
    def __cinit__(self, *argv): 
        print "BaseClass __cinit__()"
        #...
def __dealloc__(self):
        print "BaseClass __dealloc__()"
        #...

cdef class DerClass(BaseClass):
    def __cinit__(self,char* name, int n):
        print "DerClass __cinit__()"
        #...
    def __dealloc__(self):
        print "DerClass __dealloc__()"
        #...

请参阅 此处了解 *args 的说明 变量在 Python

The above answer may not pose quite the best solution. Reading the section "Initialisation methods: __cinit__() and __init__()" of the link above gives this information:

If your extension type has a base type, the __cinit__() method of the base type is automatically called before your __cinit__() method is called; you cannot explicitly call the inherited __cinit__() method.

and

If you anticipate subclassing your extension type in Python, you may find it useful to give the __cinit__() method * and ** arguments so that it can accept and ignore extra arguments.

So my solution would be to just replace the arguments of __cinit()__ in BaseClass so that a variable number of arguments can be passed to any derived class:

cdef class BaseClass:
    def __cinit__(self, *argv): 
        print "BaseClass __cinit__()"
        #...
def __dealloc__(self):
        print "BaseClass __dealloc__()"
        #...

cdef class DerClass(BaseClass):
    def __cinit__(self,char* name, int n):
        print "DerClass __cinit__()"
        #...
    def __dealloc__(self):
        print "DerClass __dealloc__()"
        #...

See here for an explanation of the *args variable in python

Cython 使用 cinit()

走过海棠暮 2024-12-15 03:47:35

它将比较基元 - Integer 将被拆箱。但根据经验:避免这种情况。总是更喜欢基元,并且在将对象与 == 进行比较时要小心,

除了 在 JLS 中看到这一点,您可以通过以下方式验证这一点:

不要使用使用缓存的 Integer.valueOf(2),而是使用新整数(2)。这保证是一个与装箱时 2 所获得的实例不同的实例(装箱发生在 Integer.valueOf(..) 中)。在这种情况下,条件仍然为真,这意味着比较的不是引用。

It will compare primitives - the Integer will be unboxed. But as a rule of thumb: avoid that. Always prefer primitives, and be careful when comparing objects with ==

Apart from seeing this in the JLS, here's how you can verify that:

Instead of Integer.valueOf(2), which uses a cache, use new Integer(2). This is guaranteed to be a different instance than the one that will be obtained if 2 if boxed (the boxing happens with Integer.valueOf(..)). In this case, the condition is still true, which means that it's not references that are compared.

java中允许整数== int

走过海棠暮 2024-12-14 15:28:54

无法在 JS 文件中实现 MVC/Razor 代码。

您应该在 HTML 中(在 .cshtml 文件中)设置变量数据,这在概念上是可以的,并且不会违反关注点分离(服务器生成的 HTML 与客户端脚本代码),因为如果您考虑一下,这些变量值是服务器问题。

看看这个(部分但很好)的解决方法: 在 MVC 框架中的 Javascript 文件中使用内联 C#

There is no way to implement MVC / Razor code in JS files.

You should set variable data in your HTML (in the .cshtml files), and this is conceptually OK and does not violate separation of concerns (Server-generated HTML vs. client script code) because if you think about it, these variable values are a server concern.

Take a look at this (partial but nice) workaround: Using Inline C# inside Javascript File in MVC Framework

访问 javascript 文件中的模型属性?

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