Skip to content

Instantly share code, notes, and snippets.

View sushain97's full-sized avatar

Sushain Cherivirala sushain97

View GitHub Profile
require "Digest"
require "pp"
files = Dir.entries("#{ARGV.first}").select { |f| !File.directory? "#{ARGV.first}#{f}" }
filehashes = Hash[files.map { |f| [f, Digest::MD5.file("#{ARGV.first}#{f}").hexdigest] }]
grouped = filehashes.group_by{ |k, v| v }.keep_if{ |_, e| e.length > 1 }
PP.pp(grouped)
@sushain97
sushain97 / fb.py
Last active June 11, 2019 21:01
Downloads, archives, analyzes and plots Facebook Messenger conversations (individual and group)
#!/usr/bin/env python3
__author__ = 'Sushain K. Cherivirala'
import argparse
import cmd
import collections
import contextlib
import copy
import datetime
#!/usr/bin/env python3
import argparse, os, lxml.etree, lxml.builder, re, collections, mimetypes, bz2, logging, json
def validFile(fname):
if not os.path.isfile(fname):
raise argparse.ArgumentError('File %s does not exist!' % fname)
return fname
numeral_map = tuple(zip(
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta name="author" content="Sushain K. Cherivirala (www.skc.name)">
<title>Bridge Project Leaderboard</title>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/tabletop.js/1.3.5/tabletop.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
@sushain97
sushain97 / concepts5-7.py
Last active October 11, 2015 18:01
Given 2n points on a plane. One wants to draw n segments which join pairs of these points such that no two segments share a common vertex. In how many ways this can be done?
>>> l = range(1, 7)
>>> pairs = list(itertools.product(l, repeat=2))
>>> pairs = list(filter(lambda x: x[0] != x[1], pairs))
>>> l = list(itertools.combinations(pairs, 3))
>>> c = set(map(lambda x: frozenset(map(lambda y: frozenset(y), x)), l))
>>> len(set(filter(lambda x: len(set(list(itertools.chain(*list(map(lambda y: list(y), x)))))) is 6, c)))
15
>>> l[:5]
[((1, 2), (1, 3), (1, 4)), ((1, 2), (1, 3), (1, 5)), ((1, 2), (1, 3), (1, 6)), ((1, 2), (1, 3), (2, 1)), ((1, 2), (1, 3), (2, 3))]
>>> list(c)[:5]
import requests
import time
import pprint
import os
from PIL import Image
'https://developers.facebook.com/tools/explorer/'
access_token = ''

Keybase proof

I hereby claim:

  • I am sushain97 on github.
  • I am sushain (https://keybase.io/sushain) on keybase.
  • I have a public key ASAa5PVbF3RDg8gQxUEQk92URQeLFGyANKd3bZ0RndWAhgo

To claim this, I am signing this object:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta name="author" content="Sushain K. Cherivirala (www.skc.name)">
<title>CMU Senate: Faculty Student Lunch Professors</title>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/tabletop.js/1.3.5/tabletop.js"></script>
import sys
import os
import collections
import itertools
import pprint
filenames = list(os.listdir(sys.argv[1]))
# filenames = list(filter(lambda x: any(map(lambda y: x.startswith('%s@' % y), andrew_ids)), filenames))
grouped_filenames = collections.defaultdict(list)
for filename in filenames:
@sushain97
sushain97 / moss.sh
Last active February 14, 2017 20:59
rm -rf /tmp/handins/*; mkdir -p /tmp/handins; cd /afs/cs.cmu.edu/academic/class/15150-s17/autolab/homework3/handin; for tarfile in *.tar; do tar -xf "$tarfile" -C /tmp/handins "code/hw03.sml" 2> /dev/null; mv /tmp/handins/code/hw03.sml "/tmp/handins/$tarfile.sml"; done; rm -r /tmp/handins/code;
python3 ~/private/filter.py /tmp/handins
~/private/moss -l ml -b ~/private/15150-TA/asgn/hw/03/src/dist/hw03.sml /tmp/handins/* && rm -rf /tmp/handins/*
cd /afs/cs.cmu.edu/academic/class/15150-s17/autolab/homework3/handin; rm -rf /tmp/handins/*; mkdir -p /tmp/handins; for tarfile in *.tar; do tar -xf "$tarfile" -C /tmp/handins hw03.pdf 2> /dev/null; pdftotext -q /tmp/handins/hw03.pdf "/tmp/handins/$tarfile.txt"; rm /tmp/handins/hw03.pdf; done;
python3 ~/private/filter.py /tmp/handins
cd ~/private/15150-TA/asgn/hw/03/writeup/ && make && pdftotext bin/hw03-handout.pdf ~/private/hw03-handout.txt
~/private/moss -l ascii -b ~/private/hw03-handout.txt /tmp/handins/* && rm -rf /tmp/handins/*
rm -rf /tmp/handins/*; mkdir -p