Skip to content

Instantly share code, notes, and snippets.

@ixtel
ixtel / mixer.py
Created October 19, 2015 12:58 — forked from bbengfort/mixer.py
Sorting a list according to the first.
from operator import itemgetter
names = ['a', 'c', 'd', 'b']
runes = [1, 2, 3, 4]
def mixer(a, b):
"""
Returns the second list sorted according to the first
"""
return [z[1] for z in sorted(zip(a, b), key=itemgetter(0))]
@ixtel
ixtel / cats.py
Created October 19, 2015 12:58 — forked from bbengfort/cats.py
Count Anchor Tags is a small program that counts the number of a tags in an HTML document that is fetched from the web. Also provides the option to write out that fetched document or the list of anchor tags on command.
#!/usr/bin/env python
# cats
# Count Anchor Tags
#
# Author: Benjamin Bengfort <[email protected]>
# Created: Thu Jun 19 06:34:50 2014 -0400
#
# Copyright (C) 2014 Bengfort.com
# For license information, see LICENSE.txt
#
@ixtel
ixtel / links.py
Created October 19, 2015 12:57 — forked from bbengfort/links.py
Download all links from a catalog.
@ixtel
ixtel / linsep.py
Created October 19, 2015 12:57 — forked from bbengfort/linsep.py
Plotting 3D points for a perceptron to determine linear separability as well as a tiny computation for that neural network (studies for evolutionary computing)
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
pts0 = [
(0, 0, 0),
(0, 1, 1),
(1, 0, 1),
(1, 1, 0),
]
@ixtel
ixtel / lsys.py
Created October 19, 2015 12:57 — forked from bbengfort/lsys.py
Draw an L-System with Python's turtle graphics library, where the L-System is defined with a turning angle (d) a line length (l) and an axiom in the using the characters 'F', 'f', '+', and '-' to indicate rules. You can also iterate the axiom for fractal like patterns.
#!/usr/bin/env python
import turtle
D = 90
L = 10
def iterate(axiom, num=0, initator='F'):
"""
Compute turtle rule string by iterating on an axiom
@ixtel
ixtel / classify.py
Created October 19, 2015 12:57 — forked from bbengfort/classify.py
Classifier handler for wrapping a pickled classifer object
#!/usr/bin/env python
import os
import sys
import time
import pickle
import argparse
import operator
import unicodecsv as csv
@ixtel
ixtel / onedca.py
Created October 19, 2015 12:57 — forked from bbengfort/onedca.py
An animation of the Rule90 one dimensional Cellular Automaton using Python and Matplotlib.
import matplotlib
matplotlib.use('TKAgg')
import numpy as np
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import matplotlib.animation as animation
N = 100
ON = 255
@ixtel
ixtel / classifier.py
Created October 19, 2015 12:57 — forked from bbengfort/classifier.py
A quick category classifier with NLTK
#!/usr/bin/env python
import nltk.classify.util
from itertools import chain, imap
from string import punctuation
from nltk.corpus import stopwords
from nltk import wordpunct_tokenize
from nltk.classify import NaiveBayesClassifier
@ixtel
ixtel / token_count.py
Created October 19, 2015 12:57 — forked from bbengfort/token_count.py
A MapReduce that counts lemmas.
import nltk
from nltk.stem import WordNetLemmatizer
from nltk.tokenize import wordpunct_tokenize
class Mapper(object):
def __init__(self):
if 'stopwords' in self.params:
with open(self.params['stopwords'], 'r') as excludes:
@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