小编rol*_*rer的帖子

使用C打开目录

我通过命令行输入接受路径.

当我做

dir=opendir(args[1]);
Run Code Online (Sandbox Code Playgroud)

它没有进入循环......即dir==null......

如何将命令行输入传递给dir指针?

void main(int c,char **args)
{
    DIR *dir;
    struct dirent *dent;
    char buffer[50];
    strcpy(buffer, args[1]);
    dir = opendir(buffer);   //this part
    if(dir!=NULL)
    {
        while((dent=readdir(dir))!=NULL)
            printf(dent->d_name);
    }
    close(dir);
}

./a.out  /root/TEST is used to run the program..
./a.out --> to execute the program
/root/TEST --> input by the user i.e valid path
Run Code Online (Sandbox Code Playgroud)

c opendir

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

如何比较PCA和NMF的预测能力

我想比较算法的输出与不同的预处理数据:NMF和PCA.为了获得可比较的结果,而不是为每个PCA和NMF选择相同数量的组件,我想选择解释的量,例如95%的保留方差.

我想知道是否有可能确定NMF每个组成部分保留的差异.

例如,使用PCA,这将通过以下方式给出: retainedVariance(i) = eigenvalue(i) / sum(eigenvalue)

有任何想法吗?

pca dimensionality-reduction scikit-learn matrix-factorization nmf

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

div旋转时jQuery可拖动跳转

请帮忙解决问题,我在跳转div时解决了跳转层的问题,在某种程度上打开了div,我在这里找到了解决方案 - Webkit和jQuery draggable jump,但是当我把div旋转90度时,它没有移动到父div的边缘.如何使它可以移动到父div的右边缘.

更多信息:

<div class="template" id="template">
    <div id="box">Some text!</div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

.template {
    width: 400px;
    height: 255px;
    position: relative;
    margin: 16px;
    border: 1px dotted #777;
    overflow: hidden;
}

#box {
    width: 100px;   
    border: 1px solid;
    background-color: red;
    position: absolute;
    left: 75px;
    top: 75px;
    -moz-transform: rotate(90deg);
    -o-transform: rotate(90deg);
    -webkit-transform: rotate(90deg);
    -ms-transform: rotate(90deg);
    -sand-transform: rotate(90deg);
    transform: rotate(90deg);
    text-align: center;
    cursor: move;
}
Run Code Online (Sandbox Code Playgroud)

我已经找到的解决方案:

 $(document).ready(function () {
             var recoupLeft, recoupTop;
             $('#box').draggable({  
                 containment: "#template",
                 start: function (event, ui) {                     
                     var …
Run Code Online (Sandbox Code Playgroud)

html css jquery rotation draggable

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

Angular 2/4上的FullScreen请求

我正在Angular 2/Angular 4上构建一个新项目,我需要在我的应用程序上使用Enter FullScreen Button.

我正在搜索,我找到了代码:

  toggleFullScreen() {
    if (!document.fullscreenElement &&    // alternative standard method
        !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement )
        {  // current working methods
      if (document.documentElement.requestFullscreen) {
        document.documentElement.requestFullscreen();
      } else if (document.documentElement.msRequestFullscreen) {
        document.documentElement.msRequestFullscreen();
      } else if (document.documentElement.mozRequestFullScreen) {
        document.documentElement.mozRequestFullScreen();
      } else if (document.documentElement.webkitRequestFullscreen) {
        document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
      }
    } else {
      if (document.exitFullscreen) {
        document.exitFullscreen();
      } else if (document.msExitFullscreen) {
        document.msExitFullscreen();
      } else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
      } else if (document.webkitExitFullscreen) {
        document.webkitExitFullscreen();
      }
    }
  }
Run Code Online (Sandbox Code Playgroud)

当我使用"ng serve"编译应用程序时,FullScreen Button工作,但它给了我以下错误: …

typescript angular

6
推荐指数
2
解决办法
5703
查看次数

需要澄清 RouterModule.forRoot([ ABOUT_ROUTE ], { useHash: true })

请解释useHash: true角度2路线方法中的方法。

我的问题:

  1. 我们使用它的目的是什么。

  2. 为什么值是“真”为什么不是“假”?

  3. 如果值为假,会发生什么?

RouterModule.forRoot([ ABOUT_ROUTE ], { useHash: true })
Run Code Online (Sandbox Code Playgroud)

router angular4-router

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

我应该为 Nodejs 模型和控制器使用类吗

在 Nodejs 中为控制器和模型使用类是个好主意吗?

如果是这样,最好对所有请求使用一个 Class 实例还是每个请求使用一个,就像 Laravel 那样?当然Node不一样。我认为一个会更好,但我不确定。

关于如果使用类,性能是优先的。

model-view-controller node.js

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

访问Ubuntu One API会导致"401 UNAUTHORIZED"或"400 BAD REQUEST"

我使用Delphi XE2和Indy 10来访问Ubuntu One API.到现在为止还挺好.我能够为从云获得OAuth令牌描述.现在我想开始使用API​​(如描述):

function TUbuntuOneApi.DoRequest(const URL: String): String;
var
  RequestParams: TStringList;
  HeaderIndex: Integer;
const
  OAuthAuthorisationHeader = 'OAuth realm="", oauth_version="%s", oauth_nonce="%s", oauth_timestamp="%s", oauth_consumer_key="%s", oauth_token="%s", oauth_signature_method="%s", oauth_signature="%s"';

begin
  RequestParams := SignOAuthRequestParams(URL, fOAuthAppToken, fOAuthAccessToken);

{  OAuth realm="", oauth_version="1.0",
  oauth_nonce="$nonce", oauth_timestamp="$timestamp",
  oauth_consumer_key="$consumer_key", oauth_token="$token",
  oauth_signature_method="PLAINTEXT",
  oauth_signature="$consumer_secret%26$token_secret"
  }

  HeaderIndex := IdHTTP.Request.CustomHeaders.IndexOfName('Authorization');
  if HeaderIndex >= 0 then
  begin
    IdHTTP.Request.CustomHeaders.Delete(HeaderIndex);
  end;

  // Solving: http://stackoverflow.com/questions/7323036/twitter-could-not-authenticate-with-oauth-401-error
  IdHTTP.Request.CustomHeaders.FoldLines := false;

  IdHTTP.Request.CustomHeaders.AddValue('Authorization', Format(OAuthAuthorisationHeader, [
      TIdURI.URLDecode(RequestParams.Values['oauth_version']),
      TIdURI.URLDecode(RequestParams.Values['oauth_nonce']),
      TIdURI.URLDecode(RequestParams.Values['oauth_timestamp']),
      TIdURI.URLDecode(RequestParams.Values['oauth_consumer_key']),
      TIdURI.URLDecode(RequestParams.Values['oauth_token']),
      TIdURI.URLDecode(RequestParams.Values['oauth_signature_method']),
      TIdURI.URLDecode(RequestParams.Values['oauth_signature'])
    ]));

  // Execute
  Result := …
Run Code Online (Sandbox Code Playgroud)

delphi oauth indy10

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

LINQ to Entities在结果上分割字符串

我有一条LINQ语句,如下所示:

var playedBanDataList =
    from bannedPlayers in query
    select new PlayerBanData
    {
        Admin = bannedPlayers.Admin,
        BannedUntil = bannedPlayers.BannedUntil,
        IsPermanentBan = bannedPlayers.IsPermanentBan,
        PlayerName = bannedPlayers.PlayerName,
        Reason = bannedPlayers.Reason,
        IpAddresses = bannedPlayers.IpAddresses.Split(new [] {","}, StringSplitOptions.RemoveEmptyEntries).ToList()
    };

    return playedBanDataList.ToList();
Run Code Online (Sandbox Code Playgroud)

这将失败,因为拆分功能失败,IpAddresses因为LINQ to Entities无法将此查询转换为SQL。

这是有道理的,但是然后又有什么等效的方法可以优雅地完成此任务呢?我想到的唯一方法是在检索到的字符串上手动运行一个循环,然后将其拆分,但我想一次获得它。

c# sql linq orm entity-framework

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

Spring Boot REST响应gzip压缩不起作用

我正在尝试在spring boot REST项目中添加gzip压缩。我已经在中设置了以下属性 application.properties

server.compression.enabled=true
server.compression.min-response-size=2048
server.compression.mime-types=text/html,text/css,application/javascript,application/json
Run Code Online (Sandbox Code Playgroud)

但这行不通。邮递员节目中的回应标题

Content-Type: application/json
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
Run Code Online (Sandbox Code Playgroud)

数据仍未压缩。

compression gzip spring-boot

5
推荐指数
0
解决办法
1507
查看次数

Windows 性能分析器缺少 ImageId 事件

我有一个应用程序,我想使用 Windows 性能分析器对其进行分析。一切正常,但我没有从我的应用程序中获得任何合理的堆栈跟踪。

有问题的应用程序是一个演示应用程序。这是为了给我一个很好的感觉,如果全部检查出来。然后我想分析另一个应用程序。因为我可以完全控制我的演示应用程序,所以我包含了一些标记函数,它们应该显示在堆栈跟踪中。

在 Windwos 7 1上运行应用程序时,Process Explorer 会显示我想要分析的部件的正确堆栈跟踪。这是第 7 - 9 行中带有标记函数的堆栈跟踪:

进程资源管理器堆栈跟踪

由于我在 Windows 10 VM 2 中安装了所有性能分析工具,因此我开始在那里进行分析。首先要注意:Process Explorer 没有显示正确的堆栈跟踪。我实现的标记功能无处可寻。

尽管如此,我还是使用UIforETWWindows Performance Recorder记录了性能轨迹。在 WPA 中打开它们并专注于目标应用程序时,这是堆栈跟踪:

WPA 堆栈跟踪

我感兴趣的所有信息都丢失了。堆栈显示为<Application>.exe!<Missing ImageId event>

我做错了什么?


如果这给你一个提示,这里是安装的相关软件:

1:Windows 7 计算机安装了 Visual Studio (C#)。

2:Windows 10 虚拟机没有 Visual Studio,但安装了 WinDBG(预览版)和 Windows Performance Toolkit。

我标记了,因为目标应用程序是用 Delphi 编写的。

windows delphi debugging windows-performance-analyzer

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