Skip to content

Instantly share code, notes, and snippets.

View amit1rrr's full-sized avatar

Amit Rathi amit1rrr

View GitHub Profile
@gbaman
gbaman / graphql_example.py
Created November 1, 2017 00:18
An example on using the Github GraphQL API with Python 3
# An example to get the remaining rate limit using the Github GraphQL API.
import requests
headers = {"Authorization": "Bearer YOUR API KEY"}
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section.
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers)
if request.status_code == 200:
@davidcelis
davidcelis / blame.graphql
Created December 6, 2016 19:28
An example GraphQL query to get `git blame` data from the GitHub GraphQL API
query {
repositoryOwner(login: "github") {
repository(name: "linguist") {
object(expression: "master") {
... on Commit {
blame(path: "github-linguist.gemspec") {
ranges {
startingLine
endingLine
age
@noporpoise
noporpoise / unifieddiff.py
Last active November 14, 2023 18:59
Apply unified diff patches in pure python2/3
#!/usr/bin/env python
# coding=utf-8
# License: Public domain (CC0)
# Isaac Turner 2016/12/05
from __future__ import print_function
import difflib
import re