Skip to content

Instantly share code, notes, and snippets.

View varunvora's full-sized avatar

Varun Vora varunvora

View GitHub Profile
@varunvora
varunvora / analyse.py
Created August 29, 2018 18:14
WhatsApp Group Chat Analysis
"""
Copy the conversation and provide it to stdin.
This program will calculate the number of messages and total length of all messages
By each person in the conversation
"""
from sys import stdin
import re
raw_conversation = stdin.readlines()
message_timestamp = re.compile(r'\[.*8\]') # example: [17:06, 8/7/2018]
@varunvora
varunvora / hash_py2.py
Last active August 4, 2018 09:51
Python 2's hash() function in Python 3
"""
Implementation of hash() differs in Python 2 and Python 3
To use Python 2's hash() in Python 3, use the following snippet.
Note that this snippet computes the expected hash only of input of type str
Source: https://www.laurentluce.com/posts/python-dictionary-implementation/
"""
import numpy as np
def str_hash(string):
x = np.array([ord(string[0]) << 7], dtype=int)