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 os, sys | |
from zappa.cli import ZappaCLI | |
from zappa.util import parse_s3_url | |
from zappa import letsencrypt | |
# get command line arguments | |
directory, stage, output_filename = sys.argv[1:] | |
# change working directory | |
owd = os.getcwd() |
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 urllib2, urllib, base64, json | |
from datetime import datetime | |
from time import mktime | |
import feedparser | |
def days_since_last_post(rss_url): | |
d = feedparser.parse(rss_url) | |
if not len(d.entries): | |
return -1 | |
# get date of last blog post and convert to datetime object |
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 re | |
def make_regex(query): | |
"""Returns a compiled regex. Use returned object like so regex.search(tweet)""" | |
s = r'(\s\S+){0,2}\s'.join(query.split()) | |
return re.compile(s, re.IGNORECASE) |
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 init_queries(): | |
phrases = [ | |
'wish there was', | |
'why isn\'t there', | |
'wish someone would create', | |
'somebody needs to create', | |
'somebody should create', | |
'someone needs to create', | |
'someone should create', | |
] |
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 urllib, urllib2, json | |
def search_twitter(query, no_retweets=True): | |
if no_retweets: | |
# use the negation operator to filter out retweets | |
query += ' -RT' | |
url = 'http://search.twitter.com/search.json?%s' % urllib.urlencode({ | |
'q': query, | |
'lang': 'en', # restrict results to english tweets |
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 re, urllib, urllib2, json | |
BLACKLIST = ['odesk', 'elance', '#jobs', 'now hiring'] | |
def search_twitter(query, no_retweets=True): | |
if no_retweets: | |
# use the negation operator to filter out retweets | |
query += ' -RT' | |
url = 'http://search.twitter.com/search.json?%s' % urllib.urlencode({ |
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
"""Quick and dirty benchmarking for readability functions. | |
""" | |
import re, time, os, json | |
from urllib import urlopen | |
from hn import grabContent | |
from lxml_readability import extract | |
import socket | |
socket.setdefaulttimeout(30) |
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
"""An lxml Port of Nirmal Patel's port (http://nirmalpatel.com/fcgi/hn.py) of | |
Arc90's Readability to Python. | |
""" | |
import re | |
from lxml.html import fromstring, tostring | |
from lxml.html.clean import Cleaner | |
NEGATIVE = re.compile('comment|meta|footer|footnote|foot') | |
POSITIVE = re.compile('post|hentry|entry|content|text|body|article') |
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
#!/usr/bin/python | |
"""Simple script to split the terminal window into regions using GNU Screen and | |
automatically run commands in the new regions. | |
""" | |
import os, sys | |
import optparse | |
parser = optparse.OptionParser(usage='splitscr.py [options] <command> ...') | |
parser.add_option('-s', '--newscreen', action='store_true', dest='new_screen', help='Create a new screen session for the splits') | |
parser.add_option('-v', '--vsplit', action='store_true', dest='vertical_split', help='Split vertically instead of horizontally') |