Skip to content

Instantly share code, notes, and snippets.

View sushain97's full-sized avatar

Sushain Cherivirala sushain97

View GitHub Profile
import requests
import time
import pprint
import os
from PIL import Image
'https://developers.facebook.com/tools/explorer/'
access_token = ''
@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]
<!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>
#!/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(
@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
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)
$ ./localisation-tools.py cleanup `find . -regextype sed -regex ".*/[a-z]\{3\}\.json" -printf "%f "` && grep "completion" *.json | sort -nrk1.33,1.35 -nrk1.38,1.43 | awk -F '"' 'BEGIN {print "{| class=\"wikitable\"\n|-\n!|code\n!|CBE*\n!|CBC**" } {sub(/\..*$/, "", $1); split($4, s, " "); print "|-\n|| " $1 " || " s[1] " || " s[2]} END { print "|}\n\n&nbsp;*CBE: completion by entries <br>\n&nbsp;**CBC: completion by characters"}'
irb(main):040:0> xml = `svn log --xml https://svn.code.sf.net/p/apertium/svn/#{ARGV[0]}/apertium-#{ARGV[1]}`; nil
=> nil
irb(main):041:0> require 'nokogiri'
=> true
irb(main):042:0> doc = Nokogiri::XML(xml); nil
=> nil
irb(main):043:0> authors = Hash.new(0)
=> {}
irb(main):044:0> doc.xpath("//author").each { |author| authors[author.text] += 1 }
=> 0
while true; do inotifywait . -r -e MODIFY && make debug -j32; done;
while true; do fswatch -o -r . | make debug -j32; done;
function addVisitToCalendar(event) {
var calendarName = 'sushain@skc.name', //The default calendar name = email address (?)
eventLocation = 'College Center',
collegeName = 'College Name',
startTime = 'Start Time',
endTime = 'End Time',
description = 'Notes';
var values = event.namedValues;
var event = CalendarApp.getCalendarsByName(calendarName)[0].createEvent(values[collegeName],