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
FROM python:3.9-slim | |
# install the notebook package | |
RUN pip install --no-cache --upgrade pip && \ | |
pip install --no-cache notebook jupyterlab | |
# create user with a home directory | |
ARG NB_USER | |
ARG NB_UID | |
ENV USER ${NB_USER} | |
ENV HOME /home/${NB_USER} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
import base64 | |
def lambda_handler(event, context): | |
assert 'headers' in event, 'missing headers' | |
assert 'authorization' in event['headers'], 'missing authorization header' | |
authorization_header: str = event['headers']['authorization'] | |
authorization_tokens = authorization_header.split() | |
assert len(authorization_tokens) == 2, 'malformed authorization bearer token' | |
bearer_token = authorization_tokens[1] | |
api_key = base64.b64decode(bearer_token).decode("utf-8")[:-1] # Remove the last character added from padding |
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
import base64 | |
import json | |
import pandas | |
def lambda_handler(event, context): | |
try: | |
records = event['Records'] | |
record_batch = [] | |
for record in records: | |
kinesis_record = record['kinesis'] |
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
import boto3 | |
import json | |
def lambda_handler(event, context): | |
... | |
str_event = json.dumps(event) | |
partition_key = event['userId'] | |
stream_name = 'Segment' | |
try: | |
client = boto3.client('kinesis') |
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
{ | |
"body": "<json string>", | |
"headers": { | |
"Accept": "*/*", | |
"Accept-Encoding": "gzip, deflate", | |
"Authorization": "<REDACTED>", | |
"Content-Type": "application/json", | |
"User-Agent": "Segment.io/1.0", | |
"X-Segment-Settings": "<REDACTED>" | |
}, |
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
version: v1 | |
breaking: | |
use: | |
- FILE | |
lint: | |
use: | |
- DEFAULT |
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
syntax = "proto3"; | |
message Taco { | |
string name = 1; | |
string description = 2; | |
int32 quantity = 3; | |
} |
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
import threading | |
from instaloader import Instaloader, Profile | |
import engagement | |
import pickle | |
loader = Instaloader() | |
NUM_POSTS = 10 | |
def get_hashtags_posts(query): | |
posts = loader.get_hashtag_posts(query) |
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
loader = Instaloader() | |
NUM_POSTS = 10 | |
def get_hashtags_posts(query): | |
posts = loader.get_hashtag_posts(query) | |
users = {} | |
count = 0 | |
for post in posts: | |
profile = post.owner_profile | |
if profile.username not in users: |
NewerOlder