Skip to content

Instantly share code, notes, and snippets.

Mike Lapidakis mlapida

Block or report user

Report or block mlapida

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mlapida
mlapida / ParticleWebook.json
Created Feb 26, 2016
A webhook to be used with a Particle Photon
View ParticleWebook.json
{
"event": "sendSleep",
"url": "https://[yourendpoint].execute-api.us-east-1.amazonaws.com/prod/ParticleSleepV1",
"requestType": "Post",
"headers": {
"x-api-key" : "[yourapikey]"
},
"json": {
"name": "{{SPARK_EVENT_NAME}}",
"data": "{{SPARK_EVENT_VALUE}}",
@mlapida
mlapida / SleepEndpoint-Lambda.py
Last active Jun 6, 2019
A Lambda Function for receiving data from an API Endpoint and sending it to a DynamoDB table.
View SleepEndpoint-Lambda.py
from __future__ import print_function
import logging
import boto3
from datetime import *
from boto3.dynamodb.conditions import Key, Attr
# enable basic logging to CloudWatch Logs
logger = logging.getLogger()
logger.setLevel(logging.INFO)
@mlapida
mlapida / sleepsensor.cpp
Created Feb 26, 2016
A small Particle firmware for sending movement data to a web-hook.
View sleepsensor.cpp
// Make sure to include the spcial library for the internet button
#include "InternetButton/InternetButton.h"
// Create a Button named b. It will be your friend, and you two will spend lots of time together.
InternetButton b = InternetButton();
int ledOldPos = 0;
char ledPosTrust[5];
int moveCount = 0;
int loopCount =0;
@mlapida
mlapida / EC2-Tag-Assets-Lambda.py
Last active Aug 19, 2019
A lambda function that will copy EC2 tags to all related Volumes and Network Interfaces. A full writeup can be found on my site http://mlapida.com/thoughts/tagging-and-snapshotting-with-lambda
View EC2-Tag-Assets-Lambda.py
from __future__ import print_function
import json
import boto3
import logging
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.ERROR)
@mlapida
mlapida / PlexToAlexa-Lambda.py
Last active Dec 7, 2017
This is my attempt to get Alexa to return Plex's On Deck and Recently Downloaded lists. It's not the prettiest, but Plex's API isn't the best at the moment. Step-by-step blog post may be found here: http://mlapida.com/thoughts/plex-alexa-interacting-with-your-media-server-through-voice
View PlexToAlexa-Lambda.py
from __future__ import print_function
import urllib
import urllib2
import xml.etree.ElementTree
import logging
#enable basic logging to CloudWatch Logs
logger = logging.getLogger()
logger.setLevel(logging.INFO)
@mlapida
mlapida / FlowLogs-to-S3-Lambda.py
Last active Aug 28, 2018
A Lambda Function for streaming and translating flow logs on the fly. This example was used for HP ArcSight. A full writeup can be found on my site http://mlapida.com/thoughts/exporting-cloudwatch-logs-to-s3-lambda
View FlowLogs-to-S3-Lambda.py
import boto3
import logging
import json
import gzip
import urllib
import time
from StringIO import StringIO
logger = logging.getLogger()
logger.setLevel(logging.INFO)
@mlapida
mlapida / CloudWatchLogsKinesisFirehose-Lambda.py
Last active Oct 3, 2019
A short Lambda Function the can be sent CloudWatch Logs (in the case Flow Logs) and send them to Kinesis Firehose for storage in S3. A full writeup can be found on my site http://mlapida.com/thoughts/exporting-cloudwatch-logs-to-s3-lambda
View CloudWatchLogsKinesisFirehose-Lambda.py
import boto3
import logging
import json
import gzip
from StringIO import StringIO
logger = logging.getLogger()
logger.setLevel(logging.INFO)
client = boto3.client('firehose')
@mlapida
mlapida / EBS-Orphaned-Report-Lambda.py
Last active Mar 31, 2018
Generate a report of orphaned EBS volumes and send an SNS. A full writeup can be found on my site http://mlapida.com/thoughts/lambda-tracking-orphaned-ebs-volumes
View EBS-Orphaned-Report-Lambda.py
import boto3
import logging
from datetime import *
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.WARNING)
#define the connection
ec2 = boto3.resource('ec2', region_name="us-west-2")
@mlapida
mlapida / EC2-Stopped-Tagged-Lambda.py
Last active Sep 23, 2019
Using a lambda function, stop all instances that are tagged appropriately.
View EC2-Stopped-Tagged-Lambda.py
import boto3
import logging
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.INFO)
#define the connection
ec2 = boto3.resource('ec2')
@mlapida
mlapida / EC2-Snapshot-Lambda.py
Last active Dec 20, 2017
A lambda function for taking a snapshot of all EC2 instances in a region and cleaning the snapshots up after a set number of days. This ones now works best in conjunction with Asset Tagging https://gist.github.com/mlapida/931c03cce1e9e43f147b A full write up can be found on my site http://mlapida.com/thoughts/tagging-and-snapshotting-with-lambda
View EC2-Snapshot-Lambda.py
import boto3
import logging
import datetime
import re
import time
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.ERROR)
You can’t perform that action at this time.