问题列表 - 第31711页

OCaml封装模块有什么用途?

最近OCaml的3.12引入了一个特征的第一级封装模块:

一流的包模块.

  • 用于打包模块的新类型表达式: (module PT)
  • 新类型的表达式,将模块打包为一等值:(module MODEXPR : PT).
  • 新类型的模块表达式,将第一类值解压缩为模块:(val EXPR : PT).
  • PT是表单的包类型SS with type t1 = ... and ... and type tn = ...(S指模块类型).

我在哪里可以找到使用此功能的激励示例或论文?

ocaml

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

在手机上下载时,.apk文件的php标头无效

我想下载一个由php页面输出的Android APK文件.我有以下内容,它适用于Firefox,但不适用于手机.

Firefox下载了apk扩展,但旁边有一个小火狐图标.

手机下载.html扩展名的文件,为什么会这样?

更新:完整来源

 function display($tpl = null) {
  //SETUP
  $appId = JRequest::getInt('id', '0');
  $model = &$this->getModel();

  $app = $model->getApplication($appId);


  if( !$app )
   JError::raiseError(500, "Invalid Application ID");

  if( empty($app->apk_file) )
   JError::raiseError(500, "No APK file found in the database");


  $result = $model->newDownload($appId);

  //Update the database
  if( !$result )
   JError::raiseError(500, "Unable to increment download count for ID:".$appId);


  //Return the file
  $filesFolder = JPATH_COMPONENT_ADMINISTRATOR .DS. 'uploads' .DS. $appId;

  //Output the file contents
  $sanitizedFolder = JFolder::makeSafe($filesFolder);
  $sanitizedFile = JFile::makeSafe($app->apk_file);
  $path = $sanitizedFolder .DS. …
Run Code Online (Sandbox Code Playgroud)

php android

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

如何告诉我的应用程序即将变为非活动状态/进入后台状态?

我假设我需要实现:

[[NSNotificationCenter defaultCenter] addObserver:self 
                                                 selector:@selector(resignActive:)
                                                     name:UIApplicationWillResignActiveNotification
                                                   object:nil];
Run Code Online (Sandbox Code Playgroud)

但我不确定这是否是确定我的应用程序即将离开活动状态的正确通知.

这是取消网络连接以及应用程序终止的好地方吗?

iphone cocoa-touch objective-c nsnotifications multitasking

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

为什么我的IAuthorizationPolicy不使用我的CustomPrincipal设置Thread.CurrentPrincipal?

对于我的WCF服务,我已经实现了IAuthorizationPolicy并将其连接起来(并且可以确认它正在被使用).

在Evaluate()方法中,我设置了一个自定义主体,如下所示:

evaluationContext.Properties["Principal"] = myCustomPrincipal;
Run Code Online (Sandbox Code Playgroud)

但是,当调用服务时,Thread.CurrentPrincipal是GenericPrincipal!

我的服务行为配置如下:

<serviceAuthorization principalPermissionMode="Custom">
    <authorizationPolicies>
        <add policyType="MyNamespace.MyPrincipalAuthorizationPolicy, MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    </authorizationPolicies>
</serviceAuthorization>
Run Code Online (Sandbox Code Playgroud)

我试图使用反射器来查看发生了什么,但没有看到任何有用的东西.

我做错了吗?我缺少一些配置吗?

c# wcf wcf-security

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

有没有办法在不写入实际文件的情况下将 CString 发送到 CFile?

我有数据存储在 a 中CString,它需要由 XML 解析器库解析。问题是 XML 解析器接受一个CFile. 将 写出CString到文本文件然后将其重新加载到CFile. 有什么方法可以直接发送CStringCFile而不制作中间输出文件?

c++ mfc visual-studio

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

Windows窗体:如何扩展按钮?

如何扩展按钮?

我想要一个具有附加属性IsSwitchOffable的Button.

我是否必须编写额外的自定义控件?

编辑: 我希望该按钮可用作标准的WindowsFormsButton.

这包括我可以在设计时添加按钮!

c# winforms

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

php和mysql,最佳实践

我今天开始使用php和mysql.基本上,我所拥有的是一个空页面,其中包含我在数据库中查找id时填写的内容.所以在我的主页上我有一个看起来像这样的网址:

<a href="content/display.php?id=id1">
Run Code Online (Sandbox Code Playgroud)

然后在我的display.php中我有这个:

<?php
    include '../includes/header.php';
    $id = $_GET['id'];
    $mysqli = new mysqli('localhost','username','password','dbname');
    if($result = $mysqli->query("SELECT * FROM portfolio WHERE id='".$id."'"))
    {
        while($row = $result->fetch_object())
        {
            $head = $row->head;
            $img1 = $row->img1;
            $img2 = $row->img2;
            $img_url = $row->imgurl;
            $img_thumb = $row->imgthumb;
            $vid = $row->vid;
            $swf = $row->swf;
            $url = $row->url;
            $url_text = $row->urltext;
            $text = $row->text;
        }
    }
    else echo $mysqli->error;
?>
Run Code Online (Sandbox Code Playgroud)

这是一个稀疏表,因为并非所有这些字段都有信息(许多字段可能为空).基本上它们包含文件名,然后在html中我有如下代码:

if(isset($img1))
                    {
                        echo '<img src="images/'.$img1.'" />';
                    }
Run Code Online (Sandbox Code Playgroud)

几个问题,

  1. 这是最好的方法吗?
  2. 每次我访问display.php时,我都在重新打开数据库连接吗?这不可能是好的......
  3. 我选择将文件的名称放在数据库中,而不是整个路径名,甚至是实际的文件本身,想一想,如果我更改文件的名称,我可以进入数据库并为文件更新它想要改变.如果我更改路径,我可以在html中更改一次.这是最好的主意吗?

谢谢!

php mysql mysqli

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

Java中不推荐使用的Date方法?

使用Java Date实用程序时的真正含义是什么并且已被弃用.这是否意味着不鼓励使用,还是暗示它被禁止?

我猜测使用弃用方法是不好的做法,但我不确定并想知道.

例如,我正在尝试使用如下代码

String date = request.getParameter("date"); 
model.setDate(new Date(date));
Run Code Online (Sandbox Code Playgroud)

当然......这是一个高级示例,但在这种情况下,我的模型使用Date类型,我需要将请求中的日期作为String拉出并使用它创建日期.

我的工作方式很好,但它使用的是不推荐使用的方法.

编辑 - 我已经回去使用了

SimpleDateFormat formatter = new SimpleDateFormat(); 
model.setDate(formatter.parse(request.getParameter("date");



日期的格式为MM/DD/YYY,如07/23/2010,但我收到了ParseException

这可能是什么?

java deprecated simpledateformat parseexception

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

Calling class methods within jQuery function

So I have some javascript class and in one method I use jQuery to bind function to click event. And within this function I need to call other methods of this class. In usual js function I did it through "this.method_name()", but here, I guess, jQuery redefines "this" pointer.

javascript jquery

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

Allow only one br in nl2br

I let my members of my website to post some information about them in textarea. I use function nl2br to be it more prettier, smth like that:

$text_of_area = nl2br($_POST['text_area_name']); //yeah, of course i use functions against xss, sql injection attacks

mysql_query("..."); //here I insert a text
Run Code Online (Sandbox Code Playgroud)

But here is problem. I don't want to allow people to use more then one enter (br) allowed in text, so what can I do?

php

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