Tag Archives: python

Posting image to thumbor using requests package

Seems like there are not many code sample there, and the requests documentation was giving the wrong hint to use files={‘file’: open(‘image.jpg’)} which you will end up getting 415 response code. I think I will just share my working sample code here to save someone’s time

 

What’s wrong with this statement?

This morning I made a code change to log some stuff in a core package and created a pull request, the change was very simple: from

to

One of the team lead pointed out the statement has a problem, and it was a life saver, but I won’t tell you why just yet,… Read More »

Python OpenCV Facial Detection On OSX

Just a code snippet to demo Python script using OpenCV

Installation: pip install numpy (sometimes you might need to run as sudo) brew tap homebrew/science brew install opencv export PYTHONPATH=/usr/local/Cellar/opencv/2.4.7.1/lib/python2.7/site-packages/ download the xml file https://warai.googlecode.com/files/haarcascade_frontalface_alt.xml and place it in the same folder.

Django CMS Haystack 2.0 Search Index

Currently django-cms-search doesn’t support haystack 2.0 yet, so here is my modified version to work on haystack 2.0 based on

Django admin UnicodeEncodeError

Don’t we all get confused by unicode encoding sometimes? Especially you wouldn’t expect this kind of error to happen in django admin. The problem is actually not in the admin section, the culprit is __unicode__ method in your model. when you have a unicode function like this:

It is actually returning a ASCII string(which… Read More »