Skip to content

Instantly share code, notes, and snippets.

View kevinjnguyen's full-sized avatar

Kevin J Nguyen kevinjnguyen

  • Austin, TX
View GitHub Profile
@kevinjnguyen
kevinjnguyen / kbeznak.md
Created February 22, 2018 23:00
Kbeznak Parmatonic
@kevinjnguyen
kevinjnguyen / engagement.py
Last active April 25, 2021 05:22
Instagram Engagement Calculator | Subtle Clothing Collection
target_profile = PROFILE_NAME
from instaloader import Instaloader, Profile
loader = Instaloader()
profile = Profile.from_username(loader.context, target_profile)
num_followers = profile.followers
total_num_likes = 0
total_num_comments = 0
@kevinjnguyen
kevinjnguyen / engagement.py
Last active January 22, 2020 13:15
Instagram Summary Information (Engagement, Post Frequency, etc)
from instaloader import Instaloader, Profile
import datetime
MAX_DAYS = 50
LIKES_WEIGHT = 1
COMMENTS_WEIGHT = 1
NUM_FOLLOWERS_WEIGHT = 1
NUM_POSTS_WEIGHT = 1
@kevinjnguyen
kevinjnguyen / hashtag.py
Created January 22, 2020 02:33
Instaloader Get Hashtag Post Summary Example
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:
@kevinjnguyen
kevinjnguyen / hashtag.py
Created January 22, 2020 02:39
Scripting all together the get hashtag instaloader.
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)
@kevinjnguyen
kevinjnguyen / store.proto
Created May 15, 2022 02:46
Simple definition of a Taco message
syntax = "proto3";
message Taco {
string name = 1;
string description = 2;
int32 quantity = 3;
}
version: v1
breaking:
use:
- FILE
lint:
use:
- DEFAULT
@kevinjnguyen
kevinjnguyen / sample_event.json
Created July 5, 2022 16:04
Segment Event Gist
{
"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>"
},
@kevinjnguyen
kevinjnguyen / add_kinesis_stream.py
Last active July 5, 2022 17:04
Read Segment Header API Key
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')
@kevinjnguyen
kevinjnguyen / process_batches.py
Created July 5, 2022 17:09
Lambda function handler to process batches
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']