Skip to content

Instantly share code, notes, and snippets.

View jharmn's full-sized avatar

Jason Harmon jharmn

View GitHub Profile
curl -i https://api.github.com/users/jasonh-n-austin
HTTP/1.1 200 OK
Server: GitHub.com
Date: Thu, 14 Feb 2013 04:52:06 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 50
200 OK
{
"id": 57005215,
"id_str": "57005215",
"name": "Jason Harmon",
"screen_name": "jasonh_n_austin",
"location": "Austin, TX",
"url": "http://pragmaticapi.com",
<snip>
@jharmn
jharmn / gist:7624044
Last active December 29, 2015 05:48
First shot at setting up a flask-oauthlib server for OAuth2
import logging
from flask import Flask
from flask import session, request
from flask import render_template, redirect, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_oauthlib.provider import OAuth2Provider
from sqlalchemy.orm import relationship
from werkzeug.security import gen_salt
from datetime import datetime, timedelta
@jharmn
jharmn / gist:7028296
Created October 17, 2013 16:47
Making a call to Twilio with an error
curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/abc123/SMS/Messages.json' -d 'From=%2B15127820461' -d 'To=5125551212'
{"status":401,"message":"Authenticate","code":20003,"more_info":"http:\/\/www.twilio.com\/docs\/errors\/20003"}
@jharmn
jharmn / gist:6516536
Created September 10, 2013 22:15
A python-based example of timezone resolution
import datetime
from pytz import timezone
from dateutil.parser import parse
appt = parse("2013-08-16T15:30:15Z") #From UTC/Zulu time
tzinfo = timezone("America/Chicago") #Retrieve timezone info for US Central
apptLocal = appt.astimezone(tzinfo) # Date is modulated as 2013-08-16 10:30:15-05:00
print apptLocal
# Produces 2013-08-16 10:30:15-05:00
@jharmn
jharmn / gist:6516492
Created September 10, 2013 22:12
Providing timezone with a datetime for an appointment
"appointmentTime": {
"value": "2013-08-16T10:30:15Z", // Note this is UTC, or "Zulu time"
"timezone": "America/Chicago" // Note zoneinfo standard
}
}
@jharmn
jharmn / gist:6516472
Last active December 22, 2015 18:59
An example of an imprecise date for an appointment
{
"address": {
"streetAddress": "123 Privacy Lane",
"city": "Austin",
"stateOrProvince": "TX",
"postalCode": "78701"
},
"appointmentTime": "2013-08-16T05:30:15-500"
}
curl https://api.example.com/widgets/ -H 'Authorization: Bearer b77yz37w7kzy8v5fuga6zz93'
{
"access_token": "b77yz37w7kzy8v5fuga6zz93",
"token_type": "bearer",
"expires_in": 2629743
}
curl -u charlie:brown https://snoopy.com