commit f8e742d0fc28de8b2d22c3a4a58a0d84378d116b Author: wes Date: Mon May 22 19:19:40 2017 -0400 initial commit diff --git a/continue-projects.rkt b/continue-projects.rkt new file mode 100644 index 0000000..bf8ccee --- /dev/null +++ b/continue-projects.rkt @@ -0,0 +1,53 @@ +#lang racket +(require net/url) +(require json) +(require net/head) +(require srfi/41) + +(define (get-next link) + (let* ([splitted (string-split link ";")] + [url (substring (car splitted) + 1 + (sub1 (string-length (car splitted))))] + [query (make-hash + (url-query + (string->url url)))]) + (string->number + (hash-ref query 'since 1)))) + +(define (get-project-names since) + (define resp + (get-impure-port + (string->url + (format + "https://api.github.com/repositories?since=~a" + since)))) + + (define headers + (make-hash + (extract-all-fields + (purify-port resp)))) + + (cond + [(string=? + (hash-ref headers "Status" "") + "403 Forbidden") + (stream)] + + [else + (stream-concat + (stream + (list->stream + (filter + (compose not (curry equal? 'null)) + (map + (lambda (p) + (hash-ref p 'description)) + (read-json resp)))) + + (get-project-names + (get-next (hash-ref headers "Link")))))])) + +(define + projects-stream + (get-project-names 1)) \ No newline at end of file