小编Mar*_*k C的帖子

Github:查找用户是评论者的 PR

Github 添加了审稿人

有没有办法找到用户是审阅者的PR(例如在Pull Requests页面上)?我已经尝试过的事情:

  • 检查https://help.github.com/articles/searching-issues/过滤器:

    没有找到

  • 已测试潜在过滤器评论者:{{user}},评论者:{{user}}

    没有 PR 返回

  • 测试了涉及的:{{user}} 过滤器

    用户仅作为审阅者的 PR 不会显示在结果中。

github pull-request

14
推荐指数
2
解决办法
5098
查看次数

如何在underscorejs中转置对象

在JavaScript中我试图转换具有类似键的对象数组:

[{'a':1,'b':2}, {'a':3,'b':4}, {'a':5,'b':6,'c':7}]
Run Code Online (Sandbox Code Playgroud)

到具有每个键的值数组的对象:

{'a':[1,3,5], 'b':[2,4,6], 'c':[7]};
Run Code Online (Sandbox Code Playgroud)

使用underscore.js 1.4.2.

我在下面有一些工作代码,但它比仅仅编写嵌套for循环感觉更长更笨拙.

在下划线中有更优雅的方式吗?我有什么简单的东西吗?

console.clear();

var input = [{'a':1,'b':2},{'a':3,'b':4},{'a':5,'b':6,'c':7}];
var expected = {'a':[1,3,5], 'b':[2,4,6], 'c':[7]};

// Ok, go
var output = _(input)
.chain()
// Get all object keys
.reduce(function(memo, obj) {
    return memo.concat(_.keys(obj));
}, [])
// Get distinct object keys
.uniq()
// Get object key, values
.map(function(key) {
    // Combine key value variables to an object  
    // ([key],[[value,value]]) -> {key: [value,value]}
    return _.object(key,[
        _(input)
        .chain()
        // Get this key's values
        .pluck(key)
        // …
Run Code Online (Sandbox Code Playgroud)

javascript transpose underscore.js

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

代理stdout/stderr在bash中保持顺序

我试图通过以下方式在文件的每一行输出前添加一些信息:

  • 抓住stdout和stderr
  • 预先填写信息
  • 输出到原始句柄

这是我的测试脚本:

#!/bin/bash
#
# Test proxying stdout and stderr
#

function proxy-stdouterr() {
    local name="$1"
    local handle=$2
    while IFS='' read -r line
    do
        echo -e "[ ${name}: ${line} ]" >&${handle}
    done
}

# Output some messages and attempt to parse them
(
    echo "1: Normal message"
    echo "2: Error" >&2
    echo "3: Normal message"
    echo "4: Error" >&2
) 2> >(proxy-stdouterr "stderr" 2) > >(proxy-stdouterr "stdout" 1)
Run Code Online (Sandbox Code Playgroud)

这工作得相当好,但不保留终端中的顺序(Ubuntu 12.04).

不代理输出时:

1: Normal message
2: Error
3: …
Run Code Online (Sandbox Code Playgroud)

bash stdout stderr

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

未设置的C指针不为空

我正在搞乱C指针.当我编译并运行以下代码时.

例1:

#include <stdio.h>

int main()
{
    int k;
    int *ptr;
    k = 555;
    if (ptr == NULL) {
        printf("ptr is NULL\n");
    } else {
        printf("ptr is not NULL\n");
        printf("ptr value is %d\n", *ptr);
    }
    printf("ptr address is %p\n", ptr);
}
Run Code Online (Sandbox Code Playgroud)

我得到输出:

ptr is not NULL
ptr value is 1
ptr address is 0x7fff801ace30
Run Code Online (Sandbox Code Playgroud)

如果我没有为k赋值:

例2:

#include <stdio.h>

int main()
{
    int k;
    int *ptr;
    if (ptr == NULL) {
        printf("ptr is NULL\n");
    } else {
        printf("ptr is not NULL\n"); …
Run Code Online (Sandbox Code Playgroud)

c null pointers variable-assignment

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