Skip to content

Instantly share code, notes, and snippets.

View davidpelayo's full-sized avatar
✌️

David Pelayo davidpelayo

✌️
View GitHub Profile
@davidpelayo
davidpelayo / jobsGeneratorGivenForks.groovy
Last active September 22, 2015 08:55
Jobs generator based on forks of a certain github repo
//thanks to https://gist.github.com/joshareed/5706061
import groovy.json.JsonSlurper
def owner = "<owner>"
def project = "<project>"
// curl -k -u <user>:<token> -X GET https://api.github.com/repos/<owner>/<repo>/forks > forks.txt
def fetch(addr, params = [:]) {
@davidpelayo
davidpelayo / GithubClient.groovy
Last active September 22, 2015 08:52
Simple Github API client using Groovy RESTClient
/**
* Simple Github API client that supports basic auth.
*/
class GithubClient {
String username
String password
String owner
String repository
String fetchFileContents(String filePath) {
@davidpelayo
davidpelayo / GithubClient.groovy
Last active September 22, 2015 08:03 — forked from joshareed/GithubClient.groovy
Fetch list of issues from Github and draft an email
//#!/usr/bin/env groovy
import groovy.json.JsonSlurper
import java.text.SimpleDateFormat
// fetches a Github API URL and parses the result as JSON
def fetch(addr, params = [:]) {
def auth = "<personal api token>"
def json = new JsonSlurper()
return json.parse(addr.toURL().newReader(requestProperties: ["Authorization": "token ${auth}".toString(), "Accept": "application/json"]))