Skip to content

Instantly share code, notes, and snippets.

@ixtel
ixtel / gbs.py
Created October 19, 2015 12:59 — forked from bbengfort/gbs.py
Google Book Service
from urllib import urlencode
from datetime import date, datetime
from httplib import HTTPSConnection, HTTPException
try:
from django.utils import simplejson as json
except ImportError:
import json
def capitalize(word):
@ixtel
ixtel / aws.py
Created October 19, 2015 12:58 — forked from bbengfort/aws.py
Lookup books on Amazon's API.
from django.conf import settings
from datetime import datetime
from urllib import urlencode
from httplib import HTTPConnection
from xml.dom.minidom import parse
import hmac, hashlib, base64
ACCESS_ID = getattr(settings, 'AWS')['ID']
ACCESS_SECRET = getattr(settings, 'AWS')['SECRET']
@ixtel
ixtel / summarize.py
Created October 19, 2015 12:58 — forked from bbengfort/summarize.py
Uses TFIDF to extract relevant sentences from text. Based off of Charlie Greenbacker's example from "A smattering of NLP with Python" presentation he gave a while ago.
# summarize
# Uses TFIDF to extract relevent sentences from text.
#
# Author: Benjamin Bengfort <[email protected]>
# Created: Sun Oct 26 16:06:36 2014 -0400
#
# ID: summarize.py [] [email protected] $
"""
Uses TFIDF to extract relevent sentences from text.
@ixtel
ixtel / tokens.py
Created October 19, 2015 12:58 — forked from bbengfort/tokens.py
Getting a normalized FreqDist
import nltk
import string
def tokenize(text):
stopwords = set(nltk.corpus.stopwords.words('english'))
for token in nltk.word_tokenize(text):
if token in stopwords or token in string.punctuation:
continue
yield token.lower()
@ixtel
ixtel / rss.json
Created October 19, 2015 12:58 — forked from bbengfort/rss.json
A summary of the fields for many RSS feeds downloaded using Python feedparser
{
"fields": {
"dc_source": 7,
"media_credit": 71,
"updated_parsed": 277,
"links": 2130,
"twitter": 20,
"media_text": 31,
"summary_detail": 1993,
"href": 386,
@ixtel
ixtel / nba.py
Created October 19, 2015 12:58 — forked from bbengfort/nba.py
Computing Statistics of NBA salaries.
# nba
# Analyzes the NBA Salary to PER data set
#
# Author: Benjamin Bengfort <[email protected]>
# Created: Sat Sep 20 09:35:11 2014 -0400
#
# Copyright (C) 2014 Bengfort.com
# For license information, see LICENSE.txt
#
# ID: nba.py [] [email protected] $
@ixtel
ixtel / big_tweet_import.py
Created October 19, 2015 12:58 — forked from bbengfort/big_tweet_import.py
Import and wrangling of the Big Tweet Dump from @murphsp1.
#!/usr/bin/env python
# big_tweet_import
# Imports the tweet-dump into MongoDB
#
# Author: Benjamin Bengfort <[email protected]>
# Created: Thu Aug 28 07:37:41 2014 -0400
#
# Copyright (C) 2014 Bengfort.com
# For license information, see LICENSE.txt
#
@ixtel
ixtel / avg.py
Created October 19, 2015 12:58 — forked from bbengfort/avg.py
Keeping a running average with Python, see: http://invisibleblocks.com/2008/07/30/long-running-averages-without-the-sum-of-preceding-values/ for more information.
#!/usr/bin/env python
from __future__ import division
import sys
import time
import random
class Averager(object):
@ixtel
ixtel / mgen.py
Created October 19, 2015 12:58 — forked from bbengfort/mgen.py
Get a random matrix with elements between 0 and 9.
#!/usr/bin/env python
##########################################################################
## Imports
##########################################################################
import sys
import argparse
import traceback
import numpy as np
@ixtel
ixtel / report.py
Created October 19, 2015 12:58 — forked from bbengfort/report.py
Plotting ingestion from CSVs
#!/usr/bin/env python
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from datetime import datetime
PATH = os.path.abspath(os.path.dirname(__file__))