Skip to content

Instantly share code, notes, and snippets.

View multiplecats
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')
@lrei
lrei / flaskrestex.py
Created Apr 17, 2012
Flask Rest Api Example Route
View flaskrestex.py
@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()
@lrei
lrei / gist:1510028
Created Dec 22, 2011
Fetch RSS Feeds Using Multiple Processes
View gist:1510028
#!/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',