Skip to content

Instantly share code, notes, and snippets.

View wiredfool's full-sized avatar
💭
Feline

wiredfool wiredfool

💭
Feline
View GitHub Profile
@wiredfool
wiredfool / gist:7679863
Created November 27, 2013 17:37
ico files
>>> from PIL import Image
>>> im = Image.open('favicon.ico')
>>> im.info
{'sizes': set([(16, 16)])}
>>> im2 = Image.open('favicon2.ico')
>>> im2.info
{'sizes': set([(16, 16), (48, 48), (32, 32)])}
>>> im2.getdata()
<ImagingCore object at 0x7f15df583110>
>>> im2
@wiredfool
wiredfool / gist:7379882
Created November 9, 2013 00:34
print a binary tree of integers in level order. Level-order printing means printing each row of the tree from left to right, from root row to the deepest row. After each row, print a newline.
import Queue
class tr:
def __init__(self,val=None,children=None):
self.val=val
self.children=children or []
def emit_level_order(tree):
cur_level = 0
q = Queue.Queue()
@wiredfool
wiredfool / gist:5784266
Created June 14, 2013 18:49
live samples, to s3
--------------------------------------------------------------------------------
Command: python manage.py generate_all_thumbnail_aliases
Massif arguments: (none)
ms_print arguments: massif.out.29677
--------------------------------------------------------------------------------
MB
104.4^ #
| #
@wiredfool
wiredfool / gist:5783854
Created June 14, 2013 17:47
live-samples
--------------------------------------------------------------------------------
Command: python manage.py generate_all_thumbnail_aliases
Massif arguments: (none)
ms_print arguments: massif.out.27846
--------------------------------------------------------------------------------
MB
99.98^ #
| #
@wiredfool
wiredfool / gist:5754556
Created June 11, 2013 04:58
object count trace
Printing the top increasing object count through each iteration -- baseline is after one photo:
(et-test)erics@builder-1204-x64:~/et-test/et-issue-example$ python manage.py generate_all_thumbnail_aliases1; RSS: 50128; Unshared: 0; Obj: 30587
Object count:
55: <type 'weakref'>
9: <type 'dict'>
5: <type 'list'>
4: <type 'instance'>
1: <class 'boto.connection.ConnectionPool'>
1: <class 'storages.backends.s3boto.S3BotoStorageFile'>
@wiredfool
wiredfool / gist:5754498
Created June 11, 2013 04:36
comparision of thumbnail generation locally and delivering to s3.
from before, no s3:
--------------------------------------------------------------------------------
Command: python manage.py generate_all_thumbnail_aliases
Massif arguments: (none)
ms_print arguments: massif.out.16695
--------------------------------------------------------------------------------
MB
126.7^ #
@wiredfool
wiredfool / gist:5730478
Created June 7, 2013 16:20
valgrind run.
(et-test)erics@builder-1204-x64:~/et-test/et-issue-example$ valgrind --tool=massif python manage.py generate_all_thumbnail_aliases
==16695== Massif, a heap profiler
==16695== Copyright (C) 2003-2011, and GNU GPL'd, by Nicholas Nethercote
==16695== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==16695== Command: python manage.py generate_all_thumbnail_aliases
==16695==
1; RSS: 142912; Unshared: 0; Obj: 27683
2; RSS: 142912; Unshared: 0; Obj: 27535
3; RSS: 177228; Unshared: 0; Obj: 27563
4; RSS: 177228; Unshared: 0; Obj: 27591
@wiredfool
wiredfool / gist:5727193
Created June 7, 2013 05:17
run of all_photos.zip
1; RSS: 75968; Obj: 27735
2; RSS: 75968; Obj: 27764
3; RSS: 115140; Obj: 27793
4; RSS: 115140; Obj: 27822
5; RSS: 115140; Obj: 27851
6; RSS: 115140; Obj: 27880
7; RSS: 115140; Obj: 27909
8; RSS: 115140; Obj: 27938
9; RSS: 115140; Obj: 27960
10; RSS: 115140; Obj: 27789
1; RSS: 55612; Obj: 35226
2; RSS: 55628; Obj: 35254
3; RSS: 55628; Obj: 35282
4; RSS: 55628; Obj: 35310
5; RSS: 55628; Obj: 35338
6; RSS: 55628; Obj: 35366
7; RSS: 55628; Obj: 35394
8; RSS: 55628; Obj: 35422
9; RSS: 55628; Obj: 35450
10; RSS: 55628; Obj: 35278
@wiredfool
wiredfool / gist:5725422
Created June 6, 2013 22:13
actual test
from django.core.management.base import NoArgsCommand
from easy_thumbnails.files import generate_all_aliases
from photos.models import Photo
import time
import gc
import resource
#gc.enable()
#gc.set_debug(gc.DEBUG_LEAK)