问题列表 - 第23515页

将IntPtr窗口句柄转换为IWin32Window ^

如何将从表单/控件的Handle属性获取的句柄转换为IWin32Window ^?

c++-cli handle

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

PHP CodeIgniter框架 - 用它开发的想法?

我一直在审查用于我的下一些主要Web应用程序的不同框架,经过几天的研究后,我几乎开始使用CodeIgniter.

我倾向于CI的原因是到目前为止它看起来最适合我.它不需要持续的命令行访问(我目前正在使用共享主机;项目还不保证专用服务器),运行它的服务器上没有任何特殊安装(你只需将框架上传到根目录)无论你开发什么,他们似乎有一些优秀的文档,视频和如何入门的教程.

你们有没有使用CodeIgniter的经验?如果是这样,您对它及其功能有何看法?您使用它开发了什么,以及哪种类型的应用程序最适合创建?我当然不想陷入这样一种情况,即我试图弯曲框架来做一些不太适合的事情.

我的两个项目都是数据库驱动的应用程序,需要用户注册,能够操纵特定于其帐户的数据(他们的帖子,列表,用户帐户详细信息等)等等.

此外,如果您有任何其他PHP框架建议,我向他们开放.

在此先感谢您的帮助!

-Sootah

php codeigniter rad

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

如何让PHP生成Chunked响应

我搜索了这个问题,但没有答案.

我希望我的PHP脚本在chunked中生成HTTP响应(http://en.wikipedia.org/wiki/Chunked_transfer_encoding).怎么做?

更新:我明白了.我必须指定Transfer-encoding标头并刷新它.

header("Transfer-encoding: chunked");
flush(); 
Run Code Online (Sandbox Code Playgroud)

冲洗是必要的.否则,将生成Content-Length标头.

而且,我必须自己制作块.有了辅助功能,并不难.

function dump_chunk($chunk)
{
    echo sprintf("%x\r\n", strlen($chunk));
    echo $chunk;
    echo "\r\n";
}
Run Code Online (Sandbox Code Playgroud)

php http chunked-encoding

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

如何在 Django 中创建相关模型的实例

我正在开发一个 CMSy 应用程序,我已经为其实现了一组模型,这些模型允许创建自定义模板实例,由多个字段组成并绑定到特定客户。最终目标是可以通过管理界面定义一个或多个具有一组自定义字段的模板并将其关联到客户,这样客户就可以按照模板规定的格式创建内容对象。

我似乎已经将其连接起来,以便我可以创建任意数量的 Template 对象,但是我正在努力解决如何在这些模板中创建实例 - 实际内容对象。例如,我可以为客户“Acme”定义一个模板“Basic Page”,其中包含字段“Title”和“Body”,但我还没有弄清楚如何创建可以填写这些字段的基本页面实例。

这是我的(有点省略)模型......

class Customer(models.Model):
    ...

class Field(models.Model):
    label = models.CharField(max_length=255)
    component = models.ForeignKey(ContentType, 
            limit_choices_to={'id__in': component_choices}
            )
    fields = models.Manager()

class Template(models.Model):
    label = models.CharField(max_length=255)
    clients = models.ManyToManyField(Customer, blank=True)
    fields = models.ManyToManyField(Field, blank=True)

class ContentObject(models.Model):
    label = models.CharField(max_length=255)
    template = models.ForeignKey(Template)
    author = models.ForeignKey(User)
    customer = models.ForeignKey(Customer)
    mod_date = models.DateTimeField('Modified Date', editable=False)
    def __unicode__(self):
        return '%s (%s)' % (self.label, self.template)
    def save(self):
        self.mod_date = datetime.datetime.now()
        super(ContentObject, self).save()
Run Code Online (Sandbox Code Playgroud)

提前感谢您的任何建议!

python django models

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

如何将setAccessible限制为仅仅"合法"使用?

我越了解它的力量java.lang.reflect.AccessibleObject.setAccessible,我就越能对它做什么感到惊讶.这是根据我对问题的回答改编的(使用反射来更改静态最终File.separatorChar以进行单元测试).

import java.lang.reflect.*;

public class EverythingIsTrue {
   static void setFinalStatic(Field field, Object newValue) throws Exception {
      field.setAccessible(true);

      Field modifiersField = Field.class.getDeclaredField("modifiers");
      modifiersField.setAccessible(true);
      modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);

      field.set(null, newValue);
   }
   public static void main(String args[]) throws Exception {      
      setFinalStatic(Boolean.class.getField("FALSE"), true);

      System.out.format("Everything is %s", false); // "Everything is true"
   }
}
Run Code Online (Sandbox Code Playgroud)

你可以做真正令人发指的事情:

public class UltimateAnswerToEverything {
   static Integer[] ultimateAnswer() {
      Integer[] ret = new Integer[256];
      java.util.Arrays.fill(ret, 42);
      return ret;
   }   
   public static void main(String args[]) throws Exception { …
Run Code Online (Sandbox Code Playgroud)

java security reflection

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

XSL在catalog.xml文件中显示最大份数

在这个catalog.xml文件中.我有两本书有相同的库存(即20).我想编写一个XSL文件,它将在目录中显示最大数量的书籍副本.如果有两本或更多相同库存的书籍,则必须显示它们.

<catalog>
  <Book>
    <sku>12345</sku>
    <title>Beauty Secrets</title>
    <condition>New</condition>
    <current_inventory>20</current_inventory>
    <price>99.99</price>
  </Book>
  <Book>
    <sku>54321</sku>
    <title>Picturescapes</title>
    <current_inventory>20</current_inventory>
    <condition>New</condition>
    <price>50.00</price>
  </Book> 
  <Book>
    <sku>33333</sku>
    <title>Tourist Perspectives</title>
    <condition>New</condition>
    <current_inventory>0</current_inventory>
    <price>75.00</price>
  </Book>
  <Book>
    <sku>10001</sku>
    <title>Fire in the Sky</title>
    <condition>Used</condition>
    <current_inventory>0</current_inventory>
    <price>10.00</price>
  </Book>
</catalog>
Run Code Online (Sandbox Code Playgroud)

以下是我的catalog3.xsl文件,它只能显示两本书中的一本:

<xsl:stylesheet 
  version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
  <xsl:variable name="max"/>

  <xsl:template match="/">
    <html>
      <body>
        <h2>Titles of Books for which Most Copies are Available</h2>
        <table border="2">
          <tr bgcolor="#9acd32">
            <th>Title</th>
            <th>No of Copies</th>
          </tr>
          <xsl:apply-templates/>
        </table>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="catalog">
    <xsl:for-each select="Book">
      <xsl:sort select="current_inventory" …
Run Code Online (Sandbox Code Playgroud)

xslt

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

您将如何在WCF数据服务中实现API密钥?

有没有办法在URL中使用API​​密钥/或以其他方式向服务传递私钥以授予对数据的访问权限?

我现在有这个......

using System;
using System.Data.Services;
using System.Data.Services.Common;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Web;
using Numina.Framework;
using System.Web;
using System.Configuration;

[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class odata : DataService {


    public static void InitializeService(DataServiceConfiguration config) {

        config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
        //config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
    }

    protected override void OnStartProcessingRequest(ProcessRequestArgs args) {

        HttpRequest Request = HttpContext.Current.Request;
        if(Request["apikey"] != ConfigurationManager.AppSettings["ApiKey"])
            throw new DataServiceException("ApiKey needed");

        base.OnStartProcessingRequest(args);
    }
} 
Run Code Online (Sandbox Code Playgroud)

...这有效,但它并不完美,因为您无法通过添加服务参考资源管理器获取元数据并发现服务.我可以检查$元数据是否在网址中,但它似乎是一个黑客.有没有更好的办法?

c# service ado.net wcf odata

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

在Perl中,while循环通常比for循环快吗?

我已经完成了一个小实验,如下所示,看起来while循环比Perl中的for循环更快.但由于实验相当粗糙,而且主题可能比看上去复杂得多,我想听听你对此有何看法.一如既往地感谢任何意见/建议:)

在以下两个小脚本中,我分别尝试while和for循环来计算100,000的阶乘.具有while循环的那个用了57分17秒完成,而for循环等效花了1小时7分54秒.

具有while循环的脚本:

use strict;
use warnings;
use bigint;

my $now = time;

my $n = shift;
my $s = 1;

while(1){
$s *= $n;
$n--;
last if $n==2;
}

print $s*$n;
$now = time - $now;
printf("\n\nTotal running time: %02d:%02d:%02d\n\n", int($now / 3600),
            int(($now % 3600) / 60), int($now % 60));
Run Code Online (Sandbox Code Playgroud)

有for循环的脚本:

use strict;
use warnings;
use bigint;

my $now = time;

my $n =shift;
my $s=1;

for (my $i=2; $i<=$n;$i++) {
$s = $s*$i;
}

print $s;
$now …
Run Code Online (Sandbox Code Playgroud)

perl performance for-loop while-loop

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

如何在PHP中实现Bloom过滤器?

有没有一个已经煮熟的PHP解决方案?

php bloom-filter

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

如果我将3除以2,我希望答案为2(即1.5舍入为2)

如何在C中得到一个数字的上限?

如果我将3除以2,我希望答案为2(即1.5舍入为2).

c decimal rounding

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