Skip to content

Instantly share code, notes, and snippets.

import base64
import json
import boto3
snsClient = boto3.client('sns')
print('Loading function')
def lambda_handler(event, context):
for record in event['Records']:
# Kinesis data is base64 encoded so decode here
-- ** Anomaly detection **
-- Compute an anomaly score for each record in the source stream using Random Cut Forest
-- Creates a temporary stream and defines a schema
CREATE OR REPLACE STREAM "TEMP_STREAM" (
"heartRate" INTEGER,
"rateType" varchar(20),
"ANOMALY_SCORE" DOUBLE);
-- Creates an output stream and defines a schema
CREATE OR REPLACE STREAM "DESTINATION_SQL_STREAM" (
"heartRate" INTEGER,
import json
from boto import kinesis
import random
import time
import boto3
cloudwatch = boto3.client('cloudwatch')
kinesis = kinesis.connect_to_region("us-east-1")
{
"Id": "Policy1470255331931",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1470255330209",
"Action": [
"s3:DeleteObject"
],
"Effect": "Deny",
#!/usr/bin/env python
from boto.s3.connection import S3Connection
from boto.s3.bucket import Bucket
ACCESS_KEY_ID = 'YOUR_ACCESS_ID'
SECRET_ACCESS_KEY = 'YOUR_SECRET_KEY'
# Replace this value with the directory path containing the objects you want to list.
# PATH should be in the form of: 'LocalyticsAccountName/YYYY/MM/DD'
# Please email support@localytics.com if you do not know your LocalyticsAccountName for S3 access.
@mgdombrowski
mgdombrowski / clearchannel_s3.py
Created November 4, 2014 15:36
python s3 access
from boto.s3.connection import S3Connection
from boto.s3.bucket import Bucket
ACCESS_KEY_ID = 'YOUR_AWS_KEY'
SECRET_ACCESS_KEY = 'YOUR_AWS_SECRET'
PATH = 'clearchannel/'
conn = S3Connection(ACCESS_KEY_ID, SECRET_ACCESS_KEY)
bucket = Bucket(conn, 'exports.localytics')
@mgdombrowski
mgdombrowski / durationTracking.js
Created October 28, 2014 17:49
page duration tracking
window.onload = start() {
startTime = new Date().getTime();
});
window.onbeforeunload = stop() {
var endTime = new Date().getTime();
//get duration in milliseconds
var duration = endTime - startTime;
switch (true) {
#!/usr/bin/env python
from boto.s3.connection import S3Connection
from boto.s3.bucket import Bucket
ACCESS_KEY_ID = 'YOUR_ACCESS_ID'
SECRET_ACCESS_KEY = 'YOUR_SECRET_KEY'
PATH = 'bridj/2014/10/12'
conn = S3Connection(ACCESS_KEY_ID, SECRET_ACCESS_KEY)
bucket = Bucket(conn, 'exports.localytics.0-b')
private final static String TAG_SEARCH_USED = "Search Used";
public void searchUsed()
{
private final static String PRODUCT_TYPE = "Product Type";
private final static String CATEGORY_ID = "Category ID";
private final static String ORIGINAL_CONTENT_ID = "Original Content ID";
private final static String SEARCH_TERM = "Search Term";
private final static String RESULT_RANKING_SELECTED = "Result Ranking Selected";
private final static String QID = "QID";
@mgdombrowski
mgdombrowski / XYZViewController.m
Last active August 29, 2015 14:05
track view duration and upload as a Localytics event attribute for charting
#import "XYZViewController.h"
#import "LocalyticsSession.h"
@interface XYZViewController ()
@end
@implementation XYZViewController
static NSDate *startOfOverallTime;