Skip to content

Instantly share code, notes, and snippets.

View brianrusso's full-sized avatar

Brian Russo brianrusso

  • Tampa, FL
View GitHub Profile
@brianrusso
brianrusso / auth_sharepointonline.py
Last active May 3, 2022 13:24
Quick and dirty example of how to authenticate to Office 365 SharePoint Online using urllib2, jinja2, cookielib. Basically you POST your user/pass to Microsoft's token service, then hand that token to SharePoint's login proper, which gives you a cookie to access SharePoint content.
import urllib2
import cookielib
import urlparse
import jinja2
from urllib2 import HTTPCookieProcessor
from lxml import etree
# Setup Jinja for SAML
JINJA_TEMPLATE_PATH = "/Users/Brian/IdeaProjects/yggdrasil/templates"
JINJA_ENVIRONMENT = jinja2.Environment(
from dogpile.cache import make_region
# key dictionary
keys = dict()
def my_key_generator(namespace, fn, **kwargs):
fname = fn.__name__
def generate_key(*arg):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import json
import geojson
import requests
class ClavinClient(object):
def __init__(self, clavin_endpoint=None):
if clavin_endpoint is None:
#self.clavin_endpoint = "http://54.186.35.170:9090/api/v0/geotag"
{"directed": false, "graph": {}, "nodes": [{"id": 716800}, {"id": 1017728}, {"id": 22275}, {"id": 592388}, {"id": 120709}, {"id": 498694}, {"id": 25099}, {"id": 1155212}, {"id": 677774}, {"id": 321039}, {"id": 121248}, {"id": 358806}, {"id": 196759}, {"id": 151576}, {"id": 1691674}, {"id": 385563}, {"id": 223901}, {"id": 379550}, {"id": 27717}, {"id": 583200}, {"id": 99708}, {"id": 555043}, {"id": 649253}, {"id": 55720}, {"id": 1152297}, {"id": 479794}, {"id": 1666738}, {"id": 950150}, {"id": 1390265}, {"id": 807866}, {"id": 1484732}, {"id": 580029}, {"id": 119614}, {"id": 470816}, {"id": 1438145}, {"id": 304324}, {"id": 1329477}, {"id": 411336}, {"id": 1603212}, {"id": 1280202}, {"id": 239820}, {"id": 114381}, {"id": 1627345}, {"id": 407843}, {"id": 1181785}, {"id": 516442}, {"id": 305115}, {"id": 36828}, {"id": 1264634}, {"id": 1239936}, {"id": 1051235}, {"id": 1175656}, {"id": 1574249}, {"id": 1266027}, {"id": 468845}, {"id": 1225149}, {"id": 943400}, {"id": 1421824}, {"id": 1690612}, {"id": 1669467}, {"id
{"directed": false, "graph": {}, "nodes": [{"id": 716800}, {"id": 1017728}, {"id": 22275}, {"id": 592388}, {"id": 120709}, {"id": 498694}, {"id": 25099}, {"id": 1155212}, {"id": 677774}, {"id": 321039}, {"id": 121248}, {"id": 358806}, {"id": 196759}, {"id": 151576}, {"id": 1691674}, {"id": 385563}, {"id": 223901}, {"id": 379550}, {"id": 27717}, {"id": 583200}, {"id": 99708}, {"id": 555043}, {"id": 649253}, {"id": 55720}, {"id": 1152297}, {"id": 479794}, {"id": 1666738}, {"id": 950150}, {"id": 1390265}, {"id": 807866}, {"id": 1484732}, {"id": 580029}, {"id": 119614}, {"id": 470816}, {"id": 1438145}, {"id": 304324}, {"id": 1329477}, {"id": 411336}, {"id": 1603212}, {"id": 1280202}, {"id": 239820}, {"id": 114381}, {"id": 1627345}, {"id": 407843}, {"id": 1181785}, {"id": 516442}, {"id": 305115}, {"id": 36828}, {"id": 1264634}, {"id": 1239936}, {"id": 1051235}, {"id": 1175656}, {"id": 1574249}, {"id": 1266027}, {"id": 468845}, {"id": 1225149}, {"id": 943400}, {"id": 1421824}, {"id": 1690612}, {"id": 1669467}, {"id
{
"directed" : false,
"graph" : {},
"nodes" : [{
"id" : 1376262
}, {
"id" : 1277961
}, {
"id" : 163853
}, {
{
"directed" : false,
"graph" : {},
"nodes" : [{
"id" : 1376262
}, {
"id" : 1277961
}, {
"id" : 163853
}, {
# If add is True (default, it will add them, else it merges.
def deepdictmerge(a, b, path=None, add=True):
if path is None: path = []
for key in b: # for every key in b..
if key not in a: # handle simple case where it's new
a[key] = b[key]
else: # key must be in a and b
# both dictionaries.
if isinstance(a[key], dict) and isinstance(b[key], dict):
deepdictmerge(a[key], b[key], path + [str(key)]) # recurse down
@brianrusso
brianrusso / tensorflow_self_check.py
Created August 25, 2017 15:01 — forked from mrry/tensorflow_self_check.py
TensorFlow on Windows self-check
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,