小编Ben*_*ier的帖子

修复一个破碎的git repo - 如何重新开始

我有点像git的新手,并对我的repo如何工作感到沮丧..或者在这种情况下不工作..所以我从git hub删除了它,删除了项目上的git文件夹,并计划重新开始.

现在,当我尝试设置一个新的回购时,我收到了很多消息,如:

warning: You appear to be on a branch yet to be born.
warning. Forcing checkout of HEAD
Run Code Online (Sandbox Code Playgroud)

当我尝试运行第一次提交时,我看到:

error: invalid object 8bcb4b5fd612e3ad55fb07e4bed087c55afd0861
fatal: git-write-tree: error building trees
Run Code Online (Sandbox Code Playgroud)

我跑了git fsck,看到我错过了一堆blob.

我怎样才能擦干净石板并再试一次?

git repository

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

从链接库中抑制输出到cout

我需要针对其产生太多输出到一对夫妇共享库链接到我的C++程序std::cout,并std::cerr使得它们既没有用我的用途.我可以访问这些库的C++源代码,但无法修改它们.

有没有办法将其输出重定向到不同的流或在链接到我的代码时抑制它?我更喜欢C++中的一种干净的方式,但是担心这是不可能的,我也会对脏的链接器黑客感到高兴.此外,"代理libstdc++"也可以作为最后的手段.

我使用的是GNU工具链(工作g++,libtool,ld)在Linux下.

c++ linux linker

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

如果baseclass有两个同名函数,则找不到baseclass函数

我有一个基类,它有两个同名的函数,但在2级继承中有不同的签名.

struct A {
    virtual void f(int) { }
    virtual void f(int, int) { };
    virtual void f1(int) { }
};

struct B: public A { };

struct C: public B {
  void f(int, int) { }
  void f1(int) { }
};

int main() {
 C obj;
 obj.f1(0);
 obj.f(0,0);

 obj.f(0);    // (1) cannot be found
 obj.B::f(0); // (2) works

}
Run Code Online (Sandbox Code Playgroud)

我希望我的编译器(gcc-4.3.2)能够找到正确的定义(1),但是我得到了

g++     main.cpp   -o main
main.cpp: In function 'int main()':
main.cpp:20: error: no matching function for call to …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance

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

在mint-15 linux上显示python的.png图像

我试图显示.png我使用以下构建的文件.

import pydot, StringIO
dot_data = StringIO.StringIO() 
tree.export_graphviz( clf, out_file = dot_data,    
feature_names =['age', 'sex', 'first_class', 'second_class', 'third_class'])
graph = pydot.graph_from_dot_data( dot_data.getvalue())
graph.write_png('titanic.png') 
from IPython.core.display import Image
Image( filename ='titanic.png')
Run Code Online (Sandbox Code Playgroud)

我从未这样做过,非常感谢你的帮助.

我尝试了以下但没有错误也没有.png显示.

from PIL import Image
image = Image.open("titanic.png")
image.show()
Run Code Online (Sandbox Code Playgroud)

python numpy pygraphviz scikit-learn

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

内部类,pimpl和朋友类 - 不同意编译器

我在一些旧的库代码中捣乱,其基本目标是重构它.这个旧代码并不完全符合最佳实践和美观(是的 - 朋友很糟糕,并且在发现下面之后它已被删除 - 因为它是重构的疏忽).

现在准备运行一些单元测试我用clang ++,g ++和vc ++编译了代码(2005年 - 是的,我知道它已经过时了,但为了向后兼容 - 我必须这样做).

g ++和clang ++编译并运行没有错误,但Visual C++抱怨,所以在查看代码后,我发现了一些效果:

#include <iostream>

class one {

  private:
    struct private_impl;
    private_impl* pimpl_;

  public:
    one();
    ~one();
    void say_hello();
};

class two {

  private:
    friend class one;
    void say_world();

  public:

};

struct one::private_impl {
  two t;
  void say_world();
};

void one::private_impl::say_world() {
   std::cout << " ";
   t.say_world();  //This should not work should it?
}

one::one() : pimpl_(new private_impl) { }

one::~one() {
  delete pimpl_;
}

void one::say_hello() …
Run Code Online (Sandbox Code Playgroud)

c++ pimpl-idiom friend inner-classes language-lawyer

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

矩阵行列式算法C++

我是编程的新手,我正在寻找一种方法来找到矩阵的行列式.我在网上找到了这个代码,但是我无法理解这里的算法.我对递归的基础没有问题,但是继续和主循环我很难理解.非常感谢任何能向我解释算法的人.

int determ(int a[MAX][MAX],int n) {
  int det=0, p, h, k, i, j, temp[MAX][MAX];
  if(n==1) {
    return a[0][0];
  } else if(n==2) {
    det=(a[0][0]*a[1][1]-a[0][1]*a[1][0]);
    return det;
  } else {
    for(p=0;p<n;p++) {
      h = 0;
      k = 0;
      for(i=1;i<n;i++) {
        for( j=0;j<n;j++) {
          if(j==p) {
            continue;
          }
          temp[h][k] = a[i][j];
          k++;
          if(k==n-1) {
            h++;
            k = 0;
          }
        }
      }
      det=det+a[0][p]*pow(-1,p)*determ(temp,n-1);
    }
    return det;
  }
}
Run Code Online (Sandbox Code Playgroud)

c++ algorithm matrix determinants

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

如何使用文本文件获取命令行参数?

我有一组文件名,我必须在我的bash脚本运行时作为命令行参数插入.有没有办法使用单独的文件(如"test.txt")给出命令行参数?

假设这些文件:fileA,fileB,FileC,FileC,FileD,,让我们假设bash脚本是testBash.sh

linux bash ubuntu command-line-arguments

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

在Apache PassEnv/SetEnv中设置LD_LIBRARY_PATH仍然无法找到库

我正在尝试测试Cyber​​source 3d party实现.我能够从命令行运行测试文件,这要求在Linux上我将支付库的路径导出到LD_LIBRARY_PATH.

为了尝试在我的服务器上测试这个,我在下面创建了apache配置

<VirtualHost 127.0.0.1:12345>
  AddHandler cgi-script .cgi
  AddHandler fcgid-script .php .fcgi
  FCGIWrapper /my/path/to/php_fcgi/bin/php-cgi .php
  AddType text/html .shtml
  AddOutputFilter INCLUDES .shtml
  DocumentRoot /my/path/to/cybersource/simapi-php-5.0.1/
  ProxyPreserveHost on

  <Directory /my/path/to/cybersource/simapi-php-5.0.1>
    SetEnv LD_LIBRARY_PATH /my/path/to/cybersource/LinkedLibraries/lib/
    AllowOverride all
    Options +Indexes
    IndexOptions Charset=UTF-8
  </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

我已经使用SetEnv命令设置了env变量,当我运行打印的页面时,这似乎正常

<?php phpinfo(); ?>
Run Code Online (Sandbox Code Playgroud)

但是,当通过浏览器调用时,测试脚本仍无法正常工作,apache说:

tail /my/apache/error_log 
[Tue Mar 30 23:11:46 2010] [notice] mod_fcgid: call /my/path/to/cybersource/index.php with wrapper /my/path/to/cybersource/php_fcgi/bin/php-cgi
PHP Warning:  PHP Startup: Unable to load dynamic library '/my/path/to/cybersource/extensionsdir/php5_cybersource.so' - libspapache.so: cannot open shared object file: No such file or directory …
Run Code Online (Sandbox Code Playgroud)

php linux apache environment-variables loader

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

git拉什么 做?

当我在我的git repo上运行时,这就是我得到的.

git pull .
From .
 * branch            HEAD       -> FETCH_HEAD
Current branch rel_20121207 is up to date.
Run Code Online (Sandbox Code Playgroud)

但是,当我运行时git pull它实际上是从遥控器更新.

我想知道我跑的时候究竟发生了什么 git pull .

git git-pull

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

清除多行

例如,是否可以清除 C 中的多行并保留其他行。

代码:

Displaysenrsordata
  loop 
    printf("This info stays"); <-stay on screen
    printf("This info stays"); <-stay on screen
    printf("This info Refreshes"); <-update redraw
    printf("This info Refreshes"); <-update redraw
    printf("This info Refreshes"); <-update redraw
Run Code Online (Sandbox Code Playgroud)

本质上,我想让一些文本留在同一个地方,并在不清除整个屏幕的情况下重绘更新数据。

c terminal console printf

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