This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import * | |
""" | |
Base configuration | |
""" | |
env.project_name = '$(project)' | |
env.database_password = '$(db_password)' | |
env.site_media_prefix = "site_media" | |
env.admin_media_prefix = "admin_media" | |
env.newsapps_media_prefix = "na_media" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nltk | |
with open('sample.txt', 'r') as f: | |
sample = f.read() | |
sentences = nltk.sent_tokenize(sample) | |
tokenized_sentences = [nltk.word_tokenize(sentence) for sentence in sentences] | |
tagged_sentences = [nltk.pos_tag(sentence) for sentence in tokenized_sentences] | |
chunked_sentences = nltk.batch_ne_chunk(tagged_sentences, binary=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import * | |
""" | |
Base configuration | |
""" | |
env.project_name = 'tables' | |
""" | |
Environments | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
# dir() | |
# >>> ['RuntimeException', 'String', 'TropoApp', 'TropoCall', 'TropoChoice', 'TropoEvent', '__name__', '_handleCallBack', '_parseTime', 'a', 'action', 'answer', 'appInstance', 'ask', 'call', 'callFactory', 'conference', 'conferenceFactory', 'context', 'createConference', 'currentApp', 'currentCall', 'destroyConference', 'engine', 'hangup', 'incomingCall', 'log', 'prompt', 'record', 'redirect', 'reject', 'say', 'startCallRecording', 'stopCallRecording', 'token', 'transcribe', 'transcription', 'transfer', 'wait'] | |
if (currentCall): | |
log("READ HERE: Incoming") | |
# log(currentCall) # object instance | |
# log(action) # undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assumes you have Postgres installed | |
mkvirtualenv --no-site-packages safecity | |
easy_install pip | |
pip install -r requirements.txt | |
# The default dataset is the South Austin neighborhood of Chicago | |
# For complete dataset edit bootstrap.sh to remove the flag to ./manage load_centerline | |
# For the downtown/loop dataset edit bootstrap.sh to change the flag to ./manage load_centerline -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
import csv | |
import re | |
from urllib2 import urlopen | |
from BeautifulSoup import BeautifulSoup, BeautifulStoneSoup | |
NOAA_ROOT_URL = 'http://www.weather.gov/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
import csv | |
import re | |
from urllib2 import urlopen | |
from BeautifulSoup import BeautifulStoneSoup | |
WEATHERBUG_API_KEY = 'A6464697672' | |
WEATHERBUG_SEARCH_URL = 'http://api.wxbug.net/getStationsXML.aspx?ACode=' + WEATHERBUG_API_KEY + '&zipCode=60601&unittype=0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Suggestions from the 11 hackers at the table: | |
* Use connection pooling (pgpool). | |
* Don't expect reporters to get excited until you can show them something. (Find a way to appeal to reporters interests.) | |
* Only update what's changed. (e.g. on election results: show changes, not raw numbers) | |
* Use the AP's "dbready" format for election results. | |
* Use CSV for everything. | |
* Use pdb with runserver for debugging. | |
* Beware circular imports when using Haystack. | |
* Make the case for building news apps with government data. (Niran will provide numbers showing that people look at it.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fetch_csv(self, options): | |
""" | |
Retrieves a single Google spreadsheet as CSV using ClientLogin | |
authentication. | |
TODO: handle retries and timeouts on auth calls | |
TOOD: handle retries and timeouts on content fetching | |
""" | |
client = gdata.docs.client.DocsClient() | |
client.ClientLogin(config.USER_EMAIL, config.USER_PASSWORD, config.APP_DOMAIN) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
backend app1 { | |
.host = "1.1.1.1"; | |
.port = "80"; | |
} | |
backend app2 { | |
.host = "2.2.2.2"; | |
.port = "80"; | |
} |
OlderNewer