小编Cha*_*429的帖子

github存储库和git裸存储库之间有什么区别?

在github存储库中,我们可以进行git push git pull操作,同时,我们可以通过Web UI提交到存储库.似乎github存储库同时作为裸存储库和工作存储库工作?

但是,在git bare repository中,我们无法将目录提交到存储库.

所以,我的问题是

github存储库和git裸存储库之间有什么区别?

git github

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

SyntaxHighlighter自动换行?

我在前面的网页中使用了syntaxhighlighter来突出显示代码.但我遇到一个问题,当代码长度超过代码长度时,代码中的单词不会被包装<div>. 在此输入图像描述

然后我google了它.并找到了下面提到的方法:

pre,code{ 
white-space:pre-wrap;/*css-3*/ 
white-space:-moz-pre-wrap;/*Mozilla,since1999*/ 
white-space:-pre-wrap;/*Opera4-6*/ 
white-space:-o-pre-wrap;/*Opera7*/ 
word-wrap:break-word;/*InternetExplorer5.5+*/??
} 
Run Code Online (Sandbox Code Playgroud)

但是,出现了一个新问题,行号与实际代码行不对应: 在此输入图像描述

我的问题是:

  • 如何在保持代码行与实际原始代码行对应的同时避免代码溢出?

html css syntax-highlighting

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

如何处理EPOLLERR和EPOLLHUP?

我阅读了libevent epoll中的代码,下面是代码:

       if (what & (EPOLLHUP|EPOLLERR)) {
            ev = EV_READ | EV_WRITE;
        } else {
            if (what & EPOLLIN)
                ev |= EV_READ;
            if (what & EPOLLOUT)
                ev |= EV_WRITE;
            if (what & EPOLLRDHUP)
                ev |= EV_CLOSED;
        }
Run Code Online (Sandbox Code Playgroud)

据我了解,当发生EPOLLERR或EPOLLHUP时,应关闭连接。但是在上面的代码中,当遇到EPOLLHUP | EPOLLERR时,事件掩码设置为EV_READ | EV_WRITE。所以我的问题是:

  • 是什么使EPOLLERR和EPOLLHUP发生?
  • 当发生EPOLLERR和EPOLLHUP时,程序应在事件句柄功能中做什么?并请详细解释其背后的原因。

提前致谢!

linux network-programming

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

if块中返回一个自动值?

#include <stdio.h>

static int test(int val)
{
    int *ptr;

    if(val == 0)
    {
        int val = 4;
        ptr = &val;
    }

    return (*ptr + 1);
}

int main(void)
{
    int i = test(0);
    printf("%d\n", i);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,valif块中的变量被破坏,因此return (*ptr + 1),该值*ptr应该是未定义的,但是该程序的结果是5.

我知道这是一个未定义的程序,但它似乎产生了预期的价值,为什么?

c

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

dup2重定向printf失败了吗?

我的代码如下:

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

int main(int argc, char *argv)
{
    int fd;
    int copy_stdout;
    char *msg = "a test message for redirect stdout";

    //open a test file to write message
    fd = open("test", O_CREAT | O_RDWR, S_IREAD | S_IWRITE);

    //copy the original file descriptor 
    copy_stdout = dup(STDOUT_FILENO);

    //redirect the stdout to fd
    dup2(fd, STDOUT_FILENO);

    //must close the fd to complete redirect
    close(fd);

    //write the message
    write(STDOUT_FILENO, msg, strlen(msg));

    //redirect …
Run Code Online (Sandbox Code Playgroud)

c unix

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

将double转换为int?

我的代码如下:

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

    double f = 18.40;
    printf("%d\n", (int)(10 * f));

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

VC6.0中的结果是184,而Codeblock的结果是183.为什么?

c double type-conversion

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

nginx codeigniter 502 错误网关

nginx的配置如下:

server {
        listen       80;
        server_name  www.example.com;

        root   /home/wwwroot/example.com;
        index index.php  index.html index.htm;

        location / {
                index  index.php index.html index.htm;
        }

        location ~ \.php($|/) {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_param   PATH_INFO $fastcgi_path_info;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php/$1 last;
            break;
        }

        location ~ /\.ht {
                deny  all;
        }
}
Run Code Online (Sandbox Code Playgroud)

请大家给我一些建议,谢谢~

codeigniter nginx

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

传递rvalue加注不能绑定到左值

该计划如下:

#include <iostream>
using namespace std;

template <typename F, typename T1, typename T2>
void flip2(F f, T1 &&t1, T2 &&t2)
{
      f(t2, t1);
}

void g(int &&i, int &j)
{
      cout << i << " " << j << endl;
}

int main(void)
{
      int i = 1;
      flip2(g, i, 42);
}
Run Code Online (Sandbox Code Playgroud)

编译器抱怨:

error: rvalue reference to type 'int' cannot bind to lvalue of type 'int'
Run Code Online (Sandbox Code Playgroud)

但据我所知,正如T2实例化那样int,那么类型t2int&&,所以应该允许它传递给函数g的第一个参数(int &&). …

c++ templates perfect-forwarding c++11

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

为什么git fetch origin master失败了?

假设我的本地存储库是github上存储库后面的一个提交.

然后我在本地存储库中提交一个提交

此时

A ------>提交1 Github/master

A ------>提交2本地存储库/主服务器

我执行以下步骤将commit 2推送到github:

  1. git fetch origin master
  2. git rebase origin/master
  3. git push origin master

但是我遇到了以下错误:

在此输入图像描述 如果我尝试用第1步替换git fetch origin它,它运行良好

然后我尝试了git fetch origin master:tmp,一个名为tmp的分支成功创建

所以,我的问题是

为什么git fetch origin master有时工作(在这种情况下git fetch origin master:tmp),而有时不工作在案例步骤1?

git github

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

不能将参数1从'char [20] [20]'转换为'char**'?

我的代码如下:

#include <stdio.h>

void print_pointer(char **str);
void print_array(char *str[20]);
void print_array2(char str[20][20]);
void print_array3(char str[][20]);

int main(int argc, char *argv[])
{
    char str[20][20] = {"test1", "test2", "test3"};

    print_pointer(str);
    print_array(str);
    print_array2(str);
    print_array3(str);

    return 0;
}

void print_pointer(char **str)
{
    int i = 0;
    for(; i < 20; i++)
    {
        printf("%s", str[i]);
    }
}
void print_array(char *str[20])
{
    int i = 0;
    for(; i < 20; i++)
    {
        printf("%s", str[i]);
    }
}
void print_array2(char str[20][20])
{
    int i = 0;
    for(; i …
Run Code Online (Sandbox Code Playgroud)

c arrays string pointers

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