Skip to content

Instantly share code, notes, and snippets.

View pengwynn's full-sized avatar

Wynn Netherland pengwynn

View GitHub Profile
@pengwynn
pengwynn / curl-ua.shell
Created May 3, 2013 01:15
Pass a User-Agent header with curl
curl -v --user-agent "dartvoid/0.1 (https://github.com/dartvoid\) terminal/0.0" https://api.github.com/users/dartvoid
* About to connect() to api.github.com port 443 (#0)
* Trying 207.97.227.243...
* connected
* Connected to api.github.com (207.97.227.243) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
@pengwynn
pengwynn / auth.sh
Created August 30, 2012 13:35
Create GitHub Authorization token with curl
curl -i -u username \
-d '{"scopes": ["repo", "user"], "note": "Your note here"}' \
https://api.github.com/authorizations
source :rubygems
gem 'sinatra', '1.0'
gem 'gowalla', '~> 0.2.0'
group :development do
gem 'shotgun'
end
@pengwynn
pengwynn / list_count.rb
Created August 6, 2015 02:05
Hack to find the total count of a GitHub API listing
require 'octokit'
Octokit.pulls("rails/rails", :state => "all", :per_page => 1)
last_page = Octokit.last_response.rels[:last].href
count = Addressable::URI.parse(last_page).query_values["page"]
#!/bin/sh
# base16-shell (https://github.com/chriskempson/base16-shell)
# Base16 Shell template by Chris Kempson (http://chriskempson.com)
# Nova scheme by Trevor Miller (https://trevordmiller.com)
# This script doesn't support linux console (use 'vconsole' template instead)
if [ "${TERM%%-*}" = 'linux' ]; then
return 2>/dev/null || exit 0
fi
### Keybase proof
I hereby claim:
* I am pengwynn on github.
* I am pengwynn (https://keybase.io/pengwynn) on keybase.
* I have a public key whose fingerprint is 0C04 D57E 795D BB21 3074 DAC4 9E6E 1D1C 5B76 C15E
To claim this, I am signing this object:
@pengwynn
pengwynn / octocat_zen.sh
Created November 14, 2012 02:42
GitHub Zen
$ curl https://api.github.com/zen | octocatsay
MMM. .MMM
MMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMM ____________________________
MMMMMMMMMMMMMMMMMMMMM | |
MMMMMMMMMMMMMMMMMMMMMMM | Practicality beats purity. |
MMMMMMMMMMMMMMMMMMMMMMMM |_ ________________________|
MMMM::- -:::::::- -::MMMM |/
MM~:~ ~:::::~ ~:~MM
@pengwynn
pengwynn / commit_stats.rb
Last active January 3, 2016 09:59
Example for getting commit additions and deletions via Octokit.rb
require 'octokit'
stats = Octokit.commit('octokit/octokit.rb', '6e0d6ccd5b68173dd030e62f4276793e5d7ce40b').stats
stats.additions
=> 7
stats.deletions
=> 78
@pengwynn
pengwynn / releases.sh
Created October 3, 2013 19:14
Conditional caching for Releases API
❯ curl -n -I -H"Accept: application/vnd.github.manifold-preview" https://api.github.com/repos/octokit/octokit.rb/releases
HTTP/1.1 200 OK
Server: GitHub.com
Date: Thu, 03 Oct 2013 19:11:09 GMT
Content-Type: application/json; charset=utf-8
Status: 200 OK
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4998
X-RateLimit-Reset: 1380831057
Cache-Control: private, max-age=60, s-maxage=60
@pengwynn
pengwynn / 1.sh
Created August 28, 2013 13:56
ETags and GitHub API paging
curl -i https://api.github.com/users/pengwynn/starred\?per_page\=1
HTTP/1.1 200 OK
Server: GitHub.com
Date: Wed, 28 Aug 2013 13:52:09 GMT
Content-Type: application/json; charset=utf-8
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 53
X-RateLimit-Reset: 1377700904
Cache-Control: public, max-age=60, s-maxage=60