Skip to content

Instantly share code, notes, and snippets.

Aditya Laghate thinrhino

View GitHub Profile
View amirocalypse.py
from __future__ import division
from bs4 import BeautifulSoup as bs
import requests
import re
import time
from pymongo import MongoClient
from time import mktime
from datetime import datetime
import plotly.plotly as py
import plotly.graph_objs as go
View proxy.pac
function FindProxyForURL(url, host)
{
if (dnsDomainIs(host, ".pandora.com"))
return "PROXY 199.189.84.217:3128"
if (dnsDomainIs(host, ".spotify.com"))
return "PROXY 54.246.92.203:80"
return "DIRECT"
}
View keybase.md

Keybase proof

I hereby claim:

  • I am thinrhino on github.
  • I am thinrhino (https://keybase.io/thinrhino) on keybase.
  • I have a public key whose fingerprint is 76EB 936C 5D76 6E82 E9A9 68FF 96C8 359B CC53 9C5F

To claim this, I am signing this object:

@thinrhino
thinrhino / DeleteTweets.py
Last active Aug 29, 2015
A small script to delete all tweets from your twitter stream
View DeleteTweets.py
# First download the twitter archive
# Get API_KEY and API_SECRET from developer.twitter.com
import os
import json
import glob
import base64
import requests
from requests_oauthlib import OAuth1Session
@thinrhino
thinrhino / emacs
Last active Aug 29, 2015
Enable mouse in emacs
View emacs
;; Enable mouse support
(unless window-system
(require 'mouse)
(xterm-mouse-mode t)
(global-set-key [mouse-4] '(lambda ()
(interactive)
(scroll-down 1)))
(global-set-key [mouse-5] '(lambda ()
(interactive)
(scroll-up 1)))
View gae_shell.py
#!/usr/bin/env python -i
"""
A local interactive IPython shell for Google App Engine on Mac OSX.
Usage:
cd /to/project/folder/with/app.yaml
python gae_shell.py
Notes:
View main.js
$(document).ready(function() {
$(chart_id).highcharts({
chart: chart,
title: title,
xAxis: xAxis,
yAxis: yAxis,
series: series
});
});
View vagrant-scp
#!/bin/sh
# Change these settings to match what you are wanting to do
FILE=/File/To/Copy
SERVER=localhost
PATH=/Where/To/Put/File
OPTIONS=`vagrant ssh-config | awk -v ORS=' ' '{print "-o " $1 "=" $2}'`
scp ${OPTIONS} $FILE vagrant@$SERVER:$PATH
@thinrhino
thinrhino / tf-idf.py
Created May 5, 2014
Calculate tf-idf
View tf-idf.py
# ref: http://www.tfidf.com/
# Example:
# Consider a document containing 100 words wherein the word cat appears 3 times.
# The term frequency (i.e., tf) for cat is then (3 / 100) = 0.03. Now, assume we
# have 10 million documents and the word cat appears in one thousand of these.
# Then, the inverse document frequency (i.e., idf) is calculated as log(10,000,000 / 1,000) = 4.
# Thus, the Tf-idf weight is the product of these quantities: 0.03 * 4 = 0.12.
#
# Hence:
# 1. Calculate term frequency
@thinrhino
thinrhino / zipfs.py
Created May 5, 2014
Plot zipf's law
View zipfs.py
from collections import defaultdict
import matplotlib.pyplot as plt
data = open('<data_file>', 'r')
r_data = []
# reading relevant data
while True:
l = data.readline()
if l == '':
You can’t perform that action at this time.