Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
# to use:
# 1) git clone git@github.com:jszakmeister/nose.git nose-711
# 2) cd nose-711
# 3) python setup.py build
# 4) cd build/lib
# 5) put this file there as test.py
# 6) PYTHONPATH=$PWD python -m nose ./test.py
# # observe the error:
import numpy as np
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import CountVectorizer
def get_vectors(vocab_size=5000):
newsgroups_train = fetch_20newsgroups(subset='train')
vectorizer = CountVectorizer(max_df=.9, max_features=vocab_size)
vecs = vectorizer.fit_transform(newsgroups_train.data)
vocabulary = vectorizer.vocabulary
terms = np.array(vocabulary.keys())
@mdengler
mdengler / gist:7042133
Created October 18, 2013 14:11
mpl_tm.py
{
"metadata": {
"name": "Untitled0"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
@mdengler
mdengler / gist:3944990
Created October 24, 2012 09:06 — forked from booyaa/gist:3944974
fixperms.sh
#!/bin/sh
set -e
set -x
for dir in /home/*; do
username=`basename "$dir"`
users_group=`id --group $username`
chown -R $username:$users_group $username
done
@mdengler
mdengler / mrw.py
Created September 14, 2012 20:26
python exercise to find the intersection of two sets of integers
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Given two lists of N integers (32-bit signed), determine the integers
in both lists.
"""
import os
import sys
import time
@mdengler
mdengler / mrw.py
Created September 10, 2012 21:27
python exercise to find the intersection of two sets of integers
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Given two lists of N integers (32-bit signed), determine the integers
in both lists.
"""
import os
import sys
import time
#!/usr/bin/env python
"""
Proof of concept scraper for pinnacle sports
#!/usr/bin/env python
"""
Proof of concept scraper for pinnacle sports
"""
FEED = "http://xml.pinnaclesports.com/pinnacleFeed.aspx"
@mdengler
mdengler / html2csv.py
Created June 21, 2012 04:45
html2csv.py
#!/bin/env python
# -*- coding: utf-8 -*-
"""
Examples:
%(progname)s http://en.wikipedia.org/wiki/List_of_Olympic_records_in_athletics
This is essentially this logic, done up