Skip to content

Instantly share code, notes, and snippets.

View erochest's full-sized avatar

Eric Rochester erochest

View GitHub Profile
@erochest
erochest / install.md
Last active October 18, 2016 18:36
Setting up
@erochest
erochest / hw1.py
Last active August 16, 2016 14:32
def square(number):
number = int(number)
return number**2
def findall(haystack, needle):
i = 0
while True:
j = haystack.find(needle, i)
if j is -1:
break
yield j
i = j + 1
brown_tagged_sents = []
simplified_tagged_sents = []
for sent in brown_tagged_sents:
sent_to_append = []
for (word, tag) in sent:
sent_to_append.append((word, tag[0]))
simplified_tagged_sents.append(sent_to_append)
import math
def dist(xs, ys):
return math.sqrt(sum((x-y)**2 for (x, y) in zip(xs, ys)))
#!/bin/bash
set -e
KEY=barth
INPUT=paragraphs/
mallet import-dir --input $INPUT --output $KEY.mallet --keep-sequence --remove-stopwords
mallet train-topics --input $KEY.mallet --num-topics 20 \
--output-model $KEY.model --output-state $KEY.state.gz --output-doc-topics $KEY.doc.topics \
import nltk
from nltk.corpus import brown
fd = nltk.FreqDist(brown.words(categories='news'))
cfd = nltk.ConditionalFreqDist(brown.tagged_words(categories='news'))
avgs = []
@erochest
erochest / gist:7ba5c8dc9a2ec7acde26
Created July 16, 2015 15:20
Prism log on My Prisms page
2015-07-16T15:19:35.320312+00:00 app[web.1]: ** [Airbrake] Failure: Net::HTTPNotFound
2015-07-16T15:19:35.405395+00:00 app[web.1]:
2015-07-16T15:19:35.405400+00:00 app[web.1]: ActionView::Template::Error (undefined method `name' for nil:NilClass):
2015-07-16T15:19:35.405402+00:00 app[web.1]: 2: <h1>myPrisms (<%= @user.email %>)</h1>
2015-07-16T15:19:35.405404+00:00 app[web.1]: 3: <%= image_tag(avatar_url(current_user), :class => "avatar") %>
2015-07-16T15:19:35.405405+00:00 app[web.1]: 4:
2015-07-16T15:19:35.405407+00:00 app[web.1]: 5: <% if @prisms.size > 0 %>
2015-07-16T15:19:35.405408+00:00 app[web.1]: 6: <h2>Owned Prisms</h2>
2015-07-16T15:19:35.405410+00:00 app[web.1]: 7: <table cellpadding="0" cellspacing="0">
2015-07-16T15:19:35.405411+00:00 app[web.1]: 8:
@erochest
erochest / show.php
Created June 26, 2015 14:09
How to show the links to the Neatline item from the Omeka item's page
<?php
$db = get_db();
$id = get_current_record('item')->id;
$sql = "SELECT id, title, exhibit_id FROM {$db->prefix}neatline_records " .
"WHERE {$db->prefix}neatline_records.item_id=?;";
$result = $db->query($sql, array($id));
$rows = $result->fetchAll();
$exhibits = $db->getTable("NeatlineExhibit");
if (! empty($rows)) {
?>
@erochest
erochest / Brewfile
Created June 23, 2015 14:02
Things installed with brew (and cask)
ack
android-sdk
ansible
ant
apple-gcc42
at-spi2-atk
at-spi2-core
atk
atkmm
autoconf