This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas | |
df = pandas.read_csv('offers.csv.gz', compression='gzip') | |
categories = df.category.tolist() | |
subset = open('subset.csv', 'w') | |
fl = open('transactions.csv', 'r') | |
fl.readline() | |
while True: | |
l = fl.readline() | |
if l == '': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Code to download and upload raw data from mix-panel | |
""" | |
import hashlib | |
import datetime | |
import time | |
import tempfile | |
import os | |
import bz2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to populate data into MongoDB | |
import twitter | |
import time | |
import logging | |
from pymongo import MongoClient | |
CONSUMER_KEY = '<twitter_consumer_key>' | |
CONSUMER_SECRET = '<twitter_secret_key>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mandrill import Mandrill | |
import base64 | |
mail_client = Mandrill('<api_key>') | |
frm_email = '[email protected]' | |
frm_name = 'Given Name' | |
# Sending image as attachment | |
img_attachment = base64.b64encode(open('~/sample_image.jpg', 'rb').read()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 == '': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$(chart_id).highcharts({ | |
chart: chart, | |
title: title, | |
xAxis: xAxis, | |
yAxis: yAxis, | |
series: series | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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))) |
OlderNewer