Skip to content

Instantly share code, notes, and snippets.

View aviraldg's full-sized avatar

Aviral Dasgupta aviraldg

View GitHub Profile
@aviraldg
aviraldg / Problem2.py
Created May 8, 2011 02:48
Solution for problem #2 in Google Code Jam 2011.
def generate(inp):
inp.reverse()
C = int(inp.pop())
C_D = dict()
for i in xrange(C):
_t = inp.pop()
C_D[_t[:2]] = _t[2]
C_D[_t[:2][::-1]] = _t[2]
@aviraldg
aviraldg / BinarySearch.java
Created March 25, 2012 14:19
Naive binary search implementation for Strings in Java.
import java.io.*;
public class BinarySearch {
private static void sort(String [] words) {
int length = words.length;
for(int i=0; i<length; i++) {
for(int j=i; j<length; j++) {
if(words[i].compareTo(words[j]) > 0) {
String temp = words[i];
words[i] = words[j];
@aviraldg
aviraldg / site.py
Created March 28, 2012 12:48
bash style clear for python
# add this to the end of your site.py
# (side effects? who cares?)
class clear:
def __repr__(self):
return '\n'*24
builtins.clear = clear()
aviraldg@aviraldg-netbook:~$ ssh -i path.to.key.pem ubuntu@ec2-???-???-???-???.ap-southeast-1.compute.amazonaws.com
Welcome to Ubuntu 11.10 (GNU/Linux 3.0.0-16-virtual x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Mon Apr 9 17:29:41 UTC 2012
System load: 0.0 Processes: 66
Usage of /: 12.9% of 7.87GB Users logged in: 0
Memory usage: 8% IP address for eth0: ???.???.???.???
@aviraldg
aviraldg / ICSE.py
Created June 6, 2012 19:08
A script that scrapes the results of the current ICSE exams for a particular school/exam centre.
#!/usr/bin/env python
import sqlite3
import requests
import bs4
import datetime
SOURCE_URI = 'http://server2.examresults.net/icseX12-res.aspx'
def main(args):
"3 hundred spartans" == 3 # true
@aviraldg
aviraldg / wikipdf.py
Created August 5, 2012 08:12
Wikipdf
import requests
import bs4
import io
ADD_URI = 'http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=add_article&arttitle={0}&oldid=0'
BOOK_URI = 'http://en.wikipedia.org/wiki/Special:Book'
def wikify(topic):
return '+'.join(topic.split(' '))

The Really Boring Phone

NOTE: This post is here because of two reasons: my blog is currently in a state of "flux" (I'm in the process of developing a custom theme and moving to a different blogging engine) and the fact that I usually don't participate in platform wars.

This is a reply to: http://virtuosovidit.blogspot.in/2013/01/the-curiously-boring-phone.html


“So, iPhone is boring. Its got this same UI for the last three years, and the same Apps launcher ever since its launch in 2007. Its boring. Its boring. Its Boring. What’s interesting is widgets, adventures with Viruses! clunky heavy themes. Quad Core processors, GBs of RAM, We want More Cores, We want More RAM! Even if we don’t know what it does! Bigger is better. More is Better. Larger is prettier. That’s just 4”, People have ‘upgraded’ to 6.3” phones. That Lumia is more colorful! iPhone’s only black or White, more color is always cooler, its interesting! Why, Apple won’t do that. They did, they’re just looking afte

import java.io.*;
import java.util.*;
/** Decomposes a number into sums */
public class Decompose {
public static final int MAX_NO = 20;
/**
* n - The number to sum up to.
* m - The number to start with (to sum up)
@aviraldg
aviraldg / rescopy.py
Created March 3, 2015 08:02
Copy Android drawable resources.
#!/usr/bin/env python
import shutil, sys, os
def main():
srcname = sys.argv[1]
destname = os.path.abspath(sys.argv[2])
base = os.path.dirname(srcname)
srcname = os.path.basename(srcname)
def copy(arg, fname, fnames):
if os.path.basename(fname).startswith('drawable'):