>>> from nltk import tokenize
>>> para = "Hello. My name is Jacob. Today you'll be learning NLTK."
>>> sents = tokenize.sent_tokenize(para)
>>> sents
['Hello.', 'My name is Jacob.', "Today you'll be learning NLTK."]
This file contains hidden or 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
/* | |
* | |
* Instead of a single backend, let's set up a more complex multi-server director. | |
* This director will randomly assign each request to one of three application servers. | |
* | |
*/ | |
director backend random { | |
.retries = 5; | |
{ | |
.backend = { |
This file contains hidden or 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
""" | |
I am sure everyone has something like this already. | |
I think PyDanny may have even built this into Django-Mongonaut. | |
But I needed to have this without installing any extra stuff. | |
Please enjoy version 0.0.3 of my class-based list/detail views for PyMongo. | |
""" | |
from bson.objectid import ObjectId | |
from common.mongo import MongoConnection | |
from django.conf import settings | |
from django.views.generic.base import View |
This file contains hidden or 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 handle_nfl_passer_rating(cmpls, yds, tds, ints): | |
""" Defines a function which handles passer rating calculation for the NFL.""" | |
def _min_max(x, xmin, xmax): | |
""" | |
Defines a function which enforces a minimum and maximum value. | |
Input: x, the value to check. | |
Input: xmin, the minumum value. | |
Input: xmax, the maximum value. | |
Output: Either x, xmin or xmax, depending. | |
""" |
This file contains hidden or 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 handle_cfb_passer_rating(yds, tds, cmpls, ints, atts): | |
""" Defines a function which computes NCAA passer rating.""" | |
yards = 8.4 * yds | |
touchdowns = 330 * tds | |
completions = 100 * cmpls | |
interceptions = 200 * ints | |
rating = yards + touchdowns + completions - interceptions | |
return float(rating / atts) |
This file contains hidden or 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/bash | |
#PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/programs/varnish/sbin | |
HOST=`hostname | cut -d. -f1` | |
DAEMON='/programs/varnish/sbin/varnishd' | |
PROC="varnishd" | |
NAME="varnish" | |
# This list contains the values for project arg ($2) case statement | |
# The values should match vcl files in /data/conf/varnish/PROJECT.vcl | |
# Please keep it alphabetical |
This file contains hidden or 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
worker_processes 2; # sets two workers. might need 4 in a very high-traffic environment. | |
user www-data; # user to run nginx as. | |
pid /var/run/nginx.pid; # you'll have to create this pidfile or else things won't work. | |
events { | |
worker_connections 1024; # connections each worker can take. | |
use epoll; # epoll is vastly superior to other alternatives. | |
} | |
http { |
This file contains hidden or 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
description "uWSGI server for electris CMS" | |
start on runlevel [2345] # start on all runlevels. | |
stop on runlevel [!2345] # stop when shutting down. | |
respawn # respawn if job crashes or is stopped ungracefully. | |
env DEPLOYMENT_TARGET=production # set any environment variables you like here. | |
env DJANGO_SETTINGS_FILE=conf/settings.py # more environment variables if you like. | |
env PYTHONPATH=/home/ubuntu/apps/my_app:/home/ubuntu/.virtualenv/my_app |