Skip to content

Instantly share code, notes, and snippets.

View bbengfort's full-sized avatar
🎯
Focusing

Benjamin Bengfort bbengfort

🎯
Focusing
View GitHub Profile
@bbengfort
bbengfort / bracket.py
Created July 8, 2013 14:54
A random bracket generator that we have used to create brackets for three hole washers.
#!/usr/bin/env python
from copy import copy
from random import randint
class Names(object):
def __init__(self, path="names.txt"):
self.path = path
#!/usr/bin/env python
import os
import sys
import time
ACCESS_KEY = ''
SECRET_KEY = ''
def get_name_for_file(url):
@bbengfort
bbengfort / reader.py
Last active December 21, 2015 06:29
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:
@bbengfort
bbengfort / similarity.py
Last active February 2, 2016 19:00
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
@bbengfort
bbengfort / .profile
Created September 11, 2013 16:40
My bash profile for Mac
##
# Adding the bin of my home directory to the path
##
export PATH=/Users/benjamin/bin:$PATH
##
# Setting the correct version of Python
##
export VERSIONER_PYTHON_VERSION=2.7
@bbengfort
bbengfort / spinnaker.sql
Last active December 23, 2015 05:39 — forked from mazelife/spinnaker
Creates a test data set from star delta 0 - selecting ten sample coalesced urls and product names from the shelves for each vendor.
SELECT product, url FROM
(SELECT ROW_NUMBER() OVER (PARTITION BY vendor ORDER BY product DESC) AS r, t.* FROM
(SELECT vendor.name AS vendor, product.name AS product, COALESCE(shelf.detail_url, shelf.buy_url, NULL) AS url
FROM shelf
JOIN product ON product.id = shelf.product_id
JOIN vendor ON vendor.id = shelf.vendor_id)
AS t)
AS x
WHERE x.r <= 10
@bbengfort
bbengfort / db.py
Created September 19, 2013 18:01
Database example.
import psycopg2
HOST = "localhost"
PORT = "5432"
USER = "cobrain"
PASS = ""
NAME = "star_delta_0"
class Database(object):
@bbengfort
bbengfort / graph.py
Last active June 27, 2019 06:25
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 <ben@cobrain.com>
# Created: Mon Sep 23 11:30:05 2013 -0400
#
# Copyright (C) 2013 Cobrain Company
# For license information, see LICENSE.txt
#
# ID: graph.py [] ben@cobrain.com $
@bbengfort
bbengfort / sublime_preferencs.json
Created September 30, 2013 18:41
Ben's sublime preferences as of 9/30/2013
{
"auto_complete_commit_on_tab": true,
"bold_folder_labels": true,
"caret_style": "solid",
"color_scheme": "Packages/User/Monokai Soda.tmTheme",
"create_window_at_startup": false,
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
".DS_Store",
@bbengfort
bbengfort / s3manager.py
Created October 8, 2013 15:02
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 <ben@cobrain.com>
# Created: Fri Sep 27 08:48:19 2013 -0400
#
# Copyright (C) 2013 Cobrain Company
# For license information, see LICENSE.txt