Skip to content

Instantly share code, notes, and snippets.

View infoankitp's full-sized avatar

Ankit Prakash Gupta infoankitp

View GitHub Profile
import json
def lambda_handler(event, context):
print( "Event : " , event)
#This will print the event passed to lambda_handler in
#Cloudwatch Logs
print( "Context : " , context)
#This will print the context passed to lambda_handler in
#Cloudwatch #Logs
name = ""
if 'queryStringParameters' in event:
@infoankitp
infoankitp / image_downloader_lambda.py
Last active January 6, 2019 08:17
A lambda function which will download images using the given link in a zipped format.
import time
import boto3
import urllib
import datetime
import os
import json
import requests
import traceback
from PIL import Image
from io import BytesIO
Page UserId SessionId
index.html 1 A
1.html 1 B
index.html 2 C
Count(Distinct userId) Count(Distinct SessionId)
2 3
git clone https://github.com/citusdata/postgresql-hll.git
cd postgresql-hll
sed -i -e 's,lstdc++,L/usr/lib,g' Makefile # This is done to include LD libraries, Also please make sure gcc is downloaded on your system.
PG_CONFIG=/Library/PostgreSQL/9.6/bin/pg_config make
sudo make install
CREATE EXTENSION hll;
CREATE TABLE test_table (page TEXT, user_id TEXT, session_id TEXT);
INSERT INTO test_table VALUES ('A', '1', 'A'), ('B', '1', 'B') ,('A', '2', 'C');
/* Since we have already added the hll Extension,
* We can now try running the following query to get the unique_user_count and unique_session_count */
SELECT hll_cardinality(hll_add_agg(hll_hash_text(user_id))) as unique_user_count, hll_cardinality(hll_add_agg(hll_hash_text(session_id))) as unique_session_count FROM test_table;
CREATE TABLE hll_test (page TEXT, user_id_hll bytea, session_id_hll bytea);
final static int SEED = 123456;
final static int LOG2M = 15; // Number of Buckets = 2^LOG2M
final static int REGWIDTH = 5;
final static int EXPTHRESH = -1;
final static boolean SPARSEON = true;
/**
* Generates a HLL Object with numbers from 0 to n the parameter passed
* @param n : Number of Elements in the HLL.
import com.google.common.hash.HashFunction
import com.google.common.hash.Hashing
val SEED = 123456;
val LOG2M = 15
val REGWIDTH = 5
val EXPTHRESH = -1
val SPARSEON = true
// A User Defined Function which is used to initiate HLL for a String
@infoankitp
infoankitp / Deep Reinforcement Learning - Certificate.pdf
Last active September 27, 2022 19:06
Reinforcement Learning Certifications - Ankit Prakash Gupta
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.