Skip to content

Instantly share code, notes, and snippets.

@fernando-mc
fernando-mc / csv_validator.py
Created February 6, 2017 05:00
Simple CSV Checker
# Validates Uploaded CSVs to S3
import boto3
import csv
import pg8000
EXPECTED_HEADERS = ['header_one', 'header_two', 'header_three']
def get_csv_from_s3(bucket_name, key_name):
"""Download CSV from s3 to local temp storage"""
# Use boto3 to connect to S3 and download the file to Lambda tmp storage
#!/usr/bin/env python
# Python Script to swap AWS Profile configs
# Assumes that credentials file is at ~/.aws/credentials
import argparse
import ConfigParser
import os
Config = ConfigParser.ConfigParser()
# ./bin/pyspark
# Assumes headers are not present in files that are processed
# This is meant to run locally. To easily verify it works you can:
# 1. `pip install pyspark`
# 2. startup pyspark: ./bin/pyspark
# 3. copy data similar to the data provided above in the document
# 4. Copy and paste the code into the repl
def cleaner(s):
return str(s).replace('"','').strip(' ')
import csv
import json
# Define the header names so we can specify them when reading the CSV
fieldnames = (
"STATION","NAME","DATE","AWND","PRCP","SNOW","SNWD",
"TAVG","TMAX","TMIN","WT01","WT02","WT03","WT05","WT08"
)
# Open both files so we can interact with them
@fernando-mc
fernando-mc / README.md
Created October 15, 2018 07:04
Vue.js Game

Open index.html, click the input field and eat the food with the arrow keys.

@fernando-mc
fernando-mc / create.js
Last active July 7, 2021 22:13
SAM Application
'use strict';
const AWS = require('aws-sdk');
module.exports.create = (event, context, callback) => {
const timestamp = new Date().getTime();
const data = JSON.parse(event.body);
var params = {
TableName: "customerTable",
Item: {
@fernando-mc
fernando-mc / create.js
Last active July 7, 2021 22:12
serverless-framework-app
'use strict';
const AWS = require('aws-sdk');
module.exports.create = (event, context, callback) => {
const timestamp = new Date().getTime();
const data = JSON.parse(event.body);
var params = {
TableName: process.env.TABLE_NAME,
Item: {
@fernando-mc
fernando-mc / dynamodb_backup.py
Created August 19, 2019 19:06
DynamoDB Backup and Migration
import time
import boto3
dynamodb = boto3.client('dynamodb')
source_table_name = "customerTable" # Or whatever your source table name is
dest_table_name = "customerTable-dev" # This should be an empty table - the script will delete it first
backup_name = source_table_name + "backupMigration" # Or any other backup name
# Create the backup
@fernando-mc
fernando-mc / contact_info_updater.py
Created December 9, 2019 21:58
AWS Route 53 Contact Info Updater
import boto3
from pprint import pprint
from bullet import Bullet, Input, styles, VerticalPrompt, Check, YesNo
# List Route 53 domains
r53domains = boto3.client('route53domains')
response = r53domains.list_domains()
domain_list = []
for domain in response["Domains"]:
@fernando-mc
fernando-mc / data.json
Created January 20, 2020 03:44
Data File for DynamoDB
[
{
"artist": "Romero Allen",
"song": "Atomic Dim",
"id": "b4b0da3f-36e3-4569-b196-3ad982f72bbd",
"priceUsdCents": 392,
"publisher": "QUAREX"
},
{
"artist": "Hilda Barnes",