Code Monkey home page Code Monkey logo

githubfs's Introduction

GitHubFS

I got curious over the weekend and wonder what it would be like to query the GitHub API in C using libCurl. I quickly realized I was going to need a JSON parser, so I reached for libfastjson, which is a fork of json-c brought to us by the rsyslog folks.

The project has evolved! it now mounts a full list of your stared repos to a directory of your choosing using Fuse.

The code has now been refactored to use LMDB for persistence, and Repo access.

Prerequisites

You're going to need a; Compiler, Make of some sort, libfastjson with headers, and libcurl with it's headers, libfuse, and now lmdb with it's headers.

Building

All you need to do is run:

make

Running

The fetcher needs two environment variables GH_USER; your github username, and GH_TOKEN; a personal access token to your public repos. Execution might look something like this:

export GH_USER=dmolik
export GH_TOKEN=<redacted>
./githubfs <some dir>

For example:

> export GH_USER=dmolik
> export GH_TOKEN=example123
> ./githubfs t

> githubfs t
t
├── aalhour
│   └── awesome-compilers
├── acassen
│   └── keepalived
├── adapta-project
│   └── adapta-gtk-theme
├── admiraltyio
│   └── multicluster-scheduler
└── AidoP
    └── Skypaper

> cat t/acassen/keepalived
URL: [email protected]:acassen/keepalived.git
Description: Keepalived

githubfs's People

Contributors

dmolik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

githubfs's Issues

Better repo datastructure.

Convert list into an index & B or B+ tree.

Save repo list to disk in $HOME someplace.

Occasionally pull stars list.

Switch to GraphQL Github API (v4)

This is to get less data over the wire and to paginate faster.

It'll look something like this:

curl -u $GH_USER:$GH_TOKEN -X POST -d '{"query": "{ viewer { starredRepositories(first: 2) { nodes { nameWithOwner sshUrl description } pageInfo { endCursor hasNextPage } } } } "}' https://api.github.com/graphql  -H 'Accept: application/json' 2>/dev/null | jq . 
{
"data": {
  "viewer": {
    "starredRepositories": {
      "nodes": [
        {
          "nameWithOwner": "dustinmm80/devops_resources",
          "sshUrl": "[email protected]:dustinmm80/devops_resources.git",
          "description": "A list of DevOps resources - podcasts, blogs, newsletters, etc"
        },
        {
          "nameWithOwner": "wandenberg/nginx-push-stream-module",
          "sshUrl": "[email protected]:wandenberg/nginx-push-stream-module.git",
          "description": "A pure stream http push technology for your Nginx setup. Comet made easy and really scalable."
        }
      ],
      "pageInfo": {
        "endCursor": "Y3Vyc29yOnYyOpHOAU0K4g==",
        "hasNextPage": true
      }
    }
  }
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.