Skip to content

Instantly share code, notes, and snippets.

View natematias's full-sized avatar

J. Nathan Matias natematias

View GitHub Profile
@natematias
natematias / popit.py
Created July 28, 2014 17:49
@natematias Popit Python Llibrary
#don't use this.
# Use https://github.com/mysociety/popit-python instead.
# But I didn't have the heart not to put it online
# after several hours of creating this, before realizing
# that a library already existed, and that
# it just hadn't appeared in my search results and
# the library wasn't listed in mySociety API documentation
import requests, json, yaml
require 'csv'
emails = CSV.read(ARGV[0])
emails.shift
full_emails = []
emails.each do |email|
if(!email[0].nil? and email[0].strip.size>0)
full_emails << email[0].strip
end
end
@natematias
natematias / moby_dick_synonyms
Created May 24, 2014 13:40
Moby Dick, Synonym edition
This file has been truncated, but you can view the full file.
The Project Gutenberg EBook of Moby Dick; or The Whale, by Herman Melville This eBook is for the use of anyone anywhere at no cost and with almost no restrictions whatsoever. You may copy it, give it away or re-use it under the terms of the Project Gutenberg License included with this eBook or online at www.gutenberg.org Title: Moby Dick; or The Whale Author: Herman Melville Last Updated: January 3, 2009 Posting Date: December 25, 2008 [ EBook # 2701 ] Release Date: June, 2001 Language: English *** START OF THIS PROJECT GUTENBERG EBOOK MOBY DICK; OR THE WHALE *** Produced by Daniel Lazarus and Jonesey MOBY DICK; OR THE WHALE By Herman Melville Original Transcriber's Notes: This text is a combination of etexts, one from the now-defunct ERIS project at Virginia Tech and one from Project Gutenberg's archives. The proofreaders of this version are indebted to The University of Adelaide Library for preserving the Virginia Tech version. The resulting etext was compared with a public domain hard copy version of the t
@natematias
natematias / QueryCLIFF.py
Created May 22, 2014 19:44
Accessing a CLIFF server from Python
import nltk
import urllib
import json
import urllib2
from urllib import urlopen
# download From Egypt to Japan by Henry Martyn
url = "http://www.gutenberg.org/cache/epub/39474/pg39474.txt"
raw_text = urlopen(url).read()
@natematias
natematias / Part of Speech Tagging
Last active August 29, 2015 14:01
Tagging parts of speech in NLTK
import nltk
from urllib import urlopen
# download alice in wonderland
url = "http://www.gutenberg.org/cache/epub/11/pg11.txt"
raw_text = urlopen(url).read()
tokens = nltk.word_tokenize(raw_text)
freq_dist = nltk.FreqDist(tokens)
#freq_dist.plot(50, cumulative=False)
import mediacloud
import json
mc = mediacloud.api.MediaCloud('')
# query mentions of civic hacking
res = mc.sentenceList('( hacking AND civic ) OR ( hackathon AND civic)', '+publish_date:[2013-01-01T00:00:00Z TO 2014-04-19T00:00:00Z] AND +media_sets_id:1')
#print "found " + res['response']['numFound'] + " sentences"
story_ids = []
[story_ids.append(i) for i in [y["stories_id"] for y in res["response"]["docs"]] if not story_ids.count(i)]
Faust, by now aged and blind all over again, gives orders for thousands of workers to be summoned to dig canals and drain the marshes. His brain, senile for the second time and-- or so the cynic Mephistopheles thinks -- crazed and clouded, is aglow with a grand idea: to make mankind happy. At a signal from Mephistopheles, hell's servants appear and start digging Faust's grave. Mephistopheles has lost all hope of winning his soul and simply wants to bury him, to be rid of him. Faust hears the sound of many shovels. "What is that?" he asks. The spirit of mockery has not deserted Mephistopheles. He paints Faust a false picture of the draining of the marshes. Soviet critics like to interpret this passage in the spirit of socialist optimism: As they would have it, Faust, feeling that he has benefited mankind, and finding in this his supreme joy, exclaims: "Stay, fleeting moment, thou art beautiful!" But we have to ask ourselves whether Goethe was not ridiculing the idea of human happiness. Because in reality nothi
Install
=============
Here's what you need to know to get a laptop to run HedyNet locally. The following notes were assembled on a Mac running OSX 10.7.5, Macports, and Python 2.7.1. It assumes you have figured out how to download a copy of HedyNet from github.
Requirements
-----------------
(see the requirements files in the requirements/ folder)
- Pip
Axelrod really wanted me to do this on teleprompter -- but I told him I'm much better when I wing it. I know these evenings run long, so I'm going to be brief. Talk about the audacity of hope. President Obama does send his greetings, though. He can't be here tonight -- because he's busy getting ready for Easter. He thinks it's about him
My record stands for itself. I never say anything I don't mean. Everybody knows whatever I say, I do. And my whole life has been devoted to leveling the playing field for middle-class people, giving them an even break, treating Main Street and Wall Street the same, holding the same responsibility. Look at my record. It's been all about the middle class. They're the people who grow this country. We think you grow this country from the middle out, not from the top down.
My fellow Democrats, and my favorite Democrat.
Jilly, I want you to know that Beau, Hunt, Ashley, and I are so proud of you. We admire the way you treat every single student who walks into your classroom. You not
@natematias
natematias / kafkacorpus
Created July 1, 2013 04:30
Kafka Short Story Text Corpus, compiled from the following websites: http://franzkafkastories.com/shortStories.php https://records.viu.ca/~Johnstoi/kafka/kafkatofc.htm This file has been compiled for the purposes of text analysis and does not differentiate between different stories. Lines have been randomised as a courtesy to the copyright holders.
'Caught in the act!' said I, tapping him lightly on the shoulder. Then I ran up the steps, and the disinterested devotion on the servants' faces in the ha"ll delighted me like an unexpected treat. I looked at them all, one after another, while they took my greatcoat off and wiped my shoes clean.
And he stood completely unsupported and kicked his legs. He was radiant with insight.
And it had taken me such a long time in this man's company to recognize the same old game. I rubbed my finger tips together to wipe away the disgrace.
For such reasons, supposing one wanted to keep up correspondence with him, one could not send him any real news such as could frankly be told to the most distant acquaintance. It was more than three years since his last visit, and for this he offered the lame excuse that the political situation in Russia was too uncertain, which apparently would not permit even the briefest absence of a small businessman while it allowed hundreds of thousands of Russians to travel peacefully abroad. Bu