Instantly share code, notes, and snippets.

Jason Rudolph jasonrudolph

View GitHub Profile

Repository redirects are coming to the GitHub API, and this functionality is now available for developers to preview. Let's try it out.

First, we need a repository that has been renamed or relocated. Since jasonrudolph/ was previously named jasonrudolph/, we can use it as our guinea pig. 🌍🐖

We'll use curl for all of our examples below, and we'll include the --location option to instruct curl to follow any redirects that it encounters.

The Present

Using the current production version of the GitHub API, when we attempt to [access the repository](

curl -H 'Accept: application/'
curl -H "Accept: application/"
View gist:6057563

James Sugrue [asked][1], "@GitHubAPI is there a way to find the number of stars for a given repository?"


$ curl -ni "" -H 'Accept: application/vnd.github.preview'
# Search for code containing the term "_cache" in repositories owned by @jasonrudolph
curl -G -H "Accept: application/vnd.github.preview.text-match" \ --data-urlencode "q=@jasonrudolph _cache"
View snippet.rb
# A Ruby snippet posted as a comment on
# [ activable?, persisted?, new?, suspended? ]
# =============================================
combinations = [
[ false, false, false, false ],
[ false, false, true, false ],
[ false, false, false, true ],
[ false, true, false, false ],
View mongo-console
# Assuming you're familiar with specifying query and sort options
# via the MongoDB console as shown here, you can specify these same
# options via the MongoHQ RESTful API using the approach shown in the
# file below.
$ mongo -u REDACTED -p
MongoDB shell version: 2.0.4
Enter password:
connecting to:
> use one-rep-max;