Skip to content

Instantly share code, notes, and snippets.

View alanbernstein's full-sized avatar

Alan Bernstein alanbernstein

View GitHub Profile
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
import httplib2
import os
from pprint import pprint
from apiclient import discovery
import oauth2client
from oauth2client import client
from oauth2client import tools
@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 re
import os
import requests
from time import sleep
from amazon.api import AmazonAPI
from canistreamit import search, streaming
# from bs4 import BeautifulSoup
# python-amazon-simple-product-api==2.1.0
@alanbernstein
alanbernstein / wunder_history.py
Created July 15, 2017 04:35
collect and cache historical wunderground data as json files
import os
import json
import requests
import time
from datetime import datetime as dt
from datetime import timedelta
CACHE_BASE = os.getenv('CACHE') # output directory
function [t1 t2] = estimatePerspectiveTransform(x,y,X,Y)
% given two planar quadrilaterals, compute a perspective transformation
% that maps the first onto the second
%
% useful, for example, for inverting the perspective transformation that an
% image undergoes when photographed. this function is based on a simplified
% model of the perspective transformation that maps quadrilaterals on an
% arbitrary, unspecified plane in world-space, to the plane in image-space.
% simplified, relative to a full estimate of camera position, orientation,
% view angle, etc etc. it simply determines a transformation that maps one
"""
simple tool for performing perspective correction
useful for "flattening" internet photos of things that i want to print or cut
"""
import os
import cv2
import numpy as np
def correct_image(fin, fout, pin, pout, dim=None, show=True):
@alanbernstein
alanbernstein / main.go
Last active August 1, 2018 15:57
pilosa menu bar example
package main
import (
"fmt"
"io/ioutil"
"time"
"github.com/getlantern/systray"
"github.com/skratchdot/open-golang/open"
"github.com/sqweek/dialog"
@alanbernstein
alanbernstein / config.md
Created September 7, 2018 17:25 — forked from 0XDE57/config.md
Firefox about:config privacy settings

ABOUT

about:config settings to harden the Firefox browser. Privacy and performance enhancements.
To change these settings type 'about:config' in the url bar. Then search the setting you would like to change and modify the value. Some settings may break certain websites from functioning and rendering normally. Some settings may also make firefox unstable.

I am not liable for any damages/loss of data.

Not all these changes are necessary and will be dependent upon your usage and hardware. Do some research on settings if you don't understand what they do. These settings are best combined with your standard privacy extensions (HTTPS Everywhere, NoScript/Request Policy, uBlock origin, agent spoofing, Privacy Badger etc), and all plugins set to "Ask To Activate".

package main
import (
"bufio"
"encoding/json"
"fmt"
"log"
"os"
"github.com/olekukonko/tablewriter"