I hereby claim:
- I am a1Gupta on github.
- I am a1gupta (https://keybase.io/a1gupta) on keybase.
- I have a public key whose fingerprint is C954 0359 FF43 7EC3 4CAA 9867 9AE8 AA8C C3E1 3762
To claim this, I am signing this object:
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
| def queryset_iterator(queryset, chunksize=1000): | |
| ''''' | |
| Iterate over a Django Queryset ordered by the primary key | |
| This method loads a maximum of chunksize (default: 1000) rows in it's | |
| memory at the same time while django normally would load all rows in it's | |
| memory. Using the iterator() method only causes it to not preload all the | |
| classes. | |
| Note that the implementation of the iterator | |
| does not support ordered query sets. | |
| ''' |
| # Identify blank/broken image | |
| try: | |
| file = cStringIO.StringIO(urllib.urlopen(user.profile_pic.url).read()) | |
| img = Image.open(file) | |
| except: | |
| print "broken image" |
I hereby claim:
To claim this, I am signing this object:
| # Matches patterns such as: | |
| # https://www.facebook.com/my_page_id => my_page_id | |
| # http://www.facebook.com/my_page_id => my_page_id | |
| # http://www.facebook.com/#!/my_page_id => my_page_id | |
| # http://www.facebook.com/pages/Paris-France/Vanity-Url/123456?v=app_555 => 123456 | |
| # http://www.facebook.com/pages/Vanity-Url/45678 => 45678 | |
| # http://www.facebook.com/#!/page_with_1_number => page_with_1_number | |
| # http://www.facebook.com/bounce_page#!/pages/Vanity-Url/45678 => 45678 | |
| # http://www.facebook.com/bounce_page#!/my_page_id?v=app_166292090072334 => my_page_id | |
| # http://www.facebook.com/my.page.is.great => my.page.is.great |
| #/usr/bin/env bash | |
| # MIT © Sindre Sorhus - sindresorhus.com | |
| # git hook to run a command after `git pull` if a specified file was changed | |
| # Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`. | |
| changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" | |
| check_run() { | |
| echo "$changed_files" | grep --quiet "$1" && eval "$2" |
| """Add user created_by and modified_by foreign key refs to any model automatically. | |
| Almost entirely taken from https://github.com/Atomidata/django-audit-log/blob/master/audit_log/middleware.py""" | |
| from django.db.models import signals | |
| from django.utils.functional import curry | |
| class WhodidMiddleware(object): | |
| def process_request(self, request): | |
| if not request.method in ('GET', 'HEAD', 'OPTIONS', 'TRACE'): | |
| if hasattr(request, 'user') and request.user.is_authenticated(): | |
| user = request.user |