Skip to content

Instantly share code, notes, and snippets.

View tveastman's full-sized avatar

Tom Eastman tveastman

View GitHub Profile
import os
from TwitterAPI import TwitterAPI
api = TwitterAPI(
consumer_key=os.environ["CONSUMER_KEY"],
consumer_secret=os.environ["CONSUMER_SECRET"],
access_token_key=os.environ["ACCESS_TOKEN"],
access_token_secret=os.environ["ACCESS_TOKEN_SECRET"],
)
import os, argparse, twitter
parser = argparse.ArgumentParser()
parser.add_argument('screen_name')
args = parser.parse_args()
api = twitter.Api( # oauth credentials
os.environ['CONSUMER_KEY'], os.environ['CONSUMER_SECRET'],
os.environ['ACCESS_TOKEN_KEY'], os.environ['ACCESS_TOKEN_SECRET'],
sleep_on_rate_limit=True # just pause execution
@tveastman
tveastman / hashids-mixin.py
Created July 10, 2019 22:46
Here's an example of how I've used HashIds to create a non-numeric identifier for Django models based on their `id`.
import hashids
class HashidsMixin(object):
"""Add a unique 'identifier' mapped from the 'id' field of a django model."""
# Updating this salt would change every identifier for all instances of
# every model. This is probably a bad idea, so it should probably never
# ever change. It's not used for security -- just a little bit of extra
# obfuscation to the numbering.
__HASHIDS_SALT = "20OGoZ5KsC"
#!/usr/bin/env python3
import sys
import asyncio
async def get_stream_reader(loop, stream):
reader = asyncio.StreamReader(loop=loop)
reader_protocol = asyncio.StreamReaderProtocol(reader)
await loop.connect_read_pipe(lambda: reader_protocol, stream)
@tveastman
tveastman / demo.py
Created January 11, 2018 22:52
Demonstration of issue #449 in django-storages
#!/usr/bin/env python
import os
import logging
from shutil import copyfileobj
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger()
# Reduce the logging level of botocore and boto3
logging.getLogger('botocore').setLevel(logging.WARNING)

Keybase proof

I hereby claim:

  • I am tveastman on github.
  • I am tveastman (https://keybase.io/tveastman) on keybase.
  • I have a public key ASBC4B4W44xbKepQGF1XDTQuvZcGWPaQ8zbEdZublyXwEwo

To claim this, I am signing this object: