Skip to content

Instantly share code, notes, and snippets.

@ixtel
ixtel / Oleh_Bike_Share_Chicago.ipynb
Created October 19, 2015 12:13 — forked from odubno/Oleh_Bike_Share_Chicago.ipynb
Oleh_Bike_Share_Chicago Project 1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ixtel
ixtel / rpsls.py
Created October 19, 2015 12:56 — forked from bbengfort/rpsls.py
Learning to program with Rock, Paper, Scissors, Lizard, Spock; a class based version with an indexed data store for reference.
#!/usr/bin/env python
"""
The idea of this program is to equate the strings "rock", "paper",
"scissors", "lizard", "Spock" to numbers as follows:
0 - rock
1 - Spock
2 - paper
3 - lizard
4 - scissors
@ixtel
ixtel / bucket.py
Created October 19, 2015 12:56 — forked from bbengfort/bucket.py
A chunker that appends data to file buckets at a specified directory, such that no file exceeds the size specified. It will append the data to the first file that has enough space available, if none do, then it appends the data to a new file. Note that an exception is raised if the data is bigger than the maximum file size. To test it with rando…
import os
import sys
DEFAULT_SIZE = 128 * 1024 * 1024 #128 MB
class Bucket(object):
"""
Handles the writing of a stream into a bucket.
Pass a path to a directory which holds the bucket, and
@ixtel
ixtel / concordance.py
Created October 19, 2015 12:56 — forked from bbengfort/concordance.py
Quick concordance search for a corpus.
#!/usr/bin/env python
from nltk import Text
from nltk.corpus import PlaintextCorpusReader
CORPUS_ROOT = '/Users/benjamin/Development/corpora/gutenburg/'
if __name__ == "__main__":
reader = PlaintextCorpusReader(CORPUS_ROOT, '.*')
@ixtel
ixtel / clock.py
Created October 19, 2015 12:56 — forked from bbengfort/clock.py
A quick command line utility for printing out dates formatted as you'd like them. I use this utility to quickly print out JSON formatted strings, or strings for use in code documentation.
#!/usr/bin/env python
import sys
from datetime import datetime
from dateutil.tz import tzlocal
class Clock(object):
FORMATS = {
"code":"%a %b %d %H:%M:%S %Y %z",
@ixtel
ixtel / reader.py
Created October 19, 2015 12:56 — forked from bbengfort/reader.py
A data structure for five star ranking preference expressions wrapped in a reader for TSV data.
#!/usr/bin/env python
import csv
import json
class PreferenceReader(object):
"""
A reader that can read the recommended format for storing preferences
of books in a tab-separated file. The recommended format is:
@ixtel
ixtel / similarity.py
Created October 19, 2015 12:56 — forked from bbengfort/similarity.py
Computation of similarity scores - Euclidean Distance and Pearson Correlations
#!/usr/bin/env python
import operator
from math import sqrt
from reader import PreferenceReader
class SimilarityScoring(PreferenceReader):
"""
Extends the preference reader class to give our data structure the
@ixtel
ixtel / db.py
Created October 19, 2015 12:56 — forked from bbengfort/db.py
Database example.
import psycopg2
HOST = "localhost"
PORT = "5432"
USER = "cobrain"
PASS = ""
NAME = "star_delta_0"
class Database(object):
@ixtel
ixtel / graph.py
Created October 19, 2015 12:57 — forked from bbengfort/graph.py
GraphSON is the ETL mechanism of choice for Titan graph databases using Cassandra. However, the GraphSON must be ordered correctly in order to correctly load the data using StringIO methodologies in Java. Therefore the simple construction of a Python dictionary to hold the graph data is not sufficient. This class wraps the `collections.OrderedDi…
# graph
# Python object that creates an ordered GraphSON representation.
#
# Author: Benjamin Bengfort <[email protected]>
# Created: Mon Sep 23 11:30:05 2013 -0400
#
# Copyright (C) 2013 Cobrain Company
# For license information, see LICENSE.txt
#
# ID: graph.py [] [email protected] $
@ixtel
ixtel / s3manager.py
Created October 19, 2015 12:57 — forked from bbengfort/s3manager.py
A wrapper for Boto that provides a posix-like management interface to S3 with Read, Write, and Delete.
#!/usr/bin/env python
# graffiti.breakdance.s3
# Handler class for writing to Amazon S3
#
# Author: Benjamin Bengfort <[email protected]>
# Created: Fri Sep 27 08:48:19 2013 -0400
#
# Copyright (C) 2013 Cobrain Company
# For license information, see LICENSE.txt