Skip to content

Instantly share code, notes, and snippets.

View johnsheehan's full-sized avatar

John Sheehan johnsheehan

  • White Bear Lake, MN
View GitHub Profile
// The JSON Schema that we place into the Initial Script
// section of the Runscope API test.
var rosterResponse = {
"definitions": {
"player": {
"id": "player",
"type": "object",
"required": ["player_number","guid","name"],
"properties": {
"player_number": { "type": "integer" },
@johnsheehan
johnsheehan / flask-keen.py
Last active October 8, 2015 00:07
automatically send flask requests to keen
from keen.client import KeenClient
keen = KeenClient(
project_id="123",
write_key="abc"
)
@app.before_request
def before_request():
if "/static/" in request.path:
return
### Keybase proof
I hereby claim:
* I am johnsheehan on github.
* I am johnsheehan (https://keybase.io/johnsheehan) on keybase.
* I have a public key whose fingerprint is 701C 7D09 54E6 82F3 8007 479A C03D CEDB A3CC 6812
To claim this, I am signing this object:
@johnsheehan
johnsheehan / gist:6125526
Created July 31, 2013 19:53
troubleshooting bitly API call with Runscope
import sys
import bitly_api
import os
from config import config
# sign up for a free account at runscope.com and make
# note of your bucket key
# connect to bitly
conn_btly = bitly_api.Connection(access_token=config['ACCESS_TOKEN'])
import sys
import bitly_api
import os
from config import config
# sign up for a free account at runscope.com and make
# note of your bucket key
# connect to bitly
conn_btly = bitly_api.Connection(access_token=config['ACCESS_TOKEN'])
public static partial class RestClientExtensions
{
public static RestResponse<dynamic> ExecuteDynamic(this IRestClient client, IRestRequest request)
{
var response = client.Execute(request);
var generic = (RestResponse<dynamic>)response;
dynamic content = SimpleJson.DeserializeObject(response.Content);
generic.Data = content;
@app.route('/xyzzy/ajax/<resource>', methods=['POST', 'GET', 'DELETE'])
@auth.required
@https_required
def admin_ajax(resource):
cmd = Command(request.method, resource)
# could replace this with data = request.params
data = request.args
if (request.method in ['PUT', 'POST']):
data = request.form
class Command:
m = ''
r = ''
resources = {
'promo-codes' : {
'POST' : post_promo_code,
'DELETE' : delete_promo_code
},
'approved-jobs' : {
@johnsheehan
johnsheehan / gist:2268978
Created March 31, 2012 22:03
sample python config
TWITTER_CONSUMER_KEY = '...'
TWITTER_CONSUMER_SECRET = '...'
TWITTER_ACCESS_TOKEN = '...'
TWITTER_TOKEN_SECRET = '...'
SENDGRID_USER = '...'
SENDGRID_KEY = '...'
STRIPE_SECRET_KEY = '...'
@johnsheehan
johnsheehan / gist:2268946
Created March 31, 2012 21:56
@ssl_required decorator for Flask on Heroku
from functools import wraps
from flask import request, redirect
import os
def https_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
scheme = 'http'
if request.headers.get('x-forwarded-proto', None):
scheme = request.headers.get('x-forwarded-proto')