Skip to content

Instantly share code, notes, and snippets.

View stefanmonkey's full-sized avatar

stefan bo stefanmonkey

View GitHub Profile
@stefanmonkey
stefanmonkey / _mysql_module.py
Created January 8, 2014 07:03
_mysql_module
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import _mysql
import sys
try:
con = _mysql.connect('localhost', 'testuser', '123456', 'testdb')
con.query('select version()')
@stefanmonkey
stefanmonkey / thumbs.py
Created December 31, 2013 02:29
python : django pic thumb
from django.core.files.uploadedfile import InMemoryUploadedFile
import StringIO
def MakeThumbnail(file):
img = Image.open(file)
img.thumbnail((128, 128), Image.ANTIALIAS)
thumbnailString = StringIO.StringIO()
img.save(thumbnailString, 'JPEG')
newFile = InMemoryUploadedFile(thumbnailString, None, 'temp.jpg', 'image/jpeg', thumbnailString.len, None)
return newFile