I recently grew quite frustrated when I had to update Emend’s Twitter bot to use OAuth.
There are, of course, readily available implementations of OAuth in python, even some specifically engineered for App Engine with lovely persistence and caching and KILL ME NOW.
I gave up after a couple hours of staring at this nonsense. I grew so displeased because my app doesn’t need 95% of what these libraries offer. I only need to sign requests with a fixed oauth_consumer_key, oauth_consumer_secret, oauth_token, and oauth_token_secret. However, this simple task would require me to subclass or instantiate several object with Culver’s library, and I can’t even begin to fathom what I’d need to do with Knapp’s offering.
(Aside: if you want to authorize and build access tokens for your app, I highly recommend this excellent OAuth test client)
I finally teased apart the core function of signing requests, thanks in large part to the great reference example. If all you need is to access a protected resource, this will get the job done with a single function call, no object-orientation required.
There are a couple posts out there that discuss stripping tags with html5lib, but they seem intent on preserving the “acceptable elements” such as <span> and <code>.
This is fine unless you really want to friggin’ strip out the tags, like I needed for Emend. The following is my solution.
Source code for stripping tags with html5lib and unit test.
For example,
>>> from strip_tags import strip_tags
>>> strip_tags('<p>foo</p> <script>bar</script>')
u'foo bar'
Thanks go to Edward O’Connor for pointing me towards html5lib in the first place. It’s a huge improvement over HTMLParser.
Last modified 2 October 2011
I present the IPA (International Phonetic Alphabet) TTS (text-to-speech) bookmarklet. (Source)
Bookmarklet: IPA TTS (drag to your bookmark bar)
How to use: select any text that contains IPA and click on the bookmarklet. Wait a second for the iframe at the bottom of the page to load.
Try these examples: /ˌɪntəˈnæʃnəl/, /ˌɪntɚˈnæʃnəl/
How does this work?
The bookmark creates a POST request to the AT&T Natural Voices® Text-to-Speech Demo with the IPA text in SSML. The AT&T demo has modest support for IPA, but often fails. If you know of another IPA TTS engine, please let me know or fork the bookmarklet and add it.