This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DeleteCreatedEntities sets up GORM `onCreate` hook and return a function that can be deferred to | |
// remove all the entities created after the hook was set up | |
// You can use it as | |
// | |
// func TestSomething(t *testing.T){ | |
// db, _ := gorm.Open(...) | |
// | |
// cleaner := DeleteCreatedEntities(db) | |
// defer cleaner() | |
// |
OlderNewer