Skip to content

Instantly share code, notes, and snippets.

View sripathikrishnan's full-sized avatar

Sripathi Krishnan sripathikrishnan

  • Bangalore, India
View GitHub Profile
@sripathikrishnan
sripathikrishnan / rough_solutions.txt
Last active February 28, 2018 01:54
Solutions to RedisOverflow assignment
Build Page: https://datascience.stackexchange.com/questions/694/best-python-library-for-neural-networks
1. Get Question Details
hgetall questions:694
2. Get tags for this question
smembers questions:694:tags
3. Get all comments for this question:
lrange posts:694:comments 0 -1
@sripathikrishnan
sripathikrishnan / askubuntu_assignment.sql
Last active March 1, 2018 03:42
Answers to AskUbuntu Data Warehouse Assignment
--Top 10 users by reputation
select id, DisplayName, Reputation
from Users order by Reputation desc limit 10;
--Top 10 questions asked by user Mitch
select p.Title, p.Score, u.DisplayName
from Posts p inner join Users u on p.OwnerUserId = u.Id
and p.PostTypeId = 1
where u.DisplayName = 'Mitch'
order by p.Score desc;
@sripathikrishnan
sripathikrishnan / requirements.txt
Last active June 23, 2024 02:32
Import StackExchange / StackOverflow XML files into Postgres
psycopg2-binary==2.7.4
python-dateutil==2.6.1
@sripathikrishnan
sripathikrishnan / redisoverflow.py
Created February 21, 2018 03:49
A simple python script to experiment with redis
from __future__ import print_function
from redis import StrictRedis, ConnectionError
import pprint
pp = pprint.PrettyPrinter(indent=4)
def get_connection():
# This is the object we will use to connect to redis server
# You can pass host, port and password to StrictRedis...
# ... but for this assigment, we will stick to defaults
@sripathikrishnan
sripathikrishnan / h1b_to_redis.py
Created January 22, 2018 08:11
Import US H1B applications into Redis
# -*- coding: utf-8 -*-
"""
Imports h1b data from a CSV file into redis
h1b_kaggle.csv contains ~3 million h1b applications. This script
will create ~4 million keys in redis.
Motivation:
-----------
This script is a part of redis-rdb-tools,
@sripathikrishnan
sripathikrishnan / stackexchange_to_redis.py
Last active January 12, 2022 03:37
Importing StackExchange Archives into Redis
# -*- coding: utf-8 -*-
"""
Imports stackexchange xml files into redis
Motivation:
-----------
This script is a part of redis-rdb-tools,
and helps us generate realistic dump files to help in testing
Schema Documentation:
@sripathikrishnan
sripathikrishnan / Utility Functions
Last active August 29, 2015 14:17
Possible Interface for Structured Logging in Java
public static final Map<String, String> _(String ...args) {
Map<String, String> map = new HashMap<String, String>();
if ((args.length %2) != 0) {
throw new IllegalArgumentException("Mismatched keys and values");
}
for(int i=0; i<args.length-1; i+=2) {
map.put(args[i], args[i+1]);
}
return map;
}
@sripathikrishnan
sripathikrishnan / smsclient.py
Last active August 29, 2015 13:58
Twilio Stateless SMS Client
class TwilioSmsClient:
def __init__(self, account_key, auth_key, sender, twilio_url):
self.account_key = account_key
self.auth_key = auth_key
self.sender = sender
self.uri = twilio_url
def send_sms(self, phone_number, message):
payload = {
'From': self.sender,
@sripathikrishnan
sripathikrishnan / smsclient.py
Created April 4, 2014 02:52
Airtel Stateful SMS Client
class AirtelStatefulSMSGateway:
def __init__(self, authentication_url, message_url, username, password):
self.authentication_url = authentication_url
self.message_url = message_url
self.username = username
self.password = password
self.session_id = None
def send_sms(self, phone_number, message):
@sripathikrishnan
sripathikrishnan / smsclient.py
Created April 4, 2014 02:50
Airtel Stateless SMS Client
class AirtelStatelessSMSGateway:
def __init__(self, url, username, password):
self.url = url
self.username = username
self.password = password
def send_sms(self, phone_number, message):
payload = {'mob_no': phone_number, 'text': message,
'login': self.username, 'pass': self.password}