Skip to content

Instantly share code, notes, and snippets.

@suchow
suchow / test.log
Created June 11, 2020 20:42
Testing smurff on Python 3.7.7
(base) ➜ ~ mkvirtualenv -p python3 smurff
created virtual environment CPython3.7.7.final.0-64 in 472ms
creator CPython3Posix(dest=/Users/suchow/.virtualenvs/smurff, clear=False, global=False)
seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/Users/suchow/Library/Application Support/virtualenv/seed-app-data/v1.0.1)
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
virtualenvwrapper.user_scripts creating /Users/suchow/.virtualenvs/smurff/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/suchow/.virtualenvs/smurff/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/suchow/.virtualenvs/smurff/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/suchow/.virtualenvs/smurff/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/suchow/.virtualenvs/smurff/bin/get_env_details

Cognition Lab onboarding

Complete the following checklist.

People and places

import textacy
import textacy.datasets
cw = textacy.datasets.SupremeCourt()
cw.download()
records = cw.records()
txt_strm, meta_strm = textacy.fileio.split_record_fields(records, 'text')
corpus = textacy.Corpus(u'en', texts=txt_strm, metadatas=meta_strm)
vectorizer = textacy.Vectorizer(
@suchow
suchow / mapr.py
Last active October 25, 2017 14:57
Reproducible multiprocessing map
"""Reproducible multiprocessing.
Output: [0.6320908733609572, 0.6407083081891108, 0.19120526615722777, ...
"""
import multiprocessing as mp
import random
random.seed(1)
# Proselint
Writing is notoriously hard, even for the best writers. Yet there is a tremendous amount of knowledge about the discipline strewn across usage guides, dictionaries, technical manuals, essays, pamphlets, websites, and the hearts and minds of great authors and editors. But poring over Strunk & White hardly makes one a better writer — it turns you into neither Strunk nor White. And nobody has the capacity to apply all the advice from Garner’s Modern American Usage, a 975-page usage guide, to everything they write. In fact, the whole notion that one becomes a better writer by reading advice on writing rests on untenable assumptions about learning and memory. The traditional formats of knowledge about writing are thus essentially inert, waiting to be transformed.
We devised a simple solution: proselint, a linter for prose. (A linter is a computer program that, like a spell checker, scans through a document and analyzes it.)
Proselint places the world's greatest writers and editors by your side, where
@suchow
suchow / gist:e75d4efdb5c86dd18ed6
Created March 5, 2015 09:20
memoization & module import issue
import os
import shelve
import functools
import inspect
def memoize(f):
"""Cache results of computations on disk."""
path_of_this_file = os.path.dirname(os.path.realpath(__file__))
cache_dirname = os.path.join(path_of_this_file, "cache")
❯ sudo ipfw -f flush
Flushed all rules.
~
❯ sudo ipfw add allow tcp from me to 54.209.68.168
00100 allow tcp from me to 54.209.68.168
~
❯ sudo ipfw add deny tcp from any to any
00200 deny tcp from any to any
@suchow
suchow / gist:4588311
Created January 21, 2013 18:51
Makes multiple sets of objects built out of gabors, with the special property that the gabors are shared across alphabets, such that each set has the same feature statistics.
% Makes multiple sets of objects built out of gabors, with the special
% property that the gabors are shared across alphabets, such that each set
% has the same feature statistics.
%
% Example usage:
% [imgs,letterStrings] = makeObjectSets()
%
function [imgs,objectStrings] = makeObjectSets
% preferences
@suchow
suchow / gist:4439973
Created January 3, 2013 01:12
fizzbuzz in MATLAB
% fizzbuzz in MATLAB
for i = 1:100
if(mod(i,3) && mod(i,5))
fprintf('%i\n', i);
else
if(~mod(i,3))
fprintf('fizz');
end
if(~mod(i,5))
fprintf('buzz');