Skip to content

Instantly share code, notes, and snippets.

@lrei
lrei / gist:1510028
Created December 22, 2011 11:50
Fetch RSS Feeds Using Multiple Processes
#!/usr/bin/env python
import Queue
import multiprocessing
import urllib2
import feedparser
import socket
feeds = ['http://today.reuters.com/rss/topNews',
'http://today.reuters.com/rss/domesticNews',
@lrei
lrei / flaskrestex.py
Created April 17, 2012 19:16
Flask Rest Api Example Route
@app.route('/users/<username>', methods = ['GET', 'POST', 'PATCH', 'DELETE'])
@requires_auth
def api_user(username):
current_user = User.get(request.authorization.username)
app.logger.debug("req.auth.username = %s", request.authorization.username)
# Only "SELF" can access/modify user info
if current_user.username != username:
return unauthorized()
from xml.dom import minidom
xmlstr = """<item>
<category>Category1</category>
<category>Category2</category>
<category>Category3</category>
</item>"""
dom = minidom.parseString(xmlstr)
items = dom.getElementsByTagName('item')
for item in items:
cats = item.getElementsByTagName('category')