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
# Use `ls` to view package contents | |
# Ref | |
# - https://stackoverflow.com/questions/12575098/to-see-all-the-content-not-just-objects-in-a-package-in-r | |
# Example for ISLR package, assuming it is installed | |
ls(pos="package:ISLR") | |
# To view only datasets in a package (results will open in a new tab): | |
data(package="ISLR") |
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
# Create and upload a deployment package for a Python Lambda function | |
# Assumes EC2 instance is associated with an IAM role with permissions to access S3 & Lambda | |
# Ref: http://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html | |
# This script is meant to be used after virtualenv has been setup to connect to Oracle RDS | |
# see https://gist.github.com/niranjv/2a576a13afe1b323e9e9600ed7de03ef | |
# Steps: | |
# - create temp dir |
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
# This script allows Python functions in AWS Lambda to query an Oracle RDS instance | |
# It is meant to run on an EC2 instance running Amazon Linux | |
# The script has been tested successfully on a t2.micro EC2 instance (Root device type: ebs; Virtualization type: hvm) | |
# running Amazon Linux AMI 2017.03.0 (HVM), SSD Volume Type - ami-c58c1dd3 | |
# and was developed with the help of AWS Support | |
# Steps: | |
# - install Oracle Instant Client | |
# - create virtualenv |
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
# A virtualenv running Python3.6 on Amazon Linux/EC2 (approximately) simulates the Python 3.6 Docker container used by Lambda | |
# and can be used for developing/testing Python 3.6 Lambda functions | |
# This script installs Python 3.6 on an EC2 instance running Amazon Linux and creates a virtualenv running this version of Python | |
# This is required because Amazon Linux does not come with Python 3.6 pre-installed | |
# and several packages available in Amazon Linux are not available in the Lambda Python 3.6 runtime | |
# The script has been tested successfully on a t2.micro EC2 instance (Root device type: ebs; Virtualization type: hvm) | |
# running Amazon Linux AMI 2017.03.0 (HVM), SSD Volume Type - ami-c58c1dd3 | |
# and was developed with the help of AWS Support |
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
# Python logger in AWS Lambda has a preset format. To change the format of the logging statement, | |
# remove the logging handler & add a new handler with the required format | |
import logging | |
import sys | |
def setup_logging(): | |
logger = logging.getLogger() | |
for h in logger.handlers: | |
logger.removeHandler(h) |