neighbor

授权协议 GPL-3.0 License
开发语言 Google Go
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 邢飞雨
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

neighbor has importable Go packages (e.g., builtin/*, sdk/*) and an accompanyingcommand-line interface for searching, cloning and executing an arbitrary binaryagainst GitHub projects. Abstractions are in place to make doing the aforementionedeasy and efficient for projects obtained from arbitrary search and retrieval methods(i.e., not limited to GitHub Search, repositories or Git clone).

The motivation for neighbor is to provide users (e.g., developers, researchers, etc.)with a way to search, efficiently clone and evaluate projects without having to"roll their own". Instead users can focus on the task at hand. [TODO] Another motivationfor neighbor is to provide researchers with a standard, reproducible way of obtaining projects.In order to guarantee fair comparisons of approaches, rather than "hand-picked"projects that reinforce claims. This can be accomplished now via zipping theproject versions retrieved from a run of neighbor.

neighbor uses v3 of GitHub's REST API.

Why neighbor

  • Extensibility
    • Abstract interfaces for projects, search and retrieval functions which meansthat it is easy to add new "types" or projects (e.g., something other than GitHubrepositories) and use other methods for search and retrieval in addition toGitHub search and Git clone, respectively.
  • Abstracting GitHub API interaction (searching, sorting and cloning)
    • Transparent pagination
    • Transparent authentication
    • Transparent rate limit handling
  • Doing the above efficiently by leveraging Go's concurrent capabilities

Requirements

Getting Started

  1. Installing the project

    GOPROXY=https://proxy.golang.org go get github.com/mccurdyc/neighbor@latest

  2. Searching and Evaluating

    First, you should review the Searching on GitHub documentation.

    1. Plain Retrieve Example
    make build
    ./bin/neighbor --query="org:neighbor-projects NOT minikube" --plain_retrieve --projects_directory="_projects_directory" --num_projects=2 --clean=false
    1. Repository Search Example
    make build
    ./bin/neighbor --query="org:neighbor-projects NOT minikube" --command="ls -al" --projects_directory="_projects_directory" --num_projects=2 --clean=false
    1. Code Search Example

    Note: GitHub requires users to be logged in to search code.Even in public repositories. Refer to the Code search documentation herefor building a query. Code searches are searched elastically and are notguaranteed to return exact matches. Searching code for exact matches is currentlyin beta and only work on very specific repositories, see this section in the documentation

    It is critical that you read the above documentation because Code search maynot behave as you would expect. For example,

    You can't use the following wildcard characters as part of your search query:

    . , : ; / \ ` ' " = * ! ? # $ & + ^ | ~ < > ( ) { } [ ]
    

    The search will simply ignore these symbols. Additionally, I have found thatusing extension:EXTENSIONis more reliable and accurate than filename:FILENAME.

    make build
    ./bin/neighbor --search_type="code" --auth_token="abc123" --query="pkg/errors in:file extension:mod path:/ user:mccurdyc" --command="ls -al"
    1. Multi-Line Command Example

    Multi-line commands work, but pipes (i.e., |) do not. In order to use pipes,you should create a custom binary that handles piping the output from one commandto the next (e.g., "How to pipe several comands in Go?" on StackOverflow)

    make build
    ./bin/neighbor --search_type="code" --auth_token="abc123" --query="pkg/errors in:file extension:mod path:/ user:mccurdyc" --command="ls \
    -al"
  3. Confirming

    One way to confirm that you obtained the number of projects that you expectedis to run the following:

    find _external_projects -mindepth 2 -maxdepth 2 | wc -l

Usage

Usage: neighbor (--file=<file> | --query=<string> (--command=<string> | --plain_retrieve)) [--auth_token=<github-access-token>] [--search_type=<repository|code>] [--projects_directory=<string>] [--num_projects=<int>] [--clean=<bool> | --plain_retrieve]

  -alsologtostderr
        log to standard error as well as files
  -auth_token string
        Your personal GitHub access token. This is required to access private repositories and increases rate limits.
  -clean
        Delete the projects directory after running the command against each project. (default true)
  -command string
        The command to execute on each project returned from a search query.
  -file string
        Absolute filepath to the config file.
  -help
        Print this help menu.
  -log_backtrace_at value
        when logging hits line file:N, emit a stack trace
  -log_dir string
        If non-empty, write log files in this directory
  -logtostderr
        log to standard error instead of files
  -num_projects int
        The number of _desired_ projects to obtain. (default 10)
  -plain_retrieve
        Whether projects should just be retrieved and not evaluated.
  -projects_directory string
        Where the projects should be stored locally and found for evalutation. (default "_external_projects")
  -query string
        The search query to execute.
  -search_type string
        The type of search to perform. (default "project")
  -stderrthreshold value
        logs at or above this threshold go to stderr
  -v value
        log level for V logs
  -vmodule value
        comma-separated list of pattern=N settings for file-filtered logging

FAQ

What about private repositories?

Generate a GitHub Personal Access Tokenneighbor uses token authentication for communicating and authenticating with GitHub.To read more about GitHub's token authentication, visit this site.

You can create a personal access token and use it in place of a password when performing Git operations over HTTPS with Git on the command line or the API.

Authentication is required to both increase the GitHub API limitationsas well as access private content (e.g., repositories, gists, etc.).

  • Use the --auth_token command-line argument
  • If using a config file, add the generated token to the file
    {
      "auth_token": "yourAccessToken1234567890abcdefghijklmnopqrstuvwxyz",
      ...
    }

Executing a Cli Command/Executable Binary

neighbor allows you to specify an executable binary to be run ona per-repository basis with each repository as the working directory.

Examples can be found in the examples.

License

FOSSA Status

  • windows7系统修改配置neighbor. 命令行‘netsh -c 'i i’ add neighbor 'interface_name' 192.168.1.9 00-45-05-65-34-34 其中-c 'i i'指定netsh的netsh interface ipv4命令行上下文,其也相当于是输入以下命令: >cmd >netsh netsh>interface netsh inte

  • 维基百科:https://en.wikipedia.org/wiki/Nearest_neighbor_search 觉得整理的挺好,翻译 最近邻搜索( NNS ) 作为**邻近搜索(proximity search)**的一种形式,是在给定集合中找到与给定点最接近(或最相似)的点的优化问题(optimization problem)。相似度通常用不相似函数表示:对象越不相似,函数值越大。 形式上

  • 命令功能 display lldp neighbor brief命令用来查看邻居设备的概要信息。 命令格式 display lldp neighbor brief 参数说明 无 视图 所有视图 缺省级别 1:监控级 使用指南 应用场景 当需要快速查看与本设备相连的邻居概要信息,如设备有哪些、分别通过哪个接口与本设备相连时,使用该命令。 前置条件 全局的LLDP功能已经使能。 使用实例 # 查看设备

  • 简介(Introduction): ANN(Approximate Nearest Neighbor)是一种用于在大规模数据集中寻找最近邻居的算法。它的目标是在尽可能短的时间内找到与给定查询点最近的数据点,而不一定是确切的最近邻。为了达到这个目标,ANN使用了一些启发式方法,例如剪枝和近似搜索,来加速最近邻搜索的过程。虽然ANN不像暴力线性搜索那样能够100%找到最近点,但它的速度非常快,因此在需

  • clickhouse中有个比较好用的函数是neighbor函数,用于排序后取上N行或者下N行,在计算同比环比等指标的时候,还是比较好用的 但是我在使用的过程中,踩过两个坑,结果都是和预期的不一样,希望能写出来给大家避避雷 踩坑1: neighbor函数必须配合order by 使用! 踩坑2: neighbor函数本质上只是在每一个数据存储块中进行排序,并没有对所有数据进行排序!! 所以, 你有可