Skip to content

Instantly share code, notes, and snippets.

View alanbernstein's full-sized avatar

Alan Bernstein alanbernstein

View GitHub Profile
@alanbernstein
alanbernstein / quadratic_ransac_fit.py
Created November 18, 2016 06:00
fit some curves with quadratic ransac
#!/usr/local/bin/python
import csv
import matplotlib.pyplot as plt
import numpy as np
from sklearn import linear_model
from sklearn.preprocessing import PolynomialFeatures
def get_data(fname):
with open(fname) as f:
import httplib2
import os
from pprint import pprint
from apiclient import discovery
import oauth2client
from oauth2client import client
from oauth2client import tools
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials
import json
import base64
import httplib2
def authorize(ga_email, ga_secret):
jwt = SignedJwtAssertionCredentials(ga_email, ga_secret, scope=self.ga_scope, private_key_password='notasecret')
http = jwt.authorize(httplib2.Http())
return build('analytics', 'v3', http=http) # failure happens here for JSON key file