小编Mat*_*ski的帖子

使用listchars在Vim中显示前导空格

我在标签上使用空格.在Sublime Text 2中,我会有前导空格显示如下:

领先的空间

我有.vimrc设置来显示标签,行结尾等.但我不知道如何复制我在Sublime中的内容.它很方便,因为我只能在使用空格时更容易看到缩进.

这是我现在的路线:

set listchars=eol:¬,tab:??,extends:>,precedes:<
Run Code Online (Sandbox Code Playgroud)

vim whitespace

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

如何在C中接收带有recvfrom()的UDP数据包后获取客户端的IP?

作为服务器,有没有办法在收到客户端的消息后将客户端的IP地址作为字符串recvfrom()?我认为它在sockaddr_in结构中,但我不知道如何访问它.谁能告诉我怎么做到这一点?

c udp

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

如何在Bash阅读行中绑定“ Enter键”?

因此我昨天学习了如何使用绑定。

通过在终端中键入Ctrl+ v后跟键,我得到了代表该键的原始字符。例如:Ctrl+ v后跟Escreturn ^[

我的问题是,如何绑定“输入密钥”。Enter键返回,^M但是当我键入命令时

bind '"\e^M":"foobar"'
Run Code Online (Sandbox Code Playgroud)

按Enter键不会导致在我的终端中键入foobar。

bash keyboard-shortcuts

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

Linux Shell中的I / O流重定向。Shell如何处理带有重定向的命令?

目前,我正在编写一个小的外壳程序(重定向,管道,exec等)。一直在尝试弄清楚Linux Shell在解决I / O重定向方面采取的步骤。

关于我需要帮助的一些问题:

  1. 寻找重定向时,shell从命令行读取哪个方向?从左到右还是相反?使用递归?

  2. 外壳需要寻找什么情况?(不确定是否有很多或只有一对可以包含很多变化)

无论如何,我能想到的是一些(如果我错了,请纠正我):

cmd > file1       # stdout of cmd goes to file

cmd file1 > file2 # stdout of cmd with file1 as an argument goes to file2

cmd file2 < file1 # stdin on file2 comes from file1
Run Code Online (Sandbox Code Playgroud)

现在,我不知道在以下情况下的过程(如外壳如何查找和处理这些情况)。Shell所采取的步骤对我来说是未知的

cmd file2 > file3  < file1 # using "tee" in place of "cmd" I don't know
                           # how to do the dups and when to exec

cmd file2 < file3 > file1  # same …
Run Code Online (Sandbox Code Playgroud)

linux bash io-redirection dup

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

R / igraph :在深度优先搜索回调中获取顶点邻居列表会导致 R 关闭。有什么建议吗?

我正在尝试在 R 中编写一个脚本来识别属于图循环的元素(边和顶点)。

我在 graph.dfs(igraph R 包)中使用回调函数。我不想修改图形,只想在每次 dfs 算法访问一个顶点时构建一个新的访问顶点列表(并更新它)。问题是如果我运行以下代码,R 程序将关闭。它可能做错了什么 - 有什么建议/帮助吗?

#create a simple graph with 4 nodes and 1 cycle
gIncidenceMatrix <- matrix (c(0,1,1,1,1,0,0,0,1,0,0,1,1,0,1,0), nrow=4, ncol=4, byrow=T)

g <- graph.adjacency(gIncidenceMatrix, mode = "undirected")

f.cycleDetection <- function(g, data, extra) {

vId <- data[1]
nVertices <- neighbors(g, vId+1, mode = 1)        #vId + 1 is to avoid having index 0 (any suggestion?)

FALSE
}

graph.dfs(g, root=1, neimode = "all", unreachable = TRUE, order = FALSE, order.out = FALSE, father = …
Run Code Online (Sandbox Code Playgroud)

r callback igraph depth-first-search

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

当使用-filter_complex在FFmpeg中进行混合时,流混合

我目前遇到了ffmpeg及其中一个过滤器的问题.

我正在尝试将视频的2个音频流合并为一个.为此我尝试了这个命令:

ffmpeg -i /home/maniaplanet/Videos/ManiaPlanet\ 2014-08-21\ 20-09-13-082.avi.output.mkv -filter_complex "[0:1][0:2] amerge=inputs=2"-c:v copy -c:a libvo_aacenc -b:a 256k /var/www/files/output.mp4
Run Code Online (Sandbox Code Playgroud)

但我得到这个输出:

ffmpeg version 1.0.10 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jul 25 2014 07:50:40 with gcc 4.7 (Debian 4.7.2-5)
  configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64-linux-gnu …
Run Code Online (Sandbox Code Playgroud)

mapping ffmpeg stream

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

如何打印匹配的字符串?

我真的不熟悉 lex/flex。我正在尝试调试一些遗留的 flex 代码。我想查看与特定规则匹配的文本。

例如。

[a-z]*      {"some C code"  "need to print the string that matched this rule"}
Run Code Online (Sandbox Code Playgroud)

例如。如果johndoe@xyz.com 是输入,我需要打印匹配的字符串,即johndoe

我尝试打印yytext,但它只显示第一个字符。

c regex lex flex-lexer

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

如何在golang的cgo中使用std :: vector或其他容器?

我想将大量的对象malloc到内存中(大约1亿个对象),因为golang的gc不够有效,所以我需要使用c/c ++来malloc内存并使用std :: vector来保存对象.这是我的代码,我想在cgo中使用std容器:

package main

import (
    "fmt"
)

/*
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>


using namespace std;

void dosome(){
    vector<int> ivec;   // empty vector
    for (vector<int>::size_type ix = 0; ix != 10; ++ix)
        ivec[ix] = ix; // disaster: ivec has no elements
}

*/
// #cgo LDFLAGS: -lstdc++
import "C"

//import "fmt"
func main() {

    C.dosome()

    var input string
    fmt.Scanln(&input)
}
Run Code Online (Sandbox Code Playgroud)

并在下面有错误消息:

go run stddemo.go 
# command-line-arguments
./stddemo.go:13:10: fatal error: 'vector' file not found
#include …
Run Code Online (Sandbox Code Playgroud)

go cgo

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

是否可以使用 .gitignore 忽略特定的可执行文件?

假设我myProgam在 Mac 上通过编译代码得到了可执行文件,如下所示:

 gcc -o myProgram myProgram.c
Run Code Online (Sandbox Code Playgroud)

如何诱导我的.gitignore文件实际上忽略该myProgram文件?我并不是在寻找为可执行文件创建单独文件夹的解决方案。

我的问题对许多人来说似乎是显而易见的,但实际上我无法在网上找到任何解决方案,尽管我已经搜索了一些页面和教程以及 StackOverflow 资源。

我将不胜感激任何提示。

git macos gitignore

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

在 FreeBSD 11.2 中找不到 clang-format

我安装了一个 FreeBSD 虚拟机,然后我运行了sudo pkg install clang-devel.

clang-format 然而,似乎缺少:

-sh:clang 格式:未找到

如何clang-format在 FreeBSD 11.2 中安装?

freebsd clang-format

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