Skip to content

Instantly share code, notes, and snippets.

@ashaegupta
ashaegupta / process_reviews.py
Created April 3, 2012 00:16
process_reviews.py
# Top level attributes
PLACE_ID_A = 'place_id'
FS_ID_A = 'fs_id'
YELP_ID_A = 'yelp_id'
PHONE_A = 'phone'
NAME_A = 'name'
LOCATION_A = 'loc' # dict, see sub attributes below
REVIEW_A = 'review' # single incoming review; a dict, see sub attributes below
ALL_REVIEWS_A = 'all_reviews' # list of raw reviews
RECOS_A = 'recos' # dict of processed reviews
def fs_parse_response(response, yelp_results):
results = {}
results["body"] = []
results["has_ordered_results"] = True
try:
r = response["response"]
groups = r["groups"]
groups = groups[0]
items = groups["items"]
for item in items:
def fs_parse_response(response, yelp_results):
results = {}
results["body"] = []
results["has_ordered_results"] = True
try:
r = response["response"]
groups = r["groups"]
groups = groups[0]
items = groups["items"]
for item in items:
@ashaegupta
ashaegupta / gist:1363015
Created November 14, 2011 01:16
unshredded Revised
from PIL import Image
PIXEL_DIFF_CONSTANT = 2
IMAGE_HEIGHT = 359
IMAGE_WIDTH = 640
SHRED_WIDTH = 32
PIXEL_IN_COL_TO_SAMPLE = [2,29,40,210,123,122,111,123,190,304] # Automate
NUMBER_OF_COLUMNS = IMAGE_WIDTH/SHRED_WIDTH
FILE = "TokyoPanoramaShredded.png"
@ashaegupta
ashaegupta / gist:1361433
Created November 13, 2011 01:19
Instadeshred
# instachallenge
# http://instagram-engineering.tumblr.com/post/12651721845/instagram-engineering-challenge-the-unshredder
from PIL import image
PIXEL_DIFF_CONSTANT = 2
IMAGE_HEIGHT = 369
IMAGE_WIDTH = 640
SHRED_WIDTH = 32
PIXEL_IN_COL_TO_SAMPLE= [2,29,40,210,123,122,111,123,190,304,504] # Automate
@ashaegupta
ashaegupta / get_matches_for_status_matched
Created October 19, 2011 02:08
Way to improve this
@classmethod
def get_matches_for_status_matched(klass, ride_doc):
ride=[]
# first ensure status is matched
if ride_doc.get(Ride.A_STATUS)==2:
# get the match ride and user info
match_ride_id = ride_doc.get(Ride.A_MATCH_ID)
@ashaegupta
ashaegupta / terminals_webscraper.py
Created September 28, 2011 17:49
Scrapes web for airline arrival terminals
import urllib2
from BeautifulSoup import BeautifulSoup
class Terminals():
def __init__(self):
self.terminals = {}
self.airports = ["jfk", "ewr", "lga"]
self.getAllTerminals()
def getAllTerminals(self):