Skip to content

Instantly share code, notes, and snippets.

View johncosta's full-sized avatar

John Costa johncosta

View GitHub Profile
FROM scratch
ADD https://github.com/johncosta/small-file/blob/master/small_file/ /
CMD ["sh"]
### Keybase proof
I hereby claim:
* I am johncosta on github.
* I am johncosta (https://keybase.io/johncosta) on keybase.
* I have a public key whose fingerprint is 9601 0D43 439B 11F6 6ECA FCB1 837A 319D F332 E5DA
To claim this, I am signing this object:
@johncosta
johncosta / README.md
Created November 30, 2012 22:09 — forked from jpetazzo/README.md
Wrap your WSGI app with Guppy

Edit your wsgi.py file to wrap your application object as shown in the attached example.

Then go to /__guppy__ to see memory usage profiling.

This is very basic and probably needs to be refined.

@johncosta
johncosta / gist:3896693
Created October 16, 2012 01:01
Reworked waitfordb.py file example
#!/usr/bin/env python
from wsgi import *
from django.contrib.auth.models import User
from pymongo.errors import AutoReconnect, ConfigurationError
import time
deadline = time.time() + 600
while time.time() < deadline:
try:
User.objects.count()
print 'Successfully connected to database.'
@johncosta
johncosta / gist:3853716
Created October 8, 2012 17:20
going to stackoverflow
We're sorry...
This IP is only allowed to access our API.
To protect our users, we can't process requests from this IP address.
If you believe you have reached this page in error, contact us.
@johncosta
johncosta / example.py
Created July 17, 2012 03:02
Shutdown method, added documentation.
# example of:
# non-trivial comments
# object linking using reStructured text class syntax
# self-documenting methods
@defer_to_detail
def shutdown(self, reason, comment, by_user):
""" Shuts down the entire order. After a successful shutdown, the
shutdown reason, additional free form comments and the user are
annotated onto the order.
@johncosta
johncosta / models.py
Created July 16, 2012 13:20
Shutdown code example with few or confusing comments
# TODO 1.5 Does shutdown belong on Order?
@defer_to_detail
def shutdown(self, reason, comment, by_user):
log.debug('Shutdown order (%s) for reason: %s' % (self, reason))
if reason == self.Status.RETURN:
# we're going to ignore deactivated and promo cards, and shutdown as long
# as the primary cards are pristine
deactivated_statuses = [gift_card.Certificate.Status.RETURN,
gift_card.Certificate.Status.DELETED, gift_card.Certificate.Status.FRAUD]