This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The site you want to log in to | |
SITE_URL = nil | |
# The username/password you want to log in with | |
USERNAME = nil | |
PASSWORD = nil | |
# All of these details are visible when you do a "login" and | |
# inspect the parameters POSTed when you click "login" on | |
# the Lock Widget. You'll want to do this in your favorite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
# Retrieve the value of a deeply nested attribute | |
# | |
# Example usage | |
# | |
# attribute = "data.foo['bar'].id" | |
# value = obj.send_nested(attribute) | |
# | |
# Under the hood this will do something akin to | |
# obj.send(data).send(foo)['bar'].send(id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Converting HL7 messages to dictionaries | |
Example Usage: | |
import pprint | |
from hl7apy.parser import parse_message | |
# Taken from http://hl7apy.org/tutorial/index.html#elements-manipulation | |
s = """MSH|^~\&|GHH_ADT||||20080115153000||ADT^A01^ADT_A01|0123456789|P|2.5||||AL | |
EVN||20080115153000||AAA|AAA|20080114003000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import contextmanager | |
from urlparse import urlparse | |
from paramiko import AuthenticationException | |
import pysftp | |
@contextmanager | |
def open_sftp(url, mode='r', n_retries=5, retry_sleep_time=5): | |
"""Context manager to read/write a file via SFTP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from marshmallow import ( | |
fields, | |
Schema) | |
def marshmallow_schema_to_dict(schema): | |
"""Convert a :class:`marshmallow.Schema` to a dict definition | |
:param schema: The :class:`marshmallow.Schema` to convert | |
:returns: A dict containing the details of the schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
"""Script to check users in healthcare exclusion lists | |
This checks the following sources: | |
* SAM exclusion list | |
* OIG Exclusion list | |
* OFAC list of Specially Designated Nationals and Blocked Persons (SDN) | |
* FDA Clinical Investigations Disqualification Proceedings | |
* FDA Debarment List (Drug Product Applications) | |
* TRICARE Sanctioned Providers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------------------------------------------------- | |
# Modifiable parameters | |
# ----------------------------------------------------------------------------- | |
# Where to save the results to | |
save_file = "times.txt" | |
# The branch locations you care about | |
locations = ["Boston", "Watertown", "Natick", "Roslindale"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import xlrd | |
if __name__ == '__main__': | |
if not len(sys.argv) > 1: | |
sys.exit("Usage: xl2wiki infile.xls [outfile]") | |
# Read it in and build up a string in the mediawiki format | |
book = xlrd.open_workbook(sys.argv[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
# Import your Flask app from your module | |
from myapp import app | |
# A fitcitious database object that has get/put methods for getting/adding | |
# data. In your code you will want to use whatever database you are using | |
# (E.g. SQLAlchemy, MongoDB, CouchDB, etc.) | |
from database import database |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""An example of how to perform a multi-threaded unit test of a web service. | |
The particulars of this example make use of some conventions used when | |
developing a web service when using the Flask microframework, but can be | |
modified to fit most needs. | |
""" | |
import json | |
import threading | |
import time |
NewerOlder