Skip to content

Instantly share code, notes, and snippets.

View prongs's full-sized avatar

Rajat Khandelwal prongs

View GitHub Profile
@prongs
prongs / gotDownload.py
Created May 11, 2014 21:32
gotDownloader.py
from bs4 import BeautifulSoup as bs
from StringIO import StringIO
import gzip
import urllib2
import os
s = bs(gzip.GzipFile(fileobj=StringIO(urllib2.urlopen("http://kickass.to/search/game%20of%20thrones/?from=opensearch").read())).read())
magnet = s.find_all('table')[1].find_all('tr')[1].find_all('a')[3]['href']
os.system('start "" "%s"' % magnet)
@prongs
prongs / gotDownloader
Created May 11, 2014 21:30
gotdownloader
from bs4 import BeautifulSoup as bs
from StringIO import StringIO
import gzip
import urllib2
import os
s = bs(gzip.GzipFile(fileobj=StringIO(urllib2.urlopen("http://kickass.to/search/game%20of%20thrones/?from=opensearch").read())).read())
magnet = s.find_all('table')[1].find_all('tr')[1].find_all('a')[3]['href']
print magnet
@prongs
prongs / cpp.TODO
Created July 6, 2013 13:12
cpp.TODO
✔ C++ templates @done (13-06-16 13:03)
✔ C++ typecasting @done (13-06-16 15:53)
✔ C function pointers @done (13-06-16 23:27)
✔ int * x and int (*x) or whatever that was @done (13-06-16 23:44)
☐ practice writing the "big three"
☐ implement class tuple
☐ ADA
☐ basic DS
☐ one height balanced tree
@prongs
prongs / cpp_test.cpp
Created June 18, 2013 08:33
cpp test
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <sstream>
@prongs
prongs / factorize.py
Last active December 18, 2015 01:39
Efficient code for factorization in python. Using Sieve of Eratosthenes
from math import sqrt
from itertools import count
from collections import defaultdict
# Sieve of Eratosthenes
# Modified from the Code by David Eppstein, UC Irvine, 28 Feb 2002
# http://code.activestate.com/recipes/117119/
def prime_candidates(begin=5, end=None):
"""Returns all prime candidates between begin and end(>=begin and <end). If end is None, it behaves like end = infinity. A prime candidate is either 2, 3 or a number of the form 6k-1 or 6k+1.
@prongs
prongs / main2.py
Created April 6, 2013 11:32
twitter challange again
import collections
users = []
def train(filename="trainingdata.txt"):
global users
tweeters = {}
first = True
f = open(filename)
@prongs
prongs / main.py
Created April 6, 2013 11:15
twitter challange
import re
from collections import *
from itertools import *
class Prob:
users = []
def __init__(self, probs=None):
if probs is None:
@prongs
prongs / Package Control.sublime-settings
Created February 23, 2013 12:36
Package Control.sublime-settings
{
"auto_upgrade_last_run": null,
"installed_packages":
[
"Alignment",
"All Autocomplete",
"Calculate",
"Case Conversion",
"Clipboard Manager",
"Codechef",
@prongs
prongs / addtopath.bat
Created January 18, 2013 15:58
batch file for adding a directory to system path
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
01-14 19:31:16.699: E/HostsActivity(6922): Usage: mount [-r] [-w] [-o options] [-t type] device directory