Skip to content

Instantly share code, notes, and snippets.

@bertomartin
bertomartin / 0-README.md
Created Aug 20, 2017 — forked from alexcasalboni/0-README.md
AWS Lambda: Advanced Coding Session - clda.co/aws-lambda-webinar
View 0-README.md

AWS Lambda: Advanced Coding Session (slides)

Live demos:

  1. Amazon API Gateway Access Control
  2. Amazon Kinesis Streams processing
  3. Amazon Cognito Sync trigger
  4. AWS CloudFormation Custom Resources
@bertomartin
bertomartin / boto3_getpolicy.py
Created Aug 20, 2017 — forked from alexcasalboni/boto3_getpolicy.py
AWS IAM Policy body with Python and boto3
View boto3_getpolicy.py
import boto3
iam = boto3.resource('iam')
def get_policy_body(arn, version_id=None):
""" Return IAM Policy JSON body """
if version_id:
version = iam.PolicyVersion(arn, version_id)
else:
policy = iam.Policy(arn)
@bertomartin
bertomartin / amazon-rekognition.md
Created Aug 20, 2017 — forked from alexcasalboni/amazon-rekognition.md
Amazon Rekognition - Python Code Samples
View amazon-rekognition.md

Amazon Rekognition - Python Code Samples

  1. Labels Detection
  2. Faces Detection
  3. Faces Comparison
  4. Faces Indexing
  5. Faces Search
@bertomartin
bertomartin / aws-lambda-demo1-restful-api.py
Created Aug 17, 2017 — forked from alexcasalboni/aws-lambda-demo1-restful-api.py
AWS Lambda Coding Session - clda.co/webinar-lambda
View aws-lambda-demo1-restful-api.py
def lambda_handler(event, context):
name = event.get('name') or 'World'
print("Name: %s" % name)
return "Hello %s!" % name
@bertomartin
bertomartin / deploy.sh
Created Aug 17, 2017 — forked from alexcasalboni/deploy.sh
Simple AWS Lambda deployment script - Zip & upload Deployment Package with initial dependencies to S3
View deploy.sh
#!/bin/bash
BUCKET="YOUR_BUCKET_NAME" # bucket name
FILENAME="deployment-package.zip" # upload key
TMP_FOLDER="/tmp/lambda-env-tmp/" # will be cleaned
OUTPUT_FOLDER="/tmp/lambda-env/" # will be cleaned
HERE=${BASH_SOURCE%/*} # relative path to this file's folder
LAMBDA_FOLDER="$HERE/lambda/" # relative path
View deep-wine-blog-GridSearched.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bertomartin
bertomartin / from_sklearn.py
Created Nov 21, 2016 — forked from napjon/from_sklearn.py
Method to convert docs using sklearn to pyLDAVis
View from_sklearn.py
def from_sklearn(docs,vect,lda,**kwargs):
"""Create Prepared Data from sklearn's vectorizer and Latent Dirichlet
Application
Parameters
----------
docs : Pandas Series.
Documents to be passed as an input.
vect : Scikit-Learn Vectorizer (CountVectorizer,TfIdfVectorizer).
View useful_pandas_snippets.py
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
View Taxes Paid and Personal Income.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View tf-idf.py
import os
import math
import re
import pandas as pd
from collections import Counter
from sklearn.datasets import fetch_20newsgroups
#get a subset of the dataset
categories = [